@@ -182,12 +182,12 @@ discard block  | 
                                                    ||
| 182 | 182 |  		if (!empty($user->email)) { | 
                                                        
| 183 | 183 | $sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">";  | 
                                                        
| 184 | 184 |  		} else { | 
                                                        
| 185 | -			$sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') . '" <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; | 
                                                        |
| 185 | +			$sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'" <'.getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; | 
                                                        |
| 186 | 186 | }  | 
                                                        
| 187 | 187 | $replyto = $sendto;  | 
                                                        
| 188 | 188 | $sendtocc = '';  | 
                                                        
| 189 | 189 |  		if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) { | 
                                                        
| 190 | -			$sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL') . '" <' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; | 
                                                        |
| 190 | +			$sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'" <'.getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; | 
                                                        |
| 191 | 191 | }  | 
                                                        
| 192 | 192 | |
| 193 | 193 | $message = "A bank transfer of ".price2num($event->data->object->amount / 100)." ".$event->data->object->currency." should arrive in your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour');  | 
                                                        
@@ -272,12 +272,12 @@ discard block  | 
                                                    ||
| 272 | 272 |  		if (!empty($user->email)) { | 
                                                        
| 273 | 273 | $sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">";  | 
                                                        
| 274 | 274 |  		} else { | 
                                                        
| 275 | -			$sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') . '" <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; | 
                                                        |
| 275 | +			$sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'" <'.getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; | 
                                                        |
| 276 | 276 | }  | 
                                                        
| 277 | 277 | $replyto = $sendto;  | 
                                                        
| 278 | 278 | $sendtocc = '';  | 
                                                        
| 279 | 279 |  		if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) { | 
                                                        
| 280 | -			$sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL') . '" <' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; | 
                                                        |
| 280 | +			$sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'" <'.getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; | 
                                                        |
| 281 | 281 | }  | 
                                                        
| 282 | 282 | |
| 283 | 283 | $message = "A bank transfer of ".price2num($event->data->object->amount / 100)." ".$event->data->object->currency." has been done to your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour');  | 
                                                        
@@ -317,19 +317,19 @@ discard block  | 
                                                    ||
| 317 | 317 | $db->commit();  | 
                                                        
| 318 | 318 |  } elseif ($event->type == 'payment_intent.succeeded') {		// Called when making payment with PaymentIntent method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on). | 
                                                        
| 319 | 319 |  	//dol_syslog("object = ".var_export($event->data, true)); | 
                                                        
| 320 | - include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';  | 
                                                        |
| 320 | + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';  | 
                                                        |
| 321 | 321 | global $stripearrayofkeysbyenv;  | 
                                                        
| 322 | 322 | $error = 0;  | 
                                                        
| 323 | 323 | $object = $event->data->object;  | 
                                                        
| 324 | - $TRANSACTIONID = $object->id; // Example pi_123456789...  | 
                                                        |
| 324 | + $TRANSACTIONID = $object->id; // Example pi_123456789...  | 
                                                        |
| 325 | 325 | $ipaddress = $object->metadata->ipaddress;  | 
                                                        
| 326 | 326 | $now = dol_now();  | 
                                                        
| 327 | 327 | $currencyCodeType = strtoupper($object->currency);  | 
                                                        
| 328 | 328 | $paymentmethodstripeid = $object->payment_method;  | 
                                                        
| 329 | 329 | $customer_id = $object->customer;  | 
                                                        
| 330 | 330 | $invoice_id = "";  | 
                                                        
| 331 | - $paymentTypeId = ""; // payment type according to Stripe  | 
                                                        |
| 332 | - $paymentTypeIdInDolibarr = ""; // payment type according to Dolibarr  | 
                                                        |
| 331 | + $paymentTypeId = ""; // payment type according to Stripe  | 
                                                        |
| 332 | + $paymentTypeIdInDolibarr = ""; // payment type according to Dolibarr  | 
                                                        |
| 333 | 333 | $payment_amount = 0;  | 
                                                        
| 334 | 334 | $payment_amountInDolibarr = 0;  | 
                                                        
| 335 | 335 | |
@@ -394,7 +394,7 @@ discard block  | 
                                                    ||
| 394 | 394 | $s = new \Stripe\StripeClient($stripeacc);  | 
                                                        
| 395 | 395 | |
| 396 | 396 | $paymentmethodstripe = $s->paymentMethods->retrieve($paymentmethodstripeid);  | 
                                                        
| 397 | - $paymentTypeId = $paymentmethodstripe->type;  | 
                                                        |
| 397 | + $paymentTypeId = $paymentmethodstripe->type;  | 
                                                        |
| 398 | 398 |  		if ($paymentTypeId == "ban" || $paymentTypeId == "sepa_debit") { | 
                                                        
| 399 | 399 | $paymentTypeId = "PRE";  | 
                                                        
| 400 | 400 |  		} elseif ($paymentTypeId == "card") { | 
                                                        
@@ -418,9 +418,9 @@ discard block  | 
                                                    ||
| 418 | 418 | $paiement->datepaye = $now;  | 
                                                        
| 419 | 419 | $paiement->date = $now;  | 
                                                        
| 420 | 420 |  			if ($currencyCodeType == $conf->currency) { | 
                                                        
| 421 | - $paiement->amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching with invoice id  | 
                                                        |
| 421 | + $paiement->amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching with invoice id  | 
                                                        |
| 422 | 422 |  			} else { | 
                                                        
| 423 | - $paiement->multicurrency_amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching  | 
                                                        |
| 423 | + $paiement->multicurrency_amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching  | 
                                                        |
| 424 | 424 | |
| 425 | 425 | $postactionmessages[] = 'Payment was done in a different currency than currency expected of company';  | 
                                                        
| 426 | 426 | $ispostactionok = -1;  | 
                                                        
@@ -430,8 +430,8 @@ discard block  | 
                                                    ||
| 430 | 430 | $paiement->paiementid = $paymentTypeId;  | 
                                                        
| 431 | 431 | $paiement->num_payment = '';  | 
                                                        
| 432 | 432 | $paiement->note_public = '';  | 
                                                        
| 433 | - $paiement->note_private = 'StripeSepa payment ' . dol_print_date($now, 'standard') . ' using ' . $servicestatus . ($ipaddress ? ' from ip ' . $ipaddress : '') . ' - Transaction ID = ' . $TRANSACTIONID;  | 
                                                        |
| 434 | - $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue.  | 
                                                        |
| 433 | + $paiement->note_private = 'StripeSepa payment '.dol_print_date($now, 'standard').' using '.$servicestatus.($ipaddress ? ' from ip '.$ipaddress : '').' - Transaction ID = '.$TRANSACTIONID;  | 
                                                        |
| 434 | + $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue.  | 
                                                        |
| 435 | 435 | $paiement->ext_payment_site = $service;  | 
                                                        
| 436 | 436 | |
| 437 | 437 | $ispaymentdone = 0;  | 
                                                        
@@ -449,20 +449,20 @@ discard block  | 
                                                    ||
| 449 | 449 | $db->begin();  | 
                                                        
| 450 | 450 | |
| 451 | 451 |  			if (!$error && !$ispaymentdone) { | 
                                                        
| 452 | -				dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document'); | 
                                                        |
| 452 | +				dol_syslog('* Record payment for invoice id '.$invoice_id.'. It includes closing of invoice and regenerating document'); | 
                                                        |
| 453 | 453 | |
| 454 | 454 | // This include closing invoices to 'paid' (and trigger including unsuspending) and regenerating document  | 
                                                        
| 455 | 455 | $paiement_id = $paiement->create($user, 1);  | 
                                                        
| 456 | 456 |  				if ($paiement_id < 0) { | 
                                                        
| 457 | -					$postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join("<br>\n", $paiement->errors); | 
                                                        |
| 457 | +					$postactionmessages[] = $paiement->error.($paiement->error ? ' ' : '').join("<br>\n", $paiement->errors); | 
                                                        |
| 458 | 458 | $ispostactionok = -1;  | 
                                                        
| 459 | 459 | $error++;  | 
                                                        
| 460 | 460 | |
| 461 | -					dol_syslog("Failed to create the payment for invoice id " . $invoice_id); | 
                                                        |
| 461 | +					dol_syslog("Failed to create the payment for invoice id ".$invoice_id); | 
                                                        |
| 462 | 462 |  				} else { | 
                                                        
| 463 | 463 | $postactionmessages[] = 'Payment created';  | 
                                                        
| 464 | 464 | |
| 465 | -					dol_syslog("The payment has been created for invoice id " . $invoice_id); | 
                                                        |
| 465 | +					dol_syslog("The payment has been created for invoice id ".$invoice_id); | 
                                                        |
| 466 | 466 | }  | 
                                                        
| 467 | 467 | }  | 
                                                        
| 468 | 468 | |
@@ -492,14 +492,14 @@ discard block  | 
                                                    ||
| 492 | 492 | $label = '(CustomerInvoicePayment)';  | 
                                                        
| 493 | 493 | $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, $customer_id, '');  | 
                                                        
| 494 | 494 |  						if ($result < 0) { | 
                                                        
| 495 | -							$postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join("<br>\n", $paiement->errors); | 
                                                        |
| 495 | +							$postactionmessages[] = $paiement->error.($paiement->error ? ' ' : '').join("<br>\n", $paiement->errors); | 
                                                        |
| 496 | 496 | $ispostactionok = -1;  | 
                                                        
| 497 | 497 | $error++;  | 
                                                        
| 498 | 498 |  						} else { | 
                                                        
| 499 | 499 | $postactionmessages[] = 'Bank transaction of payment created (by ipn.php file)';  | 
                                                        
| 500 | 500 | }  | 
                                                        
| 501 | 501 |  					} else { | 
                                                        
| 502 | - $postactionmessages[] = 'Setup of bank account to use in module ' . $paymentmethod . ' was not set. No way to record the payment.';  | 
                                                        |
| 502 | + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.';  | 
                                                        |
| 503 | 503 | $ispostactionok = -1;  | 
                                                        
| 504 | 504 | $error++;  | 
                                                        
| 505 | 505 | }  | 
                                                        
@@ -663,7 +663,7 @@ discard block  | 
                                                    ||
| 663 | 663 | $error++;  | 
                                                        
| 664 | 664 | }  | 
                                                        
