@@ -29,17 +29,17 @@ discard block  | 
                                                    ||
| 29 | 29 | * \brief File of withdrawal receipts class  | 
                                                        
| 30 | 30 | */  | 
                                                        
| 31 | 31 | |
| 32 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';  | 
                                                        |
| 33 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';  | 
                                                        |
| 34 | -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';  | 
                                                        |
| 35 | -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';  | 
                                                        |
| 36 | -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';  | 
                                                        |
| 37 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';  | 
                                                        |
| 38 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php';  | 
                                                        |
| 39 | -require_once DOL_DOCUMENT_ROOT . '/salaries/class/salary.class.php';  | 
                                                        |
| 40 | -require_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php';  | 
                                                        |
| 41 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';  | 
                                                        |
| 42 | -require_once DOL_DOCUMENT_ROOT . '/user/class/userbankaccount.class.php';  | 
                                                        |
| 32 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';  | 
                                                        |
| 33 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';  | 
                                                        |
| 34 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';  | 
                                                        |
| 35 | +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';  | 
                                                        |
| 36 | +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';  | 
                                                        |
| 37 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';  | 
                                                        |
| 38 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';  | 
                                                        |
| 39 | +require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';  | 
                                                        |
| 40 | +require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';  | 
                                                        |
| 41 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';  | 
                                                        |
| 42 | +require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';  | 
                                                        |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | /**  | 
                                                        
@@ -104,8 +104,8 @@ discard block  | 
                                                    ||
| 104 | 104 | |
| 105 | 105 | const STATUS_DRAFT = 0;  | 
                                                        
| 106 | 106 | const STATUS_TRANSFERED = 1;  | 
                                                        
| 107 | - const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 108 | - const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 107 | + const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 108 | + const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type  | 
                                                        |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | /**  | 
                                                        
@@ -258,7 +258,7 @@ discard block  | 
                                                    ||
| 258 | 258 | |
| 259 | 259 |  		if ($result == 0) { | 
                                                        
| 260 | 260 |  			if ($line_id > 0) { | 
                                                        
| 261 | -				$sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement ("; | 
                                                        |
| 261 | +				$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement ("; | 
                                                        |
| 262 | 262 |  				if ($type != 'bank-transfer') { | 
                                                        
| 263 | 263 | $sql .= "fk_facture";  | 
                                                        
| 264 | 264 |  				} else { | 
                                                        
@@ -271,24 +271,24 @@ discard block  | 
                                                    ||
| 271 | 271 | $sql .= ",fk_prelevement_lignes";  | 
                                                        
| 272 | 272 |  				$sql .= ") VALUES ("; | 
                                                        
| 273 | 273 | $sql .= ((int) $invoice_id);  | 
                                                        
| 274 | - $sql .= ", " . ((int) $line_id);  | 
                                                        |
| 274 | + $sql .= ", ".((int) $line_id);  | 
                                                        |
| 275 | 275 | $sql .= ")";  | 
                                                        
| 276 | 276 | |
| 277 | 277 |  				if ($this->db->query($sql)) { | 
                                                        
| 278 | 278 | $result = 0;  | 
                                                        
| 279 | 279 |  				} else { | 
                                                        
| 280 | 280 | $result = -1;  | 
                                                        
| 281 | - $this->errors[] = get_class($this) . "::AddFacture " . $this->db->lasterror;  | 
                                                        |
| 282 | - dol_syslog(get_class($this) . "::AddFacture Error $result");  | 
                                                        |
| 281 | + $this->errors[] = get_class($this)."::AddFacture ".$this->db->lasterror;  | 
                                                        |
| 282 | + dol_syslog(get_class($this)."::AddFacture Error $result");  | 
                                                        |
| 283 | 283 | }  | 
                                                        
| 284 | 284 |  			} else { | 
                                                        
| 285 | 285 | $result = -2;  | 
                                                        
| 286 | - $this->errors[] = get_class($this) . "::AddFacture linedid Empty";  | 
                                                        |
| 287 | - dol_syslog(get_class($this) . "::AddFacture Error $result");  | 
                                                        |
| 286 | + $this->errors[] = get_class($this)."::AddFacture linedid Empty";  | 
                                                        |
| 287 | + dol_syslog(get_class($this)."::AddFacture Error $result");  | 
                                                        |
| 288 | 288 | }  | 
                                                        
| 289 | 289 |  		} else { | 
                                                        
| 290 | 290 | $result = -3;  | 
                                                        
| 291 | - dol_syslog(get_class($this) . "::AddFacture Error $result");  | 
                                                        |
| 291 | + dol_syslog(get_class($this)."::AddFacture Error $result");  | 
                                                        |
| 292 | 292 | }  | 
                                                        
| 293 | 293 | |
| 294 | 294 | return $result;  | 
                                                        
@@ -311,23 +311,23 @@ discard block  | 
                                                    ||
| 311 | 311 | public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $sourcetype = '')  | 
                                                        
| 312 | 312 |  	{ | 
                                                        
| 313 | 313 | $result = -1;  | 
                                                        
| 314 | - $concat = 0; // ??? what is this for. Seems not used.  | 
                                                        |
| 314 | + $concat = 0; // ??? what is this for. Seems not used.  | 
                                                        |
| 315 | 315 | |
| 316 | 316 |  		if ($concat == 1) { | 
                                                        
| 317 | 317 | /*  | 
                                                        
| 318 | 318 | * We aggregate the lines  | 
                                                        
| 319 | 319 | */  | 
                                                        
| 320 | 320 | $sql = "SELECT rowid";  | 
                                                        
| 321 | - $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_lignes";  | 
                                                        |
| 322 | - $sql .= " WHERE fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 321 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes";  | 
                                                        |
| 322 | + $sql .= " WHERE fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 323 | 323 |  			if ($sourcetype == 'salary') { | 
                                                        
| 324 | - $sql .= " AND fk_soc = " . ((int) $client_id);  | 
                                                        |
| 324 | + $sql .= " AND fk_soc = ".((int) $client_id);  | 
                                                        |
| 325 | 325 |  			} else { | 
                                                        
| 326 | - $sql .= " AND fk_user = " . ((int) $client_id);  | 
                                                        |
| 326 | + $sql .= " AND fk_user = ".((int) $client_id);  | 
                                                        |
| 327 | 327 | }  | 
                                                        
| 328 | - $sql .= " AND code_banque = '" . $this->db->escape($code_banque) . "'";  | 
                                                        |
| 329 | - $sql .= " AND code_guichet = '" . $this->db->escape($code_guichet) . "'";  | 
                                                        |
| 330 | - $sql .= " AND number = '" . $this->db->escape($number) . "'";  | 
                                                        |
| 328 | + $sql .= " AND code_banque = '".$this->db->escape($code_banque)."'";  | 
                                                        |
| 329 | + $sql .= " AND code_guichet = '".$this->db->escape($code_guichet)."'";  | 
                                                        |
| 330 | + $sql .= " AND number = '".$this->db->escape($number)."'";  | 
                                                        |
| 331 | 331 | |
| 332 | 332 | $resql = $this->db->query($sql);  | 
                                                        
| 333 | 333 |  			if ($resql) { | 
                                                        
@@ -339,7 +339,7 @@ discard block  | 
                                                    ||
| 339 | 339 | /*  | 
                                                        
| 340 | 340 | * No aggregate  | 
                                                        
| 341 | 341 | */  | 
                                                        
| 342 | -			$sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_lignes ("; | 
                                                        |
| 342 | +			$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_lignes ("; | 
                                                        |
| 343 | 343 | $sql .= "fk_prelevement_bons";  | 
                                                        
| 344 | 344 | $sql .= ", fk_soc";  | 
                                                        
| 345 | 345 | $sql .= ", client_nom";  | 
                                                        
@@ -351,21 +351,21 @@ discard block  | 
                                                    ||
| 351 | 351 | $sql .= ($sourcetype == 'salary' ? ", fk_user" : "");  | 
                                                        
| 352 | 352 |  			$sql .= ") VALUES ("; | 
                                                        
| 353 | 353 | $sql .= $this->id;  | 
                                                        
| 354 | - $sql .= ", " . (($sourcetype != 'salary') ? ((int) $client_id) : "0"); // fk_soc can't be null  | 
                                                        |
| 355 | - $sql .= ", '" . $this->db->escape($client_nom) . "'";  | 
                                                        |
| 356 | - $sql .= ", " . ((float) price2num($amount));  | 
                                                        |
| 357 | - $sql .= ", '" . $this->db->escape($code_banque) . "'";  | 
                                                        |
| 358 | - $sql .= ", '" . $this->db->escape($code_guichet) . "'";  | 
                                                        |
| 359 | - $sql .= ", '" . $this->db->escape($number) . "'";  | 
                                                        |
| 360 | - $sql .= ", '" . $this->db->escape($number_key) . "'";  | 
                                                        |
| 361 | - $sql .= (($sourcetype == 'salary') ? ", " . ((int) $client_id) : '');  | 
                                                        |
| 354 | + $sql .= ", ".(($sourcetype != 'salary') ? ((int) $client_id) : "0"); // fk_soc can't be null  | 
                                                        |
| 355 | + $sql .= ", '".$this->db->escape($client_nom)."'";  | 
                                                        |
| 356 | + $sql .= ", ".((float) price2num($amount));  | 
                                                        |
| 357 | + $sql .= ", '".$this->db->escape($code_banque)."'";  | 
                                                        |
| 358 | + $sql .= ", '".$this->db->escape($code_guichet)."'";  | 
                                                        |
| 359 | + $sql .= ", '".$this->db->escape($number)."'";  | 
                                                        |
| 360 | + $sql .= ", '".$this->db->escape($number_key)."'";  | 
                                                        |
| 361 | + $sql .= (($sourcetype == 'salary') ? ", ".((int) $client_id) : '');  | 
                                                        |
| 362 | 362 | $sql .= ")";  | 
                                                        
| 363 | 363 |  			if ($this->db->query($sql)) { | 
                                                        
| 364 | - $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX . "prelevement_lignes");  | 
                                                        |
| 364 | + $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes");  | 
                                                        |
| 365 | 365 | $result = 0;  | 
                                                        
| 366 | 366 |  			} else { | 
                                                        
| 367 | - $this->errors[] = get_class($this) . "::addline Error -2 " . $this->db->lasterror;  | 
                                                        |
| 368 | - dol_syslog(get_class($this) . "::addline Error -2");  | 
                                                        |
| 367 | + $this->errors[] = get_class($this)."::addline Error -2 ".$this->db->lasterror;  | 
                                                        |
| 368 | + dol_syslog(get_class($this)."::addline Error -2");  | 
                                                        |
| 369 | 369 | $result = -2;  | 
                                                        
| 370 | 370 | }  | 
                                                        
| 371 | 371 | }  | 
                                                        
@@ -408,15 +408,15 @@ discard block  | 
                                                    ||
| 408 | 408 | $sql .= ", p.type";  | 
                                                        
| 409 | 409 | $sql .= ", p.fk_bank_account";  | 
                                                        
| 410 | 410 | $sql .= ", p.statut as status";  | 
                                                        
| 411 | - $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_bons as p";  | 
                                                        |
| 412 | -		$sql .= " WHERE p.entity IN (" . getEntity('invoice') . ")"; | 
                                                        |
| 411 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";  | 
                                                        |
| 412 | +		$sql .= " WHERE p.entity IN (".getEntity('invoice').")"; | 
                                                        |
| 413 | 413 |  		if ($rowid > 0) { | 
                                                        
| 414 | - $sql .= " AND p.rowid = " . ((int) $rowid);  | 
                                                        |
| 414 | + $sql .= " AND p.rowid = ".((int) $rowid);  | 
                                                        |
| 415 | 415 |  		} else { | 
                                                        
| 416 | - $sql .= " AND p.ref = '" . $this->db->escape($ref) . "'";  | 
                                                        |
| 416 | + $sql .= " AND p.ref = '".$this->db->escape($ref)."'";  | 
                                                        |
| 417 | 417 | }  | 
                                                        
| 418 | 418 | |
| 419 | - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);  | 
                                                        |
| 419 | + dol_syslog(get_class($this)."::fetch", LOG_DEBUG);  | 
                                                        |
| 420 | 420 | $result = $this->db->query($sql);  | 
                                                        
| 421 | 421 |  		if ($result) { | 
                                                        
| 422 | 422 |  			if ($this->db->num_rows($result)) { | 
                                                        
@@ -442,13 +442,13 @@ discard block  | 
                                                    ||
| 442 | 442 |  				if (empty($this->status)) {		// Value is sometimes null in database | 
                                                        
| 443 | 443 | $this->status = 0;  | 
                                                        
| 444 | 444 | }  | 
                                                        
| 445 | - $this->statut = $this->status; // For backward compatibility  | 
                                                        |
| 445 | + $this->statut = $this->status; // For backward compatibility  | 
                                                        |
| 446 | 446 | |
| 447 | 447 | $this->fetched = 1;  | 
                                                        
| 448 | 448 | |
| 449 | 449 | return 1;  | 
                                                        
| 450 | 450 |  			} else { | 
                                                        
| 451 | - dol_syslog(get_class($this) . "::Fetch no record found");  | 
                                                        |
| 451 | + dol_syslog(get_class($this)."::Fetch no record found");  | 
                                                        |
| 452 | 452 | return 0;  | 
                                                        
| 453 | 453 | }  | 
                                                        
| 454 | 454 |  		} else { | 
                                                        
@@ -489,19 +489,19 @@ discard block  | 
                                                    ||
| 489 | 489 |  			if ($date < $this->date_trans) { | 
                                                        
| 490 | 490 |  				$langs->load("errors"); | 
                                                        
| 491 | 491 |  				$this->error = $langs->trans('ErrorDateOfMovementLowerThanDateOfFileTransmission'); | 
                                                        
| 492 | -				dol_syslog("bon-prelevment::set_infocredit 1027 " . $this->error); | 
                                                        |
| 492 | +				dol_syslog("bon-prelevment::set_infocredit 1027 ".$this->error); | 
                                                        |
| 493 | 493 | return -1027;  | 
                                                        
| 494 | 494 | }  | 
                                                        
| 495 | 495 | |
| 496 | 496 | $this->db->begin();  | 
                                                        
| 497 | 497 | |
| 498 | - $sql = " UPDATE " . MAIN_DB_PREFIX . "prelevement_bons";  | 
                                                        |
| 499 | - $sql .= " SET fk_user_credit = " . ((int) $user->id);  | 
                                                        |
| 500 | - $sql .= ", statut = " . self::STATUS_CREDITED;  | 
                                                        |
| 501 | - $sql .= ", date_credit = '" . $this->db->idate($date) . "'";  | 
                                                        |
| 502 | - $sql .= " WHERE rowid = " . ((int) $this->id);  | 
                                                        |
| 503 | - $sql .= " AND entity = " . ((int) $conf->entity);  | 
                                                        |
| 504 | - $sql .= " AND statut = " . self::STATUS_TRANSFERED;  | 
                                                        |
| 498 | + $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons";  | 
                                                        |
| 499 | + $sql .= " SET fk_user_credit = ".((int) $user->id);  | 
                                                        |
| 500 | + $sql .= ", statut = ".self::STATUS_CREDITED;  | 
                                                        |
| 501 | + $sql .= ", date_credit = '".$this->db->idate($date)."'";  | 
                                                        |
| 502 | + $sql .= " WHERE rowid = ".((int) $this->id);  | 
                                                        |
| 503 | + $sql .= " AND entity = ".((int) $conf->entity);  | 
                                                        |
| 504 | + $sql .= " AND statut = ".self::STATUS_TRANSFERED;  | 
                                                        |
| 505 | 505 | |
| 506 | 506 | $resql = $this->db->query($sql);  | 
                                                        
| 507 | 507 |  			if ($resql) { | 
                                                        
@@ -616,7 +616,7 @@ discard block  | 
                                                    ||
| 616 | 616 | $error++;  | 
                                                        
| 617 | 617 | $this->error = $paiement->error;  | 
                                                        
| 618 | 618 | $this->errors = $paiement->errors;  | 
                                                        
| 619 | - dol_syslog(get_class($this) . "::set_infocredit AddPayment Error " . $this->error);  | 
                                                        |
| 619 | + dol_syslog(get_class($this)."::set_infocredit AddPayment Error ".$this->error);  | 
                                                        |
| 620 | 620 |  					} else { | 
                                                        
| 621 | 621 |  						if ($this->type == 'bank-transfer') { | 
                                                        
| 622 | 622 |  							if ($type == 'salary') { | 
                                                        
@@ -631,7 +631,7 @@ discard block  | 
                                                    ||
| 631 | 631 |  						} else { | 
                                                        
| 632 | 632 | $modeforaddpayment = 'payment';  | 
                                                        
| 633 | 633 | $labelforaddpayment = '(CustomerInvoicePayment)';  | 
                                                        
| 634 | - $addbankurl = 'direct-debit'; // = 'directdebit'  | 
                                                        |
| 634 | + $addbankurl = 'direct-debit'; // = 'directdebit'  | 
                                                        |
| 635 | 635 | }  | 
                                                        
| 636 | 636 | |
| 637 | 637 | $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl);  | 
                                                        
@@ -640,7 +640,7 @@ discard block  | 
                                                    ||
| 640 | 640 | $error++;  | 
                                                        
| 641 | 641 | $this->error = $paiement->error;  | 
                                                        
| 642 | 642 | $this->errors = $paiement->errors;  | 
                                                        
| 643 | - dol_syslog(get_class($this) . "::set_infocredit AddPaymentToBank Error " . $this->error);  | 
                                                        |
| 643 | + dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error ".$this->error);  | 
                                                        |
| 644 | 644 | }  | 
                                                        
| 645 | 645 | }  | 
                                                        
| 646 | 646 | }  | 
                                                        
@@ -648,24 +648,24 @@ discard block  | 
                                                    ||
| 648 | 648 | // Update withdrawal line  | 
                                                        
| 649 | 649 | // TODO: Translate to ligneprelevement.class.php  | 
                                                        
| 650 | 650 |  				if (!$error) { | 
                                                        
| 651 | - $sql = " UPDATE " . MAIN_DB_PREFIX . "prelevement_lignes";  | 
                                                        |
| 651 | + $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes";  | 
                                                        |
| 652 | 652 | $sql .= " SET statut = 2";  | 
                                                        
| 653 | - $sql .= " WHERE fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 653 | + $sql .= " WHERE fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 654 | 654 | |
| 655 | 655 |  					if (!$this->db->query($sql)) { | 
                                                        
| 656 | - dol_syslog(get_class($this) . "::set_infocredit Update lines Error");  | 
                                                        |
| 656 | + dol_syslog(get_class($this)."::set_infocredit Update lines Error");  | 
                                                        |
| 657 | 657 | $error++;  | 
                                                        
| 658 | 658 | }  | 
                                                        
| 659 | 659 | }  | 
                                                        
| 660 | 660 |  			} else { | 
                                                        
| 661 | 661 | $this->error = $this->db->lasterror();  | 
                                                        
| 662 | - dol_syslog(get_class($this) . "::set_infocredit Update Bons Error");  | 
                                                        |
| 662 | + dol_syslog(get_class($this)."::set_infocredit Update Bons Error");  | 
                                                        |
| 663 | 663 | $error++;  | 
                                                        
| 664 | 664 | }  | 
                                                        
| 665 | 665 | |
| 666 | 666 | // End of procedure  | 
                                                        
| 667 | 667 |  			if ($error == 0) { | 
                                                        
| 668 | - $this->date_credit = $date; // date credit or debit  | 
                                                        |
| 668 | + $this->date_credit = $date; // date credit or debit  | 
                                                        |
| 669 | 669 | $this->statut = self::STATUS_CREDITED;  | 
                                                        
| 670 | 670 | $this->status = self::STATUS_CREDITED;  | 
                                                        
| 671 | 671 | |
@@ -696,17 +696,17 @@ discard block  | 
                                                    ||
| 696 | 696 | |
| 697 | 697 | $error = 0;  | 
                                                        
| 698 | 698 | |
| 699 | - dol_syslog(get_class($this) . "::set_infotrans Start", LOG_INFO);  | 
                                                        |
| 699 | + dol_syslog(get_class($this)."::set_infotrans Start", LOG_INFO);  | 
                                                        |
| 700 | 700 | |
| 701 | 701 |  		if ($this->db->begin()) { | 
                                                        
| 702 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "prelevement_bons ";  | 
                                                        |
| 703 | - $sql .= " SET fk_user_trans = " . $user->id;  | 
                                                        |
| 704 | - $sql .= " , date_trans = '" . $this->db->idate($date) . "'";  | 
                                                        |
| 705 | - $sql .= " , method_trans = " . ((int) $method);  | 
                                                        |
| 706 | - $sql .= " , statut = " . self::STATUS_TRANSFERED;  | 
                                                        |
| 707 | - $sql .= " WHERE rowid = " . ((int) $this->id);  | 
                                                        |
| 708 | - $sql .= " AND entity = " . ((int) $conf->entity);  | 
                                                        |
| 709 | - $sql .= " AND statut = " . self::STATUS_DRAFT;  | 
                                                        |
| 702 | + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons ";  | 
                                                        |
| 703 | + $sql .= " SET fk_user_trans = ".$user->id;  | 
                                                        |
| 704 | + $sql .= " , date_trans = '".$this->db->idate($date)."'";  | 
                                                        |
| 705 | + $sql .= " , method_trans = ".((int) $method);  | 
                                                        |
| 706 | + $sql .= " , statut = ".self::STATUS_TRANSFERED;  | 
                                                        |
| 707 | + $sql .= " WHERE rowid = ".((int) $this->id);  | 
                                                        |
| 708 | + $sql .= " AND entity = ".((int) $conf->entity);  | 
                                                        |
| 709 | + $sql .= " AND statut = ".self::STATUS_DRAFT;  | 
                                                        |
| 710 | 710 | |
| 711 | 711 |  			if ($this->db->query($sql)) { | 
                                                        
| 712 | 712 | $this->method_trans = $method;  | 
                                                        
@@ -731,12 +731,12 @@ discard block  | 
                                                    ||
| 731 | 731 | return 0;  | 
                                                        
| 732 | 732 |  			} else { | 
                                                        
| 733 | 733 | $this->db->rollback();  | 
                                                        
| 734 | - dol_syslog(get_class($this) . "::set_infotrans ROLLBACK", LOG_ERR);  | 
                                                        |
| 734 | + dol_syslog(get_class($this)."::set_infotrans ROLLBACK", LOG_ERR);  | 
                                                        |
| 735 | 735 | |
| 736 | 736 | return -1;  | 
                                                        
| 737 | 737 | }  | 
                                                        
| 738 | 738 |  		} else { | 
                                                        
| 739 | - dol_syslog(get_class($this) . "::set_infotrans Ouverture transaction SQL impossible", LOG_CRIT);  | 
                                                        |
| 739 | + dol_syslog(get_class($this)."::set_infotrans Ouverture transaction SQL impossible", LOG_CRIT);  | 
                                                        |
| 740 | 740 | return -2;  | 
                                                        
| 741 | 741 | }  | 
                                                        
| 742 | 742 | }  | 
                                                        
@@ -754,7 +754,7 @@ discard block  | 
                                                    ||
| 754 | 754 | |
| 755 | 755 | $arr = array();  | 
                                                        
| 756 | 756 | |
| 757 | - dol_syslog(get_class($this) . "::getListInvoices");  | 
                                                        |
| 757 | + dol_syslog(get_class($this)."::getListInvoices");  | 
                                                        |
| 758 | 758 | |
| 759 | 759 | // Returns all invoices presented within same order  | 
                                                        
| 760 | 760 | $sql = "SELECT ";  | 
                                                        
@@ -770,13 +770,13 @@ discard block  | 
                                                    ||
| 770 | 770 |  		if ($amounts) { | 
                                                        
| 771 | 771 | $sql .= ", SUM(pl.amount)";  | 
                                                        
| 772 | 772 | }  | 
                                                        
| 773 | - $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_bons as pb,";  | 
                                                        |
| 774 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";  | 
                                                        |
| 775 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement as p";  | 
                                                        |
| 773 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as pb,";  | 
                                                        |
| 774 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";  | 
                                                        |
| 775 | + $sql .= " ".MAIN_DB_PREFIX."prelevement as p";  | 
                                                        |
| 776 | 776 | $sql .= " WHERE p.fk_prelevement_lignes = pl.rowid";  | 
                                                        
| 777 | 777 | $sql .= " AND pl.fk_prelevement_bons = pb.rowid";  | 
                                                        
| 778 | - $sql .= " AND pb.rowid = " . ((int) $this->id);  | 
                                                        |
| 779 | - $sql .= " AND pb.entity = " . ((int) $conf->entity);  | 
                                                        |
| 778 | + $sql .= " AND pb.rowid = ".((int) $this->id);  | 
                                                        |
| 779 | + $sql .= " AND pb.entity = ".((int) $conf->entity);  | 
                                                        |
