Completed
Branch develop (aebfce)
by
unknown
17:24
created
htdocs/filefunc.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@
 block discarded – undo
196 196
 		if ($csrfattack) {
197 197
 			//print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
198 198
 			// Note: We can't use dol_escape_htmltag here to escape output because lib functions.lib.ph is not yet loaded.
199
-			dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (Bad referer).", LOG_WARNING);
199
+			dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (Bad referer).", LOG_WARNING);
200 200
 			print "Access refused by CSRF protection in main.inc.php. Referer of form (".htmlentities($_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8').") is outside the server that serve this page (with method = ".htmlentities($_SERVER['REQUEST_METHOD'], ENT_COMPAT, 'UTF-8').").\n";
201 201
 			print "If you access your server behind a proxy using url rewriting, you might check that all HTTP headers are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file to remove this security check).\n";
202 202
 			die;
Please login to merge, or discard this patch.
htdocs/fourn/class/fournisseur.facture-rec.class.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		$now = dol_now();
271 271
 
272 272
 		// Clean parameters
273
-		$this->titre = empty($this->titre) ? '' : $this->titre;	// deprecated
273
+		$this->titre = empty($this->titre) ? '' : $this->titre; // deprecated
274 274
 		$this->title = empty($this->title) ? '' : $this->title;
275 275
 		$keyforref = $this->table_ref_field;
276 276
 		$this->ref = $this->$keyforref;
@@ -332,32 +332,32 @@  discard block
 block discarded – undo
332 332
 			$sql .= ", '".$this->db->idate($now)."'";
333 333
 			$sql .= ", ".((int) $this->suspended);
334 334
 			$sql .= ", '".$this->db->escape($this->libelle)."'";
335
-			$sql .= ", " .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0');                              // amount
336
-			$sql .= ", " .((int) $user->id);
337
-			$sql .= ", " .(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL');
338
-			$sql .= ", " .(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL');
339
-			$sql .= ", " .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL');
340
-			$sql .= ", " .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL');
341
-			$sql .= ", ".($facfourn_src->date_echeance > 0 ? "'".$this->db->idate($facfourn_src->date_echeance)."'" : 'NULL');      // date_lim_reglement
342
-			$sql .= ", " .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL');
343
-			$sql .= ", " .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL');
344
-			$sql .= ", " .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL');
345
-			$sql .= ", " . (int) $facfourn_src->fk_multicurrency;
335
+			$sql .= ", ".(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount
336
+			$sql .= ", ".((int) $user->id);
337
+			$sql .= ", ".(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL');
338
+			$sql .= ", ".(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL');
339
+			$sql .= ", ".($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL');
340
+			$sql .= ", ".($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL');
341
+			$sql .= ", ".($facfourn_src->date_echeance > 0 ? "'".$this->db->idate($facfourn_src->date_echeance)."'" : 'NULL'); // date_lim_reglement
342
+			$sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL');
343
+			$sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL');
344
+			$sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL');
345
+			$sql .= ", ".(int) $facfourn_src->fk_multicurrency;
346 346
 			$sql .= ", '".$this->db->escape($facfourn_src->multicurrency_code)."'";
347
-			$sql .= ", " . (float) $facfourn_src->multicurrency_tx;
348
-			$sql .= ", " . (int) $this->usenewprice;
349
-			$sql .= ", " . (int) $this->frequency;
347
+			$sql .= ", ".(float) $facfourn_src->multicurrency_tx;
348
+			$sql .= ", ".(int) $this->usenewprice;
349
+			$sql .= ", ".(int) $this->frequency;
350 350
 			$sql .= ", '".$this->db->escape($this->unit_frequency)."'";
351
-			$sql .= ", " .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL');
352
-			$sql .= ", " .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL');
353
-			$sql .= ", " . (int) $this->nb_gen_done;
354
-			$sql .= ", " . (int) $this->nb_gen_max;
355
-			$sql .= ", " . (int) $this->auto_validate;
356
-			$sql .= ", " . (int) $this->generate_pdf;
351
+			$sql .= ", ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL');
352
+			$sql .= ", ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL');
353
+			$sql .= ", ".(int) $this->nb_gen_done;
354
+			$sql .= ", ".(int) $this->nb_gen_max;
355
+			$sql .= ", ".(int) $this->auto_validate;
356
+			$sql .= ", ".(int) $this->generate_pdf;
357 357
 			$sql .= ')';
358 358
 
359 359
 			if ($this->db->query($sql)) {
360
-				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX. 'facture_fourn_rec');
360
+				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_rec');
361 361
 
362 362
 				// Fields used into addline later
363 363
 				$this->fk_multicurrency = $facfourn_src->fk_multicurrency;
@@ -493,46 +493,46 @@  discard block
 block discarded – undo
493 493
 		$error = 0;
494 494
 
495 495
 		$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET";
496
-		$sql .= " titre = '" . (!empty($this->title) ? $this->db->escape($this->title) : "")."'," ;
497
-		$sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
498
-		$sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ',';
496
+		$sql .= " titre = '".(!empty($this->title) ? $this->db->escape($this->title) : "")."',";
497
+		$sql .= " ref_supplier = '".(!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
498
+		$sql .= " entity = ".(!empty($this->entity) ? ((int) $this->entity) : 1).',';
499 499
 		if (!empty($this->socid) && $this->socid > 0) {
500
-			$sql .= " fk_soc = ". ((int) $this->socid). ',';
500
+			$sql .= " fk_soc = ".((int) $this->socid).',';
501 501
 		} elseif (!empty($this->fk_soc) && $this->fk_soc > 0) {	// For backward compatibility
502
-			$sql .= " fk_soc = ". ((int) $this->fk_soc). ',';
502
+			$sql .= " fk_soc = ".((int) $this->fk_soc).',';
503 503
 		}
504
-		$sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ',';
505
-		$sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ",";
506
-		$sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ',';
507
-		$sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ',';
508
-		$sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ',';
509
-		$sql .= " total_ht = ". (!empty($this->total_ht) ? ((float) $this->total_ht) : 0.00) . ',';
510
-		$sql .= " total_tva = ". (!empty($this->total_tva) ? ((float) $this->total_tva) : 0.00) . ',';
511
-		$sql .= " total_ttc = ". (!empty($this->total_ttc) ? ((float) $this->total_ttc) : 0.00) . ',';
512
-		$sql .= " fk_user_modif = ". ((int) $user->id) . ',';
513
-		$sql .= " fk_projet = ". (!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL') . ',';
514
-		$sql .= " fk_account = ". (!empty($this->fk_account) ? ((int) $this->fk_account) : 'NULL') . ',';
515
-		$sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? ((int) $this->mode_reglement_id) : 'NULL') . ',';
516
-		$sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : 'NULL') . ',';
517
-		$sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL') . ',';
518
-		$sql .= " note_private = '". (!empty($this->note_private) ? $this->db->escape($this->note_private) : '') . "',";
519
-		$sql .= " note_public = '". (!empty($this->note_public) ? $this->db->escape($this->note_public) : '') . "',";
520
-		$sql .= " modelpdf = ". (!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL') . ",";
521
-		$sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? ((int) $this->fk_multicurrency) : 'NULL') . ',';
522
-		$sql .= " multicurrency_code = ". (!empty($this->multicurrency_code) ? "'".$this->db->escape($this->multicurrency_code)."'" : 'NULL') . ",";
523
-		$sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? ((float) $this->multicurrency_tx) : 1) . ',';
524
-		$sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? ((float) $this->multicurrency_total_ht) : 0.00) . ',';
525
-		$sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? ((float) $this->multicurrency_total_tva) : 0.00) . ',';
526
-		$sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? ((float) $this->multicurrency_total_ttc) : 0.00) . ',';
527
-		$sql .= " usenewprice = ". (!empty($this->usenewprice) ? ((int) $this->usenewprice) : 0) . ',';
528
-		$sql .= " frequency = ". (!empty($this->frequency) ? ((int) $this->frequency) : 0). ',';
529
-		$sql .= " unit_frequency = '". (!empty($this->unit_frequency) ? $this->db->escape($this->unit_frequency) : ''). "',";
530
-		$sql .= " date_when = ". (!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL') . ',';
531
-		$sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL') . ',';
532
-		$sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? ((int) $this->nb_gen_done) : 0) . ',';
533
-		$sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? ((int) $this->nb_gen_max) : 0) . ',';
534
-		$sql .= " auto_validate = ". (!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0);
535
-		$sql .= " WHERE rowid = ". (int) $this->id;
504
+		$sql .= " suspended = ".(!empty($this->suspended) ? ((int) $this->suspended) : 0).',';
505
+		$sql .= " libelle = ".(!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL').",";
506
+		$sql .= " vat_src_code = ".(!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL').',';
507
+		$sql .= " localtax1 = ".(!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00).',';
508
+		$sql .= " localtax2 = ".(!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00).',';
509
+		$sql .= " total_ht = ".(!empty($this->total_ht) ? ((float) $this->total_ht) : 0.00).',';
510
+		$sql .= " total_tva = ".(!empty($this->total_tva) ? ((float) $this->total_tva) : 0.00).',';
511
+		$sql .= " total_ttc = ".(!empty($this->total_ttc) ? ((float) $this->total_ttc) : 0.00).',';
512
+		$sql .= " fk_user_modif = ".((int) $user->id).',';
513
+		$sql .= " fk_projet = ".(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL').',';
514
+		$sql .= " fk_account = ".(!empty($this->fk_account) ? ((int) $this->fk_account) : 'NULL').',';
515
+		$sql .= " fk_mode_reglement = ".(!empty($this->mode_reglement_id) ? ((int) $this->mode_reglement_id) : 'NULL').',';
516
+		$sql .= " fk_cond_reglement = ".(!empty($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : 'NULL').',';
517
+		$sql .= " date_lim_reglement = ".(!empty($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL').',';
518
+		$sql .= " note_private = '".(!empty($this->note_private) ? $this->db->escape($this->note_private) : '')."',";
519
+		$sql .= " note_public = '".(!empty($this->note_public) ? $this->db->escape($this->note_public) : '')."',";
520
+		$sql .= " modelpdf = ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL').",";
521
+		$sql .= " fk_multicurrency = ".(!empty($this->fk_multicurrency) ? ((int) $this->fk_multicurrency) : 'NULL').',';
522
+		$sql .= " multicurrency_code = ".(!empty($this->multicurrency_code) ? "'".$this->db->escape($this->multicurrency_code)."'" : 'NULL').",";
523
+		$sql .= " multicurrency_tx = ".(!empty($this->multicurrency_tx) ? ((float) $this->multicurrency_tx) : 1).',';
524
+		$sql .= " multicurrency_total_ht = ".(!empty($this->multicurrency_total_ht) ? ((float) $this->multicurrency_total_ht) : 0.00).',';
525
+		$sql .= " multicurrency_total_tva = ".(!empty($this->multicurrency_total_tva) ? ((float) $this->multicurrency_total_tva) : 0.00).',';
526
+		$sql .= " multicurrency_total_ttc = ".(!empty($this->multicurrency_total_ttc) ? ((float) $this->multicurrency_total_ttc) : 0.00).',';
527
+		$sql .= " usenewprice = ".(!empty($this->usenewprice) ? ((int) $this->usenewprice) : 0).',';
528
+		$sql .= " frequency = ".(!empty($this->frequency) ? ((int) $this->frequency) : 0).',';
529
+		$sql .= " unit_frequency = '".(!empty($this->unit_frequency) ? $this->db->escape($this->unit_frequency) : '')."',";
530
+		$sql .= " date_when = ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL').',';
531
+		$sql .= " date_last_gen = ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL').',';
532
+		$sql .= " nb_gen_done = ".(!empty($this->nb_gen_done) ? ((int) $this->nb_gen_done) : 0).',';
533
+		$sql .= " nb_gen_max = ".(!empty($this->nb_gen_max) ? ((int) $this->nb_gen_max) : 0).',';
534
+		$sql .= " auto_validate = ".(!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0);
535
+		$sql .= " WHERE rowid = ".(int) $this->id;
536 536
 
537 537
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
538 538
 		$resql = $this->db->query($sql);
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
592 592
 		$sql .= ' WHERE f.entity IN ('.getEntity('invoice').')';
593 593
 		if ($rowid) {
594
-			$sql .= ' AND f.rowid='. (int) $rowid;
594
+			$sql .= ' AND f.rowid='.(int) $rowid;
595 595
 		} elseif ($ref) {
596 596
 			$sql .= " AND f.titre='".$this->db->escape($ref)."'";
597 597
 		} else {
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 		$sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
725 725
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det_rec as l';
726 726
 		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
727
-		$sql .= ' WHERE l.fk_facture_fourn = '. (int) $this->id;
727
+		$sql .= ' WHERE l.fk_facture_fourn = '.(int) $this->id;
728 728
 		$sql .= ' ORDER BY l.rang';
729 729
 
730 730
 		dol_syslog('FactureFournisseurRec::fetch_lines', LOG_DEBUG);
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 				$line->product_type             = $objp->product_type;
765 765
 				$line->date_start               = $objp->date_start;
766 766
 				$line->date_end                 = $objp->date_end;
767
-				$line->info_bits                = $objp->info_bits	;
767
+				$line->info_bits                = $objp->info_bits;
768 768
 				$line->special_code             = $objp->special_code;
769 769
 				$line->rang                     = $objp->rang;
770 770
 				$line->fk_unit                  = $objp->fk_unit;
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 		$main = MAIN_DB_PREFIX.'facture_fourn_det_rec';
815 815
 		$ef = $main."_extrafields";
816 816
 
817
-		$sqlef = "DELETE FROM ".$ef." WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture_fourn = ". (int) $rowid .")";
818
-		$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det_rec WHERE fk_facture_fourn = ". (int) $rowid;
817
+		$sqlef = "DELETE FROM ".$ef." WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture_fourn = ".(int) $rowid.")";
818
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det_rec WHERE fk_facture_fourn = ".(int) $rowid;
819 819
 
820 820
 		if ($this->db->query($sqlef) && $this->db->query($sql)) {
821
-			$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_rec WHERE rowid = ". (int) $rowid;
821
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_rec WHERE rowid = ".(int) $rowid;
822 822
 			dol_syslog($sql);
823 823
 			if ($this->db->query($sql)) {
824 824
 				// Delete linked object
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 			}
848 848
 			// End call triggers
849 849
 		}
850
-		if (! $error) {
850
+		if (!$error) {
851 851
 			$this->db->commit();
852 852
 			return 1;
853 853
 		} else {
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 				}
960 960
 			}
961 961
 
962
-			$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec (';
962
+			$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det_rec (';
963 963
 			$sql .= 'fk_facture_fourn';
964 964
 			$sql .= ', fk_product';
965 965
 			$sql .= ', ref';
@@ -991,46 +991,46 @@  discard block
 block discarded – undo
991 991
 			$sql .= ', fk_user_author';
992 992
 			$sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
993 993
 			$sql .= ') VALUES (';
994
-			$sql .= ' ' . (int) $facid;   // source supplier invoie id
995
-			$sql .= ', ' . (!empty($fk_product) ? "'" . $this->db->escape($fk_product) . "'" : 'null');
996
-			$sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null');
997
-			$sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null');
998
-			$sql .= ", '" . $this->db->escape($desc) . "'";
999
-			$sql .= ', ' . price2num($pu_ht);
1000
-			$sql .= ', ' . price2num($pu_ttc);
1001
-			$sql .= ', ' . price2num($qty);
1002
-			$sql .= ', ' . price2num($remise_percent);
994
+			$sql .= ' '.(int) $facid; // source supplier invoie id
995
+			$sql .= ', '.(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : 'null');
996
+			$sql .= ', '.(!empty($ref) ? "'".$this->db->escape($ref)."'" : 'null');
997
+			$sql .= ', '.(!empty($label) ? "'".$this->db->escape($label)."'" : 'null');
998
+			$sql .= ", '".$this->db->escape($desc)."'";
999
+			$sql .= ', '.price2num($pu_ht);
1000
+			$sql .= ', '.price2num($pu_ttc);
1001
+			$sql .= ', '.price2num($qty);
1002
+			$sql .= ', '.price2num($remise_percent);
1003 1003
 			$sql .= ', null';
1004
-			$sql .= ", '" . $this->db->escape($vat_src_code) . "'";
1005
-			$sql .= ', ' . price2num($txtva);
1006
-			$sql .= ', ' . price2num($txlocaltax1);
1007
-			$sql .= ", '" . $this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '') . "'";
1008
-			$sql .= ', ' . price2num($txlocaltax2);
1009
-			$sql .= ", '" . $this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '') . "'";
1010
-			$sql .= ', ' . price2num($total_ht);
1011
-			$sql .= ', ' . price2num($total_tva);
1012
-			$sql .= ', ' . price2num($total_localtax1);
1013
-			$sql .= ', ' . price2num($total_localtax2);
1014
-			$sql .= ', ' . price2num($total_ttc);
1015
-			$sql .= ', ' . (int) $product_type;
1016
-			$sql .= ', ' . ($date_start > 0 ? (int) $date_start : 'NULL');
1017
-			$sql .= ', ' . ($date_end > 0 ? (int) $date_end : 'NULL');
1018
-			$sql .= ', ' . (int) $info_bits;
1019
-			$sql .= ', ' . (int) $special_code;
1020
-			$sql .= ', ' . (int) $rang;
1021
-			$sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL');
1022
-			$sql .= ', ' . (int) $user->id;
1023
-			$sql .= ', ' . (int) $this->fk_multicurrency;
1024
-			$sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'";
1025
-			$sql .= ', ' . price2num($pu_ht_devise, 'CU');
1026
-			$sql .= ', ' . price2num($multicurrency_total_ht, 'CT');
1027
-			$sql .= ', ' . price2num($multicurrency_total_tva, 'CT');
1028
-			$sql .= ', ' . price2num($multicurrency_total_ttc, 'CT');
1004
+			$sql .= ", '".$this->db->escape($vat_src_code)."'";
1005
+			$sql .= ', '.price2num($txtva);
1006
+			$sql .= ', '.price2num($txlocaltax1);
1007
+			$sql .= ", '".$this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '')."'";
1008
+			$sql .= ', '.price2num($txlocaltax2);
1009
+			$sql .= ", '".$this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '')."'";
1010
+			$sql .= ', '.price2num($total_ht);
1011
+			$sql .= ', '.price2num($total_tva);
1012
+			$sql .= ', '.price2num($total_localtax1);
1013
+			$sql .= ', '.price2num($total_localtax2);
1014
+			$sql .= ', '.price2num($total_ttc);
1015
+			$sql .= ', '.(int) $product_type;
1016
+			$sql .= ', '.($date_start > 0 ? (int) $date_start : 'NULL');
1017
+			$sql .= ', '.($date_end > 0 ? (int) $date_end : 'NULL');
1018
+			$sql .= ', '.(int) $info_bits;
1019
+			$sql .= ', '.(int) $special_code;
1020
+			$sql .= ', '.(int) $rang;
1021
+			$sql .= ', '.($fk_unit ? (int) $fk_unit : 'NULL');
1022
+			$sql .= ', '.(int) $user->id;
1023
+			$sql .= ', '.(int) $this->fk_multicurrency;
1024
+			$sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
1025
+			$sql .= ', '.price2num($pu_ht_devise, 'CU');
1026
+			$sql .= ', '.price2num($multicurrency_total_ht, 'CT');
1027
+			$sql .= ', '.price2num($multicurrency_total_tva, 'CT');
1028
+			$sql .= ', '.price2num($multicurrency_total_ttc, 'CT');
1029 1029
 			$sql .= ')';
1030 1030
 
1031
-			dol_syslog(get_class($this). '::addline', LOG_DEBUG);
1031
+			dol_syslog(get_class($this).'::addline', LOG_DEBUG);
1032 1032
 			if ($this->db->query($sql)) {
1033
-				$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX. 'facture_fourn_det_rec');
1033
+				$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det_rec');
1034 1034
 				$this->update_price();
1035 1035
 				$this->id = $facid;
1036 1036
 				$this->db->commit();
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 
1082 1082
 		$facid = $this->id;
1083 1083
 
1084
-		dol_syslog(get_class($this). '::updateline facid=' .$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
1084
+		dol_syslog(get_class($this).'::updateline facid='.$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
1085 1085
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
1086 1086
 
1087 1087
 		// Check parameters
@@ -1152,41 +1152,41 @@  discard block
 block discarded – undo
1152 1152
 				$product_type = $product->type;
1153 1153
 			}
1154 1154
 
1155
-			$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec SET';
1156
-			$sql .= ' fk_facture_fourn = ' . ((int) $facid);
1157
-			$sql .= ', fk_product = ' . ($fk_product > 0 ? ((int) $fk_product) : 'null');
1158
-			$sql .= ", ref = '" . $this->db->escape($ref) . "'";
1159
-			$sql .= ", label = '" . $this->db->escape($label) . "'";
1160
-			$sql .= ", description = '" . $this->db->escape($desc) . "'";
1161
-			$sql .= ', pu_ht = ' . price2num($pu_ht);
1162
-			$sql .= ', qty = ' . price2num($qty);
1163
-			$sql .= ", remise_percent = '" . price2num($remise_percent) . "'";
1164
-			$sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'";
1165
-			$sql .= ', tva_tx = ' . price2num($txtva);
1166
-			$sql .= ', localtax1_tx = ' . (float) $txlocaltax1;
1167
-			$sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'";
1168
-			$sql .= ', localtax2_tx = ' . (float) $txlocaltax2;
1169
-			$sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'";
1170
-			$sql .= ", total_ht = '" . price2num($total_ht) . "'";
1171
-			$sql .= ", total_tva = '" . price2num($total_tva) . "'";
1172
-			$sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'";
1173
-			$sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'";
1174
-			$sql .= ", total_ttc = '" . price2num($total_ttc) . "'";
1175
-			$sql .= ', product_type = ' . (int) $product_type;
1176
-			$sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start);
1177
-			$sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end);
1178
-			$sql .= ', info_bits = ' . (int) $info_bits;
1179
-			$sql .= ', special_code = ' . (int) $special_code;
1180
-			$sql .= ', rang = ' . (int) $rang;
1181
-			$sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
1182
-			$sql .= ', fk_user_modif = ' . (int) $user;
1155
+			$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn_det_rec SET';
1156
+			$sql .= ' fk_facture_fourn = '.((int) $facid);
1157
+			$sql .= ', fk_product = '.($fk_product > 0 ? ((int) $fk_product) : 'null');
1158
+			$sql .= ", ref = '".$this->db->escape($ref)."'";
1159
+			$sql .= ", label = '".$this->db->escape($label)."'";
1160
+			$sql .= ", description = '".$this->db->escape($desc)."'";
1161
+			$sql .= ', pu_ht = '.price2num($pu_ht);
1162
+			$sql .= ', qty = '.price2num($qty);
1163
+			$sql .= ", remise_percent = '".price2num($remise_percent)."'";
1164
+			$sql .= ", vat_src_code = '".$this->db->escape($vat_src_code)."'";
1165
+			$sql .= ', tva_tx = '.price2num($txtva);
1166
+			$sql .= ', localtax1_tx = '.(float) $txlocaltax1;
1167
+			$sql .= ", localtax1_type = '".$this->db->escape($localtaxes_type[0])."'";
1168
+			$sql .= ', localtax2_tx = '.(float) $txlocaltax2;
1169
+			$sql .= ", localtax2_type = '".$this->db->escape($localtaxes_type[2])."'";
1170
+			$sql .= ", total_ht = '".price2num($total_ht)."'";
1171
+			$sql .= ", total_tva = '".price2num($total_tva)."'";
1172
+			$sql .= ", total_localtax1 = '".price2num($total_localtax1)."'";
1173
+			$sql .= ", total_localtax2 = '".price2num($total_localtax2)."'";
1174
+			$sql .= ", total_ttc = '".price2num($total_ttc)."'";
1175
+			$sql .= ', product_type = '.(int) $product_type;
1176
+			$sql .= ', date_start = '.(empty($date_start) ? 'NULL' : (int) $date_start);
1177
+			$sql .= ', date_end = '.(empty($date_end) ? 'NULL' : (int) $date_end);
1178
+			$sql .= ', info_bits = '.(int) $info_bits;
1179
+			$sql .= ', special_code = '.(int) $special_code;
1180
+			$sql .= ', rang = '.(int) $rang;
1181
+			$sql .= ', fk_unit = '.($fk_unit ? "'".$this->db->escape($fk_unit)."'" : 'null');
1182
+			$sql .= ', fk_user_modif = '.(int) $user;
1183 1183
 			$sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise);
1184 1184
 			$sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht);
1185 1185
 			$sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva);
1186 1186
 			$sql .= ', multicurrency_total_ttc = '.price2num($multicurrency_total_ttc);
1187
-			$sql .= ' WHERE rowid = ' . (int) $rowid;
1187
+			$sql .= ' WHERE rowid = '.(int) $rowid;
1188 1188
 
1189
-			dol_syslog(get_class($this). '::updateline', LOG_DEBUG);
1189
+			dol_syslog(get_class($this).'::updateline', LOG_DEBUG);
1190 1190
 			if ($this->db->query($sql)) {
1191 1191
 				$this->id = $facid;
1192 1192
 				$this->update_price();
@@ -1275,16 +1275,16 @@  discard block
 block discarded – undo
1275 1275
 		$tmparray = dol_getdate($now);
1276 1276
 		$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
1277 1277
 
1278
-		dol_syslog('createRecurringInvoices restrictioninvoiceid=' .$restrictioninvoiceid. ' forcevalidation=' .$forcevalidation);
1278
+		dol_syslog('createRecurringInvoices restrictioninvoiceid='.$restrictioninvoiceid.' forcevalidation='.$forcevalidation);
1279 1279
 
1280 1280
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn_rec';
1281 1281
 		$sql .= ' WHERE frequency > 0'; // A recurring supplier invoice is an invoice with a frequency
1282 1282
 		$sql .= " AND (date_when IS NULL OR date_when <= '".$this->db->idate($today)."')";
1283 1283
 		$sql .= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
1284 1284
 		$sql .= ' AND suspended = 0';
1285
-		$sql .= ' AND entity = '. (int) $conf->entity; // MUST STAY = $conf->entity here
1285
+		$sql .= ' AND entity = '.(int) $conf->entity; // MUST STAY = $conf->entity here
1286 1286
 		if ($restrictioninvoiceid > 0) {
1287
-			$sql .= ' AND rowid = '. (int) $restrictioninvoiceid;
1287
+			$sql .= ' AND rowid = '.(int) $restrictioninvoiceid;
1288 1288
 		}
1289 1289
 		$sql .= $this->db->order('entity', 'ASC');
1290 1290
 		//print $sql;exit;
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
 			}
1307 1307
 
1308 1308
 			$saventity = $conf->entity;
1309
-			$laststep="None";
1309
+			$laststep = "None";
1310 1310
 
1311 1311
 			while ($i < $num) {     // Loop on each template invoice. If $num = 0, test is false at first pass.
1312 1312
 				$line = $this->db->fetch_object($resql);
@@ -1317,21 +1317,21 @@  discard block
 block discarded – undo
1317 1317
 
1318 1318
 				$new_fac_fourn = null;
1319 1319
 				$facturerec = new FactureFournisseurRec($this->db);
1320
-				$laststep="Fetch {$line->rowid}";
1320
+				$laststep = "Fetch {$line->rowid}";
1321 1321
 				$facturerec->fetch($line->rowid);
1322 1322
 
1323 1323
 				if ($facturerec->id > 0) {
1324 1324
 					// Set entity context
1325 1325
 					$conf->entity = $facturerec->entity;
1326 1326
 
1327
-					dol_syslog('createRecurringInvoices Process invoice template id=' .$facturerec->id. ', ref=' .$facturerec->ref. ', entity=' .$facturerec->entity);
1327
+					dol_syslog('createRecurringInvoices Process invoice template id='.$facturerec->id.', ref='.$facturerec->ref.', entity='.$facturerec->entity);
1328 1328
 
1329 1329
 					$new_fac_fourn = new FactureFournisseur($this->db);
1330 1330
 					$new_fac_fourn->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice
1331 1331
 					$new_fac_fourn->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice
1332 1332
 
1333 1333
 					$new_fac_fourn->type = self::TYPE_STANDARD;
1334
-					$new_fac_fourn->statut = self::STATUS_DRAFT;	// deprecated
1334
+					$new_fac_fourn->statut = self::STATUS_DRAFT; // deprecated
1335 1335
 					$new_fac_fourn->status = self::STATUS_DRAFT;
1336 1336
 					$new_fac_fourn->date = empty($facturerec->date_when) ? $now : $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
1337 1337
 					$new_fac_fourn->socid = $facturerec->socid;
@@ -1340,10 +1340,10 @@  discard block
 block discarded – undo
1340 1340
 					$new_fac_fourn->model_pdf = $facturerec->model_pdf;
1341 1341
 					$new_fac_fourn->fk_project = $facturerec->fk_project;
1342 1342
 					$new_fac_fourn->label = $facturerec->label;
1343
-					$new_fac_fourn->libelle = $facturerec->label;	// deprecated
1343
+					$new_fac_fourn->libelle = $facturerec->label; // deprecated
1344 1344
 
1345 1345
 					$invoiceidgenerated = $new_fac_fourn->create($user);
1346
-					$laststep="Create invoiceidgenerated $invoiceidgenerated";
1346
+					$laststep = "Create invoiceidgenerated $invoiceidgenerated";
1347 1347
 					if ($invoiceidgenerated <= 0) {
1348 1348
 						$this->errors = $new_fac_fourn->errors;
1349 1349
 						$this->error = $new_fac_fourn->error;
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
 					}
1352 1352
 					if (!$error && ($facturerec->auto_validate || $forcevalidation)) {
1353 1353
 						$result = $new_fac_fourn->validate($user);
1354
-						$laststep="Validate by user $user";
1354
+						$laststep = "Validate by user $user";
1355 1355
 						if ($result <= 0) {
1356 1356
 							$this->errors = $new_fac_fourn->errors;
1357 1357
 							$this->error = $new_fac_fourn->error;
@@ -1361,9 +1361,9 @@  discard block
 block discarded – undo
1361 1361
 
1362 1362
 					if (!$error && $facturerec->generate_pdf) {
1363 1363
 						// We refresh the object in order to have all necessary data (like date_lim_reglement)
1364
-						$laststep="Refresh {$new_fac_fourn->id}";
1364
+						$laststep = "Refresh {$new_fac_fourn->id}";
1365 1365
 						$new_fac_fourn->fetch($new_fac_fourn->id);
1366
-						$laststep="GenerateDocument {$new_fac_fourn->id}";
1366
+						$laststep = "GenerateDocument {$new_fac_fourn->id}";
1367 1367
 						$result = $new_fac_fourn->generateDocument($facturerec->model_pdf, $langs);
1368 1368
 						if ($result < 0) {
1369 1369
 							$this->errors = $new_fac_fourn->errors;
@@ -1373,22 +1373,22 @@  discard block
 block discarded – undo
1373 1373
 					}
1374 1374
 				} else {
1375 1375
 					$error++;
1376
-					$this->error = 'Failed to load invoice template with id=' .$line->rowid. ', entity=' .$conf->entity."\n";
1377
-					$this->errors[] = 'Failed to load invoice template with id=' .$line->rowid. ', entity=' .$conf->entity;
1378
-					dol_syslog('createRecurringInvoices Failed to load invoice template with id=' .$line->rowid. ', entity=' .$conf->entity);
1376
+					$this->error = 'Failed to load invoice template with id='.$line->rowid.', entity='.$conf->entity."\n";
1377
+					$this->errors[] = 'Failed to load invoice template with id='.$line->rowid.', entity='.$conf->entity;
1378
+					dol_syslog('createRecurringInvoices Failed to load invoice template with id='.$line->rowid.', entity='.$conf->entity);
1379 1379
 				}
1380 1380
 
1381 1381
 				if (!$error && $invoiceidgenerated >= 0) {
1382 1382
 					$facturerec->nb_gen_done++;
1383 1383
 					$facturerec->date_last_gen = dol_now();
1384
-					$facturerec->date_when= $facturerec->getNextDate();
1384
+					$facturerec->date_when = $facturerec->getNextDate();
1385 1385
 					$facturerec->update($user);
1386
-					$this->db->commit('createRecurringInvoices Process invoice template id=' .$facturerec->id. ', title=' .$facturerec->title);
1387
-					dol_syslog('createRecurringInvoices Process invoice template ' .$facturerec->title. ' is finished with a success generation');
1386
+					$this->db->commit('createRecurringInvoices Process invoice template id='.$facturerec->id.', title='.$facturerec->title);
1387
+					dol_syslog('createRecurringInvoices Process invoice template '.$facturerec->title.' is finished with a success generation');
1388 1388
 					$nb_create++;
1389 1389
 					$this->output .= $langs->trans('InvoiceGeneratedFromTemplate', $new_fac_fourn->ref, $facturerec->title)."\n";
1390 1390
 				} else {
1391
-					$this->db->rollback('createRecurringInvoices Process invoice template error='.$error.' invoiceidgenerated='.$invoiceidgenerated.' LastStep='.$laststep.' id=' .$facturerec->id. ', title=' .$facturerec->title);
1391
+					$this->db->rollback('createRecurringInvoices Process invoice template error='.$error.' invoiceidgenerated='.$invoiceidgenerated.' LastStep='.$laststep.' id='.$facturerec->id.', title='.$facturerec->title);
1392 1392
 				}
1393 1393
 
1394 1394
 				$parameters = array(
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 		}
1482 1482
 		$result .= $linkend;
1483 1483
 		global $action;
1484
-		$hookmanager->initHooks(array($this->element . 'dao'));
1484
+		$hookmanager->initHooks(array($this->element.'dao'));
1485 1485
 		$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1486 1486
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1487 1487
 		if ($reshook > 0) {
@@ -1660,8 +1660,8 @@  discard block
 block discarded – undo
1660 1660
 		$prodids = array();
1661 1661
 
1662 1662
 		$sql = 'SELECT rowid';
1663
-		$sql .= ' FROM ' .MAIN_DB_PREFIX. 'product';
1664
-		$sql .= ' WHERE entity IN (' .getEntity('product'). ')';
1663
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'product';
1664
+		$sql .= ' WHERE entity IN ('.getEntity('product').')';
1665 1665
 		$sql .= $this->db->plimit(100);
1666 1666
 
1667 1667
 		$resql = $this->db->query($sql);
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 			$xnbp = 0;
1701 1701
 			while ($xnbp < $nbp) {
1702 1702
 				$line = new FactureLigne($this->db);
1703
-				$line->desc = $langs->trans('Description'). ' ' .$xnbp;
1703
+				$line->desc = $langs->trans('Description').' '.$xnbp;
1704 1704
 				$line->qty = 1;
1705 1705
 				$line->subprice = 100;
1706 1706
 				$line->tva_tx = 19.6;
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
 
1748 1748
 			// Add a line "offered"
1749 1749
 			$line = new FactureLigne($this->db);
1750
-			$line->desc = $langs->trans('Description'). ' (offered line)';
1750
+			$line->desc = $langs->trans('Description').' (offered line)';
1751 1751
 			$line->qty = 1;
1752 1752
 			$line->subprice = 100;
1753 1753
 			$line->tva_tx = 19.6;
@@ -1794,12 +1794,12 @@  discard block
 block discarded – undo
1794 1794
 	public function setFrequencyAndUnit($frequency, $unit)
1795 1795
 	{
1796 1796
 		if (!$this->table_element) {
1797
-			dol_syslog(get_class($this). '::setFrequencyAndUnit was called on objet with property table_element not defined', LOG_ERR);
1797
+			dol_syslog(get_class($this).'::setFrequencyAndUnit was called on objet with property table_element not defined', LOG_ERR);
1798 1798
 			return -1;
1799 1799
 		}
1800 1800
 
1801 1801
 		if (!empty($frequency) && empty($unit)) {
1802
-			dol_syslog(get_class($this). '::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined', LOG_ERR);
1802
+			dol_syslog(get_class($this).'::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined', LOG_ERR);
1803 1803
 			return -2;
1804 1804
 		}
1805 1805
 
@@ -1838,11 +1838,11 @@  discard block
 block discarded – undo
1838 1838
 			return -1;
1839 1839
 		}
1840 1840
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
1841
-		$sql .= " SET date_when = " .($date ? "'".$this->db->idate($date)."'" : "NULL");
1841
+		$sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "NULL");
1842 1842
 		if ($increment_nb_gen_done > 0) {
1843 1843
 			$sql .= ", nb_gen_done = nb_gen_done + 1";
1844 1844
 		}
1845
-		$sql .= " WHERE rowid = " . (int) $this->id;
1845
+		$sql .= " WHERE rowid = ".(int) $this->id;
1846 1846
 
1847 1847
 		dol_syslog(get_class($this).'::setNextDate', LOG_DEBUG);
1848 1848
 
@@ -1876,8 +1876,8 @@  discard block
 block discarded – undo
1876 1876
 		}
1877 1877
 
1878 1878
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
1879
-		$sql .= " SET nb_gen_max = ". (int) $nb;
1880
-		$sql .= " WHERE rowid = " . (int) $this->id;
1879
+		$sql .= " SET nb_gen_max = ".(int) $nb;
1880
+		$sql .= " WHERE rowid = ".(int) $this->id;
1881 1881
 
1882 1882
 		dol_syslog(get_class($this).'::setMaxPeriod', LOG_DEBUG);
1883 1883
 
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
 
1906 1906
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
1907 1907
 		$sql .= " SET auto_validate = ".((int) $validate);
1908
-		$sql .= " WHERE rowid = " . (int) $this->id;
1908
+		$sql .= " WHERE rowid = ".(int) $this->id;
1909 1909
 
1910 1910
 		dol_syslog(get_class($this).'::setAutoValidate', LOG_DEBUG);
1911 1911
 
@@ -1932,8 +1932,8 @@  discard block
 block discarded – undo
1932 1932
 		}
1933 1933
 
1934 1934
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
1935
-		$sql .= " SET generate_pdf = ". (int) $validate;
1936
-		$sql .= " WHERE rowid = " . (int) $this->id;
1935
+		$sql .= " SET generate_pdf = ".(int) $validate;
1936
+		$sql .= " WHERE rowid = ".(int) $this->id;
1937 1937
 
1938 1938
 		dol_syslog(get_class($this).'::setGeneratePdf', LOG_DEBUG);
1939 1939
 
@@ -1961,7 +1961,7 @@  discard block
 block discarded – undo
1961 1961
 
1962 1962
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
1963 1963
 		$sql .= " SET modelpdf = '".$this->db->escape($model)."'";
1964
-		$sql .= " WHERE rowid = " . (int) $this->id;
1964
+		$sql .= " WHERE rowid = ".(int) $this->id;
1965 1965
 
1966 1966
 		dol_syslog(get_class($this).'::setModelPdf', LOG_DEBUG);
1967 1967
 
@@ -2034,8 +2034,8 @@  discard block
 block discarded – undo
2034 2034
 		$error = 0;
2035 2035
 		$this->db->begin();
2036 2036
 
2037
-		if (! $error) {
2038
-			if (! $notrigger) {
2037
+		if (!$error) {
2038
+			if (!$notrigger) {
2039 2039
 				// Call triggers
2040 2040
 				$result = $this->call_trigger('LINESUPPLIERBILLREC_DELETE', $user);
2041 2041
 				if ($result < 0) {
@@ -2045,15 +2045,15 @@  discard block
 block discarded – undo
2045 2045
 			}
2046 2046
 		}
2047 2047
 
2048
-		if (! $error) {
2048
+		if (!$error) {
2049 2049
 			$result = $this->deleteExtraFields();
2050 2050
 			if ($result < 0) {
2051 2051
 				$error++;
2052 2052
 			}
2053 2053
 		}
2054 2054
 
2055
-		if (! $error) {
2056
-			$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . ' WHERE rowid=' . (int) $this->id;
2055
+		if (!$error) {
2056
+			$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.(int) $this->id;
2057 2057
 
2058 2058
 			$res = $this->db->query($sql);
2059 2059
 			if ($res === false) {
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
 		$sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
2094 2094
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det_rec as l';
2095 2095
 		$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
2096
-		$sql .= ' WHERE l.rowid = '. (int) $rowid;
2096
+		$sql .= ' WHERE l.rowid = '.(int) $rowid;
2097 2097
 		$sql .= ' ORDER BY l.rang';
2098 2098
 
2099 2099
 		dol_syslog('FactureRec::fetch', LOG_DEBUG);
@@ -2165,44 +2165,44 @@  discard block
 block discarded – undo
2165 2165
 
2166 2166
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
2167 2167
 
2168
-		$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec SET';
2169
-		$sql .= ' fk_facture_fourn = ' . (int) $this->fk_facture_fourn;
2170
-		$sql .= ', fk_parent_line = ' . (int) $this->fk_parent;
2171
-		$sql .= ', fk_product = ' . (int) $this->fk_product;
2172
-		$sql .= ', ref = ' . (!empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'NULL');
2173
-		$sql .= ", label = " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'NULL');
2174
-		$sql .= ", description = '" . $this->db->escape($this->description) . "'";
2175
-		$sql .= ', pu_ht = ' . price2num($this->pu_ht);
2176
-		$sql .= ', pu_ttc = ' . price2num($this->pu_ttc);
2177
-		$sql .= ', qty = ' . price2num($this->qty);
2178
-		$sql .= ", remise_percent = '" . price2num($this->remise_percent) . "'";
2179
-		$sql .= ', fk_remise_except = ' . (int) $this->fk_remise_except;
2180
-		$sql .= ", vat_src_code = '" . $this->db->escape($this->vat_src_code) . "'";
2181
-		$sql .= ', tva_tx = ' . price2num($this->tva_tx);
2182
-		$sql .= ', localtax1_tx = ' . price2num($this->localtax1_tx);
2183
-		$sql .= ", localtax1_type = '" . $this->db->escape($this->localtax1_type) . "'";
2184
-		$sql .= ', localtax2_tx = ' . price2num($this->localtax2_tx);
2185
-		$sql .= ", localtax2_type = '" . $this->db->escape($this->localtax2_type) . "'";
2168
+		$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn_det_rec SET';
2169
+		$sql .= ' fk_facture_fourn = '.(int) $this->fk_facture_fourn;
2170
+		$sql .= ', fk_parent_line = '.(int) $this->fk_parent;
2171
+		$sql .= ', fk_product = '.(int) $this->fk_product;
2172
+		$sql .= ', ref = '.(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'NULL');
2173
+		$sql .= ", label = ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : 'NULL');
2174
+		$sql .= ", description = '".$this->db->escape($this->description)."'";
2175
+		$sql .= ', pu_ht = '.price2num($this->pu_ht);
2176
+		$sql .= ', pu_ttc = '.price2num($this->pu_ttc);
2177
+		$sql .= ', qty = '.price2num($this->qty);
2178
+		$sql .= ", remise_percent = '".price2num($this->remise_percent)."'";
2179
+		$sql .= ', fk_remise_except = '.(int) $this->fk_remise_except;
2180
+		$sql .= ", vat_src_code = '".$this->db->escape($this->vat_src_code)."'";
2181
+		$sql .= ', tva_tx = '.price2num($this->tva_tx);
2182
+		$sql .= ', localtax1_tx = '.price2num($this->localtax1_tx);
2183
+		$sql .= ", localtax1_type = '".$this->db->escape($this->localtax1_type)."'";
2184
+		$sql .= ', localtax2_tx = '.price2num($this->localtax2_tx);
2185
+		$sql .= ", localtax2_type = '".$this->db->escape($this->localtax2_type)."'";
2186 2186
 		if (empty($this->skip_update_total)) {
2187
-			$sql .= ', total_ht = ' . price2num($this->total_ht);
2188
-			$sql .= ', total_tva = ' . price2num($this->total_tva);
2189
-			$sql .= ', total_localtax1 = ' . price2num($this->total_localtax1);
2190
-			$sql .= ', total_localtax2 = ' . price2num($this->total_localtax2);
2191
-			$sql .= ', total_ttc = ' . price2num($this->total_ttc);
2187
+			$sql .= ', total_ht = '.price2num($this->total_ht);
2188
+			$sql .= ', total_tva = '.price2num($this->total_tva);
2189
+			$sql .= ', total_localtax1 = '.price2num($this->total_localtax1);
2190
+			$sql .= ', total_localtax2 = '.price2num($this->total_localtax2);
2191
+			$sql .= ', total_ttc = '.price2num($this->total_ttc);
2192 2192
 		}
2193
-		$sql .= ', product_type = ' . (int) $this->product_type;
2194
-		$sql .= ', date_start = ' . (int) $this->date_start;
2195
-		$sql .= ', date_end = ' . (int) $this->date_end;
2196
-		$sql .= ", info_bits = " . ((int) $this->info_bits);
2197
-		$sql .= ', special_code =' . (int) $this->special_code;
2198
-		$sql .= ', rang = ' . (int) $this->rang;
2199
-		$sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
2200
-		$sql .= ', fk_user_modif = ' . (int) $user;
2201
-		$sql .= ' WHERE rowid = ' . (int) $this->id;
2193
+		$sql .= ', product_type = '.(int) $this->product_type;
2194
+		$sql .= ', date_start = '.(int) $this->date_start;
2195
+		$sql .= ', date_end = '.(int) $this->date_end;
2196
+		$sql .= ", info_bits = ".((int) $this->info_bits);
2197
+		$sql .= ', special_code ='.(int) $this->special_code;
2198
+		$sql .= ', rang = '.(int) $this->rang;
2199
+		$sql .= ', fk_unit = '.($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
2200
+		$sql .= ', fk_user_modif = '.(int) $user;
2201
+		$sql .= ' WHERE rowid = '.(int) $this->id;
2202 2202
 
2203 2203
 		$this->db->begin();
2204 2204
 
2205
-		dol_syslog(get_class($this). '::updateline', LOG_DEBUG);
2205
+		dol_syslog(get_class($this).'::updateline', LOG_DEBUG);
2206 2206
 		$resql = $this->db->query($sql);
2207 2207
 		if ($resql) {
2208 2208
 			if (!$error) {
Please login to merge, or discard this patch.