| 665 | 665 | |
| 666 | -		if (! $error) { | 
                                                        |
| 666 | +		if (!$error) { | 
                                                        |
| 667 | 667 | $db->commit();  | 
                                                        
| 668 | 668 |  		} else { | 
                                                        
| 669 | 669 | $db->rollback();  | 
                                                        
@@ -98,8 +98,8 @@ discard block  | 
                                                    ||
| 98 | 98 | |
| 99 | 99 | const STATUS_DRAFT = 0;  | 
                                                        
| 100 | 100 | const STATUS_TRANSFERED = 1;  | 
                                                        
| 101 | - const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 102 | - const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 101 | + const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 102 | + const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | /**  | 
                                                        
@@ -145,7 +145,7 @@ discard block  | 
                                                    ||
| 145 | 145 | /**  | 
                                                        
| 146 | 146 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.  | 
                                                        
| 147 | 147 | */  | 
                                                        
| 148 | - public $fields=array(  | 
                                                        |
| 148 | + public $fields = array(  | 
                                                        |
| 149 | 149 |  		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), | 
                                                        
| 150 | 150 |  		'ref' => array('type'=>'varchar(12)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150', 'showoncombobox'=>'1',), | 
                                                        
| 151 | 151 |  		'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,), | 
                                                        
@@ -339,7 +339,7 @@ discard block  | 
                                                    ||
| 339 | 339 | $sql .= ", '".$this->db->escape($code_guichet)."'";  | 
                                                        
| 340 | 340 | $sql .= ", '".$this->db->escape($number)."'";  | 
                                                        
| 341 | 341 | $sql .= ", '".$this->db->escape($number_key)."'";  | 
                                                        
| 342 | - $sql .= (!empty($sourcetype) ? ", ". ((int) $client_id) : '');  | 
                                                        |
| 342 | + $sql .= (!empty($sourcetype) ? ", ".((int) $client_id) : '');  | 
                                                        |
| 343 | 343 | $sql .= ")";  | 
                                                        
| 344 | 344 |  			if ($this->db->query($sql)) { | 
                                                        
| 345 | 345 | $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes");  | 
                                                        
@@ -563,7 +563,7 @@ discard block  | 
                                                    ||
| 563 | 563 |  						} else { | 
                                                        
| 564 | 564 | $modeforaddpayment = 'payment';  | 
                                                        
| 565 | 565 | $labelforaddpayment = '(CustomerInvoicePayment)';  | 
                                                        
| 566 | - $addbankurl = 'direct-debit'; // = 'directdebit'  | 
                                                        |
| 566 | + $addbankurl = 'direct-debit'; // = 'directdebit'  | 
                                                        |
| 567 | 567 | }  | 
                                                        
| 568 | 568 | |
| 569 | 569 | $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl);  | 
                                                        
@@ -973,7 +973,7 @@ discard block  | 
                                                    ||
| 973 | 973 | $sql .= " FROM ".MAIN_DB_PREFIX."salary as f";  | 
                                                        
| 974 | 974 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_salary";  | 
                                                        
| 975 | 975 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON s.rowid = f.fk_user";  | 
                                                        
| 976 | - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here  | 
                                                        |
| 976 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here  | 
                                                        |
| 977 | 977 | }  | 
                                                        
| 978 | 978 |  			if ($sourcetype != 'salary') { | 
                                                        
| 979 | 979 |  				if ($type != 'bank-transfer') { | 
                                                        
@@ -996,7 +996,7 @@ discard block  | 
                                                    ||
| 996 | 996 | $sql .= " AND pd.traite = 0";  | 
                                                        
| 997 | 997 | $sql .= " AND pd.ext_payment_id IS NULL";  | 
                                                        
| 998 | 998 |  			if ($sourcetype != 'salary') { | 
                                                        
| 999 | - $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too  | 
                                                        |
| 999 | + $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too  | 
                                                        |
| 1000 | 1000 | }  | 
                                                        
| 1001 | 1001 |  			if ($did > 0) { | 
                                                        
| 1002 | 1002 | $sql .= " AND pd.rowid = ".((int) $did);  | 
                                                        
@@ -1008,7 +1008,7 @@ discard block  | 
                                                    ||
| 1008 | 1008 | $i = 0;  | 
                                                        
| 1009 | 1009 | |
| 1010 | 1010 |  				while ($i < $num) { | 
                                                        
| 1011 | - $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object()  | 
                                                        |
| 1011 | + $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object()  | 
                                                        |
| 1012 | 1012 | $factures[$i] = $row; // All fields  | 
                                                        
| 1013 | 1013 | |
| 1014 | 1014 |  					if ($row[7] == 0) { | 
                                                        
@@ -1086,30 +1086,30 @@ discard block  | 
                                                    ||
| 1086 | 1086 | $tmpsoc->id = $fac[2];  | 
                                                        
| 1087 | 1087 | $tmpsoc->name = $fac[8];  | 
                                                        
| 1088 | 1088 | $invoice_url = "<a href='".DOL_URL_ROOT.'/compta/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";  | 
                                                        
| 1089 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1090 | - $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1089 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1090 | + $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1091 | 1091 | $error++;  | 
                                                        
| 1092 | 1092 | }  | 
                                                        
| 1093 | 1093 |  							if ($type == 'bank-transfer' && $sourcetype != 'salary') { | 
                                                        
| 1094 | 1094 | $tmpsoc->id = $fac[2];  | 
                                                        
| 1095 | 1095 | $tmpsoc->name = $fac[8];  | 
                                                        
| 1096 | 1096 | $invoice_url = "<a href='".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";  | 
                                                        
| 1097 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1098 | - $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1097 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1098 | + $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1099 | 1099 | $error++;  | 
                                                        
| 1100 | 1100 | }  | 
                                                        
| 1101 | 1101 |  							if ($type == 'bank-transfer' && $sourcetype == 'salary') { | 
                                                        
| 1102 | 1102 | $tmpuser->id = $fac[2];  | 
                                                        
| 1103 | 1103 | $tmpuser->firstname = $fac[8];  | 
                                                        
| 1104 | 1104 | $salary_url = "<a href='".DOL_URL_ROOT.'/salaries/card.php?id='.$fac[0]."'>".$fac[0]."</a>";  | 
                                                        
| 1105 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);  | 
                                                        |
| 1106 | - $this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);  | 
                                                        |
| 1105 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary ".$salary_url." for employee ".$tmpuser->getNomUrl(0);  | 
                                                        |
| 1106 | + $this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary ".$salary_url." for employee ".$tmpuser->getNomUrl(0);  | 
                                                        |
| 1107 | 1107 | $error++;  | 
                                                        
| 1108 | 1108 | }  | 
                                                        
| 1109 | -							dol_syslog(__METHOD__ . " Check BAN Error on default bank number IBAN/BIC reported by verif(): " . join(', ', $fac), LOG_WARNING); | 
                                                        |
| 1109 | +							dol_syslog(__METHOD__." Check BAN Error on default bank number IBAN/BIC reported by verif(): ".join(', ', $fac), LOG_WARNING); | 
                                                        |
| 1110 | 1110 | }  | 
                                                        
| 1111 | 1111 |  					} else { | 
                                                        
| 1112 | - dol_syslog(__METHOD__ . " Check BAN Failed to read company", LOG_WARNING);  | 
                                                        |
| 1112 | + dol_syslog(__METHOD__." Check BAN Failed to read company", LOG_WARNING);  | 
                                                        |
| 1113 | 1113 | }  | 
                                                        
| 1114 | 1114 | /*  | 
                                                        
| 1115 | 1115 |  					} else { | 
                                                        
@@ -1162,7 +1162,7 @@ discard block  | 
                                                    ||
| 1162 | 1162 | $ref = substr($year, -2).$month;  | 
                                                        
| 1163 | 1163 | |
| 1164 | 1164 | // Get next free nunber for the ref of bon prelevement  | 
                                                        
| 1165 | - $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX"  | 
                                                        |
| 1165 | + $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX"  | 
                                                        |
| 1166 | 1166 | $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons";  | 
                                                        
| 1167 | 1167 | $sql .= " WHERE ref LIKE '_".$this->db->escape($ref)."%'";  | 
                                                        
| 1168 | 1168 | $sql .= " AND entity = ".((int) $conf->entity);  | 
                                                        
@@ -1356,7 +1356,7 @@ discard block  | 
                                                    ||
| 1356 | 1356 | |
| 1357 | 1357 |  			if (!$error) { | 
                                                        
| 1358 | 1358 | $this->db->commit();  | 
                                                        
| 1359 | - return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error  | 
                                                        |
| 1359 | + return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error  | 
                                                        |
| 1360 | 1360 |  			} else { | 
                                                        
| 1361 | 1361 | $this->db->rollback();  | 
                                                        
| 1362 | 1362 | return -1;  | 
                                                        
@@ -2170,7 +2170,7 @@ discard block  | 
                                                    ||
| 2170 | 2170 |  			$XML_CREDITOR .= '					<EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters | 
                                                        
| 2171 | 2171 | $XML_CREDITOR .= ' </PmtId>'.$CrLf;  | 
                                                        
| 2172 | 2172 |  			if (!empty($this->sepa_xml_pti_in_ctti)) { | 
                                                        
| 2173 | - $XML_CREDITOR .= ' <PmtTpInf>' . $CrLf;  | 
                                                        |
| 2173 | + $XML_CREDITOR .= ' <PmtTpInf>'.$CrLf;  | 
                                                        |
| 2174 | 2174 | |
| 2175 | 2175 | // Can be 'NORM' for normal or 'HIGH' for high priority level  | 
                                                        
| 2176 | 2176 |  				if (getDolGlobalString('PAYMENTBYBANKTRANSFER_FORCE_HIGH_PRIORITY')) { | 
                                                        
@@ -2178,14 +2178,14 @@ discard block  | 
                                                    ||
| 2178 | 2178 |  				} else { | 
                                                        
| 2179 | 2179 | $instrprty = 'NORM';  | 
                                                        
| 2180 | 2180 | }  | 
                                                        
| 2181 | - $XML_CREDITOR .= ' <InstrPrty>'.$instrprty.'</InstrPrty>' . $CrLf;  | 
                                                        |
| 2182 | - $XML_CREDITOR .= ' <SvcLvl>' . $CrLf;  | 
                                                        |
| 2183 | - $XML_CREDITOR .= ' <Cd>SEPA</Cd>' . $CrLf;  | 
                                                        |
| 2184 | - $XML_CREDITOR .= ' </SvcLvl>' . $CrLf;  | 
                                                        |
| 2185 | - $XML_CREDITOR .= ' <CtgyPurp>' . $CrLf;  | 
                                                        |
| 2186 | - $XML_CREDITOR .= ' <Cd>CORE</Cd>' . $CrLf;  | 
                                                        |
| 2187 | - $XML_CREDITOR .= ' </CtgyPurp>' . $CrLf;  | 
                                                        |
| 2188 | - $XML_CREDITOR .= ' </PmtTpInf>' . $CrLf;  | 
                                                        |
| 2181 | + $XML_CREDITOR .= ' <InstrPrty>'.$instrprty.'</InstrPrty>'.$CrLf;  | 
                                                        |
| 2182 | + $XML_CREDITOR .= ' <SvcLvl>'.$CrLf;  | 
                                                        |
| 2183 | + $XML_CREDITOR .= ' <Cd>SEPA</Cd>'.$CrLf;  | 
                                                        |
| 2184 | + $XML_CREDITOR .= ' </SvcLvl>'.$CrLf;  | 
                                                        |
| 2185 | + $XML_CREDITOR .= ' <CtgyPurp>'.$CrLf;  | 
                                                        |
| 2186 | + $XML_CREDITOR .= ' <Cd>CORE</Cd>'.$CrLf;  | 
                                                        |
| 2187 | + $XML_CREDITOR .= ' </CtgyPurp>'.$CrLf;  | 
                                                        |
| 2188 | + $XML_CREDITOR .= ' </PmtTpInf>'.$CrLf;  | 
                                                        |
| 2189 | 2189 | }  | 
                                                        
| 2190 | 2190 | $XML_CREDITOR .= ' <Amt>'.$CrLf;  | 
                                                        
| 2191 | 2191 | $XML_CREDITOR .= ' <InstdAmt Ccy="EUR">'.round($row_somme, 2).'</InstdAmt>'.$CrLf;  | 
                                                        
@@ -2347,7 +2347,7 @@ discard block  | 
                                                    ||
| 2347 | 2347 | $this->emetteur_iban = $account->iban;  | 
                                                        
| 2348 | 2348 | $this->emetteur_bic = $account->bic;  | 
                                                        
| 2349 | 2349 | |
| 2350 | - $this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics); // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";  | 
                                                        |
| 2350 | + $this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics); // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";  | 
                                                        |
| 2351 | 2351 | |
| 2352 | 2352 | $this->raison_sociale = $account->proprio;  | 
                                                        
| 2353 | 2353 | }  | 
                                                        
@@ -2438,15 +2438,15 @@ discard block  | 
                                                    ||
| 2438 | 2438 | $XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf;  | 
                                                        
| 2439 | 2439 | $XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf;  | 
                                                        
| 2440 | 2440 |  				if (!empty($this->sepa_xml_pti_in_ctti) && !empty($format)) {	// @TODO Using $format (FRST ou RCUR) in a section for a Credit Transfer looks strange. | 
                                                        
| 2441 | - $XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf;  | 
                                                        |
| 2442 | - $XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf;  | 
                                                        |
| 2443 | - $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;  | 
                                                        |
| 2444 | - $XML_SEPA_INFO .= ' </SvcLvl>' . $CrLf;  | 
                                                        |
| 2445 | - $XML_SEPA_INFO .= ' <LclInstrm>' . $CrLf;  | 
                                                        |
| 2446 | - $XML_SEPA_INFO .= ' <Cd>CORE</Cd>' . $CrLf;  | 
                                                        |
| 2447 | - $XML_SEPA_INFO .= ' </LclInstrm>' . $CrLf;  | 
                                                        |
| 2448 | - $XML_SEPA_INFO .= ' <SeqTp>' . $format . '</SeqTp>' . $CrLf;  | 
                                                        |
| 2449 | - $XML_SEPA_INFO .= ' </PmtTpInf>' . $CrLf;  | 
                                                        |
| 2441 | + $XML_SEPA_INFO .= ' <PmtTpInf>'.$CrLf;  | 
                                                        |
| 2442 | + $XML_SEPA_INFO .= ' <SvcLvl>'.$CrLf;  | 
                                                        |
| 2443 | + $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>'.$CrLf;  | 
                                                        |
| 2444 | + $XML_SEPA_INFO .= ' </SvcLvl>'.$CrLf;  | 
                                                        |
| 2445 | + $XML_SEPA_INFO .= ' <LclInstrm>'.$CrLf;  | 
                                                        |
| 2446 | + $XML_SEPA_INFO .= ' <Cd>CORE</Cd>'.$CrLf;  | 
                                                        |
| 2447 | + $XML_SEPA_INFO .= ' </LclInstrm>'.$CrLf;  | 
                                                        |
| 2448 | + $XML_SEPA_INFO .= ' <SeqTp>'.$format.'</SeqTp>'.$CrLf;  | 
                                                        |
| 2449 | + $XML_SEPA_INFO .= ' </PmtTpInf>'.$CrLf;  | 
                                                        |
| 2450 | 2450 | }  | 
                                                        
| 2451 | 2451 | $XML_SEPA_INFO .= ' <ReqdExctnDt>'.dol_print_date($dateTime_ETAD, 'dayrfc').'</ReqdExctnDt>'.$CrLf;  | 
                                                        
| 2452 | 2452 | $XML_SEPA_INFO .= ' <Dbtr>'.$CrLf;  | 
                                                        
@@ -98,9 +98,9 @@ discard block  | 
                                                    ||
| 98 | 98 | //print "before decoding $val\n";  | 
                                                        
| 99 | 99 |  	do { | 
                                                        
| 100 | 100 | $oldval = $val;  | 
                                                        
| 101 | - $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5); // Decode ':', ''', '	', '&NewLine', ...  | 
                                                        |
| 101 | + $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5); // Decode ':', ''', '	', '&NewLine', ...  | 
                                                        |
| 102 | 102 | // Sometimes we have entities without the ; at end so html_entity_decode does not work but entities is still interpreted by browser.  | 
                                                        
| 103 | -		$val = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', function ($m) { | 
                                                        |
| 103 | +		$val = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', function($m) { | 
                                                        |
| 104 | 104 | // Decode 'n', ...  | 
                                                        
| 105 | 105 | return realCharForNumericEntities($m); }, $val);  | 
                                                        
| 106 | 106 | |
@@ -138,7 +138,7 @@ discard block  | 
                                                    ||
| 138 | 138 |  		$inj += preg_match('/user\s*\(/i', $val); // avoid to use function user() or mysql_user() that return current database login | 
                                                        
| 139 | 139 |  		$inj += preg_match('/information_schema/i', $val); // avoid to use request that read information_schema database | 
                                                        
| 140 | 140 |  		$inj += preg_match('/<svg/i', $val); // <svg can be allowed in POST | 
                                                        
| 141 | -		$inj += preg_match('/update[^&=\w].*set.+=/i', $val);	// the [^&=\w] test is to avoid error when request is like action=update&...set... or &updatemodule=...set... | 
                                                        |
| 141 | +		$inj += preg_match('/update[^&=\w].*set.+=/i', $val); // the [^&=\w] test is to avoid error when request is like action=update&...set... or &updatemodule=...set... | 
                                                        |
| 142 | 142 |  		$inj += preg_match('/union.+select/i', $val); | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | 144 |  	if ($type == 3) { | 
                                                        
@@ -349,7 +349,7 @@ discard block  | 
                                                    ||
| 349 | 349 | session_set_cookie_params($sessioncookieparams);  | 
                                                        
| 350 | 350 | }  | 
                                                        
| 351 | 351 | session_name($sessionname);  | 
                                                        
| 352 | - session_start(); // This call the open and read of session handler  | 
                                                        |
| 352 | + session_start(); // This call the open and read of session handler  | 
                                                        |
| 353 | 353 | //exit; // this exist generates a call to write and close  | 
                                                        
| 354 | 354 | }  | 
                                                        
| 355 | 355 | |
@@ -377,11 +377,11 @@ discard block  | 
                                                    ||
| 377 | 377 |  	if (!$ok) { | 
                                                        
| 378 | 378 |  		if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED) { | 
                                                        
| 379 | 379 | print 'Sorry, your application is offline.'."\n";  | 
                                                        
| 380 | -			print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "' . getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; | 
                                                        |
| 380 | +			print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "'.getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; | 
                                                        |
| 381 | 381 | $nexturl = DOL_URL_ROOT.'/user/logout.php?token='.newToken();  | 
                                                        
| 382 | 382 | print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n";  | 
                                                        
| 383 | 383 |  		} else { | 
                                                        
| 384 | -			print 'Sorry, your application is offline. Only administrator user "' . getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; | 
                                                        |
| 384 | +			print 'Sorry, your application is offline. Only administrator user "'.getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; | 
                                                        |
| 385 | 385 | $nexturl = DOL_URL_ROOT.'/';  | 
                                                        
| 386 | 386 | print 'Please try later or <a href="'.$nexturl.'">click here to change login user</a>...'."\n";  | 
                                                        
| 387 | 387 | }  | 
                                                        
@@ -583,7 +583,7 @@ discard block  | 
                                                    ||
| 583 | 583 | print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n";  | 
                                                        
| 584 | 584 | print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0";  | 
                                                        
| 585 | 585 |  					if (getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN')) { | 
                                                        
| 586 | -						print " instead of " . getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN'); | 
                                                        |
| 586 | +						print " instead of ".getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN'); | 
                                                        |
| 587 | 587 | }  | 
                                                        
| 588 | 588 | print " into setup).\n";  | 
                                                        
| 589 | 589 | }  | 
                                                        
@@ -595,7 +595,7 @@ discard block  | 
                                                    ||
| 595 | 595 | $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']);  | 
                                                        
| 596 | 596 | // TODO Get the sessiontokenforthisurl into an array of session token (one array per base URL so we can use the CSRF per page and we keep ability for several tabs per url in a browser)  | 
                                                        
| 597 | 597 |  	if (GETPOSTISSET('token') && GETPOST('token') != 'notrequired' && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { | 
                                                        
| 598 | -			dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".(empty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']).", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha'), LOG_WARNING); | 
                                                        |
| 598 | +			dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']).", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha'), LOG_WARNING); | 
                                                        |
| 599 | 599 |  			//dol_syslog("_SESSION['token']=".$sessiontokenforthisurl, LOG_DEBUG); | 
                                                        
| 600 | 600 | // Do not output anything on standard output because this create problems when using the BACK button on browsers. So we just set a message into session.  | 
                                                        
| 601 | 601 |  		if (!defined('NOTOKENRENEWAL')) { | 
                                                        
@@ -611,7 +611,7 @@ discard block  | 
                                                    ||
| 611 | 611 | unset($_GET['action']);  | 
                                                        
| 612 | 612 | unset($_GET['confirmmassaction']);  | 
                                                        
| 613 | 613 | unset($_GET['massaction']);  | 
                                                        
| 614 | - unset($_GET['token']); // TODO Make a redirect if we have a token in url to remove it ?  | 
                                                        |
| 614 | + unset($_GET['token']); // TODO Make a redirect if we have a token in url to remove it ?  | 
                                                        |
| 615 | 615 |  		if (isset($savid)) { | 
                                                        
| 616 | 616 | $_POST['id'] = ((int) $savid);  | 
                                                        
| 617 | 617 | }  | 
                                                        
@@ -778,7 +778,7 @@ discard block  | 
                                                    ||
| 778 | 778 | |
| 779 | 779 | $allowedmethodtopostusername = 3;  | 
                                                        
| 780 | 780 |  		if (defined('MAIN_AUTHENTICATION_POST_METHOD')) { | 
                                                        
| 781 | -			$allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD');	// Note a value of 2 is not compatible with some authentication methods that put username as GET parameter | 
                                                        |
| 781 | +			$allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); // Note a value of 2 is not compatible with some authentication methods that put username as GET parameter | 
                                                        |
| 782 | 782 | }  | 
                                                        
| 783 | 783 |  		// TODO Remove use of $_COOKIE['login_dolibarr'] ? Replace $usertotest = with $usertotest = GETPOST("username", "alpha", $allowedmethodtopostusername); | 
                                                        
| 784 | 784 |  		$usertotest = (!empty($_COOKIE['login_dolibarr']) ? preg_replace('/[^a-zA-Z0-9_@\-\.]/', '', $_COOKIE['login_dolibarr']) : GETPOST("username", "alpha", $allowedmethodtopostusername)); | 
                                                        
@@ -901,7 +901,7 @@ discard block  | 
                                                    ||
| 901 | 901 |  				if (!empty($_SERVER["HTTP_USER_AGENT"]) && $_SERVER["HTTP_USER_AGENT"] == 'securitytest') { | 
                                                        
| 902 | 902 | http_response_code(401); // It makes easier to understand if session was broken during security tests  | 
                                                        
| 903 | 903 | }  | 
                                                        
| 904 | - dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); // This include http headers  | 
                                                        |
| 904 | + dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); // This include http headers  | 
                                                        |
| 905 | 905 | }  | 
                                                        
| 906 | 906 | exit;  | 
                                                        
| 907 | 907 | }  | 
                                                        
@@ -1246,7 +1246,7 @@ discard block  | 
                                                    ||
| 1246 | 1246 |  } else { | 
                                                        
| 1247 | 1247 | // We may have NOLOGIN set, but NOREQUIREUSER not  | 
                                                        
| 1248 | 1248 |  	if (!empty($user) && method_exists($user, 'loadDefaultValues') && !defined('NODEFAULTVALUES')) { | 
                                                        
| 1249 | - $user->loadDefaultValues(); // Load default values for everybody (works even if $user->id = 0  | 
                                                        |
| 1249 | + $user->loadDefaultValues(); // Load default values for everybody (works even if $user->id = 0  | 
                                                        |
| 1250 | 1250 | }  | 
                                                        
| 1251 | 1251 | }  | 
                                                        
| 1252 | 1252 | |
@@ -1426,7 +1426,7 @@ discard block  | 
                                                    ||
| 1426 | 1426 | |
| 1427 | 1427 |  if (!empty(GETPOST('seteventmessages', 'alpha'))) { | 
                                                        
| 1428 | 1428 |  	$message = GETPOST('seteventmessages', 'alpha'); | 
                                                        
| 1429 | -	$messages  = explode(',', $message); | 
                                                        |
| 1429 | +	$messages = explode(',', $message); | 
                                                        |
| 1430 | 1430 |  	foreach ($messages as $key => $msg) { | 
                                                        
| 1431 | 1431 |  		$tmp = explode(':', $msg); | 
                                                        
| 1432 | 1432 | setEventMessages($tmp[0], null, !empty($tmp[1]) ? $tmp[1] : 'mesgs');  | 
                                                        
@@ -1721,7 +1721,7 @@ discard block  | 
                                                    ||
| 1721 | 1721 | |
| 1722 | 1722 |  		if (getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')) { | 
                                                        
| 1723 | 1723 | // TODO: use auto theme color switch  | 
                                                        
| 1724 | -			print '<meta name="theme-color" content="rgb(' . getDolGlobalString('THEME_ELDY_TOPMENU_BACK1').')">'."\n"; | 
                                                        |
| 1724 | +			print '<meta name="theme-color" content="rgb('.getDolGlobalString('THEME_ELDY_TOPMENU_BACK1').')">'."\n"; | 
                                                        |
| 1725 | 1725 | }  | 
                                                        
| 1726 | 1726 | |
| 1727 | 1727 | // Auto refresh page  | 
                                                        
@@ -2038,7 +2038,7 @@ discard block  | 
                                                    ||
| 2038 | 2038 | print $head."\n";  | 
                                                        
| 2039 | 2039 | }  | 
                                                        
| 2040 | 2040 |  		if (getDolGlobalString('MAIN_HTML_HEADER')) { | 
                                                        
| 2041 | -			print getDolGlobalString('MAIN_HTML_HEADER') . "\n"; | 
                                                        |
| 2041 | +			print getDolGlobalString('MAIN_HTML_HEADER')."\n"; | 
                                                        |
| 2042 | 2042 | }  | 
                                                        
| 2043 | 2043 | |
| 2044 | 2044 | $parameters = array();  | 
                                                        
@@ -2817,7 +2817,7 @@ discard block  | 
                                                    ||
| 2817 | 2817 |  		$langs->load(explode('@', $item['name'])[1]); | 
                                                        
| 2818 | 2818 | $dropDownQuickAddHtml .= '  | 
                                                        
| 2819 | 2819 |  			<a class="dropdown-item quickadd-item" href="'.DOL_URL_ROOT.$item['url'].'" title="'.$langs->trans(explode('@', $item['title'])[0]).'"> | 
                                                        
| 2820 | -			'. img_picto('', $item['picto'], 'style="width:18px;"') . ' ' . $langs->trans(explode('@', $item['name'])[0]) . '</a> | 
                                                        |
| 2820 | +			'. img_picto('', $item['picto'], 'style="width:18px;"').' '.$langs->trans(explode('@', $item['name'])[0]).'</a> | 
                                                        |
| 2821 | 2821 | ';  | 
                                                        
| 2822 | 2822 | }  | 
                                                        
| 2823 | 2823 | |
@@ -3665,7 +3665,7 @@ discard block  | 
                                                    ||
| 3665 | 3665 |  		$forceping = GETPOST('forceping', 'alpha'); | 
                                                        
| 3666 | 3666 |  		if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || $forceping) { | 
                                                        
| 3667 | 3667 | //print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->';  | 
                                                        
| 3668 | -			$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256');	// Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. | 
                                                        |
| 3668 | +			$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. | 
                                                        |
| 3669 | 3669 | |
| 3670 | 3670 |  			if (!getDolGlobalString('MAIN_FIRST_PING_OK_DATE') | 
                                                        
| 3671 | 3671 | || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled'))  | 
                                                        
@@ -38,9 +38,9 @@ discard block  | 
                                                    ||
| 38 | 38 | // Only works if you are not in safe_mode. / Ne fonctionne que si on est pas en safe_mode.  | 
                                                        
| 39 | 39 | |
| 40 | 40 | $err = error_reporting();  | 
                                                        
| 41 | -error_reporting(0); // Disable all errors  | 
                                                        |
| 41 | +error_reporting(0); // Disable all errors  | 
                                                        |
| 42 | 42 | //error_reporting(E_ALL);  | 
                                                        
| 43 | -@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64  | 
                                                        |
| 43 | +@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64  | 
                                                        |
| 44 | 44 | error_reporting($err);  | 
                                                        
| 45 | 45 | |
| 46 | 46 |  $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]); | 
                                                        
@@ -584,7 +584,7 @@ discard block  | 
                                                    ||
| 584 | 584 | |
| 585 | 585 | $conf->file->instance_unique_id = (empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id); // Unique id of instance  | 
                                                        
| 586 | 586 | |
| 587 | -$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256');	// Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. | 
                                                        |
| 587 | +$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. | 
                                                        |
| 588 | 588 | |
| 589 | 589 |  $out  = '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> '; | 
                                                        
| 590 | 590 |  $out .= '<label for="dolibarrpingno">'.$langs->trans("MakeAnonymousPing").'</label>'; | 
                                                        
@@ -888,17 +888,17 @@ discard block  | 
                                                    ||
| 888 | 888 | }  | 
                                                        
| 889 | 889 | $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]);  | 
                                                        
| 890 | 890 |  				if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { | 
                                                        
| 891 | - $datas[$key]= '<br><b><u>'. $labelextra . '</u></b>';  | 
                                                        |
| 891 | + $datas[$key] = '<br><b><u>'.$labelextra.'</u></b>';  | 
                                                        |
| 892 | 892 |  				} else { | 
                                                        
| 893 | - $value = (empty($this->array_options['options_' . $key]) ? '' : $this->array_options['options_' . $key]);  | 
                                                        |
| 894 | - $datas[$key]= '<br><b>'. $labelextra . ':</b> ' . $extrafields->showOutputField($key, $value, '', $this->table_element);  | 
                                                        |
| 893 | + $value = (empty($this->array_options['options_'.$key]) ? '' : $this->array_options['options_'.$key]);  | 
                                                        |
| 894 | + $datas[$key] = '<br><b>'.$labelextra.':</b> '.$extrafields->showOutputField($key, $value, '', $this->table_element);  | 
                                                        |
| 895 | 895 | $count++;  | 
                                                        
| 896 | 896 | }  | 
                                                        
| 897 | 897 | }  | 
                                                        
| 898 | 898 | $datas['closedivextra'] = '</div>';  | 
                                                        
| 899 | 899 | }  | 
                                                        
| 900 | 900 | |
| 901 | - $hookmanager->initHooks(array($this->element . 'dao'));  | 
                                                        |
| 901 | + $hookmanager->initHooks(array($this->element.'dao'));  | 
                                                        |
| 902 | 902 | $parameters = array(  | 
                                                        
| 903 | 903 | 'tooltipcontentarray' => &$datas,  | 
                                                        
| 904 | 904 | 'params' => $params,  | 
                                                        
@@ -1389,7 +1389,7 @@ discard block  | 
                                                    ||
| 1389 | 1389 |  		if ($source == 'external' || $source == 'thirdparty') { | 
                                                        
| 1390 | 1390 | $sql .= " AND tc.source = 'external'";  | 
                                                        
| 1391 | 1391 |  			if ($status >= 0) { | 
                                                        
| 1392 | - $sql .= " AND t.statut = ".((int) $status); // t is llx_socpeople  | 
                                                        |
| 1392 | + $sql .= " AND t.statut = ".((int) $status); // t is llx_socpeople  | 
                                                        |
| 1393 | 1393 | }  | 
                                                        
| 1394 | 1394 | }  | 
                                                        
| 1395 | 1395 | $sql .= " AND tc.active = 1";  | 
                                                        
@@ -1748,8 +1748,8 @@ discard block  | 
                                                    ||
| 1748 | 1748 |  		if ($idtofetch) { | 
                                                        
| 1749 | 1749 | $thirdparty = new Societe($this->db);  | 
                                                        
| 1750 | 1750 | $result = $thirdparty->fetch($idtofetch);  | 
                                                        
| 1751 | -			if ($result<0) { | 
                                                        |
| 1752 | - $this->errors=array_merge($this->errors, $thirdparty->errors);  | 
                                                        |
| 1751 | +			if ($result < 0) { | 
                                                        |
| 1752 | + $this->errors = array_merge($this->errors, $thirdparty->errors);  | 
                                                        |
| 1753 | 1753 | }  | 
                                                        
| 1754 | 1754 | $this->thirdparty = $thirdparty;  | 
                                                        
| 1755 | 1755 | |
@@ -1779,7 +1779,7 @@ discard block  | 
                                                    ||
| 1779 | 1779 | }  | 
                                                        
| 1780 | 1780 | |
| 1781 | 1781 | $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element;  | 
                                                        
| 1782 | - $sql .= " WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."'"; // no escapeforlike here  | 
                                                        |
| 1782 | + $sql .= " WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."'"; // no escapeforlike here  | 
                                                        |
| 1783 | 1783 | $sql .= " LIMIT 1";  | 
                                                        
| 1784 | 1784 | |
| 1785 | 1785 | $query = $this->db->query($sql);  | 
                                                        
@@ -2072,9 +2072,9 @@ discard block  | 
                                                    ||
| 2072 | 2072 |  		if ($trigkey) { | 
                                                        
| 2073 | 2073 | $oldvalue = null;  | 
                                                        
| 2074 | 2074 | |
| 2075 | - $sql = "SELECT " . $field;  | 
                                                        |
| 2076 | - $sql .= " FROM " . MAIN_DB_PREFIX . $table;  | 
                                                        |
| 2077 | - $sql .= " WHERE " . $id_field . " = " . ((int) $id);  | 
                                                        |
| 2075 | + $sql = "SELECT ".$field;  | 
                                                        |
| 2076 | + $sql .= " FROM ".MAIN_DB_PREFIX.$table;  | 
                                                        |
| 2077 | + $sql .= " WHERE ".$id_field." = ".((int) $id);  | 
                                                        |
| 2078 | 2078 | |
| 2079 | 2079 | $resql = $this->db->query($sql);  | 
                                                        
| 2080 | 2080 |  			if ($resql) { | 
                                                        
@@ -2427,7 +2427,7 @@ discard block  | 
                                                    ||
| 2427 | 2427 | // Triggers  | 
                                                        
| 2428 | 2428 |  		if (!$error && !$notrigger) { | 
                                                        
| 2429 | 2429 | // Call triggers  | 
                                                        
| 2430 | - $result = $this->call_trigger(strtoupper($this->element) . '_MODIFY', $user);  | 
                                                        |
| 2430 | + $result = $this->call_trigger(strtoupper($this->element).'_MODIFY', $user);  | 
                                                        |
| 2431 | 2431 |  			if ($result < 0) { | 
                                                        
| 2432 | 2432 | $error++;  | 
                                                        
| 2433 | 2433 | } //Do also here what you must do to rollback action if trigger fail  | 
                                                        
@@ -2793,7 +2793,7 @@ discard block  | 
                                                    ||
| 2793 | 2793 | $sql = 'UPDATE '.$this->db->prefix().$this->table_element;  | 
                                                        
| 2794 | 2794 | $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');  | 
                                                        
| 2795 | 2795 |  			if (in_array($this->table_element, array('propal', 'commande', 'societe'))) { | 
                                                        
| 2796 | - $sql .= " , deposit_percent = " . (empty($deposit_percent) ? 'NULL' : "'".$this->db->escape($deposit_percent)."'");  | 
                                                        |
| 2796 | + $sql .= " , deposit_percent = ".(empty($deposit_percent) ? 'NULL' : "'".$this->db->escape($deposit_percent)."'");  | 
                                                        |
| 2797 | 2797 | }  | 
                                                        
| 2798 | 2798 | $sql .= ' WHERE rowid='.((int) $this->id);  | 
                                                        
| 2799 | 2799 | |
@@ -3142,10 +3142,10 @@ discard block  | 
                                                    ||
| 3142 | 3142 | $sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line;  | 
                                                        
| 3143 | 3143 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);  | 
                                                        
| 3144 | 3144 |  		if (!$renum) { | 
                                                        
| 3145 | - $sql .= " AND " . $fieldposition . " = 0";  | 
                                                        |
| 3145 | + $sql .= " AND ".$fieldposition." = 0";  | 
                                                        |
| 3146 | 3146 | }  | 
                                                        
| 3147 | 3147 |  		if ($renum) { | 
                                                        
| 3148 | - $sql .= " AND " . $fieldposition . " <> 0";  | 
                                                        |
| 3148 | + $sql .= " AND ".$fieldposition." <> 0";  | 
                                                        |
| 3149 | 3149 | }  | 
                                                        
| 3150 | 3150 | |
| 3151 | 3151 | dol_syslog(get_class($this)."::line_order", LOG_DEBUG);  | 
                                                        
@@ -3166,7 +3166,7 @@ discard block  | 
                                                    ||
| 3166 | 3166 |  			if ($fk_parent_line) { | 
                                                        
| 3167 | 3167 | $sql .= ' AND fk_parent_line IS NULL';  | 
                                                        
| 3168 | 3168 | }  | 
                                                        
| 3169 | - $sql .= " ORDER BY " . $fieldposition . " ASC, rowid " . $rowidorder;  | 
                                                        |
| 3169 | + $sql .= " ORDER BY ".$fieldposition." ASC, rowid ".$rowidorder;  | 
                                                        |
| 3170 | 3170 | |
| 3171 | 3171 | dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG);  | 
                                                        
| 3172 | 3172 | $resql = $this->db->query($sql);  | 
                                                        
@@ -3217,7 +3217,7 @@ discard block  | 
                                                    ||
| 3217 | 3217 | $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;  | 
                                                        
| 3218 | 3218 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);  | 
                                                        
| 3219 | 3219 | $sql .= ' AND fk_parent_line = '.((int) $id);  | 
                                                        
| 3220 | - $sql .= " ORDER BY " . $fieldposition . " ASC";  | 
                                                        |
| 3220 | + $sql .= " ORDER BY ".$fieldposition." ASC";  | 
                                                        |
| 3221 | 3221 | |
| 3222 | 3222 | dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG);  | 
                                                        
| 3223 | 3223 | $resql = $this->db->query($sql);  | 
                                                        
@@ -3300,8 +3300,8 @@ discard block  | 
                                                    ||
| 3300 | 3300 | dol_print_error($this->db);  | 
                                                        
| 3301 | 3301 | return -1;  | 
                                                        
| 3302 | 3302 |  		} else { | 
                                                        
| 3303 | -			$parameters=array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); | 
                                                        |
| 3304 | - $action='';  | 
                                                        |
| 3303 | +			$parameters = array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); | 
                                                        |
| 3304 | + $action = '';  | 
                                                        |
| 3305 | 3305 |  			$reshook = $hookmanager->executeHooks('afterRankOfLineUpdate', $parameters, $this, $action); | 
                                                        
| 3306 | 3306 | return 1;  | 
                                                        
| 3307 | 3307 | }  | 
                                                        
@@ -3340,7 +3340,7 @@ discard block  | 
                                                    ||
| 3340 | 3340 | |
| 3341 | 3341 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);  | 
                                                        
| 3342 | 3342 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);  | 
                                                        
| 3343 | - $sql .= " AND " . $fieldposition . " = " . ((int) ($rang - 1));  | 
                                                        |
| 3343 | + $sql .= " AND ".$fieldposition." = ".((int) ($rang - 1));  | 
                                                        |
| 3344 | 3344 |  			if ($this->db->query($sql)) { | 
                                                        
| 3345 | 3345 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));  | 
                                                        
| 3346 | 3346 | $sql .= ' WHERE rowid = '.((int) $rowid);  | 
                                                        
@@ -3371,7 +3371,7 @@ discard block  | 
                                                    ||
| 3371 | 3371 | |
| 3372 | 3372 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);  | 
                                                        
| 3373 | 3373 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);  | 
                                                        
| 3374 | - $sql .= " AND " . $fieldposition . " = " . ((int) ($rang + 1));  | 
                                                        |
| 3374 | + $sql .= " AND ".$fieldposition." = ".((int) ($rang + 1));  | 
                                                        |
| 3375 | 3375 |  			if ($this->db->query($sql)) { | 
                                                        
| 3376 | 3376 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));  | 
                                                        
| 3377 | 3377 | $sql .= ' WHERE rowid = '.((int) $rowid);  | 
                                                        
@@ -3397,7 +3397,7 @@ discard block  | 
                                                    ||
| 3397 | 3397 | $fieldposition = 'position';  | 
                                                        
| 3398 | 3398 | }  | 
                                                        
| 3399 | 3399 | |
| 3400 | - $sql = "SELECT " . $fieldposition . " FROM ".$this->db->prefix().$this->table_element_line;  | 
                                                        |
| 3400 | + $sql = "SELECT ".$fieldposition." FROM ".$this->db->prefix().$this->table_element_line;  | 
                                                        |
| 3401 | 3401 | $sql .= " WHERE rowid = ".((int) $rowid);  | 
                                                        
| 3402 | 3402 | |
| 3403 | 3403 | dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);  | 
                                                        
@@ -3425,7 +3425,7 @@ discard block  | 
                                                    ||
| 3425 | 3425 | |
| 3426 | 3426 | $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;  | 
                                                        
| 3427 | 3427 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);  | 
                                                        
| 3428 | - $sql .= " AND " . $fieldposition . " = ".((int) $rang);  | 
                                                        |
| 3428 | + $sql .= " AND ".$fieldposition." = ".((int) $rang);  | 
                                                        |
| 3429 | 3429 | $resql = $this->db->query($sql);  | 
                                                        
| 3430 | 3430 |  		if ($resql) { | 
                                                        
| 3431 | 3431 | $row = $this->db->fetch_row($resql);  | 
                                                        
@@ -3543,7 +3543,7 @@ discard block  | 
                                                    ||
| 3543 | 3543 | $newsuffix = '';  | 
                                                        
| 3544 | 3544 | }  | 
                                                        
| 3545 | 3545 |  		if (in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { | 
                                                        
| 3546 | - $fieldusermod = "fk_user_mod";  | 
                                                        |
| 3546 | + $fieldusermod = "fk_user_mod";  | 
                                                        |
| 3547 | 3547 |  		} elseif ($this->table_element == 'ecm_files') { | 
                                                        
| 3548 | 3548 | $fieldusermod = "fk_user_m";  | 
                                                        
| 3549 | 3549 |  		} else { | 
                                                        
@@ -3585,7 +3585,7 @@ discard block  | 
                                                    ||
| 3585 | 3585 | $trigger_name = 'EXPENSE_REPORT_MODIFY';  | 
                                                        
| 3586 | 3586 | break;  | 
                                                        
| 3587 | 3587 | default:  | 
                                                        
| 3588 | - $trigger_name = strtoupper($this->element) . '_MODIFY';  | 
                                                        |
| 3588 | + $trigger_name = strtoupper($this->element).'_MODIFY';  | 
                                                        |
| 3589 | 3589 | }  | 
                                                        
| 3590 | 3590 | $ret = $this->call_trigger($trigger_name, $user);  | 
                                                        
| 3591 | 3591 |  				if ($ret < 0) { | 
                                                        
@@ -3943,7 +3943,7 @@ discard block  | 
                                                    ||
| 3943 | 3943 | // It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target.  | 
                                                        
| 3944 | 3944 |  		$coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization', 'asset'); | 
                                                        
| 3945 | 3945 | // Add module part to target type if object has $module property and isn't in core modules.  | 
                                                        
| 3946 | - $targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element;  | 
                                                        |
| 3946 | + $targettype = ((!empty($this->module) && !in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element;  | 
                                                        |
| 3947 | 3947 | |
| 3948 | 3948 |  		$parameters = array('targettype'=>$targettype); | 
                                                        
| 3949 | 3949 | // Hook for explicitly set the targettype if it must be differtent than $this->element  | 
                                                        
@@ -3957,19 +3957,19 @@ discard block  | 
                                                    ||
| 3957 | 3957 | $this->db->begin();  | 
                                                        
| 3958 | 3958 | $error = 0;  | 
                                                        
| 3959 | 3959 | |
| 3960 | -		$sql = "INSERT INTO " . $this->db->prefix() . "element_element ("; | 
                                                        |
| 3960 | +		$sql = "INSERT INTO ".$this->db->prefix()."element_element ("; | 
                                                        |
| 3961 | 3961 | $sql .= "fk_source";  | 
                                                        
| 3962 | 3962 | $sql .= ", sourcetype";  | 
                                                        
| 3963 | 3963 | $sql .= ", fk_target";  | 
                                                        
| 3964 | 3964 | $sql .= ", targettype";  | 
                                                        
| 3965 | 3965 |  		$sql .= ") VALUES ("; | 
                                                        
| 3966 | 3966 | $sql .= ((int) $origin_id);  | 
                                                        
| 3967 | - $sql .= ", '" . $this->db->escape($origin) . "'";  | 
                                                        |
| 3968 | - $sql .= ", " . ((int) $this->id);  | 
                                                        |
| 3969 | - $sql .= ", '" . $this->db->escape($targettype) . "'";  | 
                                                        |
| 3967 | + $sql .= ", '".$this->db->escape($origin)."'";  | 
                                                        |
| 3968 | + $sql .= ", ".((int) $this->id);  | 
                                                        |
| 3969 | + $sql .= ", '".$this->db->escape($targettype)."'";  | 
                                                        |
| 3970 | 3970 | $sql .= ")";  | 
                                                        
| 3971 | 3971 | |
| 3972 | - dol_syslog(get_class($this) . "::add_object_linked", LOG_DEBUG);  | 
                                                        |
| 3972 | + dol_syslog(get_class($this)."::add_object_linked", LOG_DEBUG);  | 
                                                        |
| 3973 | 3973 |  		if ($this->db->query($sql)) { | 
                                                        
| 3974 | 3974 |  			if (!$notrigger) { | 
                                                        
| 3975 | 3975 | // Call trigger  | 
                                                        
@@ -4284,20 +4284,20 @@ discard block  | 
                                                    ||
| 4284 | 4284 | $this->db->begin();  | 
                                                        
| 4285 | 4285 | $error = 0;  | 
                                                        
| 4286 | 4286 | |
| 4287 | - $sql = "UPDATE " . $this->db->prefix() . "element_element SET ";  | 
                                                        |
| 4287 | + $sql = "UPDATE ".$this->db->prefix()."element_element SET ";  | 
                                                        |
| 4288 | 4288 |  		if ($updatesource) { | 
                                                        
| 4289 | - $sql .= "fk_source = " . ((int) $sourceid);  | 
                                                        |
| 4290 | - $sql .= ", sourcetype = '" . $this->db->escape($sourcetype) . "'";  | 
                                                        |
| 4291 | - $sql .= " WHERE fk_target = " . ((int) $this->id);  | 
                                                        |
| 4292 | - $sql .= " AND targettype = '" . $this->db->escape($this->element) . "'";  | 
                                                        |
| 4289 | + $sql .= "fk_source = ".((int) $sourceid);  | 
                                                        |
| 4290 | + $sql .= ", sourcetype = '".$this->db->escape($sourcetype)."'";  | 
                                                        |
| 4291 | + $sql .= " WHERE fk_target = ".((int) $this->id);  | 
                                                        |
| 4292 | + $sql .= " AND targettype = '".$this->db->escape($this->element)."'";  | 
                                                        |
| 4293 | 4293 |  		} elseif ($updatetarget) { | 
                                                        
| 4294 | - $sql .= "fk_target = " . ((int) $targetid);  | 
                                                        |
| 4295 | - $sql .= ", targettype = '" . $this->db->escape($targettype) . "'";  | 
                                                        |
| 4296 | - $sql .= " WHERE fk_source = " . ((int) $this->id);  | 
                                                        |
| 4297 | - $sql .= " AND sourcetype = '" . $this->db->escape($this->element) . "'";  | 
                                                        |
| 4294 | + $sql .= "fk_target = ".((int) $targetid);  | 
                                                        |
| 4295 | + $sql .= ", targettype = '".$this->db->escape($targettype)."'";  | 
                                                        |
| 4296 | + $sql .= " WHERE fk_source = ".((int) $this->id);  | 
                                                        |
| 4297 | + $sql .= " AND sourcetype = '".$this->db->escape($this->element)."'";  | 
                                                        |
| 4298 | 4298 | }  | 
                                                        
| 4299 | 4299 | |
| 4300 | - dol_syslog(get_class($this) . "::updateObjectLinked", LOG_DEBUG);  | 
                                                        |
| 4300 | + dol_syslog(get_class($this)."::updateObjectLinked", LOG_DEBUG);  | 
                                                        |
| 4301 | 4301 |  		if ($this->db->query($sql)) { | 
                                                        
| 4302 | 4302 |  			if (!$notrigger) { | 
                                                        
| 4303 | 4303 | // Call trigger  | 
                                                        
@@ -4373,25 +4373,25 @@ discard block  | 
                                                    ||
| 4373 | 4373 | }  | 
                                                        
| 4374 | 4374 | |
| 4375 | 4375 |  		if (!$error) { | 
                                                        
| 4376 | - $sql = "DELETE FROM " . $this->db->prefix() . "element_element";  | 
                                                        |
| 4376 | + $sql = "DELETE FROM ".$this->db->prefix()."element_element";  | 
                                                        |
| 4377 | 4377 | $sql .= " WHERE";  | 
                                                        
| 4378 | 4378 |  			if ($rowid > 0) { | 
                                                        
| 4379 | - $sql .= " rowid = " . ((int) $rowid);  | 
                                                        |
| 4379 | + $sql .= " rowid = ".((int) $rowid);  | 
                                                        |
| 4380 | 4380 |  			} else { | 
                                                        
| 4381 | 4381 |  				if ($deletesource) { | 
                                                        
| 4382 | - $sql .= " fk_source = " . ((int) $sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'";  | 
                                                        |
| 4383 | - $sql .= " AND fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "'";  | 
                                                        |
| 4382 | + $sql .= " fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."'";  | 
                                                        |
| 4383 | + $sql .= " AND fk_target = ".((int) $this->id)." AND targettype = '".$this->db->escape($this->element)."'";  | 
                                                        |
| 4384 | 4384 |  				} elseif ($deletetarget) { | 
                                                        
| 4385 | - $sql .= " fk_target = " . ((int) $targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'";  | 
                                                        |
| 4386 | - $sql .= " AND fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "'";  | 
                                                        |
| 4385 | + $sql .= " fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."'";  | 
                                                        |
| 4386 | + $sql .= " AND fk_source = ".((int) $this->id)." AND sourcetype = '".$this->db->escape($this->element)."'";  | 
                                                        |
| 4387 | 4387 |  				} else { | 
                                                        
| 4388 | - $sql .= " (fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "')";  | 
                                                        |
| 4388 | + $sql .= " (fk_source = ".((int) $this->id)." AND sourcetype = '".$this->db->escape($this->element)."')";  | 
                                                        |
| 4389 | 4389 | $sql .= " OR";  | 
                                                        
| 4390 | - $sql .= " (fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "')";  | 
                                                        |
| 4390 | + $sql .= " (fk_target = ".((int) $this->id)." AND targettype = '".$this->db->escape($this->element)."')";  | 
                                                        |
| 4391 | 4391 | }  | 
                                                        
| 4392 | 4392 | }  | 
                                                        
| 4393 | 4393 | |
| 4394 | - dol_syslog(get_class($this) . "::deleteObjectLinked", LOG_DEBUG);  | 
                                                        |
| 4394 | + dol_syslog(get_class($this)."::deleteObjectLinked", LOG_DEBUG);  | 
                                                        |
| 4395 | 4395 |  			if (!$this->db->query($sql)) { | 
                                                        
| 4396 | 4396 | $this->error = $this->db->lasterror();  | 
                                                        
| 4397 | 4397 | $this->errors[] = $this->error;  | 
                                                        
@@ -4553,14 +4553,14 @@ discard block  | 
                                                    ||
| 4553 | 4553 | $sql .= ", date_validation = '".$this->db->idate(dol_now())."'";  | 
                                                        
| 4554 | 4554 | }  | 
                                                        
| 4555 | 4555 | $sql .= " WHERE rowid = ".((int) $elementId);  | 
                                                        
| 4556 | - $sql .= " AND ".$fieldstatus." <> ".((int) $status); // We avoid update if status already correct  | 
                                                        |
| 4556 | + $sql .= " AND ".$fieldstatus." <> ".((int) $status); // We avoid update if status already correct  | 
                                                        |
| 4557 | 4557 | |
| 4558 | 4558 | dol_syslog(get_class($this)."::setStatut", LOG_DEBUG);  | 
                                                        
| 4559 | 4559 | $resql = $this->db->query($sql);  | 
                                                        
| 4560 | 4560 |  		if ($resql) { | 
                                                        
| 4561 | 4561 | $error = 0;  | 
                                                        
| 4562 | 4562 | |
| 4563 | - $nb_rows_affected = $this->db->affected_rows($resql); // should be 1 or 0 if status was already correct  | 
                                                        |
| 4563 | + $nb_rows_affected = $this->db->affected_rows($resql); // should be 1 or 0 if status was already correct  | 
                                                        |
| 4564 | 4564 | |
| 4565 | 4565 |  			if ($nb_rows_affected > 0) { | 
                                                        
| 4566 | 4566 |  				if (empty($trigkey)) { | 
                                                        
@@ -4605,7 +4605,7 @@ discard block  | 
                                                    ||
| 4605 | 4605 |  					if ($fieldstatus == 'tosell') { | 
                                                        
| 4606 | 4606 | $this->status = $status;  | 
                                                        
| 4607 | 4607 |  					} elseif ($fieldstatus == 'tobuy') { | 
                                                        
| 4608 | - $this->status_buy = $status; // @phpstan-ignore-line  | 
                                                        |
| 4608 | + $this->status_buy = $status; // @phpstan-ignore-line  | 
                                                        |
| 4609 | 4609 |  					} else { | 
                                                        
| 4610 | 4610 | $this->statut = $status;  | 
                                                        
| 4611 | 4611 | $this->status = $status;  | 
                                                        
@@ -4714,7 +4714,7 @@ discard block  | 
                                                    ||
| 4714 | 4714 | return -1;  | 
                                                        
| 4715 | 4715 | }  | 
                                                        
| 4716 | 4716 | |
| 4717 | -		$arraytoscan = $this->childtables;		// array('tablename'=>array('fk_element'=>'parentfield'), ...) or array('tablename'=>array('parent'=>table_parent, 'parentkey'=>'nameoffieldforparentfkkey'), ...) | 
                                                        |
| 4717 | +		$arraytoscan = $this->childtables; // array('tablename'=>array('fk_element'=>'parentfield'), ...) or array('tablename'=>array('parent'=>table_parent, 'parentkey'=>'nameoffieldforparentfkkey'), ...) | 
                                                        |
| 4718 | 4718 |  		// For backward compatibility, we check if array is old format array('tablename1', 'tablename2', ...) | 
                                                        
| 4719 | 4719 | $tmparray = array_keys($this->childtables);  | 
                                                        
| 4720 | 4720 |  		if (is_numeric($tmparray[0])) { | 
                                                        
@@ -4727,26 +4727,26 @@ discard block  | 
                                                    ||
| 4727 | 4727 | //print $id.'-'.$table.'-'.$elementname.'<br>';  | 
                                                        
| 4728 | 4728 | // Check if element can be deleted  | 
                                                        
| 4729 | 4729 | $sql = "SELECT COUNT(*) as nb";  | 
                                                        
| 4730 | - $sql.= " FROM ".$this->db->prefix().$table." as c";  | 
                                                        |
| 4730 | + $sql .= " FROM ".$this->db->prefix().$table." as c";  | 
                                                        |
| 4731 | 4731 |  			if (!empty($element['parent']) && !empty($element['parentkey'])) { | 
                                                        
| 4732 | - $sql.= ", ".$this->db->prefix().$element['parent']." as p";  | 
                                                        |
| 4732 | + $sql .= ", ".$this->db->prefix().$element['parent']." as p";  | 
                                                        |
| 4733 | 4733 | }  | 
                                                        
| 4734 | 4734 |  			if (!empty($element['fk_element'])) { | 
                                                        
| 4735 | - $sql.= " WHERE c.".$element['fk_element']." = ".((int) $id);  | 
                                                        |
| 4735 | + $sql .= " WHERE c.".$element['fk_element']." = ".((int) $id);  | 
                                                        |
| 4736 | 4736 |  			} else { | 
                                                        
| 4737 | - $sql.= " WHERE c.".$this->fk_element." = ".((int) $id);  | 
                                                        |
| 4737 | + $sql .= " WHERE c.".$this->fk_element." = ".((int) $id);  | 
                                                        |
| 4738 | 4738 | }  | 
                                                        
| 4739 | 4739 |  			if (!empty($element['parent']) && !empty($element['parentkey'])) { | 
                                                        
| 4740 | - $sql.= " AND c.".$element['parentkey']." = p.rowid";  | 
                                                        |
| 4740 | + $sql .= " AND c.".$element['parentkey']." = p.rowid";  | 
                                                        |
| 4741 | 4741 | }  | 
                                                        
| 4742 | 4742 |  			if (!empty($element['parent']) && !empty($element['parenttypefield']) && !empty($element['parenttypevalue'])) { | 
                                                        
| 4743 | - $sql.= " AND c.".$element['parenttypefield']." = '".$this->db->escape($element['parenttypevalue'])."'";  | 
                                                        |
| 4743 | + $sql .= " AND c.".$element['parenttypefield']." = '".$this->db->escape($element['parenttypevalue'])."'";  | 
                                                        |
| 4744 | 4744 | }  | 
                                                        
| 4745 | 4745 |  			if (!empty($entity)) { | 
                                                        
| 4746 | 4746 |  				if (!empty($element['parent']) && !empty($element['parentkey'])) { | 
                                                        
| 4747 | - $sql.= " AND p.entity = ".((int) $entity);  | 
                                                        |
| 4747 | + $sql .= " AND p.entity = ".((int) $entity);  | 
                                                        |
| 4748 | 4748 |  				} else { | 
                                                        
| 4749 | - $sql.= " AND c.entity = ".((int) $entity);  | 
                                                        |
| 4749 | + $sql .= " AND c.entity = ".((int) $entity);  | 
                                                        |
| 4750 | 4750 | }  | 
                                                        
| 4751 | 4751 | }  | 
                                                        
| 4752 | 4752 | |
@@ -5776,7 +5776,7 @@ discard block  | 
                                                    ||
| 5776 | 5776 | $setsharekey = false;  | 
                                                        
| 5777 | 5777 |  			if ($this->element == 'propal' || $this->element == 'proposal') { | 
                                                        
| 5778 | 5778 |  				if (getDolGlobalInt("PROPOSAL_ALLOW_ONLINESIGN")) { | 
                                                        
| 5779 | - $setsharekey = true; // feature to make online signature is not set or set to on (default)  | 
                                                        |
| 5779 | + $setsharekey = true; // feature to make online signature is not set or set to on (default)  | 
                                                        |
| 5780 | 5780 | }  | 
                                                        
| 5781 | 5781 |  				if (getDolGlobalInt("PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD")) { | 
                                                        
| 5782 | 5782 | $setsharekey = true;  | 
                                                        
@@ -5834,7 +5834,7 @@ discard block  | 
                                                    ||
| 5834 | 5834 | $ecmfile->gen_or_uploaded = 'generated';  | 
                                                        
| 5835 | 5835 | $ecmfile->description = ''; // indexed content  | 
                                                        
| 5836 | 5836 | $ecmfile->keywords = ''; // keyword content  | 
                                                        
| 5837 | - $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'.  | 
                                                        |
| 5837 | + $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'.  | 
                                                        |
| 5838 | 5838 | $ecmfile->src_object_id = $this->id;  | 
                                                        
| 5839 | 5839 | |
| 5840 | 5840 | $result = $ecmfile->create($user);  | 
                                                        
@@ -5886,7 +5886,7 @@ discard block  | 
                                                    ||
| 5886 | 5886 | $maxwidthmini = $tmparraysize['maxwidthmini'];  | 
                                                        
| 5887 | 5887 | $maxheightmini = $tmparraysize['maxheightmini'];  | 
                                                        
| 5888 | 5888 | //$quality = $tmparraysize['quality'];  | 
                                                        
| 5889 | - $quality = 50; // For thumbs, we force quality to 50  | 
                                                        |
| 5889 | + $quality = 50; // For thumbs, we force quality to 50  | 
                                                        |
| 5890 | 5890 | |
| 5891 | 5891 | // Create small thumbs for company (Ratio is near 16/9)  | 
                                                        
| 5892 | 5892 | // Used on logon for example  | 
                                                        
@@ -5988,8 +5988,8 @@ discard block  | 
                                                    ||
| 5988 | 5988 | // phpcs:enable  | 
                                                        
| 5989 | 5989 | global $langs, $conf;  | 
                                                        
| 5990 | 5990 | |
| 5991 | -		if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX . '_') !== 0) { | 
                                                        |
| 5992 | -			dol_print_error('', 'The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.'); | 
                                                        |
| 5991 | +		if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX.'_') !== 0) { | 
                                                        |
| 5992 | +			dol_print_error('', 'The trigger "'.$triggerName.'" does not start with "'.self::TRIGGER_PREFIX.'_" as required.'); | 
                                                        |
| 5993 | 5993 | exit;  | 
                                                        
| 5994 | 5994 | }  | 
                                                        
| 5995 | 5995 |  		if (!is_object($langs)) {	// If lang was not defined, we set it. It is required by run_triggers(). | 
                                                        
@@ -6183,7 +6183,7 @@ discard block  | 
                                                    ||
| 6183 | 6183 | $savDisableCompute = $conf->disable_compute;  | 
                                                        
| 6184 | 6184 | $conf->disable_compute = 1;  | 
                                                        
| 6185 | 6185 | |
| 6186 | - $ret = $this->fetch($id); /* @phpstan-ignore-line */  | 
                                                        |
| 6186 | + $ret = $this->fetch($id); /* @phpstan-ignore-line */  | 
                                                        |
| 6187 | 6187 | |
| 6188 | 6188 | $conf->disable_compute = $savDisableCompute;  | 
                                                        
| 6189 | 6189 | |
@@ -6287,9 +6287,9 @@ discard block  | 
                                                    ||
| 6287 | 6287 |  						if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { | 
                                                        
| 6288 | 6288 | //var_dump($conf->disable_compute);  | 
                                                        
| 6289 | 6289 |  							if (empty($conf->disable_compute)) { | 
                                                        
| 6290 | - global $objectoffield; // We set a global variable to $objectoffield so  | 
                                                        |
| 6291 | - $objectoffield = $this; // we can use it inside computed formula  | 
                                                        |
| 6292 | - $this->array_options['options_' . $key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '2');  | 
                                                        |
| 6290 | + global $objectoffield; // We set a global variable to $objectoffield so  | 
                                                        |
| 6291 | + $objectoffield = $this; // we can use it inside computed formula  | 
                                                        |
| 6292 | + $this->array_options['options_'.$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '2');  | 
                                                        |
| 6293 | 6293 | }  | 
                                                        
| 6294 | 6294 | }  | 
                                                        
| 6295 | 6295 | }  | 
                                                        