| 780 | 780 |  		if ($amounts) { | 
                                                        
| 781 | 781 |  			if ($this->type == 'bank-transfer') { | 
                                                        
| 782 | 782 |  				if ($type == 'salary') { | 
                                                        
@@ -830,17 +830,17 @@ discard block  | 
                                                    ||
| 830 | 830 | $sql = "SELECT sum(pd.amount) as nb";  | 
                                                        
| 831 | 831 |  		if ($type !== 'salary') { | 
                                                        
| 832 | 832 |  			if ($mode != 'bank-transfer') { | 
                                                        
| 833 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f,";  | 
                                                        |
| 833 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";  | 
                                                        |
| 834 | 834 |  			} else { | 
                                                        
| 835 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f,";  | 
                                                        |
| 835 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";  | 
                                                        |
| 836 | 836 | }  | 
                                                        
| 837 | 837 |  		} else { | 
                                                        
| 838 | - $sql .= " FROM " . MAIN_DB_PREFIX . "salary as s,";  | 
                                                        |
| 838 | + $sql .= " FROM ".MAIN_DB_PREFIX."salary as s,";  | 
                                                        |
| 839 | 839 | }  | 
                                                        
| 840 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_demande as pd";  | 
                                                        |
| 841 | -		$sql .= ($type !== 'salary' ? " WHERE f.entity IN (" . getEntity('invoice') . ")" : " WHERE s.entity IN (" . getEntity('salary') . ")"); | 
                                                        |
| 840 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd";  | 
                                                        |
| 841 | +		$sql .= ($type !== 'salary' ? " WHERE f.entity IN (".getEntity('invoice').")" : " WHERE s.entity IN (".getEntity('salary').")"); | 
                                                        |
| 842 | 842 |  		if (!getDolGlobalString('WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS')) { | 
                                                        
| 843 | - $sql .= ($type !== 'salary' ? " AND f.fk_statut = " . Facture::STATUS_VALIDATED : " AND s.paye = " . Salary::STATUS_UNPAID);  | 
                                                        |
| 843 | + $sql .= ($type !== 'salary' ? " AND f.fk_statut = ".Facture::STATUS_VALIDATED : " AND s.paye = ".Salary::STATUS_UNPAID);  | 
                                                        |
| 844 | 844 | }  | 
                                                        
| 845 | 845 |  		if ($type !== 'salary') { | 
                                                        
| 846 | 846 |  			if ($mode != 'bank-transfer') { | 
                                                        
@@ -865,7 +865,7 @@ discard block  | 
                                                    ||
| 865 | 865 | return $obj->nb;  | 
                                                        
| 866 | 866 |  		} else { | 
                                                        
| 867 | 867 | $error = 1;  | 
                                                        
| 868 | - dol_syslog(get_class($this) . "::SommeAPrelever Erreur -1");  | 
                                                        |
| 868 | + dol_syslog(get_class($this)."::SommeAPrelever Erreur -1");  | 
                                                        |
| 869 | 869 | dol_syslog($this->db->error());  | 
                                                        
| 870 | 870 | |
| 871 | 871 | return -1;  | 
                                                        
@@ -901,26 +901,26 @@ discard block  | 
                                                    ||
| 901 | 901 | // phpcs:enable  | 
                                                        
| 902 | 902 |  		if ($forsalary == 1) { | 
                                                        
| 903 | 903 | $sql = "SELECT count(s.rowid) as nb";  | 
                                                        
| 904 | - $sql .= " FROM " . MAIN_DB_PREFIX . "salary as s";  | 
                                                        |
| 904 | + $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";  | 
                                                        |
| 905 | 905 |  		} else { | 
                                                        
| 906 | 906 | $sql = "SELECT count(f.rowid) as nb";  | 
                                                        
| 907 | 907 | |
| 908 | 908 |  			if ($type == 'bank-transfer') { | 
                                                        
| 909 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";  | 
                                                        |
| 909 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";  | 
                                                        |
| 910 | 910 |  			} else { | 
                                                        
| 911 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";  | 
                                                        |
| 911 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";  | 
                                                        |
| 912 | 912 | }  | 
                                                        
| 913 | 913 | }  | 
                                                        
| 914 | - $sql .= ", " . MAIN_DB_PREFIX . "prelevement_demande as pd";  | 
                                                        |
| 914 | + $sql .= ", ".MAIN_DB_PREFIX."prelevement_demande as pd";  | 
                                                        |
| 915 | 915 |  		if ($forsalary == 1) { | 
                                                        
| 916 | -			$sql .= " WHERE s.entity IN (" . getEntity('invoice') . ")"; | 
                                                        |
| 916 | +			$sql .= " WHERE s.entity IN (".getEntity('invoice').")"; | 
                                                        |
| 917 | 917 |  			if (!getDolGlobalString('WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS')) { | 
                                                        
| 918 | 918 | $sql .= " AND s.paye = 0";  | 
                                                        
| 919 | 919 | }  | 
                                                        
| 920 | 920 |  		} else { | 
                                                        
| 921 | -			$sql .= " WHERE f.entity IN (" . getEntity('invoice') . ")"; | 
                                                        |
| 921 | +			$sql .= " WHERE f.entity IN (".getEntity('invoice').")"; | 
                                                        |
| 922 | 922 |  			if (!getDolGlobalString('WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS')) { | 
                                                        
| 923 | - $sql .= " AND f.fk_statut = " . Facture::STATUS_VALIDATED;  | 
                                                        |
| 923 | + $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;  | 
                                                        |
| 924 | 924 | }  | 
                                                        
| 925 | 925 | }  | 
                                                        
| 926 | 926 |  		if ($forsalary == 1) { | 
                                                        
@@ -940,7 +940,7 @@ discard block  | 
                                                    ||
| 940 | 940 | $sql .= " AND s.paye = 0";  | 
                                                        
| 941 | 941 | }  | 
                                                        
| 942 | 942 | |
| 943 | - dol_syslog(get_class($this) . "::NbFactureAPrelever");  | 
                                                        |
| 943 | + dol_syslog(get_class($this)."::NbFactureAPrelever");  | 
                                                        |
| 944 | 944 | $resql = $this->db->query($sql);  | 
                                                        
| 945 | 945 | |
| 946 | 946 |  		if ($resql) { | 
                                                        
@@ -949,7 +949,7 @@ discard block  | 
                                                    ||
| 949 | 949 | |
| 950 | 950 | return $obj->nb;  | 
                                                        
| 951 | 951 |  		} else { | 
                                                        
| 952 | - $this->error = get_class($this) . "::NbFactureAPrelever Erreur -1 sql=" . $this->db->error();  | 
                                                        |
| 952 | + $this->error = get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error();  | 
                                                        |
| 953 | 953 | return -1;  | 
                                                        
| 954 | 954 | }  | 
                                                        
| 955 | 955 | }  | 
                                                        
@@ -981,10 +981,10 @@ discard block  | 
                                                    ||
| 981 | 981 | // phpcs:enable  | 
                                                        
| 982 | 982 | global $conf, $langs, $user;  | 
                                                        
| 983 | 983 | |
| 984 | - dol_syslog(__METHOD__ . " Bank=" . $banque . " Office=" . $agence . " mode=" . $mode . " format=" . $format, LOG_DEBUG);  | 
                                                        |
| 984 | + dol_syslog(__METHOD__." Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG);  | 
                                                        |
| 985 | 985 | |
| 986 | - require_once DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php";  | 
                                                        |
| 987 | - require_once DOL_DOCUMENT_ROOT . "/societe/class/societe.class.php";  | 
                                                        |
| 986 | + require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";  | 
                                                        |
| 987 | + require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";  | 
                                                        |
| 988 | 988 | |
| 989 | 989 | // Check params  | 
                                                        
| 990 | 990 |  		if ($type != 'bank-transfer') { | 
                                                        
@@ -1020,7 +1020,7 @@ discard block  | 
                                                    ||
| 1020 | 1020 | $factures_prev_id = array();  | 
                                                        
| 1021 | 1021 | $factures_errors = array();  | 
                                                        
| 1022 | 1022 |  		if (!$error) { | 
                                                        
| 1023 | - dol_syslog(__METHOD__ . " Read invoices for did=" . ((int) $did), LOG_DEBUG);  | 
                                                        |
| 1023 | + dol_syslog(__METHOD__." Read invoices for did=".((int) $did), LOG_DEBUG);  | 
                                                        |
| 1024 | 1024 | |
| 1025 | 1025 | $sql = "SELECT f.rowid, pd.rowid as pfdrowid";  | 
                                                        
| 1026 | 1026 |  			if ($sourcetype != 'salary') { | 
                                                        
@@ -1039,28 +1039,28 @@ discard block  | 
                                                    ||
| 1039 | 1039 | }  | 
                                                        
| 1040 | 1040 |  			if ($sourcetype != 'salary') { | 
                                                        
| 1041 | 1041 |  				if ($type != 'bank-transfer') { | 
                                                        
| 1042 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";  | 
                                                        |
| 1043 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_demande as pd ON f.rowid = pd.fk_facture";  | 
                                                        |
| 1042 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";  | 
                                                        |
| 1043 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_facture";  | 
                                                        |
| 1044 | 1044 |  				} else { | 
                                                        
| 1045 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";  | 
                                                        |
| 1046 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_demande as pd ON f.rowid = pd.fk_facture_fourn";  | 
                                                        |
| 1045 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";  | 
                                                        |
| 1046 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_facture_fourn";  | 
                                                        |
| 1047 | 1047 | }  | 
                                                        
| 1048 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";  | 
                                                        |
| 1049 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_rib as sr ON s.rowid = sr.fk_soc AND sr.default_rib = 1";  | 
                                                        |
| 1048 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";  | 
                                                        |
| 1049 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_rib as sr ON s.rowid = sr.fk_soc AND sr.default_rib = 1";  | 
                                                        |
| 1050 | 1050 |  			} else { | 
                                                        
| 1051 | - $sql .= " FROM " . MAIN_DB_PREFIX . "salary as f";  | 
                                                        |
| 1052 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "prelevement_demande as pd ON f.rowid = pd.fk_salary";  | 
                                                        |
| 1053 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as s ON s.rowid = f.fk_user";  | 
                                                        |
| 1054 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here  | 
                                                        |
| 1051 | + $sql .= " FROM ".MAIN_DB_PREFIX."salary as f";  | 
                                                        |
| 1052 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_salary";  | 
                                                        |
| 1053 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON s.rowid = f.fk_user";  | 
                                                        |
| 1054 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here  | 
                                                        |
| 1055 | 1055 | }  | 
                                                        
| 1056 | 1056 |  			if ($sourcetype != 'salary') { | 
                                                        
| 1057 | 1057 |  				if ($type != 'bank-transfer') { | 
                                                        
| 1058 | -					$sql .= " WHERE f.entity IN (" . getEntity('invoice') . ')'; | 
                                                        |
| 1058 | +					$sql .= " WHERE f.entity IN (".getEntity('invoice').')'; | 
                                                        |
| 1059 | 1059 |  				} else { | 
                                                        
| 1060 | -					$sql .= " WHERE f.entity IN (" . getEntity('supplier_invoice') . ')'; | 
                                                        |
| 1060 | +					$sql .= " WHERE f.entity IN (".getEntity('supplier_invoice').')'; | 
                                                        |
| 1061 | 1061 | }  | 
                                                        
| 1062 | 1062 |  			} else { | 
                                                        
| 1063 | -				$sql .= " WHERE f.entity IN (" . getEntity('salary') . ')'; | 
                                                        |
| 1063 | +				$sql .= " WHERE f.entity IN (".getEntity('salary').')'; | 
                                                        |
| 1064 | 1064 | }  | 
                                                        
| 1065 | 1065 |  			if ($sourcetype != 'salary') { | 
                                                        
| 1066 | 1066 | $sql .= " AND f.fk_statut = 1"; // Invoice validated  | 
                                                        
@@ -1074,10 +1074,10 @@ discard block  | 
                                                    ||
| 1074 | 1074 | $sql .= " AND pd.traite = 0";  | 
                                                        
| 1075 | 1075 | $sql .= " AND pd.ext_payment_id IS NULL";  | 
                                                        
| 1076 | 1076 |  			if ($sourcetype != 'salary') { | 
                                                        
| 1077 | - $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too  | 
                                                        |
| 1077 | + $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too  | 
                                                        |
| 1078 | 1078 | }  | 
                                                        
| 1079 | 1079 |  			if ($did > 0) { | 
                                                        
| 1080 | - $sql .= " AND pd.rowid = " . ((int) $did);  | 
                                                        |
| 1080 | + $sql .= " AND pd.rowid = ".((int) $did);  | 
                                                        |
| 1081 | 1081 | }  | 
                                                        
| 1082 | 1082 | |
| 1083 | 1083 | $resql = $this->db->query($sql);  | 
                                                        
@@ -1086,41 +1086,41 @@ discard block  | 
                                                    ||
| 1086 | 1086 | $i = 0;  | 
                                                        
| 1087 | 1087 | |
| 1088 | 1088 |  				while ($i < $num) { | 
                                                        
| 1089 | - $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object()  | 
                                                        |
| 1089 | + $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object()  | 
                                                        |
| 1090 | 1090 | $factures[$i] = $row; // All fields  | 
                                                        
| 1091 | 1091 | |
| 1092 | 1092 |  					if ($row[7] == 0) { | 
                                                        
| 1093 | 1093 | $error++;  | 
                                                        
| 1094 | - dol_syslog(__METHOD__ . " Read invoices/salary error Found a null amount", LOG_ERR);  | 
                                                        |
| 1095 | - $this->invoice_in_error[$row[0]] = "Error for invoice or salary id " . $row[0] . ", found a null amount";  | 
                                                        |
| 1094 | + dol_syslog(__METHOD__." Read invoices/salary error Found a null amount", LOG_ERR);  | 
                                                        |
| 1095 | + $this->invoice_in_error[$row[0]] = "Error for invoice or salary id ".$row[0].", found a null amount";  | 
                                                        |
| 1096 | 1096 | break;  | 
                                                        
| 1097 | 1097 | }  | 
                                                        
| 1098 | 1098 | $i++;  | 
                                                        
| 1099 | 1099 | }  | 
                                                        
| 1100 | 1100 | |
| 1101 | 1101 | $this->db->free($resql);  | 
                                                        
| 1102 | - dol_syslog(__METHOD__ . " Read invoices/salary, " . $i . " invoices/salary to withdraw", LOG_DEBUG);  | 
                                                        |
| 1102 | + dol_syslog(__METHOD__." Read invoices/salary, ".$i." invoices/salary to withdraw", LOG_DEBUG);  | 
                                                        |
| 1103 | 1103 |  			} else { | 
                                                        
| 1104 | 1104 | $error++;  | 
                                                        
| 1105 | 1105 | $this->error = $this->db->lasterror();  | 
                                                        
| 1106 | - dol_syslog(__METHOD__ . " Read invoices/salary error " . $this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1106 | + dol_syslog(__METHOD__." Read invoices/salary error ".$this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1107 | 1107 | return -1;  | 
                                                        
| 1108 | 1108 | }  | 
                                                        
| 1109 | 1109 | }  | 
                                                        
| 1110 | 1110 | |
| 1111 | 1111 |  		if (!$error) { | 
                                                        
| 1112 | 1112 | // Make some checks  | 
                                                        
| 1113 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';  | 
                                                        |
| 1114 | - require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';  | 
                                                        |
| 1115 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';  | 
                                                        |
| 1116 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';  | 
                                                        |
| 1113 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';  | 
                                                        |
| 1114 | + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';  | 
                                                        |
| 1115 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';  | 
                                                        |
| 1116 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';  | 
                                                        |
| 1117 | 1117 | |
| 1118 | 1118 | $tmpsoc = new Societe($this->db);  | 
                                                        
| 1119 | 1119 | $tmpuser = new User($this->db);  | 
                                                        
| 1120 | 1120 | |
| 1121 | 1121 | // Check BAN  | 
                                                        
| 1122 | 1122 | $i = 0;  | 
                                                        
| 1123 | - dol_syslog(__METHOD__ . " Check BAN", LOG_DEBUG);  | 
                                                        |
| 1123 | + dol_syslog(__METHOD__." Check BAN", LOG_DEBUG);  | 
                                                        |
| 1124 | 1124 | |
| 1125 | 1125 |  			if (count($factures) > 0) { | 
                                                        
| 1126 | 1126 |  				foreach ($factures as $key => $fac) { | 
                                                        
@@ -1160,31 +1160,31 @@ discard block  | 
                                                    ||
| 1160 | 1160 |  							if ($type != 'bank-transfer') { | 
                                                        
| 1161 | 1161 | $tmpsoc->id = $fac[2];  | 
                                                        
| 1162 | 1162 | $tmpsoc->name = $fac[8];  | 
                                                        
| 1163 | - $invoice_url = "<a href='" . DOL_URL_ROOT . '/compta/facture/card.php?facid=' . $fac[0] . "'>" . $fac[9] . "</a>";  | 
                                                        |
| 1164 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1165 | - $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1163 | + $invoice_url = "<a href='".DOL_URL_ROOT.'/compta/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";  | 
                                                        |
| 1164 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1165 | + $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1166 | 1166 | $error++;  | 
                                                        
| 1167 | 1167 | }  | 
                                                        
| 1168 | 1168 |  							if ($type == 'bank-transfer' && $sourcetype != 'salary') { | 
                                                        
| 1169 | 1169 | $tmpsoc->id = $fac[2];  | 
                                                        
| 1170 | 1170 | $tmpsoc->name = $fac[8];  | 
                                                        
| 1171 | - $invoice_url = "<a href='" . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $fac[0] . "'>" . $fac[9] . "</a>";  | 
                                                        |
| 1172 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1173 | - $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0);  | 
                                                        |
| 1171 | + $invoice_url = "<a href='".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>";  | 
                                                        |
| 1172 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1173 | + $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0);  | 
                                                        |
| 1174 | 1174 | $error++;  | 
                                                        
| 1175 | 1175 | }  | 
                                                        
| 1176 | 1176 |  							if ($type == 'bank-transfer' && $sourcetype == 'salary') { | 
                                                        
| 1177 | 1177 | $tmpuser->id = $fac[2];  | 
                                                        
| 1178 | 1178 | $tmpuser->firstname = $fac[8];  | 
                                                        
| 1179 | - $salary_url = "<a href='" . DOL_URL_ROOT . '/salaries/card.php?id=' . $fac[0] . "'>" . $fac[0] . "</a>";  | 
                                                        |
| 1180 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);  | 
                                                        |
| 1181 | - $this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0);  | 
                                                        |
| 1179 | + $salary_url = "<a href='".DOL_URL_ROOT.'/salaries/card.php?id='.$fac[0]."'>".$fac[0]."</a>";  | 
                                                        |
| 1180 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary ".$salary_url." for employee ".$tmpuser->getNomUrl(0);  | 
                                                        |
| 1181 | + $this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary ".$salary_url." for employee ".$tmpuser->getNomUrl(0);  | 
                                                        |
| 1182 | 1182 | $error++;  | 
                                                        
| 1183 | 1183 | }  | 
                                                        
| 1184 | -							dol_syslog(__METHOD__ . " Check BAN Error on default bank number IBAN/BIC reported by verif(): " . implode(', ', $fac), LOG_WARNING); | 
                                                        |
| 1184 | +							dol_syslog(__METHOD__." Check BAN Error on default bank number IBAN/BIC reported by verif(): ".implode(', ', $fac), LOG_WARNING); | 
                                                        |
| 1185 | 1185 | }  | 
                                                        
| 1186 | 1186 |  					} else { | 
                                                        
| 1187 | - dol_syslog(__METHOD__ . " Check BAN Failed to read company", LOG_WARNING);  | 
                                                        |
| 1187 | + dol_syslog(__METHOD__." Check BAN Failed to read company", LOG_WARNING);  | 
                                                        |
| 1188 | 1188 | }  | 
                                                        
| 1189 | 1189 | /*  | 
                                                        
| 1190 | 1190 |  					} else { | 
                                                        
@@ -1193,14 +1193,14 @@ discard block  | 
                                                    ||
| 1193 | 1193 | */  | 
                                                        
| 1194 | 1194 | }  | 
                                                        
| 1195 | 1195 |  			} else { | 
                                                        
| 1196 | - dol_syslog(__METHOD__ . " Check BAN No invoice to process", LOG_WARNING);  | 
                                                        |
| 1196 | + dol_syslog(__METHOD__." Check BAN No invoice to process", LOG_WARNING);  | 
                                                        |
| 1197 | 1197 | }  | 
                                                        
| 1198 | 1198 | }  | 
                                                        
| 1199 | 1199 | |
| 1200 | 1200 | $ok = 0;  | 
                                                        
| 1201 | 1201 | |
| 1202 | 1202 | // Withdraw invoices in factures_prev array  | 
                                                        
| 1203 | - $out = count($factures_prev) . " invoices will be included.";  | 
                                                        |
| 1203 | + $out = count($factures_prev)." invoices will be included.";  | 
                                                        |
| 1204 | 1204 | //print $out."\n";  | 
                                                        
| 1205 | 1205 | dol_syslog($out);  | 
                                                        
| 1206 | 1206 | |
@@ -1234,32 +1234,32 @@ discard block  | 
                                                    ||
| 1234 | 1234 | * Process order generation  | 
                                                        
| 1235 | 1235 | */  | 
                                                        
| 1236 | 1236 |  			if (!$error) { | 
                                                        
| 1237 | - $ref = substr($year, -2) . $month;  | 
                                                        |
| 1237 | + $ref = substr($year, -2).$month;  | 
                                                        |
| 1238 | 1238 | |
| 1239 | 1239 | // Get next free number for the ref of bon prelevement  | 
                                                        
| 1240 | - $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX"  | 
                                                        |
| 1241 | - $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_bons";  | 
                                                        |
| 1242 | - $sql .= " WHERE ref LIKE '_" . $this->db->escape($ref) . "%'";  | 
                                                        |
| 1243 | - $sql .= " AND entity = " . ((int) $conf->entity);  | 
                                                        |
| 1240 | + $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX"  | 
                                                        |
| 1241 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons";  | 
                                                        |
| 1242 | + $sql .= " WHERE ref LIKE '_".$this->db->escape($ref)."%'";  | 
                                                        |
| 1243 | + $sql .= " AND entity = ".((int) $conf->entity);  | 
                                                        |
| 1244 | 1244 | $sql .= " ORDER BY ref DESC LIMIT 1";  | 
                                                        
| 1245 | 1245 | |
| 1246 | - dol_syslog(get_class($this) . " get next free number", LOG_DEBUG);  | 
                                                        |
| 1246 | + dol_syslog(get_class($this)." get next free number", LOG_DEBUG);  | 
                                                        |
| 1247 | 1247 | $resql = $this->db->query($sql);  | 
                                                        
| 1248 | 1248 | |
| 1249 | 1249 |  				if ($resql) { | 
                                                        
| 1250 | 1250 | $row = $this->db->fetch_row($resql);  | 
                                                        
| 1251 | 1251 | |
| 1252 | 1252 | // Build the new ref  | 
                                                        
| 1253 | -					$ref = "T" . $ref . sprintf("%02d", (intval($row[0]) + 1)); | 
                                                        |
| 1253 | +					$ref = "T".$ref.sprintf("%02d", (intval($row[0]) + 1)); | 
                                                        |
| 1254 | 1254 | |
| 1255 | 1255 | // $conf->abc->dir_output may be:  | 
                                                        
| 1256 | 1256 | // /home/ldestailleur/git/dolibarr_15.0/documents/abc/  | 
                                                        
| 1257 | 1257 | // or  | 
                                                        
| 1258 | 1258 | // /home/ldestailleur/git/dolibarr_15.0/documents/X/abc with X >= 2 with multicompany.  | 
                                                        
| 1259 | 1259 |  					if ($type != 'bank-transfer') { | 
                                                        
| 1260 | - $dir = $conf->prelevement->dir_output . '/receipts';  | 
                                                        |
| 1260 | + $dir = $conf->prelevement->dir_output.'/receipts';  | 
                                                        |
| 1261 | 1261 |  					} else { | 
                                                        
| 1262 | - $dir = $conf->paymentbybanktransfer->dir_output . '/receipts';  | 
                                                        |
| 1262 | + $dir = $conf->paymentbybanktransfer->dir_output.'/receipts';  | 
                                                        |
| 1263 | 1263 | }  | 
                                                        
| 1264 | 1264 |  					if (!is_dir($dir)) { | 
                                                        
| 1265 | 1265 | dol_mkdir($dir);  | 
                                                        
@@ -1267,41 +1267,41 @@ discard block  | 
                                                    ||
| 1267 | 1267 | |
| 1268 | 1268 |  					if (isModEnabled('multicompany')) { | 
                                                        
| 1269 | 1269 | $labelentity = $conf->entity;  | 
                                                        
| 1270 | - $this->filename = $dir . '/' . $ref . '-' . $labelentity . '.xml';  | 
                                                        |
| 1270 | + $this->filename = $dir.'/'.$ref.'-'.$labelentity.'.xml';  | 
                                                        |
| 1271 | 1271 |  					} else { | 
                                                        
| 1272 | - $this->filename = $dir . '/' . $ref . '.xml';  | 
                                                        |
| 1272 | + $this->filename = $dir.'/'.$ref.'.xml';  | 
                                                        |
| 1273 | 1273 | }  | 
                                                        
| 1274 | 1274 | |
| 1275 | 1275 | // Create withdraw order in database  | 
                                                        
| 1276 | -					$sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_bons ("; | 
                                                        |
| 1276 | +					$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; | 
                                                        |
| 1277 | 1277 | $sql .= "ref, entity, datec, type, fk_bank_account";  | 
                                                        
| 1278 | 1278 |  					$sql .= ") VALUES ("; | 
                                                        
| 1279 | - $sql .= "'" . $this->db->escape($ref) . "'";  | 
                                                        |
| 1280 | - $sql .= ", " . ((int) $conf->entity);  | 
                                                        |
| 1281 | - $sql .= ", '" . $this->db->idate($now) . "'";  | 
                                                        |
| 1282 | - $sql .= ", '" . ($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order') . "'";  | 
                                                        |
| 1283 | - $sql .= ", " . ((int) $fk_bank_account);  | 
                                                        |
| 1279 | + $sql .= "'".$this->db->escape($ref)."'";  | 
                                                        |
| 1280 | + $sql .= ", ".((int) $conf->entity);  | 
                                                        |
| 1281 | + $sql .= ", '".$this->db->idate($now)."'";  | 
                                                        |
| 1282 | + $sql .= ", '".($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order')."'";  | 
                                                        |
| 1283 | + $sql .= ", ".((int) $fk_bank_account);  | 
                                                        |
| 1284 | 1284 | $sql .= ")";  | 
                                                        
| 1285 | 1285 | |
| 1286 | 1286 | $resql = $this->db->query($sql);  | 
                                                        
| 1287 | 1287 | |
| 1288 | 1288 | |
| 1289 | 1289 |  					if ($resql) { | 
                                                        
| 1290 | - $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX . "prelevement_bons");  | 
                                                        |
| 1290 | + $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");  | 
                                                        |
| 1291 | 1291 | $this->id = $prev_id;  | 
                                                        
| 1292 | 1292 | $this->ref = $ref;  | 
                                                        
| 1293 | 1293 |  					} else { | 
                                                        
| 1294 | 1294 | $error++;  | 
                                                        
| 1295 | - dol_syslog(__METHOD__ . " Create withdraw receipt " . $this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1295 | + dol_syslog(__METHOD__." Create withdraw receipt ".$this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1296 | 1296 | }  | 
                                                        
| 1297 | 1297 |  				} else { | 
                                                        
| 1298 | 1298 | $error++;  | 
                                                        
| 1299 | - dol_syslog(__METHOD__ . " Get last withdraw receipt " . $this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1299 | + dol_syslog(__METHOD__." Get last withdraw receipt ".$this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1300 | 1300 | }  | 
                                                        
| 1301 | 1301 | }  | 
                                                        
| 1302 | 1302 | |
| 1303 | 1303 |  			if (!$error) { | 
                                                        
| 1304 | - dol_syslog(__METHOD__ . " Now loop on each document to insert them in llx_prelevement_demande");  | 
                                                        |
| 1304 | + dol_syslog(__METHOD__." Now loop on each document to insert them in llx_prelevement_demande");  | 
                                                        |
| 1305 | 1305 | |
| 1306 | 1306 | // Add lines for the bon  | 
                                                        
| 1307 | 1307 |  				if (count($factures_prev) > 0) { | 
                                                        
@@ -1330,17 +1330,17 @@ discard block  | 
                                                    ||
| 1330 | 1330 | }  | 
                                                        
| 1331 | 1331 | |
| 1332 | 1332 | // Update invoice requests as done  | 
                                                        
| 1333 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "prelevement_demande";  | 
                                                        |
| 1333 | + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_demande";  | 
                                                        |
| 1334 | 1334 | $sql .= " SET traite = 1";  | 
                                                        
| 1335 | - $sql .= ", date_traite = '" . $this->db->idate($now) . "'";  | 
                                                        |
| 1336 | - $sql .= ", fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 1337 | - $sql .= " WHERE rowid = " . ((int) $fac[1]);  | 
                                                        |
| 1335 | + $sql .= ", date_traite = '".$this->db->idate($now)."'";  | 
                                                        |
| 1336 | + $sql .= ", fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 1337 | + $sql .= " WHERE rowid = ".((int) $fac[1]);  | 
                                                        |
| 1338 | 1338 | |
| 1339 | 1339 | $resql = $this->db->query($sql);  | 
                                                        
| 1340 | 1340 |  						if (!$resql) { | 
                                                        
| 1341 | 1341 | $error++;  | 
                                                        
| 1342 | 1342 | $this->errors[] = $this->db->lasterror();  | 
                                                        
| 1343 | - dol_syslog(__METHOD__ . " Update Error=" . $this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1343 | + dol_syslog(__METHOD__." Update Error=".$this->db->lasterror(), LOG_ERR);  | 
                                                        |
| 1344 | 1344 | }  | 
                                                        
| 1345 | 1345 | }  | 
                                                        
| 1346 | 1346 | }  | 
                                                        
@@ -1351,7 +1351,7 @@ discard block  | 
                                                    ||
| 1351 | 1351 | * Create file of type='direct-debit' for direct debit order or type='bank-transfer' for credit transfer into a XML file  | 
                                                        
| 1352 | 1352 | */  | 
                                                        
| 1353 | 1353 | |
| 1354 | - dol_syslog(__METHOD__ . " Init direct debit or credit transfer file for " . count($factures_prev) . " invoices", LOG_DEBUG);  | 
                                                        |
| 1354 | + dol_syslog(__METHOD__." Init direct debit or credit transfer file for ".count($factures_prev)." invoices", LOG_DEBUG);  | 
                                                        |
| 1355 | 1355 | |
| 1356 | 1356 |  				if (count($factures_prev) > 0) { | 
                                                        
| 1357 | 1357 | $this->date_echeance = $datetimeprev;  | 
                                                        
@@ -1367,7 +1367,7 @@ discard block  | 
                                                    ||
| 1367 | 1367 | $this->emetteur_iban = $account->iban;  | 
                                                        
| 1368 | 1368 | $this->emetteur_bic = $account->bic;  | 
                                                        
| 1369 | 1369 | |
| 1370 | -						$this->emetteur_ics = (($type == 'bank-transfer' && getDolGlobalString("SEPA_USE_IDS")) ? $account->ics_transfer : $account->ics);	// Example "FR78ZZZ123456" | 
                                                        |
| 1370 | +						$this->emetteur_ics = (($type == 'bank-transfer' && getDolGlobalString("SEPA_USE_IDS")) ? $account->ics_transfer : $account->ics); // Example "FR78ZZZ123456" | 
                                                        |
| 1371 | 1371 | |
| 1372 | 1372 | $this->raison_sociale = $account->proprio;  | 
                                                        
| 1373 | 1373 | }  | 
                                                        
@@ -1386,7 +1386,7 @@ discard block  | 
                                                    ||
| 1386 | 1386 | $error++;  | 
                                                        
| 1387 | 1387 | }  | 
                                                        
| 1388 | 1388 | }  | 
                                                        
| 1389 | - dol_syslog(__METHOD__ . " Bank order file has been generated under filename " . $this->filename, LOG_DEBUG);  | 
                                                        |
| 1389 | + dol_syslog(__METHOD__." Bank order file has been generated under filename ".$this->filename, LOG_DEBUG);  | 
                                                        |
| 1390 | 1390 | }  | 
                                                        
| 1391 | 1391 | |
| 1392 | 1392 | |
@@ -1394,15 +1394,15 @@ discard block  | 
                                                    ||
| 1394 | 1394 | * Update total defined after generation of file  | 
                                                        
| 1395 | 1395 | */  | 
                                                        
| 1396 | 1396 |  			if (!$error) { | 
                                                        
| 1397 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "prelevement_bons";  | 
                                                        |
| 1398 | - $sql .= " SET amount = " . price2num($this->total);  | 
                                                        |
| 1399 | - $sql .= " WHERE rowid = " . ((int) $this->id);  | 
                                                        |
| 1400 | - $sql .= " AND entity = " . ((int) $conf->entity);  | 
                                                        |
| 1397 | + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";  | 
                                                        |
| 1398 | + $sql .= " SET amount = ".price2num($this->total);  | 
                                                        |
| 1399 | + $sql .= " WHERE rowid = ".((int) $this->id);  | 
                                                        |
| 1400 | + $sql .= " AND entity = ".((int) $conf->entity);  | 
                                                        |
| 1401 | 1401 | $resql = $this->db->query($sql);  | 
                                                        
| 1402 | 1402 | |
| 1403 | 1403 |  				if (!$resql) { | 
                                                        
| 1404 | 1404 | $error++;  | 
                                                        
| 1405 | - dol_syslog(__METHOD__ . " Error update total: " . $this->db->error(), LOG_ERR);  | 
                                                        |
| 1405 | + dol_syslog(__METHOD__." Error update total: ".$this->db->error(), LOG_ERR);  | 
                                                        |
| 1406 | 1406 | }  | 
                                                        
| 1407 | 1407 | }  | 
                                                        
| 1408 | 1408 | |
@@ -1422,7 +1422,7 @@ discard block  | 
                                                    ||
| 1422 | 1422 | |
| 1423 | 1423 |  			if (!$error) { | 
                                                        
| 1424 | 1424 | $this->db->commit();  | 
                                                        
| 1425 | - return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error  | 
                                                        |
| 1425 | + return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error  | 
                                                        |
| 1426 | 1426 |  			} else { | 
                                                        
| 1427 | 1427 | $this->db->rollback();  | 
                                                        
| 1428 | 1428 | return -1;  | 
                                                        
@@ -1461,7 +1461,7 @@ discard block  | 
                                                    ||
| 1461 | 1461 | }  | 
                                                        
| 1462 | 1462 | |
| 1463 | 1463 |  		if (!$error) { | 
                                                        
| 1464 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "prelevement WHERE fk_prelevement_lignes IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "prelevement_lignes WHERE fk_prelevement_bons = " . ((int) $this->id) . ")";  | 
                                                        |
| 1464 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".((int) $this->id).")";  | 
                                                        |
| 1465 | 1465 | $resql1 = $this->db->query($sql);  | 
                                                        
| 1466 | 1466 |  			if (!$resql1) { | 
                                                        
| 1467 | 1467 | dol_print_error($this->db);  | 
                                                        
@@ -1469,7 +1469,7 @@ discard block  | 
                                                    ||
| 1469 | 1469 | }  | 
                                                        
| 1470 | 1470 | |
| 1471 | 1471 |  		if (!$error) { | 
                                                        
| 1472 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "prelevement_lignes WHERE fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 1472 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 1473 | 1473 | $resql2 = $this->db->query($sql);  | 
                                                        
| 1474 | 1474 |  			if (!$resql2) { | 
                                                        
| 1475 | 1475 | dol_print_error($this->db);  | 
                                                        
@@ -1477,7 +1477,7 @@ discard block  | 
                                                    ||
| 1477 | 1477 | }  | 
                                                        
| 1478 | 1478 | |
| 1479 | 1479 |  		if (!$error) { | 
                                                        
| 1480 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "prelevement_bons WHERE rowid = " . ((int) $this->id);  | 
                                                        |
| 1480 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_bons WHERE rowid = ".((int) $this->id);  | 
                                                        |
| 1481 | 1481 | $resql3 = $this->db->query($sql);  | 
                                                        
| 1482 | 1482 |  			if (!$resql3) { | 
                                                        
| 1483 | 1483 | dol_print_error($this->db);  | 
                                                        
@@ -1485,7 +1485,7 @@ discard block  | 
                                                    ||
| 1485 | 1485 | }  | 
                                                        
| 1486 | 1486 | |
| 1487 | 1487 |  		if (!$error) { | 
                                                        
| 1488 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "prelevement_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 1488 | + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 1489 | 1489 | $resql4 = $this->db->query($sql);  | 
                                                        
| 1490 | 1490 |  			if (!$resql4) { | 
                                                        
| 1491 | 1491 | dol_print_error($this->db);  | 
                                                        
@@ -1527,22 +1527,22 @@ discard block  | 
                                                    ||
| 1527 | 1527 | $labeltoshow = 'PaymentByBankTransfer';  | 
                                                        
| 1528 | 1528 | }  | 
                                                        
| 1529 | 1529 | |
| 1530 | -		$label = img_picto('', $this->picto) . ' <u>' . $langs->trans($labeltoshow) . '</u> ' . $this->getLibStatut(5); | 
                                                        |
| 1530 | +		$label = img_picto('', $this->picto).' <u>'.$langs->trans($labeltoshow).'</u> '.$this->getLibStatut(5); | 
                                                        |
| 1531 | 1531 | $label .= '<br>';  | 
                                                        
| 1532 | -		$label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; | 
                                                        |
| 1532 | +		$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; | 
                                                        |
| 1533 | 1533 |  		if (isset($this->amount)) { | 
                                                        
| 1534 | -			$label .= '<br><b>' . $langs->trans("Amount") . ":</b> " . price($this->amount); | 
                                                        |
| 1534 | +			$label .= '<br><b>'.$langs->trans("Amount").":</b> ".price($this->amount); | 
                                                        |
| 1535 | 1535 | }  | 
                                                        
| 1536 | 1536 |  		if (isset($this->date_trans)) { | 
                                                        
| 1537 | -			$label .= '<br><b>' . $langs->trans("TransData") . ":</b> " . dol_print_date($this->date_trans, 'dayhour', 'tzuserrel'); | 
                                                        |
| 1537 | +			$label .= '<br><b>'.$langs->trans("TransData").":</b> ".dol_print_date($this->date_trans, 'dayhour', 'tzuserrel'); | 
                                                        |
| 1538 | 1538 | }  | 
                                                        
| 1539 | 1539 |  		/*if (isset($this->date_credit)) { | 
                                                        
| 1540 | 1540 |  			$label .= '<br><b>'.$langs->trans("TransData").":</b> ".dol_print_date($this->date_credit, 'dayhour', 'tzuserrel'); | 
                                                        
| 1541 | 1541 | }*/  | 
                                                        
| 1542 | 1542 | |
| 1543 | - $url = DOL_URL_ROOT . '/compta/prelevement/card.php?id=' . $this->id;  | 
                                                        |
| 1543 | + $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;  | 
                                                        |
| 1544 | 1544 |  		if (!empty($this->type) && $this->type == 'bank-transfer') { | 
                                                        
| 1545 | - $url = DOL_URL_ROOT . '/compta/prelevement/card.php?id=' . $this->id;  | 
                                                        |
| 1545 | + $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;  | 
                                                        |
| 1546 | 1546 | }  | 
                                                        
| 1547 | 1547 | |
| 1548 | 1548 |  		if ($option != 'nolink') { | 
                                                        
@@ -1560,21 +1560,21 @@ discard block  | 
                                                    ||
| 1560 | 1560 |  		if (empty($notooltip)) { | 
                                                        
| 1561 | 1561 |  			if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { | 
                                                        
| 1562 | 1562 |  				$label = $langs->trans("ShowMyObject"); | 
                                                        
| 1563 | - $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';  | 
                                                        |
| 1563 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';  | 
                                                        |
| 1564 | 1564 | }  | 
                                                        
| 1565 | - $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"';  | 
                                                        |
| 1566 | - $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"';  | 
                                                        |
| 1565 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';  | 
                                                        |
| 1566 | + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';  | 
                                                        |
| 1567 | 1567 |  		} else { | 
                                                        
| 1568 | - $linkclose = ($morecss ? ' class="' . $morecss . '"' : '');  | 
                                                        |
| 1568 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');  | 
                                                        |
| 1569 | 1569 | }  | 
                                                        
| 1570 | 1570 | |
| 1571 | - $linkstart = '<a href="' . $url . '"';  | 
                                                        |
| 1572 | - $linkstart .= $linkclose . '>';  | 
                                                        |
| 1571 | + $linkstart = '<a href="'.$url.'"';  | 
                                                        |
| 1572 | + $linkstart .= $linkclose.'>';  | 
                                                        |
| 1573 | 1573 | $linkend = '</a>';  | 
                                                        
| 1574 | 1574 | |
| 1575 | 1575 | $result .= $linkstart;  | 
                                                        
| 1576 | 1576 |  		if ($withpicto) { | 
                                                        
| 1577 | - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);  | 
                                                        |
| 1577 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);  | 
                                                        |
| 1578 | 1578 | }  | 
                                                        
| 1579 | 1579 |  		if ($withpicto != 2) { | 
                                                        
| 1580 | 1580 | $result .= $this->ref;  | 
                                                        
@@ -1603,8 +1603,8 @@ discard block  | 
                                                    ||
| 1603 | 1603 | */  | 
                                                        
| 1604 | 1604 | public function deleteNotificationById($rowid)  | 
                                                        
| 1605 | 1605 |  	{ | 
                                                        
| 1606 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "notify_def";  | 
                                                        |
| 1607 | - $sql .= " WHERE rowid = " . ((int) $rowid);  | 
                                                        |
| 1606 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";  | 
                                                        |
| 1607 | + $sql .= " WHERE rowid = ".((int) $rowid);  | 
                                                        |
| 1608 | 1608 | |
| 1609 | 1609 |  		if ($this->db->query($sql)) { | 
                                                        
| 1610 | 1610 | return 0;  | 
                                                        
@@ -1628,8 +1628,8 @@ discard block  | 
                                                    ||
| 1628 | 1628 | $userid = $user;  | 
                                                        
| 1629 | 1629 | }  | 
                                                        
| 1630 | 1630 | |
| 1631 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "notify_def";  | 
                                                        |
| 1632 | - $sql .= " WHERE fk_user=" . ((int) $userid) . " AND fk_action='" . $this->db->escape($action) . "'";  | 
                                                        |
| 1631 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";  | 
                                                        |
| 1632 | + $sql .= " WHERE fk_user=".((int) $userid)." AND fk_action='".$this->db->escape($action)."'";  | 
                                                        |
| 1633 | 1633 | |
| 1634 | 1634 |  		if ($this->db->query($sql)) { | 
                                                        
| 1635 | 1635 | return 0;  | 
                                                        
@@ -1661,15 +1661,15 @@ discard block  | 
                                                    ||
| 1661 | 1661 |  		if ($this->deleteNotification($user, $action) == 0) { | 
                                                        
| 1662 | 1662 | $now = dol_now();  | 
                                                        
| 1663 | 1663 | |
| 1664 | - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)";  | 
                                                        |
| 1665 | -			$sql .= " VALUES ('" . $this->db->idate($now) . "', " . ((int) $userid) . ", 'NULL', 'NULL', '" . $this->db->escape($action) . "')"; | 
                                                        |
| 1664 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)";  | 
                                                        |
| 1665 | +			$sql .= " VALUES ('".$this->db->idate($now)."', ".((int) $userid).", 'NULL', 'NULL', '".$this->db->escape($action)."')"; | 
                                                        |
| 1666 | 1666 | |
| 1667 | -			dol_syslog("adnotiff: " . $sql); | 
                                                        |
| 1667 | +			dol_syslog("adnotiff: ".$sql); | 
                                                        |
| 1668 | 1668 |  			if ($this->db->query($sql)) { | 
                                                        
| 1669 | 1669 | $result = 0;  | 
                                                        
| 1670 | 1670 |  			} else { | 
                                                        
| 1671 | 1671 | $result = -1;  | 
                                                        
| 1672 | - dol_syslog(get_class($this) . "::addNotification Error $result");  | 
                                                        |
| 1672 | + dol_syslog(get_class($this)."::addNotification Error $result");  | 
                                                        |
| 1673 | 1673 | }  | 
                                                        
| 1674 | 1674 | }  | 
                                                        
| 1675 | 1675 | |
@@ -1704,7 +1704,7 @@ discard block  | 
                                                    ||
| 1704 | 1704 | |
| 1705 | 1705 | $result = 0;  | 
                                                        
| 1706 | 1706 | |
| 1707 | - dol_syslog(get_class($this) . "::generate build file=" . $this->filename . " type=" . $type);  | 
                                                        |
| 1707 | + dol_syslog(get_class($this)."::generate build file=".$this->filename." type=".$type);  | 
                                                        |
| 1708 | 1708 | |
| 1709 | 1709 | $this->file = fopen($this->filename, "w");  | 
                                                        
| 1710 | 1710 |  		if ($this->file == false) { | 
                                                        
@@ -1750,13 +1750,13 @@ discard block  | 
                                                    ||
| 1750 | 1750 | $sql .= " f.ref as reffac, p.fk_facture as idfac,";  | 
                                                        
| 1751 | 1751 | $sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";  | 
                                                        
| 1752 | 1752 | $sql .= " FROM";  | 
                                                        
| 1753 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";  | 
                                                        |
| 1754 | - $sql .= " " . MAIN_DB_PREFIX . "facture as f,";  | 
                                                        |
| 1755 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement as p,";  | 
                                                        |
| 1756 | - $sql .= " " . MAIN_DB_PREFIX . "societe as soc,";  | 
                                                        |
| 1757 | - $sql .= " " . MAIN_DB_PREFIX . "c_country as c,";  | 
                                                        |
| 1758 | - $sql .= " " . MAIN_DB_PREFIX . "societe_rib as rib";  | 
                                                        |
| 1759 | - $sql .= " WHERE pl.fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 1753 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";  | 
                                                        |
| 1754 | + $sql .= " ".MAIN_DB_PREFIX."facture as f,";  | 
                                                        |
| 1755 | + $sql .= " ".MAIN_DB_PREFIX."prelevement as p,";  | 
                                                        |
| 1756 | + $sql .= " ".MAIN_DB_PREFIX."societe as soc,";  | 
                                                        |
| 1757 | + $sql .= " ".MAIN_DB_PREFIX."c_country as c,";  | 
                                                        |
| 1758 | + $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";  | 
                                                        |
| 1759 | + $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 1760 | 1760 | $sql .= " AND pl.rowid = p.fk_prelevement_lignes";  | 
                                                        
| 1761 | 1761 | $sql .= " AND p.fk_facture = f.rowid";  | 
                                                        
| 1762 | 1762 | $sql .= " AND f.fk_soc = soc.rowid";  | 
                                                        
@@ -1792,7 +1792,7 @@ discard block  | 
                                                    ||
| 1792 | 1792 | $nbtotalDrctDbtTxInf = $i;  | 
                                                        
| 1793 | 1793 |  				} else { | 
                                                        
| 1794 | 1794 | $this->error = $this->db->lasterror();  | 
                                                        
| 1795 | - fwrite($this->file, 'ERROR DEBITOR ' . $sql . $CrLf); // DEBITOR = Customers  | 
                                                        |
| 1795 | + fwrite($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers  | 
                                                        |
| 1796 | 1796 | $result = -2;  | 
                                                        
| 1797 | 1797 | }  | 
                                                        
| 1798 | 1798 | |
@@ -1809,26 +1809,26 @@ discard block  | 
                                                    ||
| 1809 | 1809 | * SECTION CREATION SEPA FILE - ISO200022  | 
                                                        
| 1810 | 1810 | */  | 
                                                        
| 1811 | 1811 | // SEPA File Header  | 
                                                        
| 1812 | - fwrite($this->file, '<' . '?xml version="1.0" encoding="UTF-8" standalone="yes"?' . '>' . $CrLf);  | 
                                                        |
| 1813 | - fwrite($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $CrLf);  | 
                                                        |
| 1814 | - fwrite($this->file, ' <CstmrDrctDbtInitn>' . $CrLf);  | 
                                                        |
| 1812 | + fwrite($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);  | 
                                                        |
| 1813 | + fwrite($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);  | 
                                                        |
| 1814 | + fwrite($this->file, ' <CstmrDrctDbtInitn>'.$CrLf);  | 
                                                        |
| 1815 | 1815 | // SEPA Group header  | 
                                                        
| 1816 | - fwrite($this->file, ' <GrpHdr>' . $CrLf);  | 
                                                        |
| 1817 | -				fwrite($this->file, '			<MsgId>' . ('DD/' . $dateTime_YMD . '/REF' . $this->id) . '</MsgId>' . $CrLf); | 
                                                        |
| 1818 | - fwrite($this->file, ' <CreDtTm>' . $dateTime_ECMA . '</CreDtTm>' . $CrLf);  | 
                                                        |
| 1819 | - fwrite($this->file, ' <NbOfTxs>' . $i . '</NbOfTxs>' . $CrLf);  | 
                                                        |
| 1820 | - fwrite($this->file, ' <CtrlSum>' . $this->total . '</CtrlSum>' . $CrLf);  | 
                                                        |
| 1821 | - fwrite($this->file, ' <InitgPty>' . $CrLf);  | 
                                                        |
| 1822 | - fwrite($this->file, ' <Nm>' . dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))) . '</Nm>' . $CrLf);  | 
                                                        |
| 1823 | - fwrite($this->file, ' <Id>' . $CrLf);  | 
                                                        |
| 1824 | - fwrite($this->file, ' <PrvtId>' . $CrLf);  | 
                                                        |
| 1825 | - fwrite($this->file, ' <Othr>' . $CrLf);  | 
                                                        |
| 1826 | - fwrite($this->file, ' <Id>' . $this->emetteur_ics . '</Id>' . $CrLf);  | 
                                                        |
| 1827 | - fwrite($this->file, ' </Othr>' . $CrLf);  | 
                                                        |
| 1828 | - fwrite($this->file, ' </PrvtId>' . $CrLf);  | 
                                                        |
| 1829 | - fwrite($this->file, ' </Id>' . $CrLf);  | 
                                                        |
| 1830 | - fwrite($this->file, ' </InitgPty>' . $CrLf);  | 
                                                        |
| 1831 | - fwrite($this->file, ' </GrpHdr>' . $CrLf);  | 
                                                        |
| 1816 | + fwrite($this->file, ' <GrpHdr>'.$CrLf);  | 
                                                        |
| 1817 | +				fwrite($this->file, '			<MsgId>'.('DD/'.$dateTime_YMD.'/REF'.$this->id).'</MsgId>'.$CrLf); | 
                                                        |
| 1818 | + fwrite($this->file, ' <CreDtTm>'.$dateTime_ECMA.'</CreDtTm>'.$CrLf);  | 
                                                        |
| 1819 | + fwrite($this->file, ' <NbOfTxs>'.$i.'</NbOfTxs>'.$CrLf);  | 
                                                        |
| 1820 | + fwrite($this->file, ' <CtrlSum>'.$this->total.'</CtrlSum>'.$CrLf);  | 
                                                        |
| 1821 | + fwrite($this->file, ' <InitgPty>'.$CrLf);  | 
                                                        |
| 1822 | + fwrite($this->file, ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf);  | 
                                                        |
| 1823 | + fwrite($this->file, ' <Id>'.$CrLf);  | 
                                                        |
| 1824 | + fwrite($this->file, ' <PrvtId>'.$CrLf);  | 
                                                        |
| 1825 | + fwrite($this->file, ' <Othr>'.$CrLf);  | 
                                                        |
| 1826 | + fwrite($this->file, ' <Id>'.$this->emetteur_ics.'</Id>'.$CrLf);  | 
                                                        |
| 1827 | + fwrite($this->file, ' </Othr>'.$CrLf);  | 
                                                        |
| 1828 | + fwrite($this->file, ' </PrvtId>'.$CrLf);  | 
                                                        |
| 1829 | + fwrite($this->file, ' </Id>'.$CrLf);  | 
                                                        |
| 1830 | + fwrite($this->file, ' </InitgPty>'.$CrLf);  | 
                                                        |
| 1831 | + fwrite($this->file, ' </GrpHdr>'.$CrLf);  | 
                                                        |
| 1832 | 1832 | // SEPA File Emetteur  | 
                                                        
| 1833 | 1833 |  				if ($result != -2) { | 
                                                        
| 1834 | 1834 | fwrite($this->file, $fileEmetteurSection);  | 
                                                        
@@ -1838,9 +1838,9 @@ discard block  | 
                                                    ||
| 1838 | 1838 | fwrite($this->file, $fileDebiteurSection);  | 
                                                        
| 1839 | 1839 | }  | 
                                                        
| 1840 | 1840 | // SEPA FILE FOOTER  | 
                                                        
| 1841 | - fwrite($this->file, ' </PmtInf>' . $CrLf);  | 
                                                        |
| 1842 | - fwrite($this->file, ' </CstmrDrctDbtInitn>' . $CrLf);  | 
                                                        |
| 1843 | - fwrite($this->file, '</Document>' . $CrLf);  | 
                                                        |
| 1841 | + fwrite($this->file, ' </PmtInf>'.$CrLf);  | 
                                                        |
| 1842 | + fwrite($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);  | 
                                                        |
| 1843 | + fwrite($this->file, '</Document>'.$CrLf);  | 
                                                        |
| 1844 | 1844 |  			} else { | 
                                                        
| 1845 | 1845 | /**  | 
                                                        
| 1846 | 1846 | * SECTION CREATION FICHIER SEPA - CREDIT TRANSFER  | 
                                                        
@@ -1872,13 +1872,13 @@ discard block  | 
                                                    ||
| 1872 | 1872 | $sql .= " s.ref as reffac, p.fk_salary as idfac,";  | 
                                                        
| 1873 | 1873 | $sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, '' as rum, '' as date_rum";  | 
                                                        
| 1874 | 1874 | $sql .= " FROM";  | 
                                                        
| 1875 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";  | 
                                                        |
| 1876 | - $sql .= " " . MAIN_DB_PREFIX . "salary as s,";  | 
                                                        |
| 1877 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement as p,";  | 
                                                        |
| 1878 | - $sql .= " " . MAIN_DB_PREFIX . "user as u";  | 
                                                        |
| 1879 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON u.fk_country = c.rowid,";  | 
                                                        |
| 1880 | - $sql .= " " . MAIN_DB_PREFIX . "user_rib as rib";  | 
                                                        |
| 1881 | - $sql .= " WHERE pl.fk_prelevement_bons=" . ((int) $this->id);  | 
                                                        |
| 1875 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";  | 
                                                        |
| 1876 | + $sql .= " ".MAIN_DB_PREFIX."salary as s,";  | 
                                                        |
| 1877 | + $sql .= " ".MAIN_DB_PREFIX."prelevement as p,";  | 
                                                        |
| 1878 | + $sql .= " ".MAIN_DB_PREFIX."user as u";  | 
                                                        |
| 1879 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid,";  | 
                                                        |
| 1880 | + $sql .= " ".MAIN_DB_PREFIX."user_rib as rib";  | 
                                                        |
| 1881 | + $sql .= " WHERE pl.fk_prelevement_bons=".((int) $this->id);  | 
                                                        |
| 1882 | 1882 | $sql .= " AND pl.rowid = p.fk_prelevement_lignes";  | 
                                                        
| 1883 | 1883 | $sql .= " AND p.fk_salary = s.rowid";  | 
                                                        
| 1884 | 1884 | $sql .= " AND s.fk_user = u.rowid";  | 
                                                        
@@ -1889,13 +1889,13 @@ discard block  | 
                                                    ||
| 1889 | 1889 | $sql .= " f.ref as reffac, f.ref_supplier as fac_ref_supplier, p.fk_facture_fourn as idfac,";  | 
                                                        
| 1890 | 1890 | $sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";  | 
                                                        
| 1891 | 1891 | $sql .= " FROM";  | 
                                                        
| 1892 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";  | 
                                                        |
| 1893 | - $sql .= " " . MAIN_DB_PREFIX . "facture_fourn as f,";  | 
                                                        |
| 1894 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement as p,";  | 
                                                        |
| 1895 | - $sql .= " " . MAIN_DB_PREFIX . "societe as soc";  | 
                                                        |
| 1896 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON soc.fk_pays = c.rowid,";  | 
                                                        |
| 1897 | - $sql .= " " . MAIN_DB_PREFIX . "societe_rib as rib";  | 
                                                        |
| 1898 | - $sql .= " WHERE pl.fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 1892 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";  | 
                                                        |
| 1893 | + $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";  | 
                                                        |
| 1894 | + $sql .= " ".MAIN_DB_PREFIX."prelevement as p,";  | 
                                                        |
| 1895 | + $sql .= " ".MAIN_DB_PREFIX."societe as soc";  | 
                                                        |
| 1896 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON soc.fk_pays = c.rowid,";  | 
                                                        |
| 1897 | + $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";  | 
                                                        |
| 1898 | + $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 1899 | 1899 | $sql .= " AND pl.rowid = p.fk_prelevement_lignes";  | 
                                                        
| 1900 | 1900 | $sql .= " AND p.fk_facture_fourn = f.rowid";  | 
                                                        
| 1901 | 1901 | $sql .= " AND f.fk_soc = soc.rowid";  | 
                                                        
@@ -1922,7 +1922,7 @@ discard block  | 
                                                    ||
| 1922 | 1922 | $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);  | 
                                                        
| 1923 | 1923 | $refobj = $obj->reffac;  | 
                                                        
| 1924 | 1924 |  						if (empty($refobj) && !empty($forsalary)) {	// If ref of salary not defined, we force a value | 
                                                        
| 1925 | - $refobj = "SAL" . $obj->idfac;  | 
                                                        |
| 1925 | + $refobj = "SAL".$obj->idfac;  | 
                                                        |
| 1926 | 1926 | }  | 
                                                        
| 1927 | 1927 | |
| 1928 | 1928 | $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $refobj, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type, $obj->fac_ref_supplier);  | 
                                                        
@@ -1933,7 +1933,7 @@ discard block  | 
                                                    ||
| 1933 | 1933 | $nbtotalDrctDbtTxInf = $i;  | 
                                                        
| 1934 | 1934 |  				} else { | 
                                                        
| 1935 | 1935 | $this->error = $this->db->lasterror();  | 
                                                        
| 1936 | - fwrite($this->file, 'ERROR CREDITOR ' . $sql . $CrLf); // CREDITORS = Suppliers  | 
                                                        |
| 1936 | + fwrite($this->file, 'ERROR CREDITOR '.$sql.$CrLf); // CREDITORS = Suppliers  | 
                                                        |
| 1937 | 1937 | $result = -2;  | 
                                                        
| 1938 | 1938 | }  | 
                                                        
| 1939 | 1939 | // Define $fileEmetteurSection. Start of block PmtInf. Will contains all $nbtotalDrctDbtTxInf  | 
                                                        
@@ -1949,26 +1949,26 @@ discard block  | 
                                                    ||
| 1949 | 1949 | * SECTION CREATION SEPA FILE - CREDIT TRANSFER - ISO200022  | 
                                                        
| 1950 | 1950 | */  | 
                                                        
| 1951 | 1951 | // SEPA File Header  | 
                                                        
| 1952 | - fwrite($this->file, '<' . '?xml version="1.0" encoding="UTF-8" standalone="yes"?' . '>' . $CrLf);  | 
                                                        |
| 1953 | - fwrite($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $CrLf);  | 
                                                        |
| 1954 | - fwrite($this->file, ' <CstmrCdtTrfInitn>' . $CrLf);  | 
                                                        |
| 1952 | + fwrite($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);  | 
                                                        |
| 1953 | + fwrite($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);  | 
                                                        |
| 1954 | + fwrite($this->file, ' <CstmrCdtTrfInitn>'.$CrLf);  | 
                                                        |
| 1955 | 1955 | // SEPA Group header  | 
                                                        
| 1956 | - fwrite($this->file, ' <GrpHdr>' . $CrLf);  | 
                                                        |
| 1957 | -				fwrite($this->file, '			<MsgId>' . ('TRF/' . $dateTime_YMD . '/REF' . $this->id) . '</MsgId>' . $CrLf); | 
                                                        |
| 1958 | - fwrite($this->file, ' <CreDtTm>' . $dateTime_ECMA . '</CreDtTm>' . $CrLf);  | 
                                                        |
| 1959 | - fwrite($this->file, ' <NbOfTxs>' . $i . '</NbOfTxs>' . $CrLf);  | 
                                                        |
| 1960 | - fwrite($this->file, ' <CtrlSum>' . $this->total . '</CtrlSum>' . $CrLf);  | 
                                                        |
| 1961 | - fwrite($this->file, ' <InitgPty>' . $CrLf);  | 
                                                        |
| 1962 | - fwrite($this->file, ' <Nm>' . dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))) . '</Nm>' . $CrLf);  | 
                                                        |
| 1963 | - fwrite($this->file, ' <Id>' . $CrLf);  | 
                                                        |
| 1964 | - fwrite($this->file, ' <PrvtId>' . $CrLf);  | 
                                                        |
| 1965 | - fwrite($this->file, ' <Othr>' . $CrLf);  | 
                                                        |
| 1966 | - fwrite($this->file, ' <Id>' . $this->emetteur_ics . '</Id>' . $CrLf);  | 
                                                        |
| 1967 | - fwrite($this->file, ' </Othr>' . $CrLf);  | 
                                                        |
| 1968 | - fwrite($this->file, ' </PrvtId>' . $CrLf);  | 
                                                        |
| 1969 | - fwrite($this->file, ' </Id>' . $CrLf);  | 
                                                        |
| 1970 | - fwrite($this->file, ' </InitgPty>' . $CrLf);  | 
                                                        |
| 1971 | - fwrite($this->file, ' </GrpHdr>' . $CrLf);  | 
                                                        |
| 1956 | + fwrite($this->file, ' <GrpHdr>'.$CrLf);  | 
                                                        |
| 1957 | +				fwrite($this->file, '			<MsgId>'.('TRF/'.$dateTime_YMD.'/REF'.$this->id).'</MsgId>'.$CrLf); | 
                                                        |
| 1958 | + fwrite($this->file, ' <CreDtTm>'.$dateTime_ECMA.'</CreDtTm>'.$CrLf);  | 
                                                        |
| 1959 | + fwrite($this->file, ' <NbOfTxs>'.$i.'</NbOfTxs>'.$CrLf);  | 
                                                        |
| 1960 | + fwrite($this->file, ' <CtrlSum>'.$this->total.'</CtrlSum>'.$CrLf);  | 
                                                        |
| 1961 | + fwrite($this->file, ' <InitgPty>'.$CrLf);  | 
                                                        |
| 1962 | + fwrite($this->file, ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf);  | 
                                                        |
| 1963 | + fwrite($this->file, ' <Id>'.$CrLf);  | 
                                                        |
| 1964 | + fwrite($this->file, ' <PrvtId>'.$CrLf);  | 
                                                        |
| 1965 | + fwrite($this->file, ' <Othr>'.$CrLf);  | 
                                                        |
| 1966 | + fwrite($this->file, ' <Id>'.$this->emetteur_ics.'</Id>'.$CrLf);  | 
                                                        |
| 1967 | + fwrite($this->file, ' </Othr>'.$CrLf);  | 
                                                        |
| 1968 | + fwrite($this->file, ' </PrvtId>'.$CrLf);  | 
                                                        |
| 1969 | + fwrite($this->file, ' </Id>'.$CrLf);  | 
                                                        |
| 1970 | + fwrite($this->file, ' </InitgPty>'.$CrLf);  | 
                                                        |
| 1971 | + fwrite($this->file, ' </GrpHdr>'.$CrLf);  | 
                                                        |
| 1972 | 1972 | // SEPA File Emetteur (mycompany)  | 
                                                        
| 1973 | 1973 |  				if ($result != -2) { | 
                                                        
| 1974 | 1974 | fwrite($this->file, $fileEmetteurSection);  | 
                                                        
@@ -1978,9 +1978,9 @@ discard block  | 
                                                    ||
| 1978 | 1978 | fwrite($this->file, $fileCrediteurSection);  | 
                                                        
| 1979 | 1979 | }  | 
                                                        
| 1980 | 1980 | // SEPA FILE FOOTER  | 
                                                        
| 1981 | - fwrite($this->file, ' </PmtInf>' . $CrLf);  | 
                                                        |
| 1982 | - fwrite($this->file, ' </CstmrCdtTrfInitn>' . $CrLf);  | 
                                                        |
| 1983 | - fwrite($this->file, '</Document>' . $CrLf);  | 
                                                        |
| 1981 | + fwrite($this->file, ' </PmtInf>'.$CrLf);  | 
                                                        |
| 1982 | + fwrite($this->file, ' </CstmrCdtTrfInitn>'.$CrLf);  | 
                                                        |
| 1983 | + fwrite($this->file, '</Document>'.$CrLf);  | 
                                                        |
| 1984 | 1984 | }  | 
                                                        
| 1985 | 1985 | }  | 
                                                        
| 1986 | 1986 | |
@@ -1989,10 +1989,10 @@ discard block  | 
                                                    ||
| 1989 | 1989 |  			if ($type != 'bank-transfer') { | 
                                                        
| 1990 | 1990 | $sql = "SELECT pl.amount";  | 
                                                        
| 1991 | 1991 | $sql .= " FROM";  | 
                                                        
| 1992 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";  | 
                                                        |
| 1993 | - $sql .= " " . MAIN_DB_PREFIX . "facture as f,";  | 
                                                        |
| 1994 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement as p";  | 
                                                        |
| 1995 | - $sql .= " WHERE pl.fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 1992 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";  | 
                                                        |
| 1993 | + $sql .= " ".MAIN_DB_PREFIX."facture as f,";  | 
                                                        |
| 1994 | + $sql .= " ".MAIN_DB_PREFIX."prelevement as p";  | 
                                                        |
| 1995 | + $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 1996 | 1996 | $sql .= " AND pl.rowid = p.fk_prelevement_lignes";  | 
                                                        
| 1997 | 1997 | $sql .= " AND p.fk_facture = f.rowid";  | 
                                                        
| 1998 | 1998 | |
@@ -2015,10 +2015,10 @@ discard block  | 
                                                    ||
| 2015 | 2015 |  			} else { | 
                                                        
| 2016 | 2016 | $sql = "SELECT pl.amount";  | 
                                                        
| 2017 | 2017 | $sql .= " FROM";  | 
                                                        
| 2018 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";  | 
                                                        |
| 2019 | - $sql .= " " . MAIN_DB_PREFIX . "facture_fourn as f,";  | 
                                                        |
| 2020 | - $sql .= " " . MAIN_DB_PREFIX . "prelevement as p";  | 
                                                        |
| 2021 | - $sql .= " WHERE pl.fk_prelevement_bons = " . ((int) $this->id);  | 
                                                        |
| 2018 | + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";  | 
                                                        |
| 2019 | + $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";  | 
                                                        |
| 2020 | + $sql .= " ".MAIN_DB_PREFIX."prelevement as p";  | 
                                                        |
| 2021 | + $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $this->id);  | 
                                                        |
| 2022 | 2022 | $sql .= " AND pl.rowid = p.fk_prelevement_lignes";  | 
                                                        
| 2023 | 2023 | $sql .= " AND p.fk_facture_fourn = f.rowid";  | 
                                                        
| 2024 | 2024 | // Lines  | 
                                                        
@@ -2067,7 +2067,7 @@ discard block  | 
                                                    ||
| 2067 | 2067 |  		$pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation) | 
                                                        
