Completed
Branch develop (c08ce9)
by
unknown
22:04
created
htdocs/accountancy/class/bookkeeping.class.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			$this->credit = 0.0;
303 303
 		}
304 304
 
305
-		$result = $this->validBookkeepingDate($this->doc_date);	// Check date according to ACCOUNTANCY_FISCAL_PERIOD_MODE.
305
+		$result = $this->validBookkeepingDate($this->doc_date); // Check date according to ACCOUNTANCY_FISCAL_PERIOD_MODE.
306 306
 		if ($result < 0) {
307 307
 			return -1;
308 308
 		} elseif ($result == 0) {
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 				if (empty($this->piece_num)) {
392 392
 					$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
393 393
 					$sqlnum .= " FROM ".$this->db->prefix().$this->table_element;
394
-					$sqlnum .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
394
+					$sqlnum .= " WHERE entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
395 395
 
396 396
 					$resqlnum = $this->db->query($sqlnum);
397 397
 					if ($resqlnum) {
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		}
492 492
 
493 493
 		// Call triggers
494
-		if (! $error && ! $notrigger) {
494
+		if (!$error && !$notrigger) {
495 495
 			$result = $this->call_trigger('BOOKKEEPING_CREATE', $user);
496 496
 			if ($result < 0) {
497 497
 				$error++;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
640 640
 
641 641
 		global $action;
642
-		$hookmanager->initHooks(array($this->element . 'dao'));
642
+		$hookmanager->initHooks(array($this->element.'dao'));
643 643
 		$parameters = array('id' => $this->id, 'getnomurl' => &$result);
644 644
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
645 645
 		if ($reshook > 0) {
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 		if (!$error) {
809 809
 			$this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element.$mode);
810 810
 			// Call triggers
811
-			if (! $notrigger) {
811
+			if (!$notrigger) {
812 812
 				$result = $this->call_trigger('BOOKKEEPING_CREATE', $user);
813 813
 				if ($result < 0) {
814 814
 					$error++;
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		$sql .= " t.date_validated as date_validation";
875 875
 		$sql .= ' FROM '.$this->db->prefix().$this->table_element.$mode.' as t';
876 876
 		$sql .= ' WHERE 1 = 1';
877
-		$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
877
+		$sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
878 878
 		if (null !== $ref) {
879 879
 			$sql .= " AND t.rowid = ".((int) $ref);
880 880
 		} else {
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 			}
1051 1051
 		}
1052 1052
 		$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
1053
-		$sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
1053
+		$sql .= ' WHERE entity = '.((int) $conf->entity); // Do not use getEntity for accounting features
1054 1054
 		if (count($sqlwhere) > 0) {
1055 1055
 			$sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere);
1056 1056
 		}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		$sql .= " t.date_validated as date_validation";
1187 1187
 		$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
1188 1188
 
1189
-		$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
1189
+		$sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features
1190 1190
 		if ($showAlreadyExportMovements == 0) {
1191 1191
 			$sql .= " AND t.date_export IS NULL";
1192 1192
 		}
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
 		$sql .= " SUM(t.debit) as debit,";
1357 1357
 		$sql .= " SUM(t.credit) as credit";
1358 1358
 		$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
1359
-		$sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
1359
+		$sql .= ' WHERE entity = '.((int) $conf->entity); // Do not use getEntity for accounting features
1360 1360
 
1361 1361
 		// Manage filter
1362 1362
 		if (is_array($filter)) {
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 		}
1585 1585
 
1586 1586
 		// Call triggers
1587
-		if (! $error && ! $notrigger) {
1587
+		if (!$error && !$notrigger) {
1588 1588
 			$result = $this->call_trigger('BOOKKEEPING_MODIFY', $user);
1589 1589
 			if ($result < 0) {
1590 1590
 				$error++;
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
 		if (!empty($journal)) {
1781 1781
 			$sql .= " AND code_journal = '".$this->db->escape($journal)."'";
1782 1782
 		}
1783
-		$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
1783
+		$sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
1784 1784
 		// Exclusion of validated entries at the time of deletion
1785 1785
 		$sql .= " AND date_validated IS NULL";
1786 1786
 		$sql .= $sql_filter;
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
 		$this->db->begin();
1827 1827
 
1828 1828
 		// Call triggers
1829
-		if (! $error && ! $notrigger) {
1829
+		if (!$error && !$notrigger) {
1830 1830
 			$result = $this->call_trigger('BOOKKEEPING_DELETE', $user);
1831 1831
 			if ($result < 0) {
1832 1832
 				$error++;
@@ -1838,8 +1838,8 @@  discard block
 block discarded – undo
1838 1838
 			$sql = "DELETE";
1839 1839
 			$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
1840 1840
 			$sql .= " WHERE piece_num = ".(int) $piecenum;
1841
-			$sql .= " AND date_validated IS NULL";		// For security, exclusion of validated entries at the time of deletion
1842
-			$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
1841
+			$sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion
1842
+			$sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
1843 1843
 			$sql .= $sql_filter;
1844 1844
 
1845 1845
 			$resql = $this->db->query($sql);
@@ -1973,7 +1973,7 @@  discard block
 block discarded – undo
1973 1973
 		}
1974 1974
 		$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
1975 1975
 		$sql .= " WHERE piece_num = ".((int) $piecenum);
1976
-		$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
1976
+		$sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
1977 1977
 
1978 1978
 		dol_syslog(__METHOD__, LOG_DEBUG);
1979 1979
 		$result = $this->db->query($sql);
@@ -2015,7 +2015,7 @@  discard block
 block discarded – undo
2015 2015
 		global $conf;
2016 2016
 
2017 2017
 		$sql = "SELECT MAX(piece_num) + 1 as max FROM ".$this->db->prefix().$this->table_element.$mode;
2018
-		$sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
2018
+		$sql .= " WHERE entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
2019 2019
 
2020 2020
 		dol_syslog(get_class($this)."::getNextNumMvt", LOG_DEBUG);
2021 2021
 
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 		if (getDolGlobalString('BOOKKEEPING_ADDON')) {
2052 2052
 			$mybool = false;
2053 2053
 
2054
-			$file = getDolGlobalString('BOOKKEEPING_ADDON') . ".php";
2054
+			$file = getDolGlobalString('BOOKKEEPING_ADDON').".php";
2055 2055
 			$classname = getDolGlobalString('BOOKKEEPING_ADDON');
2056 2056
 
2057 2057
 			// Include file with class
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 		}
2112 2112
 		$sql .= " FROM ".$this->db->prefix().$this->table_element.$mode;
2113 2113
 		$sql .= " WHERE piece_num = ".((int) $piecenum);
2114
-		$sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
2114
+		$sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
2115 2115
 
2116 2116
 		dol_syslog(__METHOD__, LOG_DEBUG);
2117 2117
 		$result = $this->db->query($sql);
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 		$sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num,";
2177 2177
 		$sql .= " date_validated as date_validation";
2178 2178
 		$sql .= " FROM ".$this->db->prefix().$this->table_element;
2179
-		$sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
2179
+		$sql .= " WHERE entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
2180 2180
 
2181 2181
 		dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG);
2182 2182
 
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
 
2262 2262
 			if (!$error) {
2263 2263
 				// Delete if there is an empty line
2264
-				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0";
2264
+				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0";
2265 2265
 				$resql = $this->db->query($sql);
2266 2266
 				if (!$resql) {
2267 2267
 					$error++;
@@ -2275,11 +2275,11 @@  discard block
 block discarded – undo
2275 2275
 				$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
2276 2276
 				$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
2277 2277
 				$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)';
2278
-				$sql .= ' SELECT doc_date, doc_type,' . "'{$ref}',";
2278
+				$sql .= ' SELECT doc_date, doc_type,'."'{$ref}',";
2279 2279
 				$sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,';
2280 2280
 				$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
2281 2281
 				$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'";
2282
-				$sql .= ' FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity);
2282
+				$sql .= ' FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = '.((int) $conf->entity);
2283 2283
 				$sql .= $sql_filter;
2284 2284
 				$resql = $this->db->query($sql);
2285 2285
 				if (!$resql) {
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 			}
2291 2291
 
2292 2292
 			if (!$error) {
2293
-				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
2293
+				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity);
2294 2294
 				$resql = $this->db->query($sql);
2295 2295
 				if (!$resql) {
2296 2296
 					$error++;
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 			}
2301 2301
 		} elseif ($direction == 1) {
2302 2302
 			if (!$error) {
2303
-				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
2303
+				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity);
2304 2304
 				$resql = $this->db->query($sql);
2305 2305
 				if (!$resql) {
2306 2306
 					$error++;
@@ -2314,11 +2314,11 @@  discard block
 block discarded – undo
2314 2314
 				$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
2315 2315
 				$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
2316 2316
 				$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
2317
-				$sql .= ' SELECT doc_date, doc_type,' . "'{$ref}',";
2317
+				$sql .= ' SELECT doc_date, doc_type,'."'{$ref}',";
2318 2318
 				$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
2319 2319
 				$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
2320 2320
 				$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
2321
-				$sql .= ' FROM '.$this->db->prefix().$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
2321
+				$sql .= ' FROM '.$this->db->prefix().$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity);
2322 2322
 				$sql .= $sql_filter;
2323 2323
 				$resql = $this->db->query($sql);
2324 2324
 				if (!$resql) {
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
 			}
2330 2330
 
2331 2331
 			if (!$error) {
2332
-				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
2332
+				$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity);
2333 2333
 				$sql .= $sql_filter;
2334 2334
 				$resql = $this->db->query($sql);
2335 2335
 				if (!$resql) {
@@ -2386,7 +2386,7 @@  discard block
 block discarded – undo
2386 2386
 		$sql .= " AND aa.active = 1";
2387 2387
 		$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
2388 2388
 		$sql .= " AND asy.rowid = ".((int) $pcgver);
2389
-		$sql .= " AND ab.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
2389
+		$sql .= " AND ab.entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
2390 2390
 		$sql .= " ORDER BY account_number ASC";
2391 2391
 
2392 2392
 		dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
 		$sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1";
2451 2451
 		$sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1";
2452 2452
 		$sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
2453
-		$sql .= " AND aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
2453
+		$sql .= " AND aa.entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
2454 2454
 
2455 2455
 		dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
2456 2456
 		$resql = $this->db->query($sql);
@@ -2490,7 +2490,7 @@  discard block
 block discarded – undo
2490 2490
 		$sql .= " AND asy.rowid = ".((int) $pcgver);
2491 2491
 		$sql .= " AND aa.active = 1";
2492 2492
 		$sql .= " LEFT JOIN ".$this->db->prefix()."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
2493
-		$sql .= " WHERE aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features
2493
+		$sql .= " WHERE aa.entity = ".((int) $conf->entity); // Do not use getEntity for accounting features
2494 2494
 
2495 2495
 		dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
2496 2496
 		$resql = $this->db->query($sql);
@@ -2523,7 +2523,7 @@  discard block
 block discarded – undo
2523 2523
 		global $conf;
2524 2524
 
2525 2525
 		$alias = trim($alias);
2526
-		$alias = !empty($alias) && strpos($alias, '.') === false ? $alias . "." : $alias;
2526
+		$alias = !empty($alias) && strpos($alias, '.') === false ? $alias."." : $alias;
2527 2527
 
2528 2528
 		if (!isset(self::$can_modify_bookkeeping_sql_cached[$alias]) || $force) {
2529 2529
 			$result = $this->loadFiscalPeriods($force, 'active');
@@ -2536,10 +2536,10 @@  discard block
 block discarded – undo
2536 2536
 				$i = 0;
2537 2537
 				foreach ($conf->cache['active_fiscal_period_cached'] as $fiscal_period) {
2538 2538
 					$sql_list[$i] = "(";
2539
-					$sql_list[$i] .= "'".$this->db->idate($fiscal_period['date_start']) . "' <= ".$this->db->sanitize($alias)."doc_date";
2539
+					$sql_list[$i] .= "'".$this->db->idate($fiscal_period['date_start'])."' <= ".$this->db->sanitize($alias)."doc_date";
2540 2540
 					if (!empty($fiscal_period['date_end'])) {
2541 2541
 						$sql_list[$i] .= " AND ";
2542
-						$sql_list[$i] .= $this->db->sanitize($alias)."doc_date <= '" . $this->db->idate($fiscal_period['date_end'])."'";
2542
+						$sql_list[$i] .= $this->db->sanitize($alias)."doc_date <= '".$this->db->idate($fiscal_period['date_end'])."'";
2543 2543
 					}
2544 2544
 					$sql_list[$i] .= ")";
2545 2545
 					$i++;
@@ -2634,10 +2634,10 @@  discard block
 block discarded – undo
2634 2634
 				$accountingLabelOperation = $thirdpartyname;
2635 2635
 			}
2636 2636
 			if (!empty($reference)) {
2637
-				$accountingLabelOperation .= ' - '. $reference;
2637
+				$accountingLabelOperation .= ' - '.$reference;
2638 2638
 			}
2639 2639
 			if (!empty($labelaccount)) {
2640
-				$accountingLabelOperation .= ' - '. $labelaccount;
2640
+				$accountingLabelOperation .= ' - '.$labelaccount;
2641 2641
 			}
2642 2642
 		} elseif (getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) {
2643 2643
 			$truncThirdpartyName = 32;
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
 				$accountingLabelOperation = $thirdpartyname;
2649 2649
 			}
2650 2650
 			if (!empty($reference)) {
2651
-				$accountingLabelOperation .= ' - '. $reference;
2651
+				$accountingLabelOperation .= ' - '.$reference;
2652 2652
 			}
2653 2653
 		} elseif (getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) {
2654 2654
 			$truncThirdpartyName = 64;
@@ -2721,8 +2721,8 @@  discard block
 block discarded – undo
2721 2721
 		if ($mode == 'active') {
2722 2722
 			if (!isset($conf->cache['active_fiscal_period_cached']) || $force) {
2723 2723
 				$sql = "SELECT date_start, date_end";
2724
-				$sql .= " FROM " . $this->db->prefix() . "accounting_fiscalyear";
2725
-				$sql .= " WHERE entity = " . ((int) $conf->entity);
2724
+				$sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear";
2725
+				$sql .= " WHERE entity = ".((int) $conf->entity);
2726 2726
 				$sql .= " AND statut = 0";
2727 2727
 
2728 2728
 				$resql = $this->db->query($sql);
@@ -2744,8 +2744,8 @@  discard block
 block discarded – undo
2744 2744
 		if ($mode == 'closed') {
2745 2745
 			if (!isset($conf->cache['closed_fiscal_period_cached']) || $force) {
2746 2746
 				$sql = "SELECT date_start, date_end";
2747
-				$sql .= " FROM " . $this->db->prefix() . "accounting_fiscalyear";
2748
-				$sql .= " WHERE entity = " . ((int) $conf->entity);
2747
+				$sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear";
2748
+				$sql .= " WHERE entity = ".((int) $conf->entity);
2749 2749
 				$sql .= " AND statut = 1";
2750 2750
 
2751 2751
 				$resql = $this->db->query($sql);
@@ -2779,8 +2779,8 @@  discard block
 block discarded – undo
2779 2779
 		$list = array();
2780 2780
 
2781 2781
 		$sql = "SELECT rowid, label, date_start, date_end, statut";
2782
-		$sql .= " FROM " . $this->db->prefix() . "accounting_fiscalyear";
2783
-		$sql .= " WHERE entity = " . ((int) $conf->entity);
2782
+		$sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear";
2783
+		$sql .= " WHERE entity = ".((int) $conf->entity);
2784 2784
 		$sql .= $this->db->order('date_start', 'ASC');
2785 2785
 
2786 2786
 		$resql = $this->db->query($sql);
@@ -2819,13 +2819,13 @@  discard block
 block discarded – undo
2819 2819
 
2820 2820
 		$sql = "SELECT YEAR(b.doc_date) as year";
2821 2821
 		for ($i = 1; $i <= 12; $i++) {
2822
-			$sql .= ", SUM(".$this->db->ifsql("MONTH(b.doc_date) = ".((int) $i), "1", "0") . ") AS month".((int) $i);
2822
+			$sql .= ", SUM(".$this->db->ifsql("MONTH(b.doc_date) = ".((int) $i), "1", "0").") AS month".((int) $i);
2823 2823
 		}
2824 2824
 		$sql .= ", COUNT(b.rowid) as total";
2825
-		$sql .= " FROM " . $this->db->prefix() . $this->table_element . " as b";
2826
-		$sql .= " WHERE b.doc_date >= '" . $this->db->idate($date_start) . "'";
2827
-		$sql .= " AND b.doc_date <= '" . $this->db->idate($date_end) . "'";
2828
-		$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy
2825
+		$sql .= " FROM ".$this->db->prefix().$this->table_element." as b";
2826
+		$sql .= " WHERE b.doc_date >= '".$this->db->idate($date_start)."'";
2827
+		$sql .= " AND b.doc_date <= '".$this->db->idate($date_end)."'";
2828
+		$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
2829 2829
 
2830 2830
 		// Get count for each month into the fiscal period
2831 2831
 		if (getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) {
@@ -2833,7 +2833,7 @@  discard block
 block discarded – undo
2833 2833
 			$sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX.'accounting_fiscalyear as af WHERE b.doc_date >= af.date_start AND b.doc_date <= af.date_end AND af.entity = '.((int) $conf->entity)." AND af.statut = 1)";
2834 2834
 		} else {
2835 2835
 			// Filter on the unitary flag/date lock on each record
2836
-			$sql .= " AND date_validated IS NULL";	// not locked
2836
+			$sql .= " AND date_validated IS NULL"; // not locked
2837 2837
 		}
2838 2838
 
2839 2839
 		$sql .= " GROUP BY YEAR(b.doc_date)";
@@ -2854,7 +2854,7 @@  discard block
 block discarded – undo
2854 2854
 				'total' => (int) $obj->total,
2855 2855
 			);
2856 2856
 			for ($i = 1; $i <= 12; $i++) {
2857
-				$year_list['count'][$i] = (int) $obj->{'month' . $i};
2857
+				$year_list['count'][$i] = (int) $obj->{'month'.$i};
2858 2858
 			}
2859 2859
 
2860 2860
 			$list[] = $year_list;
@@ -2882,11 +2882,11 @@  discard block
 block discarded – undo
2882 2882
 		$now = dol_now();
2883 2883
 
2884 2884
 		// Specify as export : update field date_validated on selected month/year
2885
-		$sql = " UPDATE " . $this->db->prefix() . $this->table_element;
2886
-		$sql .= " SET date_validated = '" . $this->db->idate($now) . "'";
2887
-		$sql .= " WHERE entity = " . ((int) $conf->entity);
2888
-		$sql .= " AND DATE(doc_date) >= '" . $this->db->idate($date_start) . "'";
2889
-		$sql .= " AND DATE(doc_date) <= '" . $this->db->idate($date_end) . "'";
2885
+		$sql = " UPDATE ".$this->db->prefix().$this->table_element;
2886
+		$sql .= " SET date_validated = '".$this->db->idate($now)."'";
2887
+		$sql .= " WHERE entity = ".((int) $conf->entity);
2888
+		$sql .= " AND DATE(doc_date) >= '".$this->db->idate($date_start)."'";
2889
+		$sql .= " AND DATE(doc_date) <= '".$this->db->idate($date_end)."'";
2890 2890
 		$sql .= " AND date_validated IS NULL";
2891 2891
 
2892 2892
 		dol_syslog(__METHOD__, LOG_DEBUG);
@@ -2919,27 +2919,27 @@  discard block
 block discarded – undo
2919 2919
 
2920 2920
 			$pcg_type_filter = array();
2921 2921
 			foreach ($accounting_groups_used_for_income_statement as $item) {
2922
-				$pcg_type_filter[] = "'" . $this->db->escape($item) . "'";
2922
+				$pcg_type_filter[] = "'".$this->db->escape($item)."'";
2923 2923
 			}
2924 2924
 
2925 2925
 			$sql = 'SELECT';
2926 2926
 			$sql .= " t.numero_compte,";
2927 2927
 			$sql .= " aa.pcg_type,";
2928 2928
 			$sql .= " (SUM(t.credit) - SUM(t.debit)) as accounting_result";
2929
-			$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t';
2930
-			$sql .= ' LEFT JOIN  ' . $this->db->prefix() . 'accounting_account as aa ON aa.account_number = t.numero_compte';
2931
-			$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
2932
-			$sql .= " AND aa.entity = " . ((int) $conf->entity);
2933
-			$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM ' . $this->db->prefix() . 'accounting_system WHERE rowid = ' . ((int) getDolGlobalInt('CHARTOFACCOUNTS')) . ')';
2934
-			$sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')';
2935
-			$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($date_start) . "'";
2936
-			$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($date_end) . "'";
2929
+			$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
2930
+			$sql .= ' LEFT JOIN  '.$this->db->prefix().'accounting_account as aa ON aa.account_number = t.numero_compte';
2931
+			$sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features
2932
+			$sql .= " AND aa.entity = ".((int) $conf->entity);
2933
+			$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM '.$this->db->prefix().'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')';
2934
+			$sql .= ' AND aa.pcg_type IN ('.$this->db->sanitize(implode(',', $pcg_type_filter), 1).')';
2935
+			$sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($date_start)."'";
2936
+			$sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($date_end)."'";
2937 2937
 			$sql .= ' GROUP BY t.numero_compte, aa.pcg_type';
2938 2938
 
2939 2939
 			$resql = $this->db->query($sql);
2940 2940
 			if (!$resql) {
2941
-				$this->errors[] = 'Error ' . $this->db->lasterror();
2942
-				dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
2941
+				$this->errors[] = 'Error '.$this->db->lasterror();
2942
+				dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
2943 2943
 			} else {
2944 2944
 				while ($obj = $this->db->fetch_object($resql)) {
2945 2945
 					$income_statement_amount += $obj->accounting_result;
@@ -2978,7 +2978,7 @@  discard block
 block discarded – undo
2978 2978
 			return -1;
2979 2979
 		} elseif (empty($fiscal_period->id)) {
2980 2980
 			$langs->loadLangs(array('errors', 'compta'));
2981
-			$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $fiscal_period_id . ')';
2981
+			$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$fiscal_period_id.')';
2982 2982
 			return -1;
2983 2983
 		}
2984 2984
 
@@ -2997,7 +2997,7 @@  discard block
 block discarded – undo
2997 2997
 			return -1;
2998 2998
 		} elseif (empty($new_fiscal_period->id)) {
2999 2999
 			$langs->loadLangs(array('errors', 'compta'));
3000
-			$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $new_fiscal_period_id . ')';
3000
+			$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$new_fiscal_period_id.')';
3001 3001
 			return -1;
3002 3002
 		}
3003 3003
 
@@ -3017,7 +3017,7 @@  discard block
 block discarded – undo
3017 3017
 			$journal_id = max(0, getDolGlobalString('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL'));
3018 3018
 			if (empty($journal_id)) {
3019 3019
 				$langs->loadLangs(array('errors', 'accountancy'));
3020
-				$this->errors[] = $langs->trans('ErrorBadParameters') . ' - ' . $langs->trans('Codejournal') . ' (' . $langs->trans('AccountingJournalType9') . ')';
3020
+				$this->errors[] = $langs->trans('ErrorBadParameters').' - '.$langs->trans('Codejournal').' ('.$langs->trans('AccountingJournalType9').')';
3021 3021
 				$error++;
3022 3022
 			}
3023 3023
 
@@ -3031,7 +3031,7 @@  discard block
 block discarded – undo
3031 3031
 					$error++;
3032 3032
 				} elseif ($result == 0) {
3033 3033
 					$langs->loadLangs(array('errors', 'accountancy'));
3034
-					$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('Codejournal') . ' (' . $langs->trans('AccountingJournalType9') . ')';
3034
+					$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('Codejournal').' ('.$langs->trans('AccountingJournalType9').')';
3035 3035
 					$error++;
3036 3036
 				}
3037 3037
 			} else {
@@ -3045,7 +3045,7 @@  discard block
 block discarded – undo
3045 3045
 				$pcg_type_filter = array();
3046 3046
 				$tmp = array_merge($accounting_groups_used_for_balance_sheet_account, $accounting_groups_used_for_income_statement);
3047 3047
 				foreach ($tmp as $item) {
3048
-					$pcg_type_filter[] = "'" . $this->db->escape($item) . "'";
3048
+					$pcg_type_filter[] = "'".$this->db->escape($item)."'";
3049 3049
 				}
3050 3050
 
3051 3051
 				$sql = 'SELECT';
@@ -3055,14 +3055,14 @@  discard block
 block discarded – undo
3055 3055
 				}
3056 3056
 				$sql .= " aa.pcg_type,";
3057 3057
 				$sql .= " (SUM(t.credit) - SUM(t.debit)) as opening_balance";
3058
-				$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t';
3059
-				$sql .= ' LEFT JOIN  ' . $this->db->prefix() . 'accounting_account as aa ON aa.account_number = t.numero_compte';
3060
-				$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
3061
-				$sql .= " AND aa.entity = ". ((int) $conf->entity);
3058
+				$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
3059
+				$sql .= ' LEFT JOIN  '.$this->db->prefix().'accounting_account as aa ON aa.account_number = t.numero_compte';
3060
+				$sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features
3061
+				$sql .= " AND aa.entity = ".((int) $conf->entity);
3062 3062
 				$sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM '.$this->db->prefix().'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')';
3063
-				$sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')';
3064
-				$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'";
3065
-				$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'";
3063
+				$sql .= ' AND aa.pcg_type IN ('.$this->db->sanitize(implode(',', $pcg_type_filter), 1).')';
3064
+				$sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($fiscal_period->date_start)."'";
3065
+				$sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($fiscal_period->date_end)."'";
3066 3066
 				$sql .= ' GROUP BY t.numero_compte, aa.pcg_type';
3067 3067
 				if ($separate_auxiliary_account) {
3068 3068
 					$sql .= " , NULLIF(t.subledger_account, '')";
@@ -3072,8 +3072,8 @@  discard block
 block discarded – undo
3072 3072
 
3073 3073
 				$resql = $this->db->query($sql);
3074 3074
 				if (!$resql) {
3075
-					$this->errors[] = 'Error ' . $this->db->lasterror();
3076
-					dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
3075
+					$this->errors[] = 'Error '.$this->db->lasterror();
3076
+					dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
3077 3077
 
3078 3078
 					$error++;
3079 3079
 				} else {
@@ -3102,14 +3102,14 @@  discard block
 block discarded – undo
3102 3102
 								$bookkeeping->subledger_account = $obj->subledger_account;
3103 3103
 								$sql = 'SELECT';
3104 3104
 								$sql .= " subledger_label";
3105
-								$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
3106
-								$sql .= " WHERE subledger_account = '" . $this->db->escape($obj->subledger_account) . "'";
3105
+								$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
3106
+								$sql .= " WHERE subledger_account = '".$this->db->escape($obj->subledger_account)."'";
3107 3107
 								$sql .= " ORDER BY doc_date DESC";
3108 3108
 								$sql .= " LIMIT 1";
3109 3109
 								$result = $this->db->query($sql);
3110 3110
 								if (!$result) {
3111
-									$this->errors[] = 'Error: ' . $this->db->lasterror();
3112
-									dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
3111
+									$this->errors[] = 'Error: '.$this->db->lasterror();
3112
+									dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
3113 3113
 									$error++;
3114 3114
 								}
3115 3115
 								$objtmp = $this->db->fetch_object($result);
@@ -3165,14 +3165,14 @@  discard block
 block discarded – undo
3165 3165
 							$bookkeeping->subledger_account = $obj->subledger_account;
3166 3166
 							$sql = 'SELECT';
3167 3167
 							$sql .= " subledger_label";
3168
-							$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
3169
-							$sql .= " WHERE subledger_account = '" . $this->db->escape($obj->subledger_account) . "'";
3168
+							$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
3169
+							$sql .= " WHERE subledger_account = '".$this->db->escape($obj->subledger_account)."'";
3170 3170
 							$sql .= " ORDER BY doc_date DESC";
3171 3171
 							$sql .= " LIMIT 1";
3172 3172
 							$result = $this->db->query($sql);
3173 3173
 							if (!$result) {
3174
-								$this->errors[] = 'Error: ' . $this->db->lasterror();
3175
-								dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
3174
+								$this->errors[] = 'Error: '.$this->db->lasterror();
3175
+								dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
3176 3176
 								$error++;
3177 3177
 							}
3178 3178
 							$objtmp = $this->db->fetch_object($result);
@@ -3244,7 +3244,7 @@  discard block
 block discarded – undo
3244 3244
 			return -1;
3245 3245
 		} elseif (empty($fiscal_period->id)) {
3246 3246
 			$langs->loadLangs(array('errors', 'compta'));
3247
-			$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $fiscal_period_id . ')';
3247
+			$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$fiscal_period_id.')';
3248 3248
 			return -1;
3249 3249
 		}
3250 3250
 
@@ -3263,7 +3263,7 @@  discard block
 block discarded – undo
3263 3263
 			return -1;
3264 3264
 		} elseif (empty($new_fiscal_period->id)) {
3265 3265
 			$langs->loadLangs(array('errors', 'compta'));
3266
-			$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $new_fiscal_period_id . ')';
3266
+			$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$new_fiscal_period_id.')';
3267 3267
 			return -1;
3268 3268
 		}
3269 3269
 
@@ -3283,7 +3283,7 @@  discard block
 block discarded – undo
3283 3283
 			return -1;
3284 3284
 		} elseif ($result == 0) {
3285 3285
 			$langs->loadLangs(array('errors', 'accountancy'));
3286
-			$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('InventoryJournal');
3286
+			$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('InventoryJournal');
3287 3287
 			return -1;
3288 3288
 		}
3289 3289
 
@@ -3291,18 +3291,18 @@  discard block
 block discarded – undo
3291 3291
 		$this->db->begin();
3292 3292
 
3293 3293
 		$sql = 'SELECT t.rowid';
3294
-		$sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t';
3295
-		$sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features
3296
-		$sql .= " AND code_journal = '" . $this->db->escape($inventory_journal->code) . "'";
3297
-		$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($date_start) . "'";
3298
-		$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($date_end) . "'";
3299
-		$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'";
3300
-		$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'";
3294
+		$sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t';
3295
+		$sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features
3296
+		$sql .= " AND code_journal = '".$this->db->escape($inventory_journal->code)."'";
3297
+		$sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($date_start)."'";
3298
+		$sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($date_end)."'";
3299
+		$sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($fiscal_period->date_start)."'";
3300
+		$sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($fiscal_period->date_end)."'";
3301 3301
 
3302 3302
 		$resql = $this->db->query($sql);
3303 3303
 		if (!$resql) {
3304
-			$this->errors[] = 'Error ' . $this->db->lasterror();
3305
-			dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
3304
+			$this->errors[] = 'Error '.$this->db->lasterror();
3305
+			dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
3306 3306
 
3307 3307
 			$error++;
3308 3308
 		} else {
@@ -3317,7 +3317,7 @@  discard block
 block discarded – undo
3317 3317
 					break;
3318 3318
 				} elseif ($result == 0) {
3319 3319
 					$langs->loadLangs(array('errors', 'accountancy'));
3320
-					$this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('LineId') . ': ' . $obj->rowid;
3320
+					$this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('LineId').': '.$obj->rowid;
3321 3321
 					$error++;
3322 3322
 					break;
3323 3323
 				}
@@ -3383,16 +3383,16 @@  discard block
 block discarded – undo
3383 3383
 			$echecT = [];
3384 3384
 			foreach ($toselect as $id) {
3385 3385
 				if ($bookkeeping->fetch($id)) {
3386
-					if ( !getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) {
3386
+					if (!getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) {
3387 3387
 						$accountcustcode = '411';
3388 3388
 					} else $accountcustcode = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER');
3389 3389
 
3390
-					if ( !getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) {
3390
+					if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) {
3391 3391
 						$accountsuppcode = '401';
3392 3392
 					} else $accountsuppcode = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER');
3393 3393
 
3394 3394
 					if (strpos($bookkeeping->numero_compte, $accountcustcode) === 0 || strpos($bookkeeping->numero_compte, $accountsuppcode) === 0) {
3395
-						$echecT[]=$bookkeeping->numero_compte;
3395
+						$echecT[] = $bookkeeping->numero_compte;
3396 3396
 						continue;
3397 3397
 					}
3398 3398
 
@@ -3419,9 +3419,9 @@  discard block
 block discarded – undo
3419 3419
 		}
3420 3420
 
3421 3421
 		if ($nb > 1) {
3422
-			setEventMessages($nb ." " . $langs->trans('AssignAccountsSuccess'), null, 'mesgs');
3422
+			setEventMessages($nb." ".$langs->trans('AssignAccountsSuccess'), null, 'mesgs');
3423 3423
 		} elseif ($nb > 0) {
3424
-			setEventMessages($nb ." " . $langs->trans('AssignAccountSuccess'), null, 'mesgs');
3424
+			setEventMessages($nb." ".$langs->trans('AssignAccountSuccess'), null, 'mesgs');
3425 3425
 		} else {
3426 3426
 			setEventMessages($langs->trans('AssignAccountError'), null, 'errors');
3427 3427
 			$error++;
@@ -3429,7 +3429,7 @@  discard block
 block discarded – undo
3429 3429
 
3430 3430
 		if (!empty($echecImplode)) {
3431 3431
 			$nbEchec = count(explode(',', $echecImplode));
3432
-			setEventMessages($nbEchec == 1 ? $langs->trans('NoAccountChangedWithAccountNumber') . ' ' . $echecImplode : $langs->trans('NoAccountsChangedWithAccountNumber') . ' ' . $echecImplode, null, 'errors'
3432
+			setEventMessages($nbEchec == 1 ? $langs->trans('NoAccountChangedWithAccountNumber').' '.$echecImplode : $langs->trans('NoAccountsChangedWithAccountNumber').' '.$echecImplode, null, 'errors'
3433 3433
 			);
3434 3434
 		}
3435 3435
 
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
 				setEventMessages($langs->trans('ErrorBookkeepingDocDateIsOnAClosedFiscalPeriod'), null, 'errors');
3471 3471
 			} else {
3472 3472
 				setEventMessages($langs->trans('ErrorBookkeepingDocDateNotOnActiveFiscalPeriod'), null, 'errors');
3473
-				header("Location: " . $_SERVER['HTTP_REFERER']);
3473
+				header("Location: ".$_SERVER['HTTP_REFERER']);
3474 3474
 			}
3475 3475
 			$error++;
3476 3476
 			return -1;
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
 		$pieceNumNext = $bookKeepingInstance->getNextNumMvt();
3482 3482
 
3483 3483
 		$cloneId = [];
3484
-		$sqlRowidClone = "SELECT rowid FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE piece_num = ".((int) $piecenum);
3484
+		$sqlRowidClone = "SELECT rowid FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE piece_num = ".((int) $piecenum);
3485 3485
 		$resqlRowidClone = $this->db->query($sqlRowidClone);
3486 3486
 
3487 3487
 		if ($resqlRowidClone) {
@@ -3497,27 +3497,27 @@  discard block
 block discarded – undo
3497 3497
 
3498 3498
 					$sql = "SELECT piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, fk_user_author, doc_ref,";
3499 3499
 					$sql .= " fk_doc, fk_docdet, debit, credit, journal_label, sens, montant";
3500
-					$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
3501
-					$sql .= " WHERE rowid = " . ((int) $toselectid);
3500
+					$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
3501
+					$sql .= " WHERE rowid = ".((int) $toselectid);
3502 3502
 					$resql = $this->db->query($sql);
3503 3503
 
3504 3504
 					if ($resql) {
3505 3505
 						while ($obj = $this->db->fetch_object($resql)) {
3506 3506
 							$docRef = $langs->trans('CloneOf', $obj->doc_ref);
3507 3507
 
3508
-							$sql_insert = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping";
3508
+							$sql_insert = "INSERT INTO ".MAIN_DB_PREFIX."accounting_bookkeeping";
3509 3509
 							$sql_insert .= " (piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, doc_date, fk_user_author, doc_ref,";
3510 3510
 							$sql_insert .= " fk_doc, fk_docdet, debit, credit, date_creation, journal_label, sens, montant)";
3511 3511
 							$sql_insert .= " VALUES";
3512
-							$sql_insert .= " (" . ((int) $pieceNumNext) . ", '" . $this->db->escape($obj->label_operation) . "', '" . $this->db->escape($obj->numero_compte) . "', '" . $this->db->escape($obj->label_compte) . "', '" . $this->db->escape($obj->doc_type) . "', '" . $this->db->escape($code_journal) . "', '" . $this->db->idate($docdate) . "', '" . $this->db->escape($obj->fk_user_author) . "', '" . $this->db->escape($docRef) . "', ";
3513
-							$sql_insert .= " ". ((int) $obj->fk_doc) . ", " . ((int) $obj->fk_docdet) . ", " . (float) $obj->debit . ", " . (float) $obj->credit . ", '" . $this->db->idate($docdate) . "', '" . $this->db->escape($journal_label) . "', '" . $this->db->escape($obj->sens) . "', " . (float) $obj->montant . ")";
3512
+							$sql_insert .= " (".((int) $pieceNumNext).", '".$this->db->escape($obj->label_operation)."', '".$this->db->escape($obj->numero_compte)."', '".$this->db->escape($obj->label_compte)."', '".$this->db->escape($obj->doc_type)."', '".$this->db->escape($code_journal)."', '".$this->db->idate($docdate)."', '".$this->db->escape($obj->fk_user_author)."', '".$this->db->escape($docRef)."', ";
3513
+							$sql_insert .= " ".((int) $obj->fk_doc).", ".((int) $obj->fk_docdet).", ".(float) $obj->debit.", ".(float) $obj->credit.", '".$this->db->idate($docdate)."', '".$this->db->escape($journal_label)."', '".$this->db->escape($obj->sens)."', ".(float) $obj->montant.")";
3514 3514
 
3515 3515
 							$resqlInsert = $this->db->query($sql_insert);
3516 3516
 
3517 3517
 							if ($resqlInsert) {
3518 3518
 								setEventMessages($langs->trans('CloningSuccess', $pieceNumNext), null, 'mesgs');
3519 3519
 							} else {
3520
-								setEventMessages($langs->trans('CloningFailed') . $this->db->lasterror(), null, 'errors');
3520
+								setEventMessages($langs->trans('CloningFailed').$this->db->lasterror(), null, 'errors');
3521 3521
 								$error++;
3522 3522
 							}
3523 3523
 						}
@@ -3558,7 +3558,7 @@  discard block
 block discarded – undo
3558 3558
 		$idImplodeSelect = implode(',', $toselect);
3559 3559
 		$pieceNumT = [];
3560 3560
 
3561
-		$sqlPieceNum = "SELECT DISTINCT(piece_num) FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE rowid IN (".$this->db->sanitize($idImplodeSelect).")";
3561
+		$sqlPieceNum = "SELECT DISTINCT(piece_num) FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE rowid IN (".$this->db->sanitize($idImplodeSelect).")";
3562 3562
 		$resqlPieceNum = $this->db->query($sqlPieceNum);
3563 3563
 
3564 3564
 		if ($resqlPieceNum) {
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 						setEventMessages($langs->trans('ErrorBookkeepingDocDateIsOnAClosedFiscalPeriod'), null, 'errors');
3579 3579
 					} else {
3580 3580
 						setEventMessages($langs->trans('ErrorBookkeepingDocDateNotOnActiveFiscalPeriod'), null, 'errors');
3581
-						header("Location: " . $_SERVER['HTTP_REFERER']);
3581
+						header("Location: ".$_SERVER['HTTP_REFERER']);
3582 3582
 					}
3583 3583
 					$error++;
3584 3584
 				}
@@ -3586,7 +3586,7 @@  discard block
 block discarded – undo
3586 3586
 				$bookKeepingInstance = new BookKeeping($this->db);
3587 3587
 				$pieceNumNext = $bookKeepingInstance->getNextNumMvt();
3588 3588
 				$cloneId = [];
3589
-				$sqlRowidClone = "SELECT rowid FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE piece_num = $pieceNum";
3589
+				$sqlRowidClone = "SELECT rowid FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE piece_num = $pieceNum";
3590 3590
 				$resqlRowidClone = $this->db->query($sqlRowidClone);
3591 3591
 
3592 3592
 				if ($resqlRowidClone) {
@@ -3600,15 +3600,15 @@  discard block
 block discarded – undo
3600 3600
 							$code_journal = getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL') ? $code_journal : $bookKeeping->code_journal;
3601 3601
 							$journal_label = getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL') ? $accountingJournal->label : $bookKeeping->journal_label;
3602 3602
 							$sql = "SELECT piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, fk_user_author, doc_ref, fk_doc, fk_docdet, debit, credit, journal_label, sens, montant ";
3603
-							$sql .= "FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE rowid = " . ((int) $toselectid);
3603
+							$sql .= "FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE rowid = ".((int) $toselectid);
3604 3604
 
3605 3605
 							$resql = $this->db->query($sql);
3606 3606
 							if ($resql) {
3607 3607
 								while ($obj = $this->db->fetch_object($resql)) {
3608
-									$docRef = "Duplicata de " . $obj->doc_ref;
3608
+									$docRef = "Duplicata de ".$obj->doc_ref;
3609 3609
 
3610
-									$sql_insert = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, doc_date, fk_user_author, doc_ref, fk_doc, fk_docdet, debit, credit, date_creation, journal_label, sens, montant)";
3611
-									$sql_insert .=	" VALUES (" . ((int) $pieceNumNext) . ", '" . $this->db->escape($obj->label_operation) . "', '" . $this->db->escape($obj->numero_compte) . "', '" . $this->db->escape($obj->label_compte) . "', '" . $this->db->escape($obj->doc_type) . "', '" . $this->db->escape($code_journal) . "', '" . $this->db->idate($docdate)."'";
3610
+									$sql_insert = "INSERT INTO ".MAIN_DB_PREFIX."accounting_bookkeeping (piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, doc_date, fk_user_author, doc_ref, fk_doc, fk_docdet, debit, credit, date_creation, journal_label, sens, montant)";
3611
+									$sql_insert .= " VALUES (".((int) $pieceNumNext).", '".$this->db->escape($obj->label_operation)."', '".$this->db->escape($obj->numero_compte)."', '".$this->db->escape($obj->label_compte)."', '".$this->db->escape($obj->doc_type)."', '".$this->db->escape($code_journal)."', '".$this->db->idate($docdate)."'";
3612 3612
 									$sql_insert .= 'Bug here !!! code to forge sql_insert is not finished';
3613 3613
 
3614 3614
 									$resqlInsert = $this->db->query($sql_insert);
@@ -3660,17 +3660,17 @@  discard block
 block discarded – undo
3660 3660
 		$accountingJournal->fetch(0, $code_journal);
3661 3661
 
3662 3662
 		$this->db->begin();
3663
-		$sqlAlreadyExtourne = "SELECT DISTINCT(piece_num) FROM " .MAIN_DB_PREFIX. "accounting_bookkeeping WHERE label_operation LIKE '%Extourne%'";
3663
+		$sqlAlreadyExtourne = "SELECT DISTINCT(piece_num) FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE label_operation LIKE '%Extourne%'";
3664 3664
 		$resqlAlreadyExtourne = $this->db->query($sqlAlreadyExtourne);
3665 3665
 		$alreadyExtourneT = array();
3666 3666
 		if ($resqlAlreadyExtourne) {
3667 3667
 			while ($obj4 = $this->db->fetch_object($resqlAlreadyExtourne)) {
3668
-				$alreadyExtourneT []= $obj4->piece_num;
3668
+				$alreadyExtourneT [] = $obj4->piece_num;
3669 3669
 			}
3670 3670
 		}
3671 3671
 
3672 3672
 		$idImplode = implode(',', $toselect);
3673
-		$sql1 = "SELECT DISTINCT(piece_num) from " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE rowid IN (".$this->db->sanitize($idImplode).")";
3673
+		$sql1 = "SELECT DISTINCT(piece_num) from ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE rowid IN (".$this->db->sanitize($idImplode).")";
3674 3674
 		$resql1 = $this->db->query($sql1);
3675 3675
 		$pieceNumT = [];
3676 3676
 
@@ -3684,7 +3684,7 @@  discard block
 block discarded – undo
3684 3684
 				$newBookKeepingInstance = new BookKeeping($this->db);
3685 3685
 				$pieceNumNext = $newBookKeepingInstance->getNextNumMvt();
3686 3686
 				$extourneIds = [];
3687
-				$sql2 = "SELECT rowid FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE piece_num = ".((int) $pieceNum);
3687
+				$sql2 = "SELECT rowid FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE piece_num = ".((int) $pieceNum);
3688 3688
 				$resql2 = $this->db->query($sql2);
3689 3689
 
3690 3690
 				if ($resql2) {
@@ -3708,7 +3708,7 @@  discard block
 block discarded – undo
3708 3708
 									$newBookKeeping->sens = 'D';
3709 3709
 								}
3710 3710
 
3711
-								$newBookKeeping->label_operation = "Extourne " . $bookKeeping->piece_num . " - " . $bookKeeping->numero_compte . " - " . date('d/m/Y', dol_now()) . " - " . $i;
3711
+								$newBookKeeping->label_operation = "Extourne ".$bookKeeping->piece_num." - ".$bookKeeping->numero_compte." - ".date('d/m/Y', dol_now())." - ".$i;
3712 3712
 
3713 3713
 								$newBookKeeping->numero_compte = $bookKeeping->numero_compte;
3714 3714
 								$newBookKeeping->label_compte = $bookKeeping->label_compte;
Please login to merge, or discard this patch.