@@ -6303,7 +6303,7 @@ discard block  | 
                                                    ||
| 6303 | 6303 | return 0;  | 
                                                        
| 6304 | 6304 | }  | 
                                                        
| 6305 | 6305 |  			} else { | 
                                                        
| 6306 | - $this->errors[]=$this->db->lasterror;  | 
                                                        |
| 6306 | + $this->errors[] = $this->db->lasterror;  | 
                                                        |
| 6307 | 6307 | return -1;  | 
                                                        
| 6308 | 6308 | }  | 
                                                        
| 6309 | 6309 | }  | 
                                                        
@@ -6470,7 +6470,7 @@ discard block  | 
                                                    ||
| 6470 | 6470 | // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update.  | 
                                                        
| 6471 | 6471 |  										if ($algo == 'dolcrypt') {	// dolibarr reversible encryption | 
                                                        
| 6472 | 6472 |  											if (!preg_match('/^dolcrypt:/', $this->array_options[$key])) { | 
                                                        
| 6473 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master  | 
                                                        |
| 6473 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master  | 
                                                        |
| 6474 | 6474 |  											} else { | 
                                                        
| 6475 | 6475 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept  | 
                                                        
| 6476 | 6476 | }  | 
                                                        
@@ -6481,7 +6481,7 @@ discard block  | 
                                                    ||
| 6481 | 6481 | // If value has changed  | 
                                                        
| 6482 | 6482 |  										if ($algo == 'dolcrypt') {	// dolibarr reversible encryption | 
                                                        
| 6483 | 6483 |  											if (!preg_match('/^dolcrypt:/', $this->array_options[$key])) { | 
                                                        
| 6484 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master  | 
                                                        |
| 6484 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master  | 
                                                        |
| 6485 | 6485 |  											} else { | 
                                                        
| 6486 | 6486 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept  | 
                                                        
| 6487 | 6487 | }  | 
                                                        
@@ -6493,7 +6493,7 @@ discard block  | 
                                                    ||
| 6493 | 6493 |  									//var_dump('jjj'.$algo.' '.$this->oldcopy->array_options[$key].' -> '.$this->array_options[$key]); | 
                                                        
| 6494 | 6494 | // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value  | 
                                                        
| 6495 | 6495 |  									if ($algo == 'dolcrypt' && !preg_match('/^dolcrypt:/', $this->array_options[$key])) {	// dolibarr reversible encryption | 
                                                        
| 6496 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master  | 
                                                        |
| 6496 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master  | 
                                                        |
| 6497 | 6497 |  									} else { | 
                                                        
| 6498 | 6498 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept  | 
                                                        
| 6499 | 6499 | }  | 
                                                        
@@ -6879,7 +6879,7 @@ discard block  | 
                                                    ||
| 6879 | 6879 |  								if (isset($this->oldcopy->array_options["options_".$key]) && $this->array_options["options_".$key] == $this->oldcopy->array_options["options_".$key]) {	// If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. | 
                                                        
| 6880 | 6880 |  									if ($algo == 'dolcrypt') {	// dolibarr reversible encryption | 
                                                        
| 6881 | 6881 |  										if (!preg_match('/^dolcrypt:/', $this->array_options["options_".$key])) { | 
                                                        
| 6882 | - $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master  | 
                                                        |
| 6882 | + $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master  | 
                                                        |
| 6883 | 6883 |  										} else { | 
                                                        
| 6884 | 6884 | $new_array_options["options_".$key] = $this->array_options["options_".$key]; // Value is kept  | 
                                                        
| 6885 | 6885 | }  | 
                                                        
@@ -6899,7 +6899,7 @@ discard block  | 
                                                    ||
| 6899 | 6899 | }  | 
                                                        
| 6900 | 6900 |  							} else { | 
                                                        
| 6901 | 6901 |  								if ($algo == 'dolcrypt' && !preg_match('/^dolcrypt:/', $this->array_options["options_".$key])) {	// dolibarr reversible encryption | 
                                                        
| 6902 | - $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master  | 
                                                        |
| 6902 | + $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master  | 
                                                        |
| 6903 | 6903 |  								} else { | 
                                                        
| 6904 | 6904 | $new_array_options["options_".$key] = $this->array_options["options_".$key]; // Value is kept  | 
                                                        
| 6905 | 6905 | }  | 
                                                        
@@ -7149,7 +7149,7 @@ discard block  | 
                                                    ||
| 7149 | 7149 | // Special case that force options and type ($type can be integer, varchar, ...)  | 
                                                        
| 7150 | 7150 |  		if (!empty($this->fields[$key]['arrayofkeyval']) && is_array($this->fields[$key]['arrayofkeyval'])) { | 
                                                        
| 7151 | 7151 | $param['options'] = $this->fields[$key]['arrayofkeyval'];  | 
                                                        
| 7152 | - $type = (($this->fields[$key]['type']=='checkbox') ? $this->fields[$key]['type'] : 'select');  | 
                                                        |
| 7152 | + $type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select');  | 
                                                        |
| 7153 | 7153 | }  | 
                                                        
| 7154 | 7154 | |
| 7155 | 7155 | $label = $this->fields[$key]['label'];  | 
                                                        
@@ -7201,7 +7201,7 @@ discard block  | 
                                                    ||
| 7201 | 7201 | |
| 7202 | 7202 | // Add validation state class  | 
                                                        
| 7203 | 7203 |  		if (!empty($validationClass)) { | 
                                                        
| 7204 | - $morecss.= $validationClass;  | 
                                                        |
| 7204 | + $morecss .= $validationClass;  | 
                                                        |
| 7205 | 7205 | }  | 
                                                        
| 7206 | 7206 | |
| 7207 | 7207 |  		if (in_array($type, array('date'))) { | 
                                                        
@@ -7309,7 +7309,7 @@ discard block  | 
                                                    ||
| 7309 | 7309 |  			if (is_array($param['options'])) { | 
                                                        
| 7310 | 7310 | $param_list = array_keys($param['options']);  | 
                                                        
| 7311 | 7311 |  				$InfoFieldList = explode(":", $param_list[0], 5); | 
                                                        
| 7312 | -				if (! empty($InfoFieldList[4])) { | 
                                                        |
| 7312 | +				if (!empty($InfoFieldList[4])) { | 
                                                        |
| 7313 | 7313 | $pos = 0;  | 
                                                        
| 7314 | 7314 | $parenthesisopen = 0;  | 
                                                        
| 7315 | 7315 |  					while (substr($InfoFieldList[4], $pos, 1) !== '' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) != ':')) { | 
                                                        
@@ -7322,7 +7322,7 @@ discard block  | 
                                                    ||
| 7322 | 7322 | $pos++;  | 
                                                        
| 7323 | 7323 | }  | 
                                                        
| 7324 | 7324 | $tmpbefore = substr($InfoFieldList[4], 0, $pos);  | 
                                                        
| 7325 | - $tmpafter = substr($InfoFieldList[4], $pos+1);  | 
                                                        |
| 7325 | + $tmpafter = substr($InfoFieldList[4], $pos + 1);  | 
                                                        |
| 7326 | 7326 | //var_dump($InfoFieldList[4].' -> '.$pos); var_dump($tmpafter);  | 
                                                        
| 7327 | 7327 | $InfoFieldList[4] = $tmpbefore;  | 
                                                        
| 7328 | 7328 |  					if ($tmpafter !== '') { | 
                                                        
@@ -7370,8 +7370,8 @@ discard block  | 
                                                    ||
| 7370 | 7370 | }  | 
                                                        
| 7371 | 7371 | |
| 7372 | 7372 | $sqlwhere = '';  | 
                                                        
| 7373 | - $sql = "SELECT " . $keyList;  | 
                                                        |
| 7374 | - $sql .= " FROM " . $this->db->prefix() . $InfoFieldList[0];  | 
                                                        |
| 7373 | + $sql = "SELECT ".$keyList;  | 
                                                        |
| 7374 | + $sql .= " FROM ".$this->db->prefix().$InfoFieldList[0];  | 
                                                        |
| 7375 | 7375 |  					if (!empty($InfoFieldList[4])) { | 
                                                        
| 7376 | 7376 | // can use SELECT request  | 
                                                        
| 7377 | 7377 |  						if (strpos($InfoFieldList[4], '$SEL$') !== false) { | 
                                                        
@@ -7388,18 +7388,18 @@ discard block  | 
                                                    ||
| 7388 | 7388 | // We have to join on extrafield table  | 
                                                        
| 7389 | 7389 | $errstr = '';  | 
                                                        
| 7390 | 7390 |  						if (strpos($InfoFieldList[4], 'extra') !== false) { | 
                                                        
| 7391 | - $sql .= " as main, " . $this->db->prefix() . $InfoFieldList[0] . "_extrafields as extra";  | 
                                                        |
| 7392 | - $sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2];  | 
                                                        |
| 7393 | - $sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);  | 
                                                        |
| 7391 | + $sql .= " as main, ".$this->db->prefix().$InfoFieldList[0]."_extrafields as extra";  | 
                                                        |
| 7392 | + $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2];  | 
                                                        |
| 7393 | + $sqlwhere .= " AND ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);  | 
                                                        |
| 7394 | 7394 |  						} else { | 
                                                        
| 7395 | - $sqlwhere .= " WHERE " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);  | 
                                                        |
| 7395 | + $sqlwhere .= " WHERE ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1);  | 
                                                        |
| 7396 | 7396 | }  | 
                                                        
| 7397 | 7397 |  					} else { | 
                                                        
| 7398 | 7398 | $sqlwhere .= ' WHERE 1=1';  | 
                                                        
| 7399 | 7399 | }  | 
                                                        
| 7400 | 7400 | // Some tables may have field, some other not. For the moment we disable it.  | 
                                                        
| 7401 | 7401 |  					if (in_array($InfoFieldList[0], array('tablewithentity'))) { | 
                                                        
| 7402 | - $sqlwhere .= " AND entity = " . ((int) $conf->entity);  | 
                                                        |
| 7402 | + $sqlwhere .= " AND entity = ".((int) $conf->entity);  | 
                                                        |
| 7403 | 7403 | }  | 
                                                        
| 7404 | 7404 | $sql .= $sqlwhere;  | 
                                                        
| 7405 | 7405 | //print $sql;  | 
                                                        
@@ -7411,7 +7411,7 @@ discard block  | 
                                                    ||
| 7411 | 7411 |  						$sql .= " ORDER BY ".$this->db->sanitize(implode(', ', $fields_label)); | 
                                                        
| 7412 | 7412 | }  | 
                                                        
| 7413 | 7413 | |
| 7414 | - dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG);  | 
                                                        |