| 2068 | 2068 | |
| 2069 | 2069 | // 3 char + '-' + 12 + '-' + id + '-' + code Must be lower than 32.  | 
                                                        
| 2070 | - return $pre . '-' . dol_print_date($row_datec, 'dayhourlogsmall') . '-' . dol_trunc($row_drum . ($row_code_client ? '-' . $row_code_client : ''), 13, 'right', 'UTF-8', 1);  | 
                                                        |
| 2070 | + return $pre.'-'.dol_print_date($row_datec, 'dayhourlogsmall').'-'.dol_trunc($row_drum.($row_code_client ? '-'.$row_code_client : ''), 13, 'right', 'UTF-8', 1);  | 
                                                        |
| 2071 | 2071 | }  | 
                                                        
| 2072 | 2072 | |
| 2073 | 2073 | |
@@ -2106,11 +2106,11 @@ discard block  | 
                                                    ||
| 2106 | 2106 | |
| 2107 | 2107 | // Raison Sociale Destinataire C2  | 
                                                        
| 2108 | 2108 | |
| 2109 | - fwrite($this->file, substr(strtoupper($client_nom) . " ", 0, 24));  | 
                                                        |
| 2109 | + fwrite($this->file, substr(strtoupper($client_nom)." ", 0, 24));  | 
                                                        |