| 7414 | + dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG);  | 
                                                        |
| 7415 | 7415 | $resql = $this->db->query($sql);  | 
                                                        
| 7416 | 7416 |  					if ($resql) { | 
                                                        
| 7417 | 7417 | $out .= '<option value="0"> </option>';  | 
                                                        
@@ -7427,7 +7427,7 @@ discard block  | 
                                                    ||
| 7427 | 7427 |  							if (count($fields_label) > 1) { | 
                                                        
| 7428 | 7428 | $notrans = true;  | 
                                                        
| 7429 | 7429 |  								foreach ($fields_label as $field_toshow) { | 
                                                        
| 7430 | - $labeltoshow .= $obj->$field_toshow . ' ';  | 
                                                        |
| 7430 | + $labeltoshow .= $obj->$field_toshow.' ';  | 
                                                        |
| 7431 | 7431 | }  | 
                                                        
| 7432 | 7432 |  							} else { | 
                                                        
| 7433 | 7433 |  								$labeltoshow = $obj->{$InfoFieldList[1]}; | 
                                                        
@@ -7438,12 +7438,12 @@ discard block  | 
                                                    ||
| 7438 | 7438 |  								foreach ($fields_label as $field_toshow) { | 
                                                        
| 7439 | 7439 | $translabel = $langs->trans($obj->$field_toshow);  | 
                                                        
| 7440 | 7440 |  									if ($translabel != $obj->$field_toshow) { | 
                                                        
| 7441 | - $labeltoshow = dol_trunc($translabel) . ' ';  | 
                                                        |
| 7441 | + $labeltoshow = dol_trunc($translabel).' ';  | 
                                                        |
| 7442 | 7442 |  									} else { | 
                                                        
| 7443 | - $labeltoshow = dol_trunc($obj->$field_toshow) . ' ';  | 
                                                        |
| 7443 | + $labeltoshow = dol_trunc($obj->$field_toshow).' ';  | 
                                                        |
| 7444 | 7444 | }  | 
                                                        
| 7445 | 7445 | }  | 
                                                        
| 7446 | - $out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';  | 
                                                        |
| 7446 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';  | 
                                                        |
| 7447 | 7447 |  							} else { | 
                                                        
| 7448 | 7448 |  								if (!$notrans) { | 
                                                        
| 7449 | 7449 |  									$translabel = $langs->trans($obj->{$InfoFieldList[1]}); | 
                                                        
@@ -7457,34 +7457,34 @@ discard block  | 
                                                    ||
| 7457 | 7457 | $labeltoshow = '(not defined)';  | 
                                                        
| 7458 | 7458 | }  | 
                                                        
| 7459 | 7459 |  								if ($value == $obj->rowid) { | 
                                                        
| 7460 | - $out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';  | 
                                                        |
| 7460 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';  | 
                                                        |
| 7461 | 7461 | }  | 
                                                        
| 7462 | 7462 | |
| 7463 | 7463 |  								if (!empty($InfoFieldList[3]) && $parentField) { | 
                                                        
| 7464 | -									$parent = $parentName . ':' . $obj->{$parentField}; | 
                                                        |
| 7464 | +									$parent = $parentName.':'.$obj->{$parentField}; | 
                                                        |
| 7465 | 7465 | $isDependList = 1;  | 
                                                        
| 7466 | 7466 | }  | 
                                                        
| 7467 | 7467 | |
| 7468 | - $out .= '<option value="' . $obj->rowid . '"';  | 
                                                        |
| 7468 | + $out .= '<option value="'.$obj->rowid.'"';  | 
                                                        |
| 7469 | 7469 | $out .= ($value == $obj->rowid ? ' selected' : '');  | 
                                                        
| 7470 | - $out .= (!empty($parent) ? ' parent="' . $parent . '"' : '');  | 
                                                        |
| 7471 | - $out .= '>' . $labeltoshow . '</option>';  | 
                                                        |
| 7470 | + $out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');  | 
                                                        |
| 7471 | + $out .= '>'.$labeltoshow.'</option>';  | 
                                                        |
| 7472 | 7472 | }  | 
                                                        
| 7473 | 7473 | |
| 7474 | 7474 | $i++;  | 
                                                        
| 7475 | 7475 | }  | 
                                                        
| 7476 | 7476 | $this->db->free($resql);  | 
                                                        
| 7477 | 7477 |  					} else { | 
                                                        
| 7478 | - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';  | 
                                                        |
| 7478 | + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';  | 
                                                        |
| 7479 | 7479 | }  | 
                                                        
| 7480 | 7480 |  				} else { | 
                                                        
| 7481 | 7481 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';  | 
                                                        
| 7482 | 7482 | $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1);  | 
                                                        
| 7483 | 7483 | $out .= '<option value="0"> </option>';  | 
                                                        
| 7484 | 7484 |  					foreach ($data as $data_key => $data_value) { | 
                                                        
| 7485 | - $out .= '<option value="' . $data_key . '"';  | 
                                                        |
| 7485 | + $out .= '<option value="'.$data_key.'"';  | 
                                                        |
| 7486 | 7486 | $out .= ($value == $data_key ? ' selected' : '');  | 
                                                        
| 7487 | - $out .= '>' . $data_value . '</option>';  | 
                                                        |
| 7487 | + $out .= '>'.$data_value.'</option>';  | 
                                                        |
| 7488 | 7488 | }  | 
                                                        
| 7489 | 7489 | }  | 
                                                        
| 7490 | 7490 | }  | 
                                                        
@@ -7549,8 +7549,8 @@ discard block  | 
                                                    ||