| 2110 | 2110 | |
| 2111 | 2111 | // Address optional D1  | 
                                                        
| 2112 | 2112 |  		$address = strtr($rib_dom, array(" " => "-", chr(13) => " ", chr(10) => "")); | 
                                                        
| 2113 | - fwrite($this->file, substr($address . " ", 0, 24));  | 
                                                        |
| 2113 | + fwrite($this->file, substr($address." ", 0, 24));  | 
                                                        |
| 2114 | 2114 | |
| 2115 | 2115 | // Zone Reservee D2  | 
                                                        
| 2116 | 2116 | |
@@ -2122,17 +2122,17 @@ discard block  | 
                                                    ||
| 2122 | 2122 | |
| 2123 | 2123 | // Numero de compte D4  | 
                                                        
| 2124 | 2124 | |
| 2125 | -		fwrite($this->file, substr("000000000000000" . $rib_number, -11)); | 
                                                        |
| 2125 | +		fwrite($this->file, substr("000000000000000".$rib_number, -11)); | 
                                                        |
| 2126 | 2126 | |
| 2127 | 2127 | // Zone E Montant  | 
                                                        
| 2128 | 2128 | |
| 2129 | 2129 | $montant = (round($amount, 2) * 100);  | 
                                                        
| 2130 | 2130 | |
| 2131 | -		fwrite($this->file, substr("000000000000000" . $montant, -16)); | 
                                                        |
| 2131 | +		fwrite($this->file, substr("000000000000000".$montant, -16)); | 
                                                        |
| 2132 | 2132 | |
| 2133 | 2133 | // Label F  | 
                                                        
| 2134 | 2134 | |
| 2135 | -		fwrite($this->file, substr("*_" . $ref . "_RDVnet" . $rowid . "                               ", 0, 31)); | 
                                                        |
| 2135 | +		fwrite($this->file, substr("*_".$ref."_RDVnet".$rowid."                               ", 0, 31)); | 
                                                        |
| 2136 | 2136 | |
| 2137 | 2137 | // Code etablissement G1  | 
                                                        
| 2138 | 2138 | |
@@ -2183,7 +2183,7 @@ discard block  | 
                                                    ||
| 2183 | 2183 | $row_somme = round((float) $row_somme, 2);  | 
                                                        
| 2184 | 2184 | }  | 
                                                        
| 2185 | 2185 | |
| 2186 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';  | 
                                                        |
| 2186 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';  | 
                                                        |
| 2187 | 2187 | |
| 2188 | 2188 | $CrLf = "\n";  | 
                                                        
| 2189 | 2189 |  		$Rowing = sprintf("%010d", $row_idfac); | 
                                                        
@@ -2198,61 +2198,61 @@ discard block  | 
                                                    ||
| 2198 | 2198 |  		if ($type != 'bank-transfer') { | 
                                                        
| 2199 | 2199 | // SEPA Paiement Information of buyer for Direct Debit  | 
                                                        
| 2200 | 2200 | $XML_DEBITOR = '';  | 
                                                        
| 2201 | - $XML_DEBITOR .= ' <DrctDbtTxInf>' . $CrLf;  | 
                                                        |
| 2202 | - $XML_DEBITOR .= ' <PmtId>' . $CrLf;  | 
                                                        |
| 2201 | + $XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf;  | 
                                                        |
| 2202 | + $XML_DEBITOR .= ' <PmtId>'.$CrLf;  | 
                                                        |
| 2203 | 2203 | // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)  | 
                                                        
| 2204 | -			$XML_DEBITOR .= '					<EndToEndId>' . ((getDolGlobalString('PRELEVEMENT_END_TO_END') != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('DD-' . dol_trunc($row_idfac . '-' . $row_ref, 20, 'right', 'UTF-8', 1)) . '-' . $Rowing) . '</EndToEndId>' . $CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters | 
                                                        |
| 2205 | - $XML_DEBITOR .= ' </PmtId>' . $CrLf;  | 
                                                        |
| 2206 | - $XML_DEBITOR .= ' <InstdAmt Ccy="EUR">' . $row_somme . '</InstdAmt>' . $CrLf;  | 
                                                        |
| 2207 | - $XML_DEBITOR .= ' <DrctDbtTx>' . $CrLf;  | 
                                                        |
| 2208 | - $XML_DEBITOR .= ' <MndtRltdInf>' . $CrLf;  | 
                                                        |
| 2209 | - $XML_DEBITOR .= ' <MndtId>' . $Rum . '</MndtId>' . $CrLf;  | 
                                                        |
| 2210 | - $XML_DEBITOR .= ' <DtOfSgntr>' . $DtOfSgntr . '</DtOfSgntr>' . $CrLf;  | 
                                                        |
| 2211 | - $XML_DEBITOR .= ' <AmdmntInd>false</AmdmntInd>' . $CrLf;  | 
                                                        |
| 2212 | - $XML_DEBITOR .= ' </MndtRltdInf>' . $CrLf;  | 
                                                        |
| 2213 | - $XML_DEBITOR .= ' </DrctDbtTx>' . $CrLf;  | 
                                                        |
| 2214 | - $XML_DEBITOR .= ' <DbtrAgt>' . $CrLf;  | 
                                                        |
| 2215 | - $XML_DEBITOR .= ' <FinInstnId>' . $CrLf;  | 
                                                        |
| 2216 | -			if (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC')==0) { | 
                                                        |
| 2217 | - $XML_DEBITOR .= ' <BIC>' . $row_bic . '</BIC>' . $CrLf;  | 
                                                        |
| 2204 | +			$XML_DEBITOR .= '					<EndToEndId>'.((getDolGlobalString('PRELEVEMENT_END_TO_END') != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('DD-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters | 
                                                        |
| 2205 | + $XML_DEBITOR .= ' </PmtId>'.$CrLf;  | 
                                                        |
| 2206 | + $XML_DEBITOR .= ' <InstdAmt Ccy="EUR">'.$row_somme.'</InstdAmt>'.$CrLf;  | 
                                                        |
| 2207 | + $XML_DEBITOR .= ' <DrctDbtTx>'.$CrLf;  | 
                                                        |
| 2208 | + $XML_DEBITOR .= ' <MndtRltdInf>'.$CrLf;  | 
                                                        |
| 2209 | + $XML_DEBITOR .= ' <MndtId>'.$Rum.'</MndtId>'.$CrLf;  | 
                                                        |
| 2210 | + $XML_DEBITOR .= ' <DtOfSgntr>'.$DtOfSgntr.'</DtOfSgntr>'.$CrLf;  | 
                                                        |
| 2211 | + $XML_DEBITOR .= ' <AmdmntInd>false</AmdmntInd>'.$CrLf;  | 
                                                        |
| 2212 | + $XML_DEBITOR .= ' </MndtRltdInf>'.$CrLf;  | 
                                                        |
| 2213 | + $XML_DEBITOR .= ' </DrctDbtTx>'.$CrLf;  | 
                                                        |
| 2214 | + $XML_DEBITOR .= ' <DbtrAgt>'.$CrLf;  | 
                                                        |
| 2215 | + $XML_DEBITOR .= ' <FinInstnId>'.$CrLf;  | 
                                                        |
| 2216 | +			if (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0) { | 
                                                        |
| 2217 | + $XML_DEBITOR .= ' <BIC>'.$row_bic.'</BIC>'.$CrLf;  | 
                                                        |
| 2218 | 2218 | }  | 
                                                        
| 2219 | - $XML_DEBITOR .= ' </FinInstnId>' . $CrLf;  | 
                                                        |
| 2220 | - $XML_DEBITOR .= ' </DbtrAgt>' . $CrLf;  | 
                                                        |
| 2221 | - $XML_DEBITOR .= ' <Dbtr>' . $CrLf;  | 
                                                        |
| 2222 | - $XML_DEBITOR .= ' <Nm>' . dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom), ' '))) . '</Nm>' . $CrLf;  | 
                                                        |
| 2223 | - $XML_DEBITOR .= ' <PstlAdr>' . $CrLf;  | 
                                                        |
| 2224 | - $XML_DEBITOR .= ' <Ctry>' . $row_country_code . '</Ctry>' . $CrLf;  | 
                                                        |
| 2219 | + $XML_DEBITOR .= ' </FinInstnId>'.$CrLf;  | 
                                                        |
| 2220 | + $XML_DEBITOR .= ' </DbtrAgt>'.$CrLf;  | 
                                                        |
| 2221 | + $XML_DEBITOR .= ' <Dbtr>'.$CrLf;  | 
                                                        |
| 2222 | + $XML_DEBITOR .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom), ' '))).'</Nm>'.$CrLf;  | 
                                                        |
| 2223 | + $XML_DEBITOR .= ' <PstlAdr>'.$CrLf;  | 
                                                        |
| 2224 | + $XML_DEBITOR .= ' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;  | 
                                                        |