| 7549 | 7549 | }  | 
                                                        
| 7550 | 7550 | |
| 7551 | 7551 | $sqlwhere = '';  | 
                                                        
| 7552 | - $sql = "SELECT " . $keyList;  | 
                                                        |
| 7553 | - $sql .= ' FROM ' . $this->db->prefix() . $InfoFieldList[0];  | 
                                                        |
| 7552 | + $sql = "SELECT ".$keyList;  | 
                                                        |
| 7553 | + $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];  | 
                                                        |
| 7554 | 7554 |  					if (!empty($InfoFieldList[4])) { | 
                                                        
| 7555 | 7555 | // can use SELECT request  | 
                                                        
| 7556 | 7556 |  						if (strpos($InfoFieldList[4], '$SEL$') !== false) { | 
                                                        
@@ -7566,23 +7566,23 @@ discard block  | 
                                                    ||
| 7566 | 7566 | |
| 7567 | 7567 | // We have to join on extrafield table  | 
                                                        
| 7568 | 7568 |  						if (strpos($InfoFieldList[4], 'extra') !== false) { | 
                                                        
| 7569 | - $sql .= ' as main, ' . $this->db->prefix() . $InfoFieldList[0] . '_extrafields as extra';  | 
                                                        |
| 7570 | - $sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4];  | 
                                                        |
| 7569 | + $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra';  | 
                                                        |
| 7570 | + $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];  | 
                                                        |
| 7571 | 7571 |  						} else { | 
                                                        
| 7572 | - $sqlwhere .= " WHERE " . $InfoFieldList[4];  | 
                                                        |
| 7572 | + $sqlwhere .= " WHERE ".$InfoFieldList[4];  | 
                                                        |
| 7573 | 7573 | }  | 
                                                        
| 7574 | 7574 |  					} else { | 
                                                        
| 7575 | 7575 | $sqlwhere .= ' WHERE 1=1';  | 
                                                        
| 7576 | 7576 | }  | 
                                                        
| 7577 | 7577 | // Some tables may have field, some other not. For the moment we disable it.  | 
                                                        
| 7578 | 7578 |  					if (in_array($InfoFieldList[0], array('tablewithentity'))) { | 
                                                        
| 7579 | - $sqlwhere .= " AND entity = " . ((int) $conf->entity);  | 
                                                        |
| 7579 | + $sqlwhere .= " AND entity = ".((int) $conf->entity);  | 
                                                        |
| 7580 | 7580 | }  | 
                                                        
| 7581 | 7581 |  					// $sql.=preg_replace('/^ AND /','',$sqlwhere); | 
                                                        
| 7582 | 7582 | // print $sql;  | 
                                                        
| 7583 | 7583 | |
| 7584 | 7584 | $sql .= $sqlwhere;  | 
                                                        
| 7585 | - dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG);  | 
                                                        |
| 7585 | + dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG);  | 
                                                        |
| 7586 | 7586 | $resql = $this->db->query($sql);  | 
                                                        
| 7587 | 7587 |  					if ($resql) { | 
                                                        
| 7588 | 7588 | $num = $this->db->num_rows($resql);  | 
                                                        
@@ -7600,7 +7600,7 @@ discard block  | 
                                                    ||
| 7600 | 7600 |  							if (count($fields_label) > 1) { | 
                                                        
| 7601 | 7601 | $notrans = true;  | 
                                                        
| 7602 | 7602 |  								foreach ($fields_label as $field_toshow) { | 
                                                        
| 7603 | - $labeltoshow .= $obj->$field_toshow . ' ';  | 
                                                        |
| 7603 | + $labeltoshow .= $obj->$field_toshow.' ';  | 
                                                        |
| 7604 | 7604 | }  | 
                                                        
| 7605 | 7605 |  							} else { | 
                                                        
| 7606 | 7606 |  								$labeltoshow = $obj->{$InfoFieldList[1]}; | 
                                                        
@@ -7611,9 +7611,9 @@ discard block  | 
                                                    ||
| 7611 | 7611 |  								foreach ($fields_label as $field_toshow) { | 
                                                        
| 7612 | 7612 | $translabel = $langs->trans($obj->$field_toshow);  | 
                                                        
| 7613 | 7613 |  									if ($translabel != $obj->$field_toshow) { | 
                                                        
| 7614 | - $labeltoshow = dol_trunc($translabel, 18) . ' ';  | 
                                                        |
| 7614 | + $labeltoshow = dol_trunc($translabel, 18).' ';  | 
                                                        |
| 7615 | 7615 |  									} else { | 
                                                        
| 7616 | - $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';  | 
                                                        |
| 7616 | + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' ';  | 
                                                        |
| 7617 | 7617 | }  | 
                                                        
| 7618 | 7618 | }  | 
                                                        
| 7619 | 7619 | |
@@ -7636,7 +7636,7 @@ discard block  | 
                                                    ||
| 7636 | 7636 | }  | 
                                                        
| 7637 | 7637 | |
| 7638 | 7638 |  								if (!empty($InfoFieldList[3]) && $parentField) { | 
                                                        
| 7639 | -									$parent = $parentName . ':' . $obj->{$parentField}; | 
                                                        |
| 7639 | +									$parent = $parentName.':'.$obj->{$parentField}; | 
                                                        |
| 7640 | 7640 | $isDependList = 1;  | 
                                                        
| 7641 | 7641 | }  | 
                                                        
| 7642 | 7642 | |
@@ -7647,14 +7647,14 @@ discard block  | 
                                                    ||
| 7647 | 7647 | }  | 
                                                        
| 7648 | 7648 | $this->db->free($resql);  | 
                                                        
| 7649 | 7649 | |
| 7650 | - $out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%');  | 
                                                        |
| 7650 | + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%');  | 
                                                        |
| 7651 | 7651 |  					} else { | 
                                                        
| 7652 | - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';  | 
                                                        |
| 7652 | + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';  | 
                                                        |
| 7653 | 7653 | }  | 
                                                        
| 7654 | 7654 |  				} else { | 
                                                        
| 7655 | 7655 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';  | 
                                                        
| 7656 | 7656 | $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1);  | 
                                                        
| 7657 | - $out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%');  | 
                                                        |
| 7657 | + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%');  | 
                                                        |
| 7658 | 7658 | }  | 
                                                        
| 7659 | 7659 | }  | 
                                                        
| 7660 | 7660 |  		} elseif ($type == 'link') { | 
                                                        
@@ -7740,7 +7740,7 @@ discard block  | 
                                                    ||
| 7740 | 7740 | $out = '<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';  | 
                                                        
| 7741 | 7741 | }  | 
                                                        