| 2225 | 2225 | $addressline1 = strtr($row_address, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        
| 2226 | - $addressline2 = strtr($row_zip . (($row_zip && $row_town) ? ' ' : (string) $row_town), array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2226 | + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2227 | 2227 |  			if (trim($addressline1)) { | 
                                                        
| 2228 | - $XML_DEBITOR .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2228 | + $XML_DEBITOR .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2229 | 2229 | }  | 
                                                        
| 2230 | 2230 |  			if (trim($addressline2)) { | 
                                                        
| 2231 | - $XML_DEBITOR .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2231 | + $XML_DEBITOR .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2232 | 2232 | }  | 
                                                        
| 2233 | - $XML_DEBITOR .= ' </PstlAdr>' . $CrLf;  | 
                                                        |
| 2234 | - $XML_DEBITOR .= ' </Dbtr>' . $CrLf;  | 
                                                        |
| 2235 | - $XML_DEBITOR .= ' <DbtrAcct>' . $CrLf;  | 
                                                        |
| 2236 | - $XML_DEBITOR .= ' <Id>' . $CrLf;  | 
                                                        |
| 2237 | -			$XML_DEBITOR .= '						<IBAN>' . preg_replace('/\s/', '', $row_iban) . '</IBAN>' . $CrLf; | 
                                                        |
| 2238 | - $XML_DEBITOR .= ' </Id>' . $CrLf;  | 
                                                        |
| 2239 | - $XML_DEBITOR .= ' </DbtrAcct>' . $CrLf;  | 
                                                        |
| 2240 | - $XML_DEBITOR .= ' <RmtInf>' . $CrLf;  | 
                                                        |
| 2233 | + $XML_DEBITOR .= ' </PstlAdr>'.$CrLf;  | 
                                                        |
| 2234 | + $XML_DEBITOR .= ' </Dbtr>'.$CrLf;  | 
                                                        |
| 2235 | + $XML_DEBITOR .= ' <DbtrAcct>'.$CrLf;  | 
                                                        |
| 2236 | + $XML_DEBITOR .= ' <Id>'.$CrLf;  | 
                                                        |
| 2237 | +			$XML_DEBITOR .= '						<IBAN>'.preg_replace('/\s/', '', $row_iban).'</IBAN>'.$CrLf; | 
                                                        |
| 2238 | + $XML_DEBITOR .= ' </Id>'.$CrLf;  | 
                                                        |
| 2239 | + $XML_DEBITOR .= ' </DbtrAcct>'.$CrLf;  | 
                                                        |
| 2240 | + $XML_DEBITOR .= ' <RmtInf>'.$CrLf;  | 
                                                        |
| 2241 | 2241 | // A string with some information on payment - 140 max  | 
                                                        
| 2242 | -			$XML_DEBITOR .= '					<Ustrd>' . getDolGlobalString('PRELEVEMENT_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref . ($row_comment ? ' - ' . $row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))) . '</Ustrd>' . $CrLf; // Free unstuctured data - 140 max | 
                                                        |
| 2243 | - $XML_DEBITOR .= ' </RmtInf>' . $CrLf;  | 
                                                        |
| 2244 | - $XML_DEBITOR .= ' </DrctDbtTxInf>' . $CrLf;  | 
                                                        |
| 2242 | +			$XML_DEBITOR .= '					<Ustrd>'.getDolGlobalString('PRELEVEMENT_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref.($row_comment ? ' - '.$row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))).'</Ustrd>'.$CrLf; // Free unstuctured data - 140 max | 
                                                        |
| 2243 | + $XML_DEBITOR .= ' </RmtInf>'.$CrLf;  | 
                                                        |
| 2244 | + $XML_DEBITOR .= ' </DrctDbtTxInf>'.$CrLf;  | 
                                                        |
| 2245 | 2245 | return $XML_DEBITOR;  | 
                                                        
| 2246 | 2246 |  		} else { | 
                                                        
| 2247 | 2247 | // SEPA Payment Information of seller for Credit Transfer  | 
                                                        
| 2248 | 2248 | $XML_CREDITOR = '';  | 
                                                        
| 2249 | - $XML_CREDITOR .= ' <CdtTrfTxInf>' . $CrLf;  | 
                                                        |
| 2250 | - $XML_CREDITOR .= ' <PmtId>' . $CrLf;  | 
                                                        |
| 2249 | + $XML_CREDITOR .= ' <CdtTrfTxInf>'.$CrLf;  | 
                                                        |
| 2250 | + $XML_CREDITOR .= ' <PmtId>'.$CrLf;  | 
                                                        |
| 2251 | 2251 | // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)  | 
                                                        
| 2252 | -			$XML_CREDITOR .= '					<EndToEndId>' . ((getDolGlobalString('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 | 
                                                        |
| 2253 | - $XML_CREDITOR .= ' </PmtId>' . $CrLf;  | 
                                                        |
| 2252 | +			$XML_CREDITOR .= '					<EndToEndId>'.((getDolGlobalString('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 | 
                                                        |
| 2253 | + $XML_CREDITOR .= ' </PmtId>'.$CrLf;  | 
                                                        |
| 2254 | 2254 |  			if (!empty($this->sepa_xml_pti_in_ctti)) { | 
                                                        
| 2255 | - $XML_CREDITOR .= ' <PmtTpInf>' . $CrLf;  | 
                                                        |
| 2255 | + $XML_CREDITOR .= ' <PmtTpInf>'.$CrLf;  | 
                                                        |
| 2256 | 2256 | |
| 2257 | 2257 | // Can be 'NORM' for normal or 'HIGH' for high priority level  | 
                                                        
| 2258 | 2258 |  				if (getDolGlobalString('PAYMENTBYBANKTRANSFER_FORCE_HIGH_PRIORITY')) { | 
                                                        
@@ -2260,18 +2260,18 @@ discard block  | 
                                                    ||
| 2260 | 2260 |  				} else { | 
                                                        
| 2261 | 2261 | $instrprty = 'NORM';  | 
                                                        
| 2262 | 2262 | }  | 
                                                        
| 2263 | - $XML_CREDITOR .= ' <InstrPrty>' . $instrprty . '</InstrPrty>' . $CrLf;  | 
                                                        |
| 2264 | - $XML_CREDITOR .= ' <SvcLvl>' . $CrLf;  | 
                                                        |
| 2265 | - $XML_CREDITOR .= ' <Cd>SEPA</Cd>' . $CrLf;  | 
                                                        |
| 2266 | - $XML_CREDITOR .= ' </SvcLvl>' . $CrLf;  | 
                                                        |
| 2267 | - $XML_CREDITOR .= ' <CtgyPurp>' . $CrLf;  | 
                                                        |
| 2268 | - $XML_CREDITOR .= ' <Cd>CORE</Cd>' . $CrLf;  | 
                                                        |
| 2269 | - $XML_CREDITOR .= ' </CtgyPurp>' . $CrLf;  | 
                                                        |
| 2270 | - $XML_CREDITOR .= ' </PmtTpInf>' . $CrLf;  | 
                                                        |
| 2263 | + $XML_CREDITOR .= ' <InstrPrty>'.$instrprty.'</InstrPrty>'.$CrLf;  | 
                                                        |
| 2264 | + $XML_CREDITOR .= ' <SvcLvl>'.$CrLf;  | 
                                                        |
| 2265 | + $XML_CREDITOR .= ' <Cd>SEPA</Cd>'.$CrLf;  | 
                                                        |
| 2266 | + $XML_CREDITOR .= ' </SvcLvl>'.$CrLf;  | 
                                                        |
| 2267 | + $XML_CREDITOR .= ' <CtgyPurp>'.$CrLf;  | 
                                                        |
| 2268 | + $XML_CREDITOR .= ' <Cd>CORE</Cd>'.$CrLf;  | 
                                                        |
| 2269 | + $XML_CREDITOR .= ' </CtgyPurp>'.$CrLf;  | 
                                                        |
| 2270 | + $XML_CREDITOR .= ' </PmtTpInf>'.$CrLf;  | 
                                                        |
| 2271 | 2271 | }  | 
                                                        
| 2272 | - $XML_CREDITOR .= ' <Amt>' . $CrLf;  | 
                                                        |
| 2272 | + $XML_CREDITOR .= ' <Amt>'.$CrLf;  | 
                                                        |
| 2273 | 2273 | $XML_CREDITOR .= ' <InstdAmt Ccy="EUR">'.round((float) $row_somme, 2).'</InstdAmt>'.$CrLf;  | 
                                                        
| 2274 | - $XML_CREDITOR .= ' </Amt>' . $CrLf;  | 
                                                        |
| 2274 | + $XML_CREDITOR .= ' </Amt>'.$CrLf;  | 
                                                        |
| 2275 | 2275 | /*  | 
                                                        
| 2276 | 2276 | $XML_CREDITOR .= ' <DrctDbtTx>'.$CrLf;  | 
                                                        
| 2277 | 2277 | $XML_CREDITOR .= ' <MndtRltdInf>'.$CrLf;  | 
                                                        
@@ -2282,35 +2282,35 @@ discard block  | 
                                                    ||
| 2282 | 2282 | $XML_CREDITOR .= ' </DrctDbtTx>'.$CrLf;  | 
                                                        
| 2283 | 2283 | */  | 
                                                        
| 2284 | 2284 | //$XML_CREDITOR .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf;  | 
                                                        
| 2285 | - $XML_CREDITOR .= ' <CdtrAgt>' . $CrLf;  | 
                                                        |
| 2286 | - $XML_CREDITOR .= ' <FinInstnId>' . $CrLf;  | 
                                                        |
| 2287 | - $XML_CREDITOR .= ' <BIC>' . $row_bic . '</BIC>' . $CrLf;  | 
                                                        |
| 2288 | - $XML_CREDITOR .= ' </FinInstnId>' . $CrLf;  | 
                                                        |
| 2289 | - $XML_CREDITOR .= ' </CdtrAgt>' . $CrLf;  | 
                                                        |
| 2290 | - $XML_CREDITOR .= ' <Cdtr>' . $CrLf;  | 
                                                        |
| 2291 | - $XML_CREDITOR .= ' <Nm>' . dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom), ' '))) . '</Nm>' . $CrLf;  | 
                                                        |
| 2292 | - $XML_CREDITOR .= ' <PstlAdr>' . $CrLf;  | 
                                                        |
| 2293 | - $XML_CREDITOR .= ' <Ctry>' . $row_country_code . '</Ctry>' . $CrLf;  | 
                                                        |
| 2285 | + $XML_CREDITOR .= ' <CdtrAgt>'.$CrLf;  | 
                                                        |
| 2286 | + $XML_CREDITOR .= ' <FinInstnId>'.$CrLf;  | 
                                                        |
| 2287 | + $XML_CREDITOR .= ' <BIC>'.$row_bic.'</BIC>'.$CrLf;  | 
                                                        |
| 2288 | + $XML_CREDITOR .= ' </FinInstnId>'.$CrLf;  | 
                                                        |
| 2289 | + $XML_CREDITOR .= ' </CdtrAgt>'.$CrLf;  | 
                                                        |
| 2290 | + $XML_CREDITOR .= ' <Cdtr>'.$CrLf;  | 
                                                        |
| 2291 | + $XML_CREDITOR .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom), ' '))).'</Nm>'.$CrLf;  | 
                                                        |
| 2292 | + $XML_CREDITOR .= ' <PstlAdr>'.$CrLf;  | 
                                                        |
| 2293 | + $XML_CREDITOR .= ' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;  | 
                                                        |
| 2294 | 2294 | $addressline1 = strtr($row_address, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        
| 2295 | - $addressline2 = strtr($row_zip . (($row_zip && $row_town) ? ' ' : (string) $row_town), array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2295 | + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2296 | 2296 |  			if (trim($addressline1)) { | 
                                                        
| 2297 | - $XML_CREDITOR .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2297 | + $XML_CREDITOR .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2298 | 2298 | }  | 
                                                        
| 2299 | 2299 |  			if (trim($addressline2)) { | 
                                                        
| 2300 | - $XML_CREDITOR .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2300 | + $XML_CREDITOR .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2301 | 2301 | }  | 
                                                        
| 2302 | - $XML_CREDITOR .= ' </PstlAdr>' . $CrLf;  | 
                                                        |
| 2303 | - $XML_CREDITOR .= ' </Cdtr>' . $CrLf;  | 
                                                        |
| 2304 | - $XML_CREDITOR .= ' <CdtrAcct>' . $CrLf;  | 
                                                        |
| 2305 | - $XML_CREDITOR .= ' <Id>' . $CrLf;  | 
                                                        |
| 2306 | -			$XML_CREDITOR .= '						<IBAN>' . preg_replace('/\s/', '', $row_iban) . '</IBAN>' . $CrLf; | 
                                                        |
| 2307 | - $XML_CREDITOR .= ' </Id>' . $CrLf;  | 
                                                        |
| 2308 | - $XML_CREDITOR .= ' </CdtrAcct>' . $CrLf;  | 
                                                        |
| 2309 | - $XML_CREDITOR .= ' <RmtInf>' . $CrLf;  | 
                                                        |
| 2302 | + $XML_CREDITOR .= ' </PstlAdr>'.$CrLf;  | 
                                                        |
| 2303 | + $XML_CREDITOR .= ' </Cdtr>'.$CrLf;  | 
                                                        |
| 2304 | + $XML_CREDITOR .= ' <CdtrAcct>'.$CrLf;  | 
                                                        |
| 2305 | + $XML_CREDITOR .= ' <Id>'.$CrLf;  | 
                                                        |
| 2306 | +			$XML_CREDITOR .= '						<IBAN>'.preg_replace('/\s/', '', $row_iban).'</IBAN>'.$CrLf; | 
                                                        |
| 2307 | + $XML_CREDITOR .= ' </Id>'.$CrLf;  | 
                                                        |
| 2308 | + $XML_CREDITOR .= ' </CdtrAcct>'.$CrLf;  | 
                                                        |
| 2309 | + $XML_CREDITOR .= ' <RmtInf>'.$CrLf;  | 
                                                        |
| 2310 | 2310 | // A string with some information on payment - 140 max  | 
                                                        
| 2311 | -			$XML_CREDITOR .= '					<Ustrd>' . getDolGlobalString('CREDITTRANSFER_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref . ($row_comment ? ' - ' . $row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))) . '</Ustrd>' . $CrLf; // Free unstructured data - 140 max | 
                                                        |
| 2312 | - $XML_CREDITOR .= ' </RmtInf>' . $CrLf;  | 
                                                        |
| 2313 | - $XML_CREDITOR .= ' </CdtTrfTxInf>' . $CrLf;  | 
                                                        |
| 2311 | +			$XML_CREDITOR .= '					<Ustrd>'.getDolGlobalString('CREDITTRANSFER_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref.($row_comment ? ' - '.$row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))).'</Ustrd>'.$CrLf; // Free unstructured data - 140 max | 
                                                        |
| 2312 | + $XML_CREDITOR .= ' </RmtInf>'.$CrLf;  | 
                                                        |
| 2313 | + $XML_CREDITOR .= ' </CdtTrfTxInf>'.$CrLf;  | 
                                                        |
| 2314 | 2314 | return $XML_CREDITOR;  | 
                                                        
| 2315 | 2315 | }  | 
                                                        
| 2316 | 2316 | }  | 
                                                        
@@ -2342,11 +2342,11 @@ discard block  | 
                                                    ||
| 2342 | 2342 | |
| 2343 | 2343 | // Raison Sociale C2  | 
                                                        
| 2344 | 2344 | |
| 2345 | - fwrite($this->file, substr($this->raison_sociale . " ", 0, 24));  | 
                                                        |
| 2345 | + fwrite($this->file, substr($this->raison_sociale." ", 0, 24));  | 
                                                        |
| 2346 | 2346 | |
| 2347 | 2347 | // Ref of thirdparty on 7 characters  | 
                                                        
| 2348 | 2348 | |
| 2349 | - fwrite($this->file, substr($this->reference_remise . " ", 0, 7));  | 
                                                        |
| 2349 | + fwrite($this->file, substr($this->reference_remise." ", 0, 7));  | 
                                                        |
| 2350 | 2350 | |
| 2351 | 2351 | // Zone Reservee D1-2  | 
                                                        
| 2352 | 2352 | |
@@ -2364,7 +2364,7 @@ discard block  | 
                                                    ||
| 2364 | 2364 | |
| 2365 | 2365 | // Numero de compte D4  | 
                                                        
| 2366 | 2366 | |
| 2367 | -		fwrite($this->file, substr("000000000000000" . $this->emetteur_numero_compte, -11)); | 
                                                        |
| 2367 | +		fwrite($this->file, substr("000000000000000".$this->emetteur_numero_compte, -11)); | 
                                                        |
| 2368 | 2368 | |
| 2369 | 2369 | // Zone Reservee E  | 
                                                        
| 2370 | 2370 | |
@@ -2427,15 +2427,15 @@ discard block  | 
                                                    ||
| 2427 | 2427 | $this->emetteur_iban = $account->iban;  | 
                                                        
| 2428 | 2428 | $this->emetteur_bic = $account->bic;  | 
                                                        
| 2429 | 2429 | |
| 2430 | -			$this->emetteur_ics = (($type == 'bank-transfer' && getDolGlobalString("SEPA_USE_IDS")) ? $account->ics_transfer : $account->ics);  // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; | 
                                                        |
| 2430 | +			$this->emetteur_ics = (($type == 'bank-transfer' && getDolGlobalString("SEPA_USE_IDS")) ? $account->ics_transfer : $account->ics); // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; | 
                                                        |
| 2431 | 2431 | |
| 2432 | 2432 | $this->raison_sociale = $account->proprio;  | 
                                                        
| 2433 | 2433 | }  | 
                                                        
| 2434 | 2434 | |
| 2435 | 2435 | // Get pending payments  | 
                                                        
| 2436 | 2436 | $sql = "SELECT rowid, ref";  | 
                                                        
| 2437 | - $sql .= " FROM " . MAIN_DB_PREFIX . "prelevement_bons as pb";  | 
                                                        |
| 2438 | - $sql .= " WHERE pb.rowid = " . ((int) $this->id);  | 
                                                        |
| 2437 | + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as pb";  | 
                                                        |
| 2438 | + $sql .= " WHERE pb.rowid = ".((int) $this->id);  | 
                                                        |
| 2439 | 2439 | |
| 2440 | 2440 | $resql = $this->db->query($sql);  | 
                                                        
| 2441 | 2441 |  		if ($resql) { | 
                                                        
@@ -2452,45 +2452,45 @@ discard block  | 
                                                    ||
| 2452 | 2452 |  			if ($type != 'bank-transfer') { | 
                                                        
| 2453 | 2453 | // SEPA Paiement Information of my company for Direct Debit  | 
                                                        
| 2454 | 2454 | $XML_SEPA_INFO = '';  | 
                                                        
| 2455 | - $XML_SEPA_INFO .= ' <PmtInf>' . $CrLf;  | 
                                                        |
| 2456 | -				$XML_SEPA_INFO .= '			<PmtInfId>' . ('DD/' . $dateTime_YMD . '/ID' . $IdBon . '-' . $RefBon) . '</PmtInfId>' . $CrLf; | 
                                                        |
| 2457 | - $XML_SEPA_INFO .= ' <PmtMtd>DD</PmtMtd>' . $CrLf;  | 
                                                        |
| 2458 | - $XML_SEPA_INFO .= ' <NbOfTxs>' . $nombre . '</NbOfTxs>' . $CrLf;  | 
                                                        |
| 2459 | - $XML_SEPA_INFO .= ' <CtrlSum>' . $total . '</CtrlSum>' . $CrLf;  | 
                                                        |
| 2460 | - $XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf;  | 
                                                        |
| 2461 | - $XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf;  | 
                                                        |
| 2462 | - $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;  | 
                                                        |
| 2463 | - $XML_SEPA_INFO .= ' </SvcLvl>' . $CrLf;  | 
                                                        |
| 2464 | - $XML_SEPA_INFO .= ' <LclInstrm>' . $CrLf;  | 
                                                        |
| 2465 | - $XML_SEPA_INFO .= ' <Cd>CORE</Cd>' . $CrLf;  | 
                                                        |
| 2466 | - $XML_SEPA_INFO .= ' </LclInstrm>' . $CrLf;  | 
                                                        |
| 2467 | - $XML_SEPA_INFO .= ' <SeqTp>' . $format . '</SeqTp>' . $CrLf;  | 
                                                        |
| 2468 | - $XML_SEPA_INFO .= ' </PmtTpInf>' . $CrLf;  | 
                                                        |
| 2469 | - $XML_SEPA_INFO .= ' <ReqdColltnDt>' . $dateTime_ETAD . '</ReqdColltnDt>' . $CrLf;  | 
                                                        |
| 2470 | - $XML_SEPA_INFO .= ' <Cdtr>' . $CrLf;  | 
                                                        |
| 2471 | - $XML_SEPA_INFO .= ' <Nm>' . dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))) . '</Nm>' . $CrLf;  | 
                                                        |
| 2472 | - $XML_SEPA_INFO .= ' <PstlAdr>' . $CrLf;  | 
                                                        |
| 2473 | - $XML_SEPA_INFO .= ' <Ctry>' . $country[1] . '</Ctry>' . $CrLf;  | 
                                                        |
| 2455 | + $XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;  | 
                                                        |
| 2456 | +				$XML_SEPA_INFO .= '			<PmtInfId>'.('DD/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).'</PmtInfId>'.$CrLf; | 
                                                        |
| 2457 | + $XML_SEPA_INFO .= ' <PmtMtd>DD</PmtMtd>'.$CrLf;  | 
                                                        |
| 2458 | + $XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf;  | 
                                                        |
| 2459 | + $XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf;  | 
                                                        |
| 2460 | + $XML_SEPA_INFO .= ' <PmtTpInf>'.$CrLf;  | 
                                                        |
| 2461 | + $XML_SEPA_INFO .= ' <SvcLvl>'.$CrLf;  | 
                                                        |
| 2462 | + $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>'.$CrLf;  | 
                                                        |
| 2463 | + $XML_SEPA_INFO .= ' </SvcLvl>'.$CrLf;  | 
                                                        |
| 2464 | + $XML_SEPA_INFO .= ' <LclInstrm>'.$CrLf;  | 
                                                        |
| 2465 | + $XML_SEPA_INFO .= ' <Cd>CORE</Cd>'.$CrLf;  | 
                                                        |
| 2466 | + $XML_SEPA_INFO .= ' </LclInstrm>'.$CrLf;  | 
                                                        |
| 2467 | + $XML_SEPA_INFO .= ' <SeqTp>'.$format.'</SeqTp>'.$CrLf;  | 
                                                        |
| 2468 | + $XML_SEPA_INFO .= ' </PmtTpInf>'.$CrLf;  | 
                                                        |
| 2469 | + $XML_SEPA_INFO .= ' <ReqdColltnDt>'.$dateTime_ETAD.'</ReqdColltnDt>'.$CrLf;  | 
                                                        |
| 2470 | + $XML_SEPA_INFO .= ' <Cdtr>'.$CrLf;  | 
                                                        |
| 2471 | + $XML_SEPA_INFO .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf;  | 
                                                        |
| 2472 | + $XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;  | 
                                                        |
| 2473 | + $XML_SEPA_INFO .= ' <Ctry>'.$country[1].'</Ctry>'.$CrLf;  | 
                                                        |
| 2474 | 2474 | $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        
| 2475 | - $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP . (($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' ' . $configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '') . $configuration->global->MAIN_INFO_SOCIETE_TOWN, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2475 | + $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2476 | 2476 |  				if ($addressline1) { | 
                                                        
| 2477 | - $XML_SEPA_INFO .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2477 | + $XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2478 | 2478 | }  | 
                                                        
| 2479 | 2479 |  				if ($addressline2) { | 
                                                        
| 2480 | - $XML_SEPA_INFO .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2480 | + $XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2481 | 2481 | }  | 
                                                        
| 2482 | - $XML_SEPA_INFO .= ' </PstlAdr>' . $CrLf;  | 
                                                        |
| 2483 | - $XML_SEPA_INFO .= ' </Cdtr>' . $CrLf;  | 
                                                        |
| 2484 | - $XML_SEPA_INFO .= ' <CdtrAcct>' . $CrLf;  | 
                                                        |
| 2485 | - $XML_SEPA_INFO .= ' <Id>' . $CrLf;  | 
                                                        |
| 2486 | -				$XML_SEPA_INFO .= '					<IBAN>' . preg_replace('/\s/', '', $this->emetteur_iban) . '</IBAN>' . $CrLf; | 
                                                        |
| 2487 | - $XML_SEPA_INFO .= ' </Id>' . $CrLf;  | 
                                                        |
| 2488 | - $XML_SEPA_INFO .= ' </CdtrAcct>' . $CrLf;  | 
                                                        |
| 2489 | - $XML_SEPA_INFO .= ' <CdtrAgt>' . $CrLf;  | 
                                                        |
| 2490 | - $XML_SEPA_INFO .= ' <FinInstnId>' . $CrLf;  | 
                                                        |
| 2491 | - $XML_SEPA_INFO .= ' <BIC>' . $this->emetteur_bic . '</BIC>' . $CrLf;  | 
                                                        |
| 2492 | - $XML_SEPA_INFO .= ' </FinInstnId>' . $CrLf;  | 
                                                        |
| 2493 | - $XML_SEPA_INFO .= ' </CdtrAgt>' . $CrLf;  | 
                                                        |
| 2482 | + $XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;  | 
                                                        |
| 2483 | + $XML_SEPA_INFO .= ' </Cdtr>'.$CrLf;  | 
                                                        |
| 2484 | + $XML_SEPA_INFO .= ' <CdtrAcct>'.$CrLf;  | 
                                                        |
| 2485 | + $XML_SEPA_INFO .= ' <Id>'.$CrLf;  | 
                                                        |
| 2486 | +				$XML_SEPA_INFO .= '					<IBAN>'.preg_replace('/\s/', '', $this->emetteur_iban).'</IBAN>'.$CrLf; | 
                                                        |
| 2487 | + $XML_SEPA_INFO .= ' </Id>'.$CrLf;  | 
                                                        |
| 2488 | + $XML_SEPA_INFO .= ' </CdtrAcct>'.$CrLf;  | 
                                                        |
| 2489 | + $XML_SEPA_INFO .= ' <CdtrAgt>'.$CrLf;  | 
                                                        |
| 2490 | + $XML_SEPA_INFO .= ' <FinInstnId>'.$CrLf;  | 
                                                        |
| 2491 | + $XML_SEPA_INFO .= ' <BIC>'.$this->emetteur_bic.'</BIC>'.$CrLf;  | 
                                                        |
| 2492 | + $XML_SEPA_INFO .= ' </FinInstnId>'.$CrLf;  | 
                                                        |
| 2493 | + $XML_SEPA_INFO .= ' </CdtrAgt>'.$CrLf;  | 
                                                        |
| 2494 | 2494 | /* $XML_SEPA_INFO .= ' <UltmtCdtr>'.$CrLf;  | 
                                                        
| 2495 | 2495 | $XML_SEPA_INFO .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf;  | 
                                                        
| 2496 | 2496 | $XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;  | 
                                                        
@@ -2499,64 +2499,64 @@ discard block  | 
                                                    ||
| 2499 | 2499 | $XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        
| 2500 | 2500 | $XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;  | 
                                                        
| 2501 | 2501 | $XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/  | 
                                                        
| 2502 | - $XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>' . $CrLf; // Field "Responsible of fees". Must be SLEV  | 
                                                        |
| 2503 | - $XML_SEPA_INFO .= ' <CdtrSchmeId>' . $CrLf;  | 
                                                        |
| 2504 | - $XML_SEPA_INFO .= ' <Id>' . $CrLf;  | 
                                                        |
| 2505 | - $XML_SEPA_INFO .= ' <PrvtId>' . $CrLf;  | 
                                                        |
| 2506 | - $XML_SEPA_INFO .= ' <Othr>' . $CrLf;  | 
                                                        |
| 2507 | - $XML_SEPA_INFO .= ' <Id>' . $this->emetteur_ics . '</Id>' . $CrLf;  | 
                                                        |
| 2508 | - $XML_SEPA_INFO .= ' <SchmeNm>' . $CrLf;  | 
                                                        |
| 2509 | - $XML_SEPA_INFO .= ' <Prtry>SEPA</Prtry>' . $CrLf;  | 
                                                        |
| 2510 | - $XML_SEPA_INFO .= ' </SchmeNm>' . $CrLf;  | 
                                                        |
| 2511 | - $XML_SEPA_INFO .= ' </Othr>' . $CrLf;  | 
                                                        |
| 2512 | - $XML_SEPA_INFO .= ' </PrvtId>' . $CrLf;  | 
                                                        |
| 2513 | - $XML_SEPA_INFO .= ' </Id>' . $CrLf;  | 
                                                        |
| 2514 | - $XML_SEPA_INFO .= ' </CdtrSchmeId>' . $CrLf;  | 
                                                        |
| 2502 | + $XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV  | 
                                                        |
| 2503 | + $XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf;  | 
                                                        |
| 2504 | + $XML_SEPA_INFO .= ' <Id>'.$CrLf;  | 
                                                        |
| 2505 | + $XML_SEPA_INFO .= ' <PrvtId>'.$CrLf;  | 
                                                        |
| 2506 | + $XML_SEPA_INFO .= ' <Othr>'.$CrLf;  | 
                                                        |
| 2507 | + $XML_SEPA_INFO .= ' <Id>'.$this->emetteur_ics.'</Id>'.$CrLf;  | 
                                                        |
| 2508 | + $XML_SEPA_INFO .= ' <SchmeNm>'.$CrLf;  | 
                                                        |
| 2509 | + $XML_SEPA_INFO .= ' <Prtry>SEPA</Prtry>'.$CrLf;  | 
                                                        |
| 2510 | + $XML_SEPA_INFO .= ' </SchmeNm>'.$CrLf;  | 
                                                        |
| 2511 | + $XML_SEPA_INFO .= ' </Othr>'.$CrLf;  | 
                                                        |
| 2512 | + $XML_SEPA_INFO .= ' </PrvtId>'.$CrLf;  | 
                                                        |
| 2513 | + $XML_SEPA_INFO .= ' </Id>'.$CrLf;  | 
                                                        |
| 2514 | + $XML_SEPA_INFO .= ' </CdtrSchmeId>'.$CrLf;  | 
                                                        |
| 2515 | 2515 |  			} else { | 
                                                        
| 2516 | 2516 | // SEPA Paiement Information of my company for Credit Transfer  | 
                                                        
| 2517 | 2517 | $XML_SEPA_INFO = '';  | 
                                                        
| 2518 | - $XML_SEPA_INFO .= ' <PmtInf>' . $CrLf;  | 
                                                        |
| 2519 | -				$XML_SEPA_INFO .= '			<PmtInfId>' . ('TRF/' . $dateTime_YMD . '/ID' . $IdBon . '-' . $RefBon) . '</PmtInfId>' . $CrLf; | 
                                                        |
| 2520 | - $XML_SEPA_INFO .= ' <PmtMtd>TRF</PmtMtd>' . $CrLf;  | 
                                                        |
| 2518 | + $XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;  | 
                                                        |
| 2519 | +				$XML_SEPA_INFO .= '			<PmtInfId>'.('TRF/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).'</PmtInfId>'.$CrLf; | 
                                                        |
| 2520 | + $XML_SEPA_INFO .= ' <PmtMtd>TRF</PmtMtd>'.$CrLf;  | 
                                                        |
| 2521 | 2521 | //$XML_SEPA_INFO .= ' <BtchBookg>False</BtchBookg>'.$CrLf;  | 
                                                        
| 2522 | - $XML_SEPA_INFO .= ' <NbOfTxs>' . $nombre . '</NbOfTxs>' . $CrLf;  | 
                                                        |
| 2523 | - $XML_SEPA_INFO .= ' <CtrlSum>' . $total . '</CtrlSum>' . $CrLf;  | 
                                                        |
| 2522 | + $XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf;  | 
                                                        |
| 2523 | + $XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf;  | 
                                                        |
| 2524 | 2524 |  				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. | 
                                                        
| 2525 | - $XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf;  | 
                                                        |
| 2526 | - $XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf;  | 
                                                        |
| 2527 | - $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;  | 
                                                        |
| 2528 | - $XML_SEPA_INFO .= ' </SvcLvl>' . $CrLf;  | 
                                                        |
| 2529 | - $XML_SEPA_INFO .= ' <LclInstrm>' . $CrLf;  | 
                                                        |
| 2530 | - $XML_SEPA_INFO .= ' <Cd>CORE</Cd>' . $CrLf;  | 
                                                        |
| 2531 | - $XML_SEPA_INFO .= ' </LclInstrm>' . $CrLf;  | 
                                                        |
| 2532 | - $XML_SEPA_INFO .= ' <SeqTp>' . $format . '</SeqTp>' . $CrLf;  | 
                                                        |
| 2533 | - $XML_SEPA_INFO .= ' </PmtTpInf>' . $CrLf;  | 
                                                        |
| 2525 | + $XML_SEPA_INFO .= ' <PmtTpInf>'.$CrLf;  | 
                                                        |
| 2526 | + $XML_SEPA_INFO .= ' <SvcLvl>'.$CrLf;  | 
                                                        |
| 2527 | + $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>'.$CrLf;  | 
                                                        |
| 2528 | + $XML_SEPA_INFO .= ' </SvcLvl>'.$CrLf;  | 
                                                        |
| 2529 | + $XML_SEPA_INFO .= ' <LclInstrm>'.$CrLf;  | 
                                                        |
| 2530 | + $XML_SEPA_INFO .= ' <Cd>CORE</Cd>'.$CrLf;  | 
                                                        |
| 2531 | + $XML_SEPA_INFO .= ' </LclInstrm>'.$CrLf;  | 
                                                        |
| 2532 | + $XML_SEPA_INFO .= ' <SeqTp>'.$format.'</SeqTp>'.$CrLf;  | 
                                                        |
| 2533 | + $XML_SEPA_INFO .= ' </PmtTpInf>'.$CrLf;  | 
                                                        |
| 2534 | 2534 | }  | 
                                                        
| 2535 | - $XML_SEPA_INFO .= ' <ReqdExctnDt>' . dol_print_date($dateTime_ETAD, 'dayrfc') . '</ReqdExctnDt>' . $CrLf;  | 
                                                        |
| 2536 | - $XML_SEPA_INFO .= ' <Dbtr>' . $CrLf;  | 
                                                        |
| 2537 | - $XML_SEPA_INFO .= ' <Nm>' . dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))) . '</Nm>' . $CrLf;  | 
                                                        |
| 2538 | - $XML_SEPA_INFO .= ' <PstlAdr>' . $CrLf;  | 
                                                        |
| 2539 | - $XML_SEPA_INFO .= ' <Ctry>' . $country[1] . '</Ctry>' . $CrLf;  | 
                                                        |
| 2535 | + $XML_SEPA_INFO .= ' <ReqdExctnDt>'.dol_print_date($dateTime_ETAD, 'dayrfc').'</ReqdExctnDt>'.$CrLf;  | 
                                                        |
| 2536 | + $XML_SEPA_INFO .= ' <Dbtr>'.$CrLf;  | 
                                                        |
| 2537 | + $XML_SEPA_INFO .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf;  | 
                                                        |
| 2538 | + $XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;  | 
                                                        |
| 2539 | + $XML_SEPA_INFO .= ' <Ctry>'.$country[1].'</Ctry>'.$CrLf;  | 
                                                        |
| 2540 | 2540 | $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        
| 2541 | - $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP . (($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' ' . $configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '') . $configuration->global->MAIN_INFO_SOCIETE_TOWN, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2541 | + $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(chr(13) => ", ", chr(10) => ""));  | 
                                                        |
| 2542 | 2542 |  				if ($addressline1) { | 
                                                        
| 2543 | - $XML_SEPA_INFO .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2543 | + $XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2544 | 2544 | }  | 
                                                        
| 2545 | 2545 |  				if ($addressline2) { | 
                                                        
| 2546 | - $XML_SEPA_INFO .= ' <AdrLine>' . dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)) . '</AdrLine>' . $CrLf;  | 
                                                        |
| 2546 | + $XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        |
| 2547 | 2547 | }  | 
                                                        
| 2548 | - $XML_SEPA_INFO .= ' </PstlAdr>' . $CrLf;  | 
                                                        |
| 2549 | - $XML_SEPA_INFO .= ' </Dbtr>' . $CrLf;  | 
                                                        |
| 2550 | - $XML_SEPA_INFO .= ' <DbtrAcct>' . $CrLf;  | 
                                                        |
| 2551 | - $XML_SEPA_INFO .= ' <Id>' . $CrLf;  | 
                                                        |
| 2552 | -				$XML_SEPA_INFO .= '					<IBAN>' . preg_replace('/\s/', '', $this->emetteur_iban) . '</IBAN>' . $CrLf; | 
                                                        |
| 2553 | - $XML_SEPA_INFO .= ' </Id>' . $CrLf;  | 
                                                        |
| 2554 | - $XML_SEPA_INFO .= ' </DbtrAcct>' . $CrLf;  | 
                                                        |
| 2555 | - $XML_SEPA_INFO .= ' <DbtrAgt>' . $CrLf;  | 
                                                        |
| 2556 | - $XML_SEPA_INFO .= ' <FinInstnId>' . $CrLf;  | 
                                                        |
| 2557 | - $XML_SEPA_INFO .= ' <BIC>' . $this->emetteur_bic . '</BIC>' . $CrLf;  | 
                                                        |
| 2558 | - $XML_SEPA_INFO .= ' </FinInstnId>' . $CrLf;  | 
                                                        |
| 2559 | - $XML_SEPA_INFO .= ' </DbtrAgt>' . $CrLf;  | 
                                                        |
| 2548 | + $XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;  | 
                                                        |
| 2549 | + $XML_SEPA_INFO .= ' </Dbtr>'.$CrLf;  | 
                                                        |
| 2550 | + $XML_SEPA_INFO .= ' <DbtrAcct>'.$CrLf;  | 
                                                        |
| 2551 | + $XML_SEPA_INFO .= ' <Id>'.$CrLf;  | 
                                                        |
| 2552 | +				$XML_SEPA_INFO .= '					<IBAN>'.preg_replace('/\s/', '', $this->emetteur_iban).'</IBAN>'.$CrLf; | 
                                                        |
| 2553 | + $XML_SEPA_INFO .= ' </Id>'.$CrLf;  | 
                                                        |
| 2554 | + $XML_SEPA_INFO .= ' </DbtrAcct>'.$CrLf;  | 
                                                        |
| 2555 | + $XML_SEPA_INFO .= ' <DbtrAgt>'.$CrLf;  | 
                                                        |
| 2556 | + $XML_SEPA_INFO .= ' <FinInstnId>'.$CrLf;  | 
                                                        |
| 2557 | + $XML_SEPA_INFO .= ' <BIC>'.$this->emetteur_bic.'</BIC>'.$CrLf;  | 
                                                        |
| 2558 | + $XML_SEPA_INFO .= ' </FinInstnId>'.$CrLf;  | 
                                                        |
| 2559 | + $XML_SEPA_INFO .= ' </DbtrAgt>'.$CrLf;  | 
                                                        |
| 2560 | 2560 | /* $XML_SEPA_INFO .= ' <UltmtCdtr>'.$CrLf;  | 
                                                        
| 2561 | 2561 | $XML_SEPA_INFO .= ' <Nm>'.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale), ' '))).'</Nm>'.$CrLf;  | 
                                                        
| 2562 | 2562 | $XML_SEPA_INFO .= ' <PstlAdr>'.$CrLf;  | 
                                                        
@@ -2565,7 +2565,7 @@ discard block  | 
                                                    ||
| 2565 | 2565 | $XML_SEPA_INFO .= ' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN), ' '), 70, 'right', 'UTF-8', 1)).'</AdrLine>'.$CrLf;  | 
                                                        
| 2566 | 2566 | $XML_SEPA_INFO .= ' </PstlAdr>'.$CrLf;  | 
                                                        
| 2567 | 2567 | $XML_SEPA_INFO .= ' </UltmtCdtr>'.$CrLf;*/  | 
                                                        
| 2568 | - $XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>' . $CrLf; // Field "Responsible of fees". Must be SLEV  | 
                                                        |
| 2568 | + $XML_SEPA_INFO .= ' <ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV  | 
                                                        |
| 2569 | 2569 | /*$XML_SEPA_INFO .= ' <CdtrSchmeId>'.$CrLf;  | 
                                                        
| 2570 | 2570 | $XML_SEPA_INFO .= ' <Id>'.$CrLf;  | 
                                                        
| 2571 | 2571 | $XML_SEPA_INFO .= ' <PrvtId>'.$CrLf;  | 
                                                        
@@ -2580,7 +2580,7 @@ discard block  | 
                                                    ||
| 2580 | 2580 | $XML_SEPA_INFO .= ' </CdtrSchmeId>'.$CrLf;*/  | 
                                                        
| 2581 | 2581 | }  | 
                                                        
| 2582 | 2582 |  		} else { | 
                                                        
| 2583 | - fwrite($this->file, 'INCORRECT EMETTEUR ' . $this->raison_sociale . $CrLf);  | 
                                                        |
| 2583 | + fwrite($this->file, 'INCORRECT EMETTEUR '.$this->raison_sociale.$CrLf);  | 
                                                        |
| 2584 | 2584 | $XML_SEPA_INFO = '';  | 
                                                        
| 2585 | 2585 | }  | 
                                                        
| 2586 | 2586 | return $XML_SEPA_INFO;  | 
                                                        
@@ -2632,7 +2632,7 @@ discard block  | 
                                                    ||
| 2632 | 2632 | |
| 2633 | 2633 | $montant = ($total * 100);  | 
                                                        
| 2634 | 2634 | |
| 2635 | -		fwrite($this->file, substr("000000000000000" . $montant, -16)); | 
                                                        |
| 2635 | +		fwrite($this->file, substr("000000000000000".$montant, -16)); | 
                                                        |
| 2636 | 2636 | |
| 2637 | 2637 | // Zone Reservee F  | 
                                                        
| 2638 | 2638 | |
@@ -2789,18 +2789,18 @@ discard block  | 
                                                    ||
| 2789 | 2789 |  		$return .= img_picto('', $this->picto); | 
                                                        
| 2790 | 2790 | $return .= '</span>';  | 
                                                        
| 2791 | 2791 | $return .= '<div class="info-box-content">';  | 
                                                        
| 2792 | - $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . (method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref) . '</span>';  | 
                                                        |
| 2792 | + $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';  | 
                                                        |
| 2793 | 2793 |  		if ($selected >= 0) { | 
                                                        
| 2794 | - $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';  | 
                                                        |
| 2794 | + $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';  | 
                                                        |
| 2795 | 2795 | }  | 
                                                        
| 2796 | 2796 |  		if (property_exists($this, 'date_echeance')) { | 
                                                        
| 2797 | -			$return .= '<br><span class="opacitymedium">' . $langs->trans("Date") . '</span> : <span class="info-box-label">' . dol_print_date($this->db->jdate($this->date_echeance), 'day') . '</span>'; | 
                                                        |
| 2797 | +			$return .= '<br><span class="opacitymedium">'.$langs->trans("Date").'</span> : <span class="info-box-label">'.dol_print_date($this->db->jdate($this->date_echeance), 'day').'</span>'; | 
                                                        |
| 2798 | 2798 | }  | 
                                                        
| 2799 | 2799 |  		if (property_exists($this, 'total')) { | 
                                                        
| 2800 | -			$return .= '<br><span class="opacitymedium">' . $langs->trans("Amount") . '</span> : <span class="amount">' . price($this->total) . '</span>'; | 
                                                        |
| 2800 | +			$return .= '<br><span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="amount">'.price($this->total).'</span>'; | 
                                                        |
| 2801 | 2801 | }  | 
                                                        
| 2802 | 2802 |  		if (method_exists($this, 'LibStatut')) { | 
                                                        
| 2803 | - $return .= '<br><div class="info-box-status">' . $this->getLibStatut(3) . '</div>';  | 
                                                        |
| 2803 | + $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';  | 
                                                        |
| 2804 | 2804 | }  | 
                                                        
| 2805 | 2805 | $return .= '</div>';  | 
                                                        
| 2806 | 2806 | $return .= '</div>';  | 
                                                        
@@ -2821,9 +2821,9 @@ discard block  | 
                                                    ||
| 2821 | 2821 | return 0;  | 
                                                        
| 2822 | 2822 | }  | 
                                                        
| 2823 | 2823 |  		if ($id) { | 
                                                        
| 2824 | - $sql = "SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX . "prelevement_lignes";  | 
                                                        |
| 2825 | - $sql .= " WHERE fk_prelevement_bons = " . ((int) $id);  | 
                                                        |
| 2826 | - $sql .= " AND fk_soc = 0"; // fk_soc can't be NULL  | 
                                                        |
| 2824 | + $sql = "SELECT COUNT(*) AS nb FROM ".MAIN_DB_PREFIX."prelevement_lignes";  | 
                                                        |
| 2825 | + $sql .= " WHERE fk_prelevement_bons = ".((int) $id);  | 
                                                        |
| 2826 | + $sql .= " AND fk_soc = 0"; // fk_soc can't be NULL  | 
                                                        |
| 2827 | 2827 | $sql .= " AND fk_user IS NOT NULL";  | 
                                                        
| 2828 | 2828 | |
| 2829 | 2829 | $num = 0;  | 
                                                        
@@ -26,8 +26,8 @@ discard block  | 
                                                    ||
| 26 | 26 | require '../../main.inc.php';  | 
                                                        
| 27 | 27 | |
| 28 | 28 | // Libraries  | 
                                                        
| 29 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';  | 
                                                        |
| 30 | -require_once DOL_DOCUMENT_ROOT . '/zapier/lib/zapier.lib.php';  | 
                                                        |
| 29 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';  | 
                                                        |
| 30 | +require_once DOL_DOCUMENT_ROOT.'/zapier/lib/zapier.lib.php';  | 
                                                        |
| 31 | 31 | |
| 32 | 32 | // Translations  | 
                                                        
| 33 | 33 |  $langs->loadLangs(array('admin', 'zapier')); | 
                                                        
@@ -58,7 +58,7 @@ discard block  | 
                                                    ||
| 58 | 58 | * Actions  | 
                                                        
| 59 | 59 | */  | 
                                                        
| 60 | 60 | |
| 61 | -include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';  | 
                                                        |
| 61 | +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';  | 
                                                        |
| 62 | 62 | |
| 63 | 63 | /*  | 
                                                        
| 64 | 64 | * View  | 
                                                        
@@ -69,7 +69,7 @@ discard block  | 
                                                    ||
| 69 | 69 |  llxHeader('', $langs->trans($page_name), $help_url, '', 0, 0, '', '', '', 'mod-zapier page-admin_setup'); | 
                                                        
| 70 | 70 | |
| 71 | 71 | // Subheader  | 
                                                        
| 72 | -$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>'; | 
                                                        |
| 72 | +$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>'; | 
                                                        |
| 73 | 73 | |
| 74 | 74 | print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier');  | 
                                                        
| 75 | 75 | |
@@ -79,45 +79,45 @@ discard block  | 
                                                    ||
| 79 | 79 | |
| 80 | 80 |  if (!empty($arrayofparameters)) { | 
                                                        
| 81 | 81 |  	if ($action == 'edit') { | 
                                                        
| 82 | - print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';  | 
                                                        |
| 83 | - print '<input type="hidden" name="token" value="' . newToken() . '">';  | 
                                                        |
| 82 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';  | 
                                                        |
| 83 | + print '<input type="hidden" name="token" value="'.newToken().'">';  | 
                                                        |
| 84 | 84 | print '<input type="hidden" name="action" value="update">';  | 
                                                        
| 85 | 85 | |
| 86 | 86 | print '<table class="noborder centpercent">';  | 
                                                        
| 87 | -		print '<tr class="liste_titre"><td class="titlefield">' . $langs->trans("Parameter") . '</td><td>' . $langs->trans("Value") . '</td></tr>'; | 
                                                        |
| 87 | +		print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; | 
                                                        |
| 88 | 88 | |
| 89 | 89 |  		foreach ($arrayofparameters as $key => $val) { | 
                                                        
| 90 | 90 | print '<tr class="oddeven"><td>';  | 
                                                        
| 91 | - print $form->textwithpicto($langs->trans($key), $langs->trans($key . 'Tooltip'));  | 
                                                        |
| 92 | - print '</td><td><input name="' . $key . '" class="flat ' . (empty($val['css']) ? 'minwidth200' : $val['css']) . '" value="' . getDolGlobalString($key) . '"></td></tr>';  | 
                                                        |
| 91 | + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));  | 
                                                        |
| 92 | + print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'"></td></tr>';  | 
                                                        |
| 93 | 93 | }  | 
                                                        
| 94 | 94 | print '</table>';  | 
                                                        
| 95 | 95 | |
| 96 | 96 | print '<br><div class="center">';  | 
                                                        
| 97 | -		print '<input class="button button-save" type="submit" value="' . $langs->trans("Save") . '">'; | 
                                                        |
| 97 | +		print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">'; | 
                                                        |
| 98 | 98 | print '</div>';  | 
                                                        
| 99 | 99 | |
| 100 | 100 | print '</form>';  | 
                                                        
| 101 | 101 | print '<br>';  | 
                                                        
| 102 | 102 |  	} else { | 
                                                        
| 103 | 103 | print '<table class="noborder centpercent">';  | 
                                                        
| 104 | -		print '<tr class="liste_titre"><td class="titlefield">' . $langs->trans("Parameter") . '</td><td>' . $langs->trans("Value") . '</td></tr>'; | 
                                                        |
| 104 | +		print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; | 
                                                        |
| 105 | 105 | |
| 106 | 106 |  		foreach ($arrayofparameters as $key => $val) { | 
                                                        
| 107 | 107 | print '<tr class="oddeven"><td>';  | 
                                                        
| 108 | - print $form->textwithpicto($langs->trans($key), $langs->trans($key . 'Tooltip'));  | 
                                                        |
| 109 | - print '</td><td>' . getDolGlobalString($key) . '</td></tr>';  | 
                                                        |
| 108 | + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));  | 
                                                        |
| 109 | + print '</td><td>'.getDolGlobalString($key).'</td></tr>';  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | print '</table>';  | 
                                                        
| 113 | 113 | |
| 114 | 114 | print '<div class="tabsAction">';  | 
                                                        
| 115 | -		print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>'; | 
                                                        |
| 115 | +		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>'; | 
                                                        |
| 116 | 116 | print '</div>';  | 
                                                        
| 117 | 117 | }  | 
                                                        
| 118 | 118 |  } else { | 
                                                        
| 119 | 119 | // Setup page goes here  | 
                                                        
| 120 | -	echo '<br><br><span class="opacitymediumdisabled">' . $langs->trans("ZapierSetupPage") . '</span><br><br>'; | 
                                                        |
| 120 | +	echo '<br><br><span class="opacitymediumdisabled">'.$langs->trans("ZapierSetupPage").'</span><br><br>'; | 
                                                        |
| 121 | 121 |  	//print '<br>'.$langs->trans("NothingToSetup"); | 
                                                        
| 122 | 122 | }  | 
                                                        
| 123 | 123 | |
@@ -356,7 +356,7 @@ discard block  | 
                                                    ||
| 356 | 356 | }  | 
                                                        
| 357 | 357 | |
| 358 | 358 |  $usercanedit = $user->hasRight('website', 'write'); | 
                                                        
| 359 | -$permissiontoadd = $user->hasRight('website', 'write');	// Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles | 
                                                        |
| 359 | +$permissiontoadd = $user->hasRight('website', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles | 
                                                        |
| 360 | 360 |  $permissiontodelete = $user->hasRight('website', 'delete'); | 
                                                        
| 361 | 361 | |
| 362 | 362 | |
@@ -423,7 +423,7 @@ discard block  | 
                                                    ||
| 423 | 423 |  if ($sortorder) { | 
                                                        
| 424 | 424 | $backtopage .= '&sortorder='.urlencode($sortorder);  | 
                                                        
| 425 | 425 | }  | 
                                                        
| 426 | -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // This manage 'sendit', 'confirm_deletefile', 'renamefile' action when submitting new file.  | 
                                                        |
| 426 | +include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // This manage 'sendit', 'confirm_deletefile', 'renamefile' action when submitting new file.  | 
                                                        |
| 427 | 427 | |
| 428 | 428 | $backtopage = $savbacktopage;  | 
                                                        
| 429 | 429 | //var_dump($backtopage);  | 
                                                        
@@ -1152,7 +1152,7 @@ discard block  | 
                                                    ||
| 1152 | 1152 |  		$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); | 
                                                        
| 1153 | 1153 |  		$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); | 
                                                        
| 1154 | 1154 |  		$objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); | 
                                                        
| 1155 | -		$objectpage->htmlheader = GETPOST('htmlheader', 'none');	// Must accept tags like '<script>' and '<link>' | 
                                                        |
| 1155 | +		$objectpage->htmlheader = GETPOST('htmlheader', 'none'); // Must accept tags like '<script>' and '<link>' | 
                                                        |
| 1156 | 1156 |  		$objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml'); | 
                                                        
| 1157 | 1157 |  		$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS'); | 
                                                        
| 1158 | 1158 |  		$objectpage->fk_object = GETPOST('WEBSITE_OBJECTID'); | 
                                                        
@@ -1185,7 +1185,7 @@ discard block  | 
                                                    ||
| 1185 | 1185 | $content = '';  | 
                                                        
| 1186 | 1186 |  		if (GETPOSTISSET('content')) { | 
                                                        
| 1187 | 1187 |  			//$content = GETPOST('content', 'restricthtmlallowunvalid');	// @TODO Use a restricthtmlallowunvalidwithphp | 
                                                        
| 1188 | -			$content = GETPOST('content', 'none');	// @TODO Use a restricthtmlallowunvalidwithphp | 
                                                        |
| 1188 | +			$content = GETPOST('content', 'none'); // @TODO Use a restricthtmlallowunvalidwithphp | 
                                                        |
| 1189 | 1189 | |
| 1190 | 1190 | $objectpage->content = make_substitutions($content, $substitutionarray);  | 
                                                        
| 1191 | 1191 |  		} else { | 
                                                        
@@ -1558,7 +1558,7 @@ discard block  | 
                                                    ||
| 1558 | 1558 | $error++;  | 
                                                        
| 1559 | 1559 |  					setEventMessages($langs->trans('ErrorFaviconMustBeASquaredImage'), array(), 'errors'); | 
                                                        
| 1560 | 1560 | }  | 
                                                        
| 1561 | -				if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) { | 
                                                        |
| 1561 | +				if (!$error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) { | 
                                                        |
| 1562 | 1562 | $error++;  | 
                                                        
| 1563 | 1563 |  					setEventMessages($langs->trans('ErrorFaviconSize'), array(), 'errors'); | 
                                                        
| 1564 | 1564 | }  | 
                                                        
@@ -1570,7 +1570,7 @@ discard block  | 
                                                    ||
| 1570 | 1570 |  				if (!GETPOSTISSET('updateandstay')) {	// If we click on "Save And Stay", we don not make the redirect | 
                                                        
| 1571 | 1571 | $action = 'preview';  | 
                                                        
| 1572 | 1572 |  					if ($backtopage) { | 
                                                        
| 1573 | -						$backtopage = preg_replace('/searchstring=[^&]*/', '', $backtopage);	// Clean backtopage url | 
                                                        |
| 1573 | +						$backtopage = preg_replace('/searchstring=[^&]*/', '', $backtopage); // Clean backtopage url | 
                                                        |
| 1574 | 1574 |  						header("Location: ".$backtopage); | 
                                                        
| 1575 | 1575 | exit;  | 
                                                        
| 1576 | 1576 | }  | 
                                                        
@@ -1603,7 +1603,7 @@ discard block  | 
                                                    ||
| 1603 | 1603 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1604 | 1604 | |
| 1605 | 1605 | // Security analysis  | 
                                                        
| 1606 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1606 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1607 | 1607 | |
| 1608 | 1608 |  			if (!$errorphpcheck) { | 
                                                        
| 1609 | 1609 | $htmlheadercontent = '';  | 
                                                        
@@ -1641,7 +1641,7 @@ discard block  | 
                                                    ||
| 1641 | 1641 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1642 | 1642 | |
| 1643 | 1643 | // Security analysis  | 
                                                        
| 1644 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1644 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1645 | 1645 | |
| 1646 | 1646 |  			if (!$errorphpcheck) { | 
                                                        
| 1647 | 1647 | $csscontent = '';  | 
                                                        
@@ -1684,7 +1684,7 @@ discard block  | 
                                                    ||
| 1684 | 1684 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1685 | 1685 | |
| 1686 | 1686 | // Security analysis  | 
                                                        
| 1687 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1687 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1688 | 1688 | |
| 1689 | 1689 |  			if (!$errorphpcheck) { | 
                                                        
| 1690 | 1690 | $jscontent = '';  | 
                                                        
@@ -1722,7 +1722,7 @@ discard block  | 
                                                    ||
| 1722 | 1722 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1723 | 1723 | |
| 1724 | 1724 | // Security analysis  | 
                                                        
| 1725 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1725 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1726 | 1726 | |
| 1727 | 1727 |  			if (!$errorphpcheck) { | 
                                                        
| 1728 | 1728 | $robotcontent = '';  | 
                                                        
@@ -1760,7 +1760,7 @@ discard block  | 
                                                    ||
| 1760 | 1760 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1761 | 1761 | |
| 1762 | 1762 | // Security analysis  | 
                                                        
| 1763 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1763 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1764 | 1764 | |
| 1765 | 1765 |  			if (!$errorphpcheck) { | 
                                                        
| 1766 | 1766 | $htaccesscontent = '';  | 
                                                        
@@ -1784,7 +1784,7 @@ discard block  | 
                                                    ||
| 1784 | 1784 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1785 | 1785 | |
| 1786 | 1786 | // Security analysis  | 
                                                        
| 1787 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1787 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1788 | 1788 | |
| 1789 | 1789 |  			if (!$errorphpcheck) { | 
                                                        
| 1790 | 1790 | $manifestjsoncontent = '';  | 
                                                        
@@ -1823,7 +1823,7 @@ discard block  | 
                                                    ||
| 1823 | 1823 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1824 | 1824 | |
| 1825 | 1825 | // Security analysis  | 
                                                        
| 1826 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1826 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1827 | 1827 | |
| 1828 | 1828 |  			if (!$errorphpcheck) { | 
                                                        
| 1829 | 1829 | $readmecontent = '';  | 
                                                        
@@ -1862,7 +1862,7 @@ discard block  | 
                                                    ||
| 1862 | 1862 | $phpfullcodestring = dolKeepOnlyPhpCode($dataposted);  | 
                                                        
| 1863 | 1863 | |
| 1864 | 1864 | // Security analysis  | 
                                                        
| 1865 | - $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1865 | + $errorphpcheck = checkPHPCode($phpfullcodestringold, $phpfullcodestring); // Contains the setEventMessages  | 
                                                        |
| 1866 | 1866 | |
| 1867 | 1867 |  			if (!$errorphpcheck) { | 
                                                        
| 1868 | 1868 | $licensecontent = '';  | 
                                                        
@@ -1904,7 +1904,7 @@ discard block  | 
                                                    ||
| 1904 | 1904 |  			if (!GETPOSTISSET('updateandstay')) {	// If we click on "Save And Stay", we don not make the redirect | 
                                                        
| 1905 | 1905 | $action = 'preview';  | 
                                                        
| 1906 | 1906 |  				if ($backtopage) { | 
                                                        
| 1907 | -					$backtopage = preg_replace('/searchstring=[^&]*/', '', $backtopage);	// Clean backtopage url | 
                                                        |
| 1907 | +					$backtopage = preg_replace('/searchstring=[^&]*/', '', $backtopage); // Clean backtopage url | 
                                                        |
| 1908 | 1908 |  					header("Location: ".$backtopage); | 
                                                        
| 1909 | 1909 | exit;  | 
                                                        
| 1910 | 1910 | }  | 
                                                        
@@ -1923,7 +1923,7 @@ discard block  | 
                                                    ||
| 1923 | 1923 | |
| 1924 | 1924 | $object->fk_default_home = $pageid;  | 
                                                        
| 1925 | 1925 | $res = $object->update($user);  | 
                                                        
| 1926 | -	if (! ($res > 0)) { | 
                                                        |
| 1926 | +	if (!($res > 0)) { | 
                                                        |
| 1927 | 1927 | $error++;  | 
                                                        
| 1928 | 1928 | setEventMessages($object->error, $object->errors, 'errors');  | 
                                                        
| 1929 | 1929 | }  | 
                                                        
@@ -2038,7 +2038,7 @@ discard block  | 
                                                    ||
| 2038 | 2038 |  		$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha'); | 
                                                        
| 2039 | 2039 |  		$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml')); | 
                                                        
| 2040 | 2040 |  		$objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09'); | 
                                                        
| 2041 | -		$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));		// Must accept tags like '<script>' and '<link>' | 
                                                        |
| 2041 | +		$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); // Must accept tags like '<script>' and '<link>' | 
                                                        |
| 2042 | 2042 |  		$objectpage->fk_page = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); | 
                                                        
| 2043 | 2043 |  		$objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml')); | 
                                                        
| 2044 | 2044 |  		$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS', 'alpha'); | 
                                                        
@@ -2314,7 +2314,7 @@ discard block  | 
                                                    ||
| 2314 | 2314 | |
| 2315 | 2315 | $phpfullcodestringold = dolKeepOnlyPhpCode($objectpage->content);  | 
                                                        
| 2316 | 2316 | |
| 2317 | -			$objectpage->content = GETPOST('PAGE_CONTENT', 'none');	// any HTML content allowed | 
                                                        |
| 2317 | +			$objectpage->content = GETPOST('PAGE_CONTENT', 'none'); // any HTML content allowed | 
                                                        |
| 2318 | 2318 | |
| 2319 | 2319 | $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content);  | 
                                                        
| 2320 | 2320 | |
@@ -2535,7 +2535,7 @@ discard block  | 
                                                    ||
| 2535 | 2535 | $fileofzip = '';  | 
                                                        
| 2536 | 2536 |  				if (GETPOSTISSET('templateuserfile')) { | 
                                                        
| 2537 | 2537 | // Case we selected one template  | 
                                                        
| 2538 | -					$fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha');	// $fileofzip will be sanitized later into the importWebSite() | 
                                                        |
| 2538 | +					$fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); // $fileofzip will be sanitized later into the importWebSite() | 
                                                        |
| 2539 | 2539 |  				} elseif (!empty($_FILES) && is_array($_FILES['userfile'])) { | 
                                                        
| 2540 | 2540 | // Case we upload a new template  | 
                                                        
| 2541 | 2541 |  					if (is_array($_FILES['userfile']['tmp_name'])) { | 
                                                        
@@ -2617,7 +2617,7 @@ discard block  | 
                                                    ||
| 2617 | 2617 |  	if ($website->virtualhost) { | 
                                                        
| 2618 | 2618 | $domainname = $website->virtualhost;  | 
                                                        
| 2619 | 2619 | }  | 
                                                        
| 2620 | -	if (! preg_match('/^http/i', $domainname)) { | 
                                                        |
| 2620 | +	if (!preg_match('/^http/i', $domainname)) { | 
                                                        |
| 2621 | 2621 | $domainname = 'https://'.$domainname;  | 
                                                        
| 2622 | 2622 | }  | 
                                                        
| 2623 | 2623 | |
@@ -2683,7 +2683,7 @@ discard block  | 
                                                    ||
| 2683 | 2683 | $url->appendChild($lastmod);  | 
                                                        
| 2684 | 2684 | // Add suggested frequency for refresh  | 
                                                        
| 2685 | 2685 |  				if (getDolGlobalString('WEBSITE_SITEMAPS_ADD_WEEKLY_FREQ')) { | 
                                                        
| 2686 | -					$changefreq = $domtree->createElement('changefreq', 'weekly');	// TODO Manage other values | 
                                                        |
| 2686 | +					$changefreq = $domtree->createElement('changefreq', 'weekly'); // TODO Manage other values | 
                                                        |
| 2687 | 2687 | $url->appendChild($changefreq);  | 
                                                        
| 2688 | 2688 | }  | 
                                                        
| 2689 | 2689 | // Add higher priority for home page  | 
                                                        
@@ -2788,7 +2788,7 @@ discard block  | 
                                                    ||
| 2788 | 2788 | $url->appendChild($lastmod);  | 
                                                        
| 2789 | 2789 | // Add suggested frequency for refresh  | 
                                                        
| 2790 | 2790 |  				if (getDolGlobalString('WEBSITE_SITEMAPS_ADD_WEEKLY_FREQ')) { | 
                                                        
| 2791 | -					$changefreq = $domtree->createElement('changefreq', 'weekly');	// TODO Manage other values | 
                                                        |
| 2791 | +					$changefreq = $domtree->createElement('changefreq', 'weekly'); // TODO Manage other values | 
                                                        |
| 2792 | 2792 | $url->appendChild($changefreq);  | 
                                                        
| 2793 | 2793 | }  | 
                                                        
| 2794 | 2794 | |
@@ -3076,11 +3076,11 @@ discard block  | 
                                                    ||
| 3076 | 3076 | |
| 3077 | 3077 | // // Export web site  | 
                                                        
| 3078 | 3078 |  			$extraCssClass = getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ? 'hideobject' : ''; | 
                                                        
| 3079 | - print '<input type="submit" class="button bordertransp ' . $extraCssClass . '" ' . $disabledexport . ' value="' . dol_escape_htmltag($exportlabel) . '" name="exportsite">';  | 
                                                        |
| 3079 | + print '<input type="submit" class="button bordertransp '.$extraCssClass.'" '.$disabledexport.' value="'.dol_escape_htmltag($exportlabel).'" name="exportsite">';  | 
                                                        |
| 3080 | 3080 | |
| 3081 | 3081 |  			if (getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE')) { | 
                                                        
| 3082 | 3082 | // Overwrite template in sources  | 
                                                        
| 3083 | - $overwriteGitUrl = $_SERVER["PHP_SELF"] . '?action=overwritesite&website=' . urlencode($website->ref);  | 
                                                        |
| 3083 | + $overwriteGitUrl = $_SERVER["PHP_SELF"].'?action=overwritesite&website='.urlencode($website->ref);  | 
                                                        |
| 3084 | 3084 |  				print dolButtonToOpenExportDialog('exportpopup', $langs->trans('ExportOptions'), $langs->trans('ExportSite'), 'exportsite', $overwriteGitUrl, $website); | 
                                                        
| 3085 | 3085 |  				//print '<a href="'.$_SERVER["PHP_SELF"].'?action=overwritesite&website='.urlencode($website->ref).'" class="button bordertransp hideobject" title="'.dol_escape_htmltag($langs->trans("ExportIntoGIT").". Directory ".getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE')).'">'.dol_escape_htmltag($langs->trans("ExportIntoGIT")).'</a>'; | 
                                                        
| 3086 | 3086 | }  | 
                                                        
@@ -3438,7 +3438,7 @@ discard block  | 
                                                    ||
| 3438 | 3438 | print '<!-- button EditInLine and ShowSubcontainers -->'."\n";  | 
                                                        
| 3439 | 3439 | print '<div class="websiteselectionsection inline-block">';  | 
                                                        
| 3440 | 3440 | |
| 3441 | - print '<div class="inline-block marginrightonly">'; // Button includes dynamic content  | 
                                                        |
| 3441 | + print '<div class="inline-block marginrightonly">'; // Button includes dynamic content  | 
                                                        |
| 3442 | 3442 |  				print $langs->trans("ShowSubcontainers"); | 
                                                        
| 3443 | 3443 |  				if (!getDolGlobalString('WEBSITE_SUBCONTAINERSINLINE')) { | 
                                                        
| 3444 | 3444 |  					print '<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$websitepage->id.'&action=setshowsubcontainers&token='.newToken().'">'.img_picto($langs->trans("ShowSubContainersOnOff", $langs->transnoentitiesnoconv("Off")), 'switch_off', '', false, 0, 0, '', 'nomarginleft').'</a>'; | 
                                                        
@@ -3447,7 +3447,7 @@ discard block  | 
                                                    ||
| 3447 | 3447 | }  | 
                                                        
| 3448 | 3448 | print '</div>';  | 
                                                        
| 3449 | 3449 | |
| 3450 | - print '<div class="inline-block marginrightonly">'; // Button edit inline  | 
                                                        |
| 3450 | + print '<div class="inline-block marginrightonly">'; // Button edit inline  | 
                                                        |
| 3451 | 3451 | |
| 3452 | 3452 | print '<span id="switchckeditorinline">'."\n";  | 
                                                        
| 3453 | 3453 | // Enable CKEditor inline with js on section and div with conteneditable=true  | 
                                                        
@@ -3539,15 +3539,15 @@ discard block  | 
                                                    ||
| 3539 | 3539 | // Sending data via AJAX  | 
                                                        
| 3540 | 3540 |  													$.ajax({ | 
                                                        
| 3541 | 3541 | type: \'POST\',  | 
                                                        
| 3542 | - url: \'' . DOL_URL_ROOT . '/core/ajax/editinline.php\',  | 
                                                        |
| 3542 | + url: \'' . DOL_URL_ROOT.'/core/ajax/editinline.php\',  | 
                                                        |
| 3543 | 3543 |  														data: { | 
                                                        
| 3544 | 3544 | website_ref: \''.$website->ref.'\',  | 
                                                        
| 3545 | - page_id: \'' . $websitepage->id . '\',  | 
                                                        |
| 3545 | + page_id: \'' . $websitepage->id.'\',  | 
                                                        |
| 3546 | 3546 | content: content,  | 
                                                        
| 3547 | 3547 | element_id: elementId,  | 
                                                        
| 3548 | 3548 | element_type: elementType,  | 
                                                        
| 3549 | 3549 | action: \'updatedElementContent\',  | 
                                                        
| 3550 | - token: \'' . newToken() . '\'  | 
                                                        |
| 3550 | + token: \'' . newToken().'\'  | 
                                                        |
| 3551 | 3551 | },  | 
                                                        
| 3552 | 3552 |  														success: function(response) { | 
                                                        
| 3553 | 3553 | console.log(response);  | 
                                                        
@@ -3633,7 +3633,7 @@ discard block  | 
                                                    ||
| 3633 | 3633 |  				} else { | 
                                                        
| 3634 | 3634 | $disabled = '';  | 
                                                        
| 3635 | 3635 | $title = '';  | 
                                                        
| 3636 | - $url = $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&pageid='.((int) $websitepage->id).'&website='.urlencode($website->ref); // action=delete for webpage, deletesite for website  | 
                                                        |
| 3636 | + $url = $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&pageid='.((int) $websitepage->id).'&website='.urlencode($website->ref); // action=delete for webpage, deletesite for website  | 
                                                        |
| 3637 | 3637 | }  | 
                                                        
| 3638 | 3638 |  				print '<a href="'.$url.'" class="button buttonDelete bordertransp'.($disabled ? ' disabled' : '').'"'.$disabled.' title="'.dol_escape_htmltag($title).'">'.img_picto('', 'delete', 'class=""').'<span class="hideonsmartphone paddingleft">'.$langs->trans("Delete").'</span></a>'; | 
                                                        
| 3639 | 3639 | print '</span>';  | 
                                                        
@@ -3822,7 +3822,7 @@ discard block  | 
                                                    ||
| 3822 | 3822 | // Clean the php htmlheader file to remove php code and get only html part  | 
                                                        
| 3823 | 3823 |  		$htmlheadercontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims', '', $htmlheadercontent); | 
                                                        
| 3824 | 3824 |  	} else { | 
                                                        
| 3825 | -		$htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none');		// Must accept tags like '<script>' and '<link>' | 
                                                        |
| 3825 | +		$htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none'); // Must accept tags like '<script>' and '<link>' | 
                                                        |
| 3826 | 3826 | }  | 
                                                        
| 3827 | 3827 |  	if (!trim($htmlheadercontent)) { | 
                                                        
| 3828 | 3828 | $htmlheadercontent = "<html>\n";  | 
                                                        
@@ -3853,7 +3853,7 @@ discard block  | 
                                                    ||
| 3853 | 3853 | // Clean the php htaccesscontent file to remove php code and get only html part  | 
                                                        
| 3854 | 3854 |  		$htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims', '', $htaccesscontent); | 
                                                        
| 3855 | 3855 |  	} else { | 
                                                        
| 3856 | -		$htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml');	// We must use 'nohtml' and not 'alphanohtml' because we must accept " | 
                                                        |
| 3856 | +		$htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml'); // We must use 'nohtml' and not 'alphanohtml' because we must accept " | 
                                                        |
| 3857 | 3857 | }  | 
                                                        
| 3858 | 3858 |  	if (!trim($htaccesscontent)) { | 
                                                        
| 3859 | 3859 | $htaccesscontent .= "# Order allow,deny\n";  | 
                                                        
@@ -3954,7 +3954,7 @@ discard block  | 
                                                    ||
| 3954 | 3954 | $maxfilesizearray = getMaxFileSizeArray();  | 
                                                        
| 3955 | 3955 | $maxmin = $maxfilesizearray['maxmin'];  | 
                                                        
| 3956 | 3956 |  	if ($maxmin > 0) { | 
                                                        
| 3957 | - print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file  | 
                                                        |
| 3957 | + print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file  | 
                                                        |
| 3958 | 3958 | }  | 
                                                        
| 3959 | 3959 | print '<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';  | 
                                                        
| 3960 | 3960 | |
@@ -4211,7 +4211,7 @@ discard block  | 
                                                    ||
| 4211 | 4211 | $maxfilesizearray = getMaxFileSizeArray();  | 
                                                        
| 4212 | 4212 | $maxmin = $maxfilesizearray['maxmin'];  | 
                                                        
| 4213 | 4213 |  		if ($maxmin > 0) { | 
                                                        
| 4214 | - print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file  | 
                                                        |
| 4214 | + print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file  | 
                                                        |
| 4215 | 4215 | }  | 
                                                        
| 4216 | 4216 | print '<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';  | 
                                                        
| 4217 | 4217 |  		print '<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans("Upload")).'">'; | 
                                                        
@@ -4867,7 +4867,7 @@ discard block  | 
                                                    ||
| 4867 | 4867 | |
| 4868 | 4868 | |
| 4869 | 4869 | $module = 'medias';  | 
                                                        
| 4870 | - $formalreadyopen = 2; // So the form to submit a new file will not be open another time inside the core/tpl/filemanager.tpl.php  | 
                                                        |
| 4870 | + $formalreadyopen = 2; // So the form to submit a new file will not be open another time inside the core/tpl/filemanager.tpl.php  | 
                                                        |
| 4871 | 4871 |  	if (empty($url)) { | 
                                                        
| 4872 | 4872 | $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param  | 
                                                        
| 4873 | 4873 | }  | 
                                                        
@@ -5102,8 +5102,8 @@ discard block  | 
                                                    ||
| 5102 | 5102 |  			print getTitleFieldOfList("Categories", 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; | 
                                                        
| 5103 | 5103 |  			print getTitleFieldOfList("", 0, $_SERVER['PHP_SELF']); | 
                                                        
| 5104 | 5104 |  			print getTitleFieldOfList("UserCreation", 0, $_SERVER['PHP_SELF'], 'fk_user_creat', '', $param, '', $sortfield, $sortorder, '')."\n"; | 
                                                        
| 5105 | -			print getTitleFieldOfList("DateCreation", 0, $_SERVER['PHP_SELF'], 'date_creation', '', $param, '', $sortfield, $sortorder, 'center ')."\n";		// Date creation | 
                                                        |
| 5106 | -			print getTitleFieldOfList("DateLastModification", 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";		// Date last modif | 
                                                        |
| 5105 | +			print getTitleFieldOfList("DateCreation", 0, $_SERVER['PHP_SELF'], 'date_creation', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; // Date creation | 
                                                        |
| 5106 | +			print getTitleFieldOfList("DateLastModification", 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; // Date last modif | 
                                                        |
| 5107 | 5107 |  			print getTitleFieldOfList("", 0, $_SERVER['PHP_SELF']); | 
                                                        
| 5108 | 5108 | // Action column  | 
                                                        
| 5109 | 5109 |  			if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { | 
                                                        
@@ -42,7 +42,7 @@ discard block  | 
                                                    ||
| 42 | 42 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';  | 
                                                        
| 43 | 43 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';  | 
                                                        
| 44 | 44 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';  | 
                                                        
| 45 | -require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';  | 
                                                        |
| 45 | +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';  | 
                                                        |
| 46 | 46 |  if (isModEnabled('invoice')) { | 
                                                        
| 47 | 47 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';  | 
                                                        
| 48 | 48 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';  | 
                                                        
@@ -861,7 +861,7 @@ discard block  | 
                                                    ||
| 861 | 861 | print '<td class="nowraponall">';  | 
                                                        
| 862 | 862 | $propal_static->id = $objp->propalid;  | 
                                                        
| 863 | 863 | $propal_static->ref = $objp->ref;  | 
                                                        
| 864 | - $propal_static->ref_client = $objp->ref_client; // deprecated  | 
                                                        |
| 864 | + $propal_static->ref_client = $objp->ref_client; // deprecated  | 
                                                        |
| 865 | 865 | $propal_static->ref_customer = $objp->ref_client;  | 
                                                        
| 866 | 866 | $propal_static->fk_project = $objp->fk_projet;  | 
                                                        
| 867 | 867 | $propal_static->total_ht = $objp->total_ht;  | 
                                                        
@@ -926,7 +926,7 @@ discard block  | 
                                                    ||
| 926 | 926 | * Latest orders  | 
                                                        
| 927 | 927 | */  | 
                                                        
| 928 | 928 |  	if (isModEnabled('order') && $user->hasRight('commande', 'lire')) { | 
                                                        
| 929 | - $param ="";  | 
                                                        |
| 929 | + $param = "";  | 
                                                        |
| 930 | 930 | |
| 931 | 931 | $sql = "SELECT s.nom, s.rowid";  | 
                                                        
| 932 | 932 | $sql .= ", c.rowid as cid, c.entity, c.fk_projet, c.total_ht";  | 
                                                        
@@ -1237,7 +1237,7 @@ discard block  | 
                                                    ||
| 1237 | 1237 | print $late;  | 
                                                        
| 1238 | 1238 | print "</td>\n";  | 
                                                        
| 1239 | 1239 | print '<td class="nowrap">';  | 
                                                        
| 1240 | - print dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);  | 
                                                        |
| 1240 | + print dol_trunc(strtolower(get_class($object)) == strtolower(Client::class) ? $objp->refcus : $objp->refsup, 12);  | 
                                                        |
| 1241 | 1241 | print "</td>\n";  | 
                                                        
| 1242 | 1242 |  				//print '<td class="right" width="80px"><span title="'.$langs->trans("DateCreation").'">'.dol_print_date($db->jdate($objp->dc), 'day')."</span></td>\n"; | 
                                                        
| 1243 | 1243 |  				print '<td class="right" width="80px"><span title="'.$langs->trans("DateContract").'">'.dol_print_date($db->jdate($objp->dcon), 'day')."</span></td>\n"; | 
                                                        
@@ -104,7 +104,7 @@ discard block  | 
                                                    ||
| 104 | 104 |  if ($action != '') { | 
                                                        
| 105 | 105 |  	if (!$error) { | 
                                                        
| 106 | 106 |  		setEventMessage($langs->trans("SetupSaved")); | 
                                                        
| 107 | -		header("Location: " . $_SERVER["PHP_SELF"]); | 
                                                        |
| 107 | +		header("Location: ".$_SERVER["PHP_SELF"]); | 
                                                        |
| 108 | 108 | exit;  | 
                                                        
| 109 | 109 |  	} else { | 
                                                        
| 110 | 110 |  		setEventMessages('', $errors, 'errors'); | 
                                                        
@@ -120,7 +120,7 @@ discard block  | 
                                                    ||
| 120 | 120 | |
| 121 | 121 | llxHeader();  | 
                                                        
| 122 | 122 | |
| 123 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; | 
                                                        |
| 123 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; | 
                                                        |
| 124 | 124 |  print load_fiche_titre($langs->trans("OpenIDconnectSetup"), $linkback, 'title_setup'); | 
                                                        
| 125 | 125 | print "<br>\n";  | 
                                                        
| 126 | 126 | |
@@ -134,7 +134,7 @@ discard block  | 
                                                    ||
| 134 | 134 | print '<input type="hidden" name="token" value="'.newToken().'">';  | 
                                                        
| 135 | 135 | print '<input type="hidden" name="action" value="set">';  | 
                                                        
| 136 | 136 | |
| 137 | -$var=true;  | 
                                                        |
| 137 | +$var = true;  | 
                                                        |
| 138 | 138 | |
| 139 | 139 | print '<table class="noborder" width="100%">';  | 
                                                        
| 140 | 140 | print '<tr class="liste_titre">';  | 
                                                        
@@ -145,93 +145,93 @@ discard block  | 
                                                    ||
| 145 | 145 | |
| 146 | 146 | // MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM  | 
                                                        
| 147 | 147 | $var = !$var;  | 
                                                        
| 148 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 148 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 149 | 149 |  print '<td>'.$langs->trans("MainAuthenticationOidcLoginClaimName").'</td>'."\n"; | 
                                                        
| 150 | 150 |  print '<td>'.$langs->trans("MainAuthenticationOidcLoginClaimDesc").'</td>'."\n"; | 
                                                        
| 151 | -print '<td align="right">' . "\n";  | 
                                                        |
| 151 | +print '<td align="right">'."\n";  | 
                                                        |
| 152 | 152 |  print '<input name="MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM" id="MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM') ? GETPOST('MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM") : ''))).'"></td></tr>'; | 
                                                        
| 153 | -print '</td></tr>' . "\n";  | 
                                                        |
| 153 | +print '</td></tr>'."\n";  | 
                                                        |
| 154 | 154 | |
| 155 | 155 | // MAIN_AUTHENTICATION_OIDC_CLIENT_ID  | 
                                                        
| 156 | 156 | $var = !$var;  | 
                                                        
| 157 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 157 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 158 | 158 |  print '<td>'.$langs->trans("MainAuthenticationOidcClientIdName").'</td>'."\n"; | 
                                                        
| 159 | 159 |  print '<td>'.$langs->trans("MainAuthenticationOidcClientIdDesc").'</td>'."\n"; | 
                                                        
| 160 | -print '<td align="right">' . "\n";  | 
                                                        |
| 160 | +print '<td align="right">'."\n";  | 
                                                        |
| 161 | 161 |  print '<input name="MAIN_AUTHENTICATION_OIDC_CLIENT_ID" id="MAIN_AUTHENTICATION_OIDC_CLIENT_ID" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_CLIENT_ID') ? GETPOST('MAIN_AUTHENTICATION_OIDC_CLIENT_ID', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_ID) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_CLIENT_ID") : ''))).'"></td></tr>'; | 
                                                        
| 162 | -print '</td></tr>' . "\n";  | 
                                                        |
| 162 | +print '</td></tr>'."\n";  | 
                                                        |
| 163 | 163 | |
| 164 | 164 | // MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET  | 
                                                        
| 165 | 165 | $var = !$var;  | 
                                                        
| 166 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 166 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 167 | 167 |  print '<td>'.$langs->trans("MainAuthenticationOidcClientSecretName").'</td>'."\n"; | 
                                                        
| 168 | 168 |  print '<td>'.$langs->trans("MainAuthenticationOidcClientSecretDesc").'</td>'."\n"; | 
                                                        
| 169 | -print '<td align="right">' . "\n";  | 
                                                        |
| 169 | +print '<td align="right">'."\n";  | 
                                                        |
| 170 | 170 |  print '<input type="password" name="MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET" id="MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET') ? GETPOST('MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET") : ''))).'"></td></tr>'; | 
                                                        
| 171 | -print '</td></tr>' . "\n";  | 
                                                        |
| 171 | +print '</td></tr>'."\n";  | 
                                                        |
| 172 | 172 | |
| 173 | 173 | // MAIN_AUTHENTICATION_OIDC_SCOPES  | 
                                                        
| 174 | 174 | $var = !$var;  | 
                                                        
| 175 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 175 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 176 | 176 |  print '<td>'.$langs->trans("MainAuthenticationOidcScopesName").'</td>'."\n"; | 
                                                        
| 177 | 177 |  print '<td>'.$langs->trans("MainAuthenticationOidcScopesDesc").'</td>'."\n"; | 
                                                        
| 178 | -print '<td align="right">' . "\n";  | 
                                                        |
| 178 | +print '<td align="right">'."\n";  | 
                                                        |
| 179 | 179 |  print '<input name="MAIN_AUTHENTICATION_OIDC_SCOPES" id="MAIN_AUTHENTICATION_OIDC_SCOPES" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_SCOPES') ? GETPOST('MAIN_AUTHENTICATION_OIDC_SCOPES', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_SCOPES) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_SCOPES") : ''))).'"></td></tr>'; | 
                                                        
| 180 | -print '</td></tr>' . "\n";  | 
                                                        |
| 180 | +print '</td></tr>'."\n";  | 
                                                        |
| 181 | 181 | |
| 182 | 182 | // MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL  | 
                                                        
| 183 | 183 | $var = !$var;  | 
                                                        
| 184 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 184 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 185 | 185 |  print '<td>'.$langs->trans("MainAuthenticationOidcAuthorizeUrlName").'</td>'."\n"; | 
                                                        
| 186 | 186 |  print '<td>'.$langs->trans("MainAuthenticationOidcAuthorizeUrlDesc").'</td>'."\n"; | 
                                                        
| 187 | -print '<td align="right">' . "\n";  | 
                                                        |
| 187 | +print '<td align="right">'."\n";  | 
                                                        |
| 188 | 188 |  print '<input name="MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL" id="MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL') ? GETPOST('MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL") : ''))).'"></td></tr>'; | 
                                                        
| 189 | -print '</td></tr>' . "\n";  | 
                                                        |
| 189 | +print '</td></tr>'."\n";  | 
                                                        |
| 190 | 190 | |
| 191 | 191 | // MAIN_AUTHENTICATION_OIDC_TOKEN_URL  | 
                                                        
| 192 | 192 | $var = !$var;  | 
                                                        
| 193 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 193 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 194 | 194 |  print '<td>'.$langs->trans("MainAuthenticationOidcTokenUrlName").'</td>'."\n"; | 
                                                        
| 195 | 195 |  print '<td>'.$langs->trans("MainAuthenticationOidcTokenUrlDesc").'</td>'."\n"; | 
                                                        
| 196 | -print '<td align="right">' . "\n";  | 
                                                        |
| 196 | +print '<td align="right">'."\n";  | 
                                                        |
| 197 | 197 |  print '<input name="MAIN_AUTHENTICATION_OIDC_TOKEN_URL" id="MAIN_AUTHENTICATION_OIDC_TOKEN_URL" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_TOKEN_URL') ? GETPOST('MAIN_AUTHENTICATION_OIDC_TOKEN_URL', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_TOKEN_URL) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_TOKEN_URL") : ''))).'"></td></tr>'; | 
                                                        
| 198 | -print '</td></tr>' . "\n";  | 
                                                        |
| 198 | +print '</td></tr>'."\n";  | 
                                                        |
| 199 | 199 | |
| 200 | 200 | // MAIN_AUTHENTICATION_OIDC_USERINFO_URL  | 
                                                        
| 201 | 201 | $var = !$var;  | 
                                                        
| 202 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 202 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 203 | 203 |  print '<td>'.$langs->trans("MainAuthenticationOidcUserinfoUrlName").'</td>'."\n"; | 
                                                        
| 204 | 204 |  print '<td>'.$langs->trans("MainAuthenticationOidcUserinfoUrlDesc").'</td>'."\n"; | 
                                                        
| 205 | -print '<td align="right">' . "\n";  | 
                                                        |
| 205 | +print '<td align="right">'."\n";  | 
                                                        |
| 206 | 206 |  print '<input name="MAIN_AUTHENTICATION_OIDC_USERINFO_URL" id="MAIN_AUTHENTICATION_OIDC_USERINFO_URL" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_USERINFO_URL') ? GETPOST('MAIN_AUTHENTICATION_OIDC_USERINFO_URL', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_USERINFO_URL) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_USERINFO_URL") : ''))).'"></td></tr>'; | 
                                                        
| 207 | -print '</td></tr>' . "\n";  | 
                                                        |
| 207 | +print '</td></tr>'."\n";  | 
                                                        |
| 208 | 208 | |
| 209 | 209 | // MAIN_AUTHENTICATION_OIDC_LOGOUT_URL  | 
                                                        
| 210 | 210 | $var = !$var;  | 
                                                        
| 211 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 211 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 212 | 212 |  print '<td>'.$langs->trans("MainAuthenticationOidcLogoutUrlName").'</td>'."\n"; | 
                                                        
| 213 | 213 |  print '<td>'.$langs->trans("MainAuthenticationOidcLogoutUrlDesc").'</td>'."\n"; | 
                                                        
| 214 | -print '<td align="right">' . "\n";  | 
                                                        |
| 214 | +print '<td align="right">'."\n";  | 
                                                        |
| 215 | 215 |  print '<input name="MAIN_AUTHENTICATION_OIDC_LOGOUT_URL" id="MAIN_AUTHENTICATION_OIDC_LOGOUT_URL" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_AUTHENTICATION_OIDC_LOGOUT_URL') ? GETPOST('MAIN_AUTHENTICATION_OIDC_LOGOUT_URL', 'nohtml') : (!empty($conf->global->MAIN_AUTHENTICATION_OIDC_LOGOUT_URL) ? getDolGlobalString("MAIN_AUTHENTICATION_OIDC_LOGOUT_URL") : ''))).'"></td></tr>'; | 
                                                        
| 216 | -print '</td></tr>' . "\n";  | 
                                                        |
| 216 | +print '</td></tr>'."\n";  | 
                                                        |
| 217 | 217 | |
| 218 | 218 | // REDIRECT_URL  | 
                                                        
| 219 | 219 | $var = !$var;  | 
                                                        
| 220 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 220 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 221 | 221 |  print '<td>'.$langs->trans("MainAuthenticationOidcRedirectUrlName").'</td>'."\n"; | 
                                                        
| 222 | 222 |  print '<td>'.$langs->trans("MainAuthenticationOidcRedirectUrlDesc").'</td>'."\n"; | 
                                                        
| 223 | -print '<td align="right">' . "\n";  | 
                                                        |
| 223 | +print '<td align="right">'."\n";  | 
                                                        |
| 224 | 224 | print '<input class="minwidth300" value="'.dol_escape_htmltag(openid_connect_get_redirect_url()).'" disabled></td></tr>';  | 
                                                        
| 225 | -print '</td></tr>' . "\n";  | 
                                                        |
| 225 | +print '</td></tr>'."\n";  | 
                                                        |
| 226 | 226 | |
| 227 | 227 | // LOGOUT_URL  | 
                                                        
| 228 | 228 | $var = !$var;  | 
                                                        
| 229 | -print '<tr ' . $bc[$var] . '>' . "\n";  | 
                                                        |
| 229 | +print '<tr '.$bc[$var].'>'."\n";  | 
                                                        |
| 230 | 230 |  print '<td>'.$langs->trans("MainAuthenticationOidcLogoutRedirectUrlName").'</td>'."\n"; | 
                                                        
| 231 | 231 |  print '<td>'.$langs->trans("MainAuthenticationOidcLogoutRedirectUrlDesc").'</td>'."\n"; | 
                                                        
| 232 | -print '<td align="right">' . "\n";  | 
                                                        |
| 233 | -print '<input class="minwidth300" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_LOGOUT_GOTO_URL', DOL_MAIN_URL_ROOT . "/index.php")).'" disabled></td></tr>'; | 
                                                        |
| 234 | -print '</td></tr>' . "\n";  | 
                                                        |
| 232 | +print '<td align="right">'."\n";  | 
                                                        |
| 233 | +print '<input class="minwidth300" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_LOGOUT_GOTO_URL', DOL_MAIN_URL_ROOT."/index.php")).'" disabled></td></tr>'; | 
                                                        |
| 234 | +print '</td></tr>'."\n";  | 
                                                        |
| 235 | 235 | |
| 236 | 236 | print '</table>'."\n";  | 
                                                        
| 237 | 237 | |
@@ -31,7 +31,9 @@  | 
                                                    ||
| 31 | 31 |  $langs->load("admin"); | 
                                                        
| 32 | 32 |  $langs->load("openidconnect"); | 
                                                        
| 33 | 33 | |
| 34 | -if (!$user->admin) accessforbidden();  | 
                                                        |
| 34 | +if (!$user->admin) { | 
                                                        |
| 35 | + accessforbidden();  | 
                                                        |
| 36 | +}  | 
                                                        |
| 35 | 37 | |
| 36 | 38 |  $action = GETPOST('action', 'alpha'); | 
                                                        
| 37 | 39 | |
@@ -85,7 +85,7 @@ discard block  | 
                                                    ||
| 85 | 85 |  $dateendvalidity = dol_mktime(0, 0, 0, GETPOSTINT('dateendvaliditymonth'), GETPOSTINT('dateendvalidityday'), GETPOSTINT('dateendvalidityyear')); | 
                                                        
| 86 | 86 |  $dateofbirth = dol_mktime(0, 0, 0, GETPOSTINT('dateofbirthmonth'), GETPOSTINT('dateofbirthday'), GETPOSTINT('dateofbirthyear')); | 
                                                        
| 87 | 87 | |
| 88 | -$childids = $user->getAllChildIds(1); // For later, test on salary visibility  | 
                                                        |
| 88 | +$childids = $user->getAllChildIds(1); // For later, test on salary visibility  | 
                                                        |
| 89 | 89 | |
| 90 | 90 | $object = new User($db);  | 
                                                        
| 91 | 91 | $extrafields = new ExtraFields($db);  | 
                                                        
@@ -117,7 +117,7 @@ discard block  | 
                                                    ||
| 117 | 117 | // Define value to know what current user can do on users  | 
                                                        
| 118 | 118 |  $canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); | 
                                                        
| 119 | 119 |  $canreaduser = (!empty($user->admin) || $user->hasRight("user", "user", "read")); | 
                                                        
| 120 | -$canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write"));	// edit other user | 
                                                        |
| 120 | +$canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); // edit other user | 
                                                        |
| 121 | 121 |  $candisableuser = (!empty($user->admin) || $user->hasRight("user", "user", "delete")); | 
                                                        
| 122 | 122 | $canreadgroup = $canreaduser;  | 
                                                        
| 123 | 123 | $caneditgroup = $canedituser;  | 
                                                        
@@ -546,7 +546,7 @@ discard block  | 
                                                    ||
| 546 | 546 | }  | 
                                                        
| 547 | 547 | }  | 
                                                        
| 548 | 548 | |
| 549 | - $ret = $object->update($user); // This may include call to setPassword if password has changed  | 
                                                        |
| 549 | + $ret = $object->update($user); // This may include call to setPassword if password has changed  | 
                                                        |
| 550 | 550 |  					if ($ret < 0) { | 
                                                        
| 551 | 551 | $error++;  | 
                                                        
| 552 | 552 |  						if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { | 
                                                        
@@ -676,7 +676,7 @@ discard block  | 
                                                    ||
| 676 | 676 |  	) { | 
                                                        
| 677 | 677 | $object->fetch($id);  | 
                                                        
| 678 | 678 | |
| 679 | - $newpassword = $object->setPassword($user, ''); // This will generate a new password  | 
                                                        |
| 679 | + $newpassword = $object->setPassword($user, ''); // This will generate a new password  | 
                                                        |
| 680 | 680 |  		if (is_int($newpassword) && $newpassword < 0) { | 
                                                        
| 681 | 681 | // Echec  | 
                                                        
| 682 | 682 |  			setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors'); | 
                                                        
@@ -1449,7 +1449,7 @@ discard block  | 
                                                    ||
| 1449 | 1449 | $ldap = new Ldap();  | 
                                                        
| 1450 | 1450 | $result = $ldap->connectBind();  | 
                                                        
| 1451 | 1451 |  			if ($result > 0) { | 
                                                        
| 1452 | -				$userSearchFilter = '(' . getDolGlobalString('LDAP_FILTER_CONNECTION').'('.$ldap->getUserIdentifier().'='.$object->login.'))'; | 
                                                        |
| 1452 | +				$userSearchFilter = '('.getDolGlobalString('LDAP_FILTER_CONNECTION').'('.$ldap->getUserIdentifier().'='.$object->login.'))'; | 
                                                        |
| 1453 | 1453 | $entries = $ldap->fetch($object->login, $userSearchFilter);  | 
                                                        
| 1454 | 1454 |  				if (!$entries) { | 
                                                        
| 1455 | 1455 | setEventMessages($ldap->error, $ldap->errors, 'errors');  | 
                                                        
@@ -1954,7 +1954,7 @@ discard block  | 
                                                    ||
| 1954 | 1954 | print '<td>';  | 
                                                        
| 1955 | 1955 |  				if (!empty($object->api_key)) { | 
                                                        
| 1956 | 1956 | print '<span class="opacitymedium">';  | 
                                                        
| 1957 | -					print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden"));		// TODO Add an option to also reveal the hash, not only copy paste | 
                                                        |
| 1957 | +					print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste | 
                                                        |
| 1958 | 1958 | print '</span>';  | 
                                                        
| 1959 | 1959 | }  | 
                                                        
| 1960 | 1960 | print '</td></tr>';  | 
                                                        
@@ -2008,7 +2008,7 @@ discard block  | 
                                                    ||
| 2008 | 2008 |  						$langs->load("mails"); | 
                                                        
| 2009 | 2009 |  						$params['attr']['title'] = $langs->trans('NoEMail'); | 
                                                        
| 2010 | 2010 | }  | 
                                                        
| 2011 | -					print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); | 
                                                        |
| 2011 | +					print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); | 
                                                        |
| 2012 | 2012 | }  | 
                                                        
| 2013 | 2013 | |
| 2014 | 2014 |  				if ($caneditfield && (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || (getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) { | 
                                                        
@@ -2060,13 +2060,13 @@ discard block  | 
                                                    ||
| 2060 | 2060 | if ($user->id != $id && $candisableuser && $object->statut == 0 &&  | 
                                                        
| 2061 | 2061 |  				((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) { | 
                                                        
| 2062 | 2062 | unset($params['attr']['title']);  | 
                                                        
| 2063 | -					print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken(), '', true, $params); | 
                                                        |
| 2063 | +					print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', true, $params); | 
                                                        |
| 2064 | 2064 | }  | 
                                                        
| 2065 | 2065 | // Disable user  | 
                                                        
| 2066 | 2066 | if ($user->id != $id && $candisableuser && $object->statut == 1 &&  | 
                                                        
| 2067 | 2067 |  				((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) { | 
                                                        
| 2068 | 2068 | unset($params['attr']['title']);  | 
                                                        
| 2069 | -					print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken(), '', true, $params); | 
                                                        |
| 2069 | +					print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', true, $params); | 
                                                        |
| 2070 | 2070 |  				} else { | 
                                                        
| 2071 | 2071 |  					if ($user->id == $id) { | 
                                                        
| 2072 | 2072 |  						$params['attr']['title'] = $langs->trans('CantDisableYourself'); | 
                                                        
@@ -50,7 +50,7 @@ discard block  | 
                                                    ||
| 50 | 50 | unset($_SESSION["dol_login"]);  | 
                                                        
| 51 | 51 | unset($_SESSION['dol_entity']);  | 
                                                        
| 52 | 52 | unset($_SESSION['urlfrom']);  | 
                                                        
| 53 | -	die("Applicative disconnection should be useless when connection was made in mode ".$_SESSION["dol_authmode"]);	// TODO Really ? It at least delete the session file ?! | 
                                                        |
| 53 | +	die("Applicative disconnection should be useless when connection was made in mode ".$_SESSION["dol_authmode"]); // TODO Really ? It at least delete the session file ?! | 
                                                        |
| 54 | 54 | }  | 
                                                        
| 55 | 55 | |
| 56 | 56 | //global $conf, $langs, $user;  | 
                                                        
@@ -103,9 +103,9 @@ discard block  | 
                                                    ||
| 103 | 103 |  if (getDolGlobalInt('MAIN_MODULE_OPENIDCONNECT', 0) > 0 && !empty($_SESSION['OPENID_CONNECT']) && getDolGlobalString("MAIN_AUTHENTICATION_OIDC_LOGOUT_URL")) { | 
                                                        
| 104 | 104 | // We need the full URL  | 
                                                        
| 105 | 105 |  	if (strpos($url, '/') === 0) { | 
                                                        
| 106 | - $url = DOL_MAIN_URL_ROOT . $url;  | 
                                                        |
| 106 | + $url = DOL_MAIN_URL_ROOT.$url;  | 
                                                        |
| 107 | 107 | }  | 
                                                        
| 108 | -	$url = getDolGlobalString('MAIN_AUTHENTICATION_OIDC_LOGOUT_URL') . '?client_id=' . getDolGlobalString('MAIN_AUTHENTICATION_OIDC_CLIENT_ID') . '&returnTo=' . urlencode($url); | 
                                                        |
| 108 | +	$url = getDolGlobalString('MAIN_AUTHENTICATION_OIDC_LOGOUT_URL').'?client_id='.getDolGlobalString('MAIN_AUTHENTICATION_OIDC_CLIENT_ID').'&returnTo='.urlencode($url); | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | // Destroy session  | 
                                                        
@@ -300,7 +300,7 @@ discard block  | 
                                                    ||
| 300 | 300 |  			$object->gender      = trim(GETPOST("gender", 'alphanohtml')); | 
                                                        
| 301 | 301 |  			$object->login       = trim(GETPOST("login", 'alphanohtml')); | 
                                                        
| 302 | 302 |  			if (GETPOSTISSET('pass')) { | 
                                                        
| 303 | -				$object->pass        = trim(GETPOST("pass", 'password'));	// For password, we must use 'none' | 
                                                        |
| 303 | +				$object->pass = trim(GETPOST("pass", 'password')); // For password, we must use 'none' | 
                                                        |
| 304 | 304 | }  | 
                                                        
| 305 | 305 | |
| 306 | 306 |  			$object->societe     = trim(GETPOST("societe", 'alphanohtml')); // deprecated | 
                                                        
@@ -355,10 +355,10 @@ discard block  | 
                                                    ||
| 355 | 355 | }  | 
                                                        
| 356 | 356 | |
| 357 | 357 | // Check if we need to also synchronize password information  | 
                                                        
| 358 | - $nosyncuserpass = 1; // no by default  | 
                                                        |
| 358 | + $nosyncuserpass = 1; // no by default  | 
                                                        |
| 359 | 359 |  			if (GETPOSTISSET('pass')) { | 
                                                        
| 360 | 360 |  				if ($object->user_id) {	// If member is linked to a user | 
                                                        
| 361 | - $nosyncuserpass = 0; // We may try to sync password  | 
                                                        |
| 361 | + $nosyncuserpass = 0; // We may try to sync password  | 
                                                        |
| 362 | 362 |  					if ($user->id == $object->user_id) { | 
                                                        
| 363 | 363 |  						if (!$user->hasRight('user', 'self', 'password')) { | 
                                                        
| 364 | 364 | $nosyncuserpass = 1; // Disable synchronizing  | 
                                                        
@@ -468,7 +468,7 @@ discard block  | 
                                                    ||
| 468 | 468 |  		$email = preg_replace('/\s+/', '', GETPOST("member_email", 'aZ09arobase')); | 
                                                        
| 469 | 469 |  		$url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); | 
                                                        
| 470 | 470 |  		$login = GETPOST("member_login", 'alphanohtml'); | 
                                                        
| 471 | -		$pass = GETPOST("password", 'password');	// For password, we use 'none' | 
                                                        |
| 471 | +		$pass = GETPOST("password", 'password'); // For password, we use 'none' | 
                                                        |
| 472 | 472 |  		$photo = GETPOST("photo", 'alphanohtml'); | 
                                                        
| 473 | 473 |  		$morphy = GETPOST("morphy", 'alphanohtml'); | 
                                                        
| 474 | 474 |  		$public = GETPOST("public", 'alphanohtml'); | 
                                                        
@@ -1290,7 +1290,7 @@ discard block  | 
                                                    ||
| 1290 | 1290 | $maxfilesizearray = getMaxFileSizeArray();  | 
                                                        
| 1291 | 1291 | $maxmin = $maxfilesizearray['maxmin'];  | 
                                                        
| 1292 | 1292 |  			if ($maxmin > 0) { | 
                                                        
| 1293 | - print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file  | 
                                                        |
| 1293 | + print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file  | 
                                                        |
| 1294 | 1294 | }  | 
                                                        
| 1295 | 1295 | print '<input type="file" class="flat" name="photo" id="photoinput">';  | 
                                                        
| 1296 | 1296 | print '</td></tr>';  | 
                                                        
@@ -108,7 +108,7 @@ discard block  | 
                                                    ||
| 108 | 108 | // Set a cookie to transfer rollback page information  | 
                                                        
| 109 | 109 |  	$prefix = dol_getprefix(''); | 
                                                        
| 110 | 110 |  	if (empty($_COOKIE["DOL_rollback_url_$prefix"])) { | 
                                                        
| 111 | -		setcookie('DOL_rollback_url_' . $prefix, $_SERVER['REQUEST_URI'], time() + 3600, '/'); | 
                                                        |
| 111 | +		setcookie('DOL_rollback_url_'.$prefix, $_SERVER['REQUEST_URI'], time() + 3600, '/'); | 
                                                        |
| 112 | 112 | }  | 
                                                        
| 113 | 113 | |
| 114 | 114 | // Auto redirect if OpenID Connect is the only authentication  | 
                                                        
@@ -116,10 +116,10 @@ discard block  | 
                                                    ||
| 116 | 116 | // Avoid redirection hell  | 
                                                        
| 117 | 117 |  		if (empty(GETPOST('openid_mode'))) { | 
                                                        
| 118 | 118 |  			dol_include_once('/core/lib/openid_connect.lib.php'); | 
                                                        
| 119 | -			header("Location: " . openid_connect_get_url(), true, 302); | 
                                                        |
| 119 | +			header("Location: ".openid_connect_get_url(), true, 302); | 
                                                        |
| 120 | 120 |  		} elseif (!empty($_SESSION['dol_loginmesg'])) { | 
                                                        
| 121 | 121 | // Show login error without the login form  | 
                                                        
| 122 | - print '<div class="center login_main_message"><div class="error">' . dol_escape_htmltag($_SESSION['dol_loginmesg']) . '</div></div>';  | 
                                                        |
| 122 | + print '<div class="center login_main_message"><div class="error">'.dol_escape_htmltag($_SESSION['dol_loginmesg']).'</div></div>';  | 
                                                        |
| 123 | 123 | }  | 
                                                        
| 124 | 124 | // We shouldn't continue executing this page  | 
                                                        
| 125 | 125 | exit();  | 
                                                        
@@ -369,7 +369,7 @@ discard block  | 
                                                    ||
| 369 | 369 |  	if (!getDolGlobalString("MAIN_AUTHENTICATION_OPENID_URL")) { | 
                                                        
| 370 | 370 | $url = openid_connect_get_url();  | 
                                                        
| 371 | 371 |  	} else { | 
                                                        
| 372 | -		$url = getDolGlobalString('MAIN_AUTHENTICATION_OPENID_URL').'&state=' . openid_connect_get_state(); | 
                                                        |
| 372 | +		$url = getDolGlobalString('MAIN_AUTHENTICATION_OPENID_URL').'&state='.openid_connect_get_state(); | 
                                                        |
| 373 | 373 | }  | 
                                                        
| 374 | 374 |  	if (!empty($url)) { | 
                                                        
| 375 | 375 |  		print '<a class="alogin" href="'.$url.'">'.$langs->trans("LoginUsingOpenID").'</a>'; | 
                                                        
@@ -427,7 +427,7 @@ discard block  | 
                                                    ||
| 427 | 427 | <?php  | 
                                                        
| 428 | 428 | // Show error message if defined  | 
                                                        
| 429 | 429 |  if (!empty($_SESSION['dol_loginmesg'])) { | 
                                                        
| 430 | - $message = $_SESSION['dol_loginmesg']; // By default this is an error message  | 
                                                        |
| 430 | + $message = $_SESSION['dol_loginmesg']; // By default this is an error message  | 
                                                        |
| 431 | 431 |  	if (!empty($conf->use_javascript_ajax)) { | 
                                                        
| 432 | 432 |  		if (preg_match('/<!-- warning -->/', $message)) {	// if it contains this comment, this is a warning message | 
                                                        
| 433 | 433 |  			$message = str_replace('<!-- warning -->', '', $message); | 
                                                        
@@ -473,7 +473,7 @@ discard block  | 
                                                    ||
| 473 | 473 | libxml_disable_entity_loader(true);  | 
                                                        
| 474 | 474 | }  | 
                                                        
| 475 | 475 | |
| 476 | - $xml = simplexml_load_string($resgetcommitstrip['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);  | 
                                                        |
| 476 | + $xml = simplexml_load_string($resgetcommitstrip['content'], 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NONET);  | 
                                                        |
| 477 | 477 |  		$little = $xml->channel->item[0]->children('content', true); | 
                                                        
| 478 | 478 |  		print preg_replace('/width="650" height="658"/', '', $little->encoded); | 
                                                        
| 479 | 479 | }  |