| 7742 | 7742 | |
| 7743 | -		if ($isDependList==1) { | 
                                                        |
| 7743 | +		if ($isDependList == 1) { | 
                                                        |
| 7744 | 7744 |  			$out .= $this->getJSListDependancies('_common'); | 
                                                        
| 7745 | 7745 | }  | 
                                                        
| 7746 | 7746 | /* Add comments  | 
                                                        
@@ -7791,7 +7791,7 @@ discard block  | 
                                                    ||
| 7791 | 7791 | $type = 'varchar'; // convert varchar(xx) int varchar  | 
                                                        
| 7792 | 7792 | }  | 
                                                        
| 7793 | 7793 |  		if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { | 
                                                        
| 7794 | - $type = (($this->fields[$key]['type']=='checkbox') ? $this->fields[$key]['type'] : 'select');  | 
                                                        |
| 7794 | + $type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select');  | 
                                                        |
| 7795 | 7795 | }  | 
                                                        
| 7796 | 7796 |  		if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { | 
                                                        
| 7797 | 7797 | $type = 'link';  | 
                                                        
@@ -7876,7 +7876,7 @@ discard block  | 
                                                    ||
| 7876 | 7876 | $value = $this->getLibStatut(3);  | 
                                                        
| 7877 | 7877 |  		} elseif ($type == 'date') { | 
                                                        
| 7878 | 7878 |  			if (!empty($value)) { | 
                                                        
| 7879 | - $value = dol_print_date($value, 'day'); // We suppose dates without time are always gmt (storage of course + output)  | 
                                                        |
| 7879 | + $value = dol_print_date($value, 'day'); // We suppose dates without time are always gmt (storage of course + output)  | 
                                                        |
| 7880 | 7880 |  			} else { | 
                                                        
| 7881 | 7881 | $value = '';  | 
                                                        
| 7882 | 7882 | }  | 
                                                        
@@ -7974,9 +7974,9 @@ discard block  | 
                                                    ||
| 7974 | 7974 | $translabel = $langs->trans($obj->$field_toshow);  | 
                                                        
| 7975 | 7975 | }  | 
                                                        
| 7976 | 7976 |  								if ($translabel != $field_toshow) { | 
                                                        
| 7977 | - $value .= dol_trunc($translabel, 18) . ' ';  | 
                                                        |
| 7977 | + $value .= dol_trunc($translabel, 18).' ';  | 
                                                        |
| 7978 | 7978 |  								} else { | 
                                                        
| 7979 | - $value .= $obj->$field_toshow . ' ';  | 
                                                        |
| 7979 | + $value .= $obj->$field_toshow.' ';  | 
                                                        |
| 7980 | 7980 | }  | 
                                                        
| 7981 | 7981 | }  | 
                                                        
| 7982 | 7982 |  						} else { | 
                                                        
@@ -7992,7 +7992,7 @@ discard block  | 
                                                    ||
| 7992 | 7992 | }  | 
                                                        
| 7993 | 7993 | }  | 
                                                        
| 7994 | 7994 |  				} else { | 
                                                        
| 7995 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';  | 
                                                        |
| 7995 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';  | 
                                                        |
| 7996 | 7996 | |
| 7997 | 7997 | $toprint = array();  | 
                                                        
| 7998 | 7998 | $obj = $this->db->fetch_object($resql);  | 
                                                        
@@ -8000,7 +8000,7 @@ discard block  | 
                                                    ||
| 8000 | 8000 | $c->fetch($obj->rowid);  | 
                                                        
| 8001 | 8001 | $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text  | 
                                                        
| 8002 | 8002 |  					foreach ($ways as $way) { | 
                                                        
| 8003 | -						$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>'; | 
                                                        |
| 8003 | +						$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'</li>'; | 
                                                        |
| 8004 | 8004 | }  | 
                                                        
| 8005 | 8005 |  					$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; | 
                                                        
| 8006 | 8006 | }  | 
                                                        
@@ -8016,11 +8016,11 @@ discard block  | 
                                                    ||
| 8016 | 8016 | $toprint = array();  | 
                                                        
| 8017 | 8017 |  				foreach ($value_arr as $keyval => $valueval) { | 
                                                        
| 8018 | 8018 |  					if (!empty($valueval)) { | 
                                                        
| 8019 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $param['options'][$valueval] . '</li>';  | 
                                                        |
| 8019 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param['options'][$valueval].'</li>';  | 
                                                        |
| 8020 | 8020 | }  | 
                                                        
| 8021 | 8021 | }  | 
                                                        
| 8022 | 8022 |  				if (!empty($toprint)) { | 
                                                        
| 8023 | -					$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>'; | 
                                                        |
| 8023 | +					$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; | 
                                                        |
| 8024 | 8024 | }  | 
                                                        
| 8025 | 8025 | }  | 
                                                        
| 8026 | 8026 |  		} elseif ($type == 'chkbxlst') { | 
                                                        
@@ -8075,9 +8075,9 @@ discard block  | 
                                                    ||
| 8075 | 8075 | $translabel = $langs->trans($obj->$field_toshow);  | 
                                                        
| 8076 | 8076 | }  | 
                                                        
| 8077 | 8077 |  									if ($translabel != $field_toshow) { | 
                                                        
| 8078 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . dol_trunc($translabel, 18) . '</li>';  | 
                                                        |
| 8078 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).'</li>';  | 
                                                        |
| 8079 | 8079 |  									} else { | 
                                                        
| 8080 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $obj->$field_toshow . '</li>';  | 
                                                        |
| 8080 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->$field_toshow.'</li>';  | 
                                                        |
| 8081 | 8081 | }  | 
                                                        
| 8082 | 8082 | }  | 
                                                        
| 8083 | 8083 |  							} else { | 
                                                        
@@ -8086,15 +8086,15 @@ discard block  | 
                                                    ||
| 8086 | 8086 |  									$translabel = $langs->trans($obj->{$InfoFieldList[1]}); | 
                                                        
| 8087 | 8087 | }  | 
                                                        
| 8088 | 8088 |  								if ($translabel != $obj->{$InfoFieldList[1]}) { | 
                                                        
| 8089 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . dol_trunc($translabel, 18) . '</li>';  | 
                                                        |
| 8089 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).'</li>';  | 
                                                        |
| 8090 | 8090 |  								} else { | 
                                                        
| 8091 | -									$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $obj->{$InfoFieldList[1]} . '</li>'; | 
                                                        |
| 8091 | +									$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.'</li>'; | 
                                                        |
| 8092 | 8092 | }  | 
                                                        
| 8093 | 8093 | }  | 
                                                        
| 8094 | 8094 | }  | 
                                                        
| 8095 | 8095 | }  | 
                                                        
| 8096 | 8096 |  				} else { | 
                                                        
| 8097 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';  | 
                                                        |
| 8097 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';  | 
                                                        |
| 8098 | 8098 | |
| 8099 | 8099 | $toprint = array();  | 
                                                        
| 8100 | 8100 |  					while ($obj = $this->db->fetch_object($resql)) { | 
                                                        
@@ -8103,7 +8103,7 @@ discard block  | 
                                                    ||
| 8103 | 8103 | $c->fetch($obj->rowid);  | 
                                                        
| 8104 | 8104 | $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text  | 
                                                        
| 8105 | 8105 |  							foreach ($ways as $way) { | 
                                                        
| 8106 | -								$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>'; | 
                                                        |
| 8106 | +								$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'</li>'; | 
                                                        |
| 8107 | 8107 | }  | 
                                                        
| 8108 | 8108 | }  | 
                                                        
| 8109 | 8109 | }  | 
                                                        
@@ -8250,7 +8250,7 @@ discard block  | 
                                                    ||
| 8250 | 8250 | global $langs;  | 
                                                        
| 8251 | 8251 | |
| 8252 | 8252 |  		if (!class_exists('Validate')) { | 
                                                        
| 8253 | - require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php';  | 
                                                        |
| 8253 | + require_once DOL_DOCUMENT_ROOT.'/core/class/validate.class.php';  | 
                                                        |
| 8254 | 8254 | }  | 
                                                        
| 8255 | 8255 | |
| 8256 | 8256 | $this->clearFieldError($fieldKey);  | 
                                                        
@@ -8482,7 +8482,7 @@ discard block  | 
                                                    ||
| 8482 | 8482 | $out .= "\n";  | 
                                                        
| 8483 | 8483 | |
| 8484 | 8484 | $nbofextrafieldsshown = 0;  | 
                                                        
| 8485 | - $e = 0; // var to manage the modulo (odd/even)  | 
                                                        |
| 8485 | + $e = 0; // var to manage the modulo (odd/even)  | 
                                                        |
| 8486 | 8486 | |
| 8487 | 8487 | $lastseparatorkeyfound = '';  | 
                                                        
| 8488 | 8488 | $extrafields_collapse_num = '';  | 
                                                        
@@ -8533,7 +8533,7 @@ discard block  | 
                                                    ||
| 8533 | 8533 | }  | 
                                                        
| 8534 | 8534 | |
| 8535 | 8535 | $colspan = 0;  | 
                                                        
| 8536 | -					if (is_array($params) && count($params) > 0 && $display_type=='card') { | 
                                                        |
| 8536 | +					if (is_array($params) && count($params) > 0 && $display_type == 'card') { | 
                                                        |
| 8537 | 8537 |  						if (array_key_exists('cols', $params)) { | 
                                                        
| 8538 | 8538 | $colspan = $params['cols'];  | 
                                                        
| 8539 | 8539 |  						} elseif (array_key_exists('colspan', $params)) {	// For backward compatibility. Use cols instead now. | 
                                                        
@@ -8620,7 +8620,7 @@ discard block  | 
                                                    ||
| 8620 | 8620 | $domData .= ' data-targetid="'.$this->id.'"';  | 
                                                        
| 8621 | 8621 | |
| 8622 | 8622 | $html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id);  | 
                                                        
| 8623 | -						if ($display_type=='card') { | 
                                                        |
| 8623 | +						if ($display_type == 'card') { | 
                                                        |
| 8624 | 8624 |  							if (getDolGlobalString('MAIN_EXTRAFIELDS_USE_TWO_COLUMS') && ($e % 2) == 0) { | 
                                                        
| 8625 | 8625 | $colspan = 0;  | 
                                                        
| 8626 | 8626 | }  | 
                                                        
@@ -8731,12 +8731,12 @@ discard block  | 
                                                    ||
| 8731 | 8731 | break;  | 
                                                        
| 8732 | 8732 | }  | 
                                                        
| 8733 | 8733 | |
| 8734 | - $out .= ($display_type=='card' ? '</td>' : '</div>');  | 
                                                        |
| 8734 | + $out .= ($display_type == 'card' ? '</td>' : '</div>');  | 
                                                        |
| 8735 | 8735 | |
| 8736 | 8736 |  						if (getDolGlobalString('MAIN_EXTRAFIELDS_USE_TWO_COLUMS') && (($e % 2) == 1)) { | 
                                                        
| 8737 | - $out .= ($display_type=='card' ? '</tr>' : '</div>');  | 
                                                        |
| 8737 | + $out .= ($display_type == 'card' ? '</tr>' : '</div>');  | 
                                                        |
| 8738 | 8738 |  						} else { | 
                                                        
| 8739 | - $out .= ($display_type=='card' ? '</tr>' : '</div>');  | 
                                                        |
| 8739 | + $out .= ($display_type == 'card' ? '</tr>' : '</div>');  | 
                                                        |
| 8740 | 8740 | }  | 
                                                        
| 8741 | 8741 | |
| 8742 | 8742 | $e++;  | 
                                                        
@@ -9540,7 +9540,7 @@ discard block  | 
                                                    ||
| 9540 | 9540 | continue;  | 
                                                        
| 9541 | 9541 | }  | 
                                                        
| 9542 | 9542 | }  | 
                                                        
| 9543 | - $keys_with_alias[] = $alias . '.' . $fieldname;  | 
                                                        |
| 9543 | + $keys_with_alias[] = $alias.'.'.$fieldname;  | 
                                                        |
| 9544 | 9544 | }  | 
                                                        
| 9545 | 9545 |  			return implode(',', $keys_with_alias); | 
                                                        
| 9546 | 9546 |  		} else { | 
                                                        
@@ -9660,7 +9660,7 @@ discard block  | 
                                                    ||
| 9660 | 9660 |  		if (!$error) { | 
                                                        
| 9661 | 9661 | $sql = "INSERT INTO ".$this->db->prefix().$this->table_element;  | 
                                                        
| 9662 | 9662 |  			$sql .= " (".implode(", ", $keys).')'; | 
                                                        
| 9663 | -			$sql .= " VALUES (".implode(", ", $values).")";		// $values can contains 'abc' or 123 | 
                                                        |
| 9663 | +			$sql .= " VALUES (".implode(", ", $values).")"; // $values can contains 'abc' or 123 | 
                                                        |
| 9664 | 9664 | |
| 9665 | 9665 | $res = $this->db->query($sql);  | 
                                                        
| 9666 | 9666 |  			if (!$res) { | 
                                                        
@@ -9945,7 +9945,7 @@ discard block  | 
                                                    ||
| 9945 | 9945 | |
| 9946 | 9946 | // Update extrafield  | 
                                                        
| 9947 | 9947 |  		if (!$error) { | 
                                                        
| 9948 | - $result = $this->insertExtraFields(); // This delete and reinsert extrafields  | 
                                                        |
| 9948 | + $result = $this->insertExtraFields(); // This delete and reinsert extrafields  | 
                                                        |
| 9949 | 9949 |  			if ($result < 0) { | 
                                                        
| 9950 | 9950 | $error++;  | 
                                                        
| 9951 | 9951 | }  | 
                                                        
@@ -10153,12 +10153,12 @@ discard block  | 
                                                    ||
| 10153 | 10153 | $error++;  | 
                                                        
| 10154 | 10154 |  			} else { | 
                                                        
| 10155 | 10155 |  				while ($obj = $this->db->fetch_object($resql)) { | 
                                                        
| 10156 | - $result = $this->fetch($obj->rowid); // @phpstan-ignore-line  | 
                                                        |
| 10156 | + $result = $this->fetch($obj->rowid); // @phpstan-ignore-line  | 
                                                        |
| 10157 | 10157 |  					if ($result < 0) { | 
                                                        
| 10158 | 10158 | $error++;  | 
                                                        
| 10159 | 10159 | $this->errors[] = $this->error;  | 
                                                        
| 10160 | 10160 |  					} else { | 
                                                        
| 10161 | - $result = $this->delete($user); // @phpstan-ignore-line  | 
                                                        |
| 10161 | + $result = $this->delete($user); // @phpstan-ignore-line  | 
                                                        |
| 10162 | 10162 |  						if ($result < 0) { | 
                                                        
| 10163 | 10163 | $error++;  | 
                                                        
| 10164 | 10164 | $this->errors[] = $this->error;  | 
                                                        
@@ -10323,7 +10323,7 @@ discard block  | 
                                                    ||
| 10323 | 10323 | );  | 
                                                        
| 10324 | 10324 |  		foreach ($fields as $key => $value) { | 
                                                        
| 10325 | 10325 |  			if (array_key_exists($key, $this->fields)) { | 
                                                        
| 10326 | -				$this->{$key} = $value;		// @phpstan-ignore-line | 
                                                        |
| 10326 | +				$this->{$key} = $value; // @phpstan-ignore-line | 
                                                        |
| 10327 | 10327 | }  | 
                                                        
| 10328 | 10328 | }  | 
                                                        
| 10329 | 10329 | |
@@ -10468,7 +10468,7 @@ discard block  | 
                                                    ||
| 10468 | 10468 | // Process  | 
                                                        
| 10469 | 10469 |  		foreach ($to_del as $del) { | 
                                                        
| 10470 | 10470 |  			if ($c->fetch($del) > 0) { | 
                                                        
| 10471 | - $result=$c->del_type($this, $type_categ);  | 
                                                        |
| 10471 | + $result = $c->del_type($this, $type_categ);  | 
                                                        |
| 10472 | 10472 |  				if ($result < 0) { | 
                                                        
| 10473 | 10473 | $error++;  | 
                                                        
| 10474 | 10474 | $this->error = $c->error;  | 
                                                        
@@ -100,10 +100,10 @@ discard block  | 
                                                    ||
| 100 | 100 | function dolGetRandomBytes($length)  | 
                                                        
| 101 | 101 |  { | 
                                                        
| 102 | 102 |  	if (function_exists('random_bytes')) {	// Available with PHP 7 only. | 
                                                        
| 103 | - return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2  | 
                                                        |
| 103 | + return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2  | 
                                                        |
| 104 | 104 | }  | 
                                                        
| 105 | 105 | |
| 106 | - return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows.  | 
                                                        |
| 106 | + return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows.  | 
                                                        |
| 107 | 107 | }  | 
                                                        
| 108 | 108 | |
| 109 | 109 | /**  | 
                                                        
@@ -241,7 +241,7 @@ discard block  | 
                                                    ||
| 241 | 241 | |
| 242 | 242 | // Salt value  | 
                                                        
| 243 | 243 |  	if (getDolGlobalString('MAIN_SECURITY_SALT') && $type != '4' && $type !== 'openldap') { | 
                                                        
| 244 | -		$chain = getDolGlobalString('MAIN_SECURITY_SALT') . $chain; | 
                                                        |
| 244 | +		$chain = getDolGlobalString('MAIN_SECURITY_SALT').$chain; | 
                                                        |
| 245 | 245 | }  | 
                                                        
| 246 | 246 | |
| 247 | 247 |  	if ($type == '1' || $type == 'sha1') { | 
                                                        
@@ -281,7 +281,7 @@ discard block  | 
                                                    ||
| 281 | 281 | function dol_verifyHash($chain, $hash, $type = '0')  | 
                                                        
| 282 | 282 |  { | 
                                                        
| 283 | 283 |  	if ($type == '0' && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'password_hash' && function_exists('password_verify')) { | 
                                                        
| 284 | -		if (! empty($hash[0]) && $hash[0] == '$') { | 
                                                        |
| 284 | +		if (!empty($hash[0]) && $hash[0] == '$') { | 
                                                        |
| 285 | 285 | return password_verify($chain, $hash);  | 
                                                        
| 286 | 286 |  		} elseif (dol_strlen($hash) == 32) { | 
                                                        
| 287 | 287 | return dol_verifyHash($chain, $hash, '3'); // md5  | 
                                                        
@@ -311,31 +311,31 @@ discard block  | 
                                                    ||
| 311 | 311 | $salt = substr(sha1(time()), 0, 8);  | 
                                                        
| 312 | 312 | |
| 313 | 313 |  	if ($type === 'md5') { | 
                                                        
| 314 | -		return '{MD5}' . base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) | 
                                                        |
| 314 | +		return '{MD5}'.base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) | 
                                                        |
| 315 | 315 |  	} elseif ($type === 'md5frommd5') { | 
                                                        
| 316 | -		return '{MD5}' . base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password | 
                                                        |
| 316 | +		return '{MD5}'.base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password | 
                                                        |
| 317 | 317 |  	} elseif ($type === 'smd5') { | 
                                                        
| 318 | -		return "{SMD5}" . base64_encode(hash("md5", $password . $salt, true) . $salt); | 
                                                        |
| 318 | +		return "{SMD5}".base64_encode(hash("md5", $password.$salt, true).$salt); | 
                                                        |
| 319 | 319 |  	} elseif ($type === 'sha') { | 
                                                        
| 320 | -		return '{SHA}' . base64_encode(hash("sha1", $password, true)); | 
                                                        |
| 320 | +		return '{SHA}'.base64_encode(hash("sha1", $password, true)); | 
                                                        |
| 321 | 321 |  	} elseif ($type === 'ssha') { | 
                                                        
| 322 | -		return "{SSHA}" . base64_encode(hash("sha1", $password . $salt, true) . $salt); | 
                                                        |
| 322 | +		return "{SSHA}".base64_encode(hash("sha1", $password.$salt, true).$salt); | 
                                                        |
| 323 | 323 |  	} elseif ($type === 'sha256') { | 
                                                        
| 324 | -		return "{SHA256}" . base64_encode(hash("sha256", $password, true)); | 
                                                        |
| 324 | +		return "{SHA256}".base64_encode(hash("sha256", $password, true)); | 
                                                        |
| 325 | 325 |  	} elseif ($type === 'ssha256') { | 
                                                        
| 326 | -		return "{SSHA256}" . base64_encode(hash("sha256", $password . $salt, true) . $salt); | 
                                                        |
| 326 | +		return "{SSHA256}".base64_encode(hash("sha256", $password.$salt, true).$salt); | 
                                                        |
| 327 | 327 |  	} elseif ($type === 'sha384') { | 
                                                        
| 328 | -		return "{SHA384}" . base64_encode(hash("sha384", $password, true)); | 
                                                        |
| 328 | +		return "{SHA384}".base64_encode(hash("sha384", $password, true)); | 
                                                        |
| 329 | 329 |  	} elseif ($type === 'ssha384') { | 
                                                        
| 330 | -		return "{SSHA384}" . base64_encode(hash("sha384", $password . $salt, true) . $salt); | 
                                                        |
| 330 | +		return "{SSHA384}".base64_encode(hash("sha384", $password.$salt, true).$salt); | 
                                                        |
| 331 | 331 |  	} elseif ($type === 'sha512') { | 
                                                        
| 332 | -		return "{SHA512}" . base64_encode(hash("sha512", $password, true)); | 
                                                        |
| 332 | +		return "{SHA512}".base64_encode(hash("sha512", $password, true)); | 
                                                        |
| 333 | 333 |  	} elseif ($type === 'ssha512') { | 
                                                        
| 334 | -		return "{SSHA512}" . base64_encode(hash("sha512", $password . $salt, true) . $salt); | 
                                                        |
| 334 | +		return "{SSHA512}".base64_encode(hash("sha512", $password.$salt, true).$salt); | 
                                                        |
| 335 | 335 |  	} elseif ($type === 'crypt') { | 
                                                        
| 336 | -		return '{CRYPT}' . crypt($password, $salt); | 
                                                        |
| 336 | +		return '{CRYPT}'.crypt($password, $salt); | 
                                                        |
| 337 | 337 |  	} elseif ($type === 'clear') { | 
                                                        
| 338 | -		return '{CLEAR}' . $password;  // Just for test, plain text password is not secured ! | 
                                                        |
| 338 | +		return '{CLEAR}'.$password; // Just for test, plain text password is not secured ! | 
                                                        |
| 339 | 339 | }  | 
                                                        
| 340 | 340 | return "";  | 
                                                        
| 341 | 341 | }  | 
                                                        
@@ -369,13 +369,13 @@ discard block  | 
                                                    ||
| 369 | 369 |  	if (is_object($object)) { | 
                                                        
| 370 | 370 | $objectid = $object->id;  | 
                                                        
| 371 | 371 |  	} else { | 
                                                        
| 372 | - $objectid = $object; // $objectid can be X or 'X,Y,Z'  | 
                                                        |
| 372 | + $objectid = $object; // $objectid can be X or 'X,Y,Z'  | 
                                                        |
| 373 | 373 | }  | 
                                                        
| 374 | 374 |  	if ($objectid == "-1") { | 
                                                        
| 375 | 375 | $objectid = 0;  | 
                                                        
| 376 | 376 | }  | 
                                                        
| 377 | 377 |  	if ($objectid) { | 
                                                        
| 378 | -		$objectid = preg_replace('/[^0-9\.\,]/', '', $objectid);	// For the case value is coming from a non sanitized user input | 
                                                        |
| 378 | +		$objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input | 
                                                        |
| 379 | 379 | }  | 
                                                        
| 380 | 380 | |
| 381 | 381 |  	//dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); | 
                                                        
@@ -852,9 +852,9 @@ discard block  | 
                                                    ||
| 852 | 852 |  	if (is_object($object)) { | 
                                                        
| 853 | 853 | $objectid = $object->id;  | 
                                                        
| 854 | 854 |  	} else { | 
                                                        
| 855 | - $objectid = $object; // $objectid can be X or 'X,Y,Z'  | 
                                                        |
| 855 | + $objectid = $object; // $objectid can be X or 'X,Y,Z'  | 
                                                        |
| 856 | 856 | }  | 
                                                        
| 857 | -	$objectid = preg_replace('/[^0-9\.\,]/', '', $objectid);	// For the case value is coming from a non sanitized user input | 
                                                        |
| 857 | +	$objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input | 
                                                        |
| 858 | 858 | |
| 859 | 859 |  	//dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); | 
                                                        
| 860 | 860 |  	//print "user_id=".$user->id.", features=".join(',', $featuresarray).", objectid=".$objectid; | 
                                                        
@@ -901,8 +901,8 @@ discard block  | 
                                                    ||
| 901 | 901 |  		$checkparentsoc = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). | 
                                                        
| 902 | 902 |  		$checkproject = array('projet', 'project'); // Test for project object | 
                                                        
| 903 | 903 |  		$checktask = array('projet_task'); // Test for task object | 
                                                        
| 904 | -		$checkhierarchy = array('expensereport', 'holiday');	// check permission among the hierarchy of user | 
                                                        |
| 905 | -		$checkuser = array('bookmark');	// check permission among the fk_user (must be myself or null) | 
                                                        |
| 904 | +		$checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user | 
                                                        |
| 905 | +		$checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null) | 
                                                        |
| 906 | 906 |  		$nocheck = array('barcode', 'stock'); // No test | 
                                                        
| 907 | 907 | |
| 908 | 908 | //$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...).  | 
                                                        
@@ -915,7 +915,7 @@ discard block  | 
                                                    ||
| 915 | 915 | |
| 916 | 916 | // To avoid an access forbidden with a numeric ref  | 
                                                        
| 917 | 917 |  		if ($dbt_select != 'rowid' && $dbt_select != 'id') { | 
                                                        
| 918 | - $objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method.  | 
                                                        |
| 918 | + $objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method.  | 
                                                        |
| 919 | 919 | }  | 
                                                        
| 920 | 920 | // Check permission for objectid on entity only  | 
                                                        
| 921 | 921 |  		if (in_array($feature, $check) && $objectid > 0) {		// For $objectid = 0, no check |