@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | if ($searchCategoryContactOperator == 0) { |
225 | 225 | $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE t.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")"; |
226 | 226 | } else { |
227 | - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); |
|
227 | + $listofcategoryid .= ($listofcategoryid ? ', ' : '').((int) $searchCategoryContact); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $this->contact->oldcopy = clone $this->contact; // @phan-suppress-current-line PhanTypeMismatchProperty |
439 | 439 | |
440 | 440 | if ($this->contact->delete(DolibarrApiAccess::$user) <= 0) { |
441 | - throw new RestException(500, 'Error when delete contact ' . $this->contact->error); |
|
441 | + throw new RestException(500, 'Error when delete contact '.$this->contact->error); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | return array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('ODTPHP_PATHTOPCLZIP')) { |
|
2 | +if (!defined('ODTPHP_PATHTOPCLZIP')) { |
|
3 | 3 | define('ODTPHP_PATHTOPCLZIP', DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/'); |
4 | 4 | } |
5 | 5 | require_once ODTPHP_PATHTOPCLZIP.'pclzip.lib.php'; |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @throws PclZipProxyException |
30 | 30 | */ |
31 | - public function __construct($forcedir='') |
|
31 | + public function __construct($forcedir = '') |
|
32 | 32 | { |
33 | - if (! class_exists('PclZip')) { |
|
33 | + if (!class_exists('PclZip')) { |
|
34 | 34 | throw new PclZipProxyException('PclZip class not loaded - PclZip library |
35 | 35 | is required for using PclZipProxy'); ; |
36 | 36 | } |
37 | - if ($forcedir) $this->tmpdir=preg_replace('|[//\/]$|','',$forcedir); // $this->tmpdir must not contains / at the end |
|
37 | + if ($forcedir) $this->tmpdir = preg_replace('|[//\/]$|', '', $forcedir); // $this->tmpdir must not contains / at the end |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | } |
92 | 92 | $localname = preg_replace("/(?:\.|\/)*(.*)/", "\\1", $localname); |
93 | 93 | $localpath = dirname($localname); |
94 | - $tmpfilename = $this->tmpdir . '/' . basename($localname); |
|
94 | + $tmpfilename = $this->tmpdir.'/'.basename($localname); |
|
95 | 95 | if (false !== file_put_contents($tmpfilename, $contents)) { |
96 | 96 | //print "tmpfilename=".$tmpfilename; |
97 | 97 | //print "localname=".$localname; |
98 | - $res=$this->pclzip->delete(PCLZIP_OPT_BY_NAME, $localname); |
|
98 | + $res = $this->pclzip->delete(PCLZIP_OPT_BY_NAME, $localname); |
|
99 | 99 | $add = $this->pclzip->add($tmpfilename, |
100 | 100 | PCLZIP_OPT_REMOVE_PATH, $this->tmpdir, |
101 | 101 | PCLZIP_OPT_ADD_PATH, $localpath); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | if (isSet($localname)) { |
127 | 127 | $localname = preg_replace("/(?:\.|\/)*(.*)/", "\\1", $localname); |
128 | 128 | $localpath = dirname($localname); |
129 | - $tmpfilename = $this->tmpdir . '/' . basename($localname); |
|
129 | + $tmpfilename = $this->tmpdir.'/'.basename($localname); |
|
130 | 130 | } else { |
131 | 131 | $localname = basename($filename); |
132 | - $tmpfilename = $this->tmpdir . '/' . $localname; |
|
132 | + $tmpfilename = $this->tmpdir.'/'.$localname; |
|
133 | 133 | $localpath = ''; |
134 | 134 | } |
135 | 135 | if (file_exists($filename)) { |
@@ -34,7 +34,10 @@ |
||
34 | 34 | throw new PclZipProxyException('PclZip class not loaded - PclZip library |
35 | 35 | is required for using PclZipProxy'); ; |
36 | 36 | } |
37 | - if ($forcedir) $this->tmpdir=preg_replace('|[//\/]$|','',$forcedir); // $this->tmpdir must not contains / at the end |
|
37 | + if ($forcedir) { |
|
38 | + $this->tmpdir=preg_replace('|[//\/]$|','',$forcedir); |
|
39 | + } |
|
40 | + // $this->tmpdir must not contains / at the end |
|
38 | 41 | } |
39 | 42 | |
40 | 43 | /** |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * @param mixed $v Feature information of a product. |
651 | 651 | * @return bool |
652 | 652 | */ |
653 | - static function ($v) { |
|
653 | + static function($v) { |
|
654 | 654 | return !empty($v); |
655 | 655 | } |
656 | 656 | ); |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | |
855 | 855 | if ($forced_refvar === false) { |
856 | 856 | if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { |
857 | - $newproduct->ref .= getDolGlobalString('PRODUIT_ATTRIBUTES_SEPARATOR') . $prodattrval->ref; |
|
857 | + $newproduct->ref .= getDolGlobalString('PRODUIT_ATTRIBUTES_SEPARATOR').$prodattrval->ref; |
|
858 | 858 | } else { |
859 | 859 | $newproduct->ref .= '_'.$prodattrval->ref; |
860 | 860 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | $productCombinationLevel->variation_price = $price_impact[$i]; |
883 | 883 | |
884 | 884 | if (is_array($price_var_percent)) { |
885 | - $productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ; |
|
885 | + $productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i]; |
|
886 | 886 | } else { |
887 | 887 | $productCombinationLevel->variation_price_percentage = $price_var_percent; |
888 | 888 | } |
@@ -229,32 +229,32 @@ discard block |
||
229 | 229 | $error++; |
230 | 230 | } |
231 | 231 | if ($error) { |
232 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
232 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
233 | 233 | return -1; |
234 | 234 | } |
235 | 235 | |
236 | 236 | $this->db->begin(); |
237 | 237 | |
238 | - $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; |
|
238 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; |
|
239 | 239 | $sql .= " ref, ref_ext, label, entity, position"; |
240 | 240 | $sql .= ")"; |
241 | 241 | $sql .= " VALUES ("; |
242 | - $sql .= " '" . $this->db->escape($this->ref) . "'"; |
|
243 | - $sql .= ", '" . $this->db->escape($this->ref_ext) . "'"; |
|
244 | - $sql .= ", '" . $this->db->escape($this->label) . "'"; |
|
245 | - $sql .= ", " . ((int) $this->entity); |
|
246 | - $sql .= ", " . ((int) $this->position); |
|
242 | + $sql .= " '".$this->db->escape($this->ref)."'"; |
|
243 | + $sql .= ", '".$this->db->escape($this->ref_ext)."'"; |
|
244 | + $sql .= ", '".$this->db->escape($this->label)."'"; |
|
245 | + $sql .= ", ".((int) $this->entity); |
|
246 | + $sql .= ", ".((int) $this->position); |
|
247 | 247 | $sql .= ")"; |
248 | 248 | |
249 | 249 | dol_syslog(__METHOD__, LOG_DEBUG); |
250 | 250 | $resql = $this->db->query($sql); |
251 | 251 | if (!$resql) { |
252 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
252 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
253 | 253 | $error++; |
254 | 254 | } |
255 | 255 | |
256 | 256 | if (!$error) { |
257 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); |
|
257 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); |
|
258 | 258 | $result = $this->insertExtraFields(); |
259 | 259 | if ($result < 0) { |
260 | 260 | $error++; |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | $error++; |
300 | 300 | } |
301 | 301 | if ($error) { |
302 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
302 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
303 | 303 | return -1; |
304 | 304 | } |
305 | 305 | |
306 | 306 | $sql = "SELECT rowid, ref, ref_ext, label, position"; |
307 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
308 | - $sql .= " WHERE rowid = " . ((int) $id); |
|
309 | - $sql .= " AND entity IN (" . getEntity('product') . ")"; |
|
307 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
308 | + $sql .= " WHERE rowid = ".((int) $id); |
|
309 | + $sql .= " AND entity IN (".getEntity('product').")"; |
|
310 | 310 | |
311 | 311 | dol_syslog(__METHOD__, LOG_DEBUG); |
312 | 312 | $resql = $this->db->query($sql); |
313 | 313 | if (!$resql) { |
314 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
315 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
314 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
315 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
316 | 316 | return -1; |
317 | 317 | } |
318 | 318 | |
@@ -343,14 +343,14 @@ discard block |
||
343 | 343 | $return = array(); |
344 | 344 | |
345 | 345 | $sql = "SELECT rowid, ref, ref_ext, label, position"; |
346 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
347 | - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; |
|
346 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
347 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
348 | 348 | $sql .= $this->db->order("position", "asc"); |
349 | 349 | |
350 | 350 | dol_syslog(__METHOD__, LOG_DEBUG); |
351 | 351 | $resql = $this->db->query($sql); |
352 | 352 | if (!$resql) { |
353 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
353 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
354 | 354 | dol_print_error($this->db); |
355 | 355 | return $return; |
356 | 356 | } |
@@ -402,25 +402,25 @@ discard block |
||
402 | 402 | $error++; |
403 | 403 | } |
404 | 404 | if ($error) { |
405 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
405 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
406 | 406 | return -1; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $this->db->begin(); |
410 | 410 | |
411 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET"; |
|
411 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; |
|
412 | 412 | |
413 | - $sql .= " ref = '" . $this->db->escape($this->ref) . "'"; |
|
414 | - $sql .= ", ref_ext = '" . $this->db->escape($this->ref_ext) . "'"; |
|
415 | - $sql .= ", label = '" . $this->db->escape($this->label) . "'"; |
|
416 | - $sql .= ", position = " . ((int) $this->position); |
|
413 | + $sql .= " ref = '".$this->db->escape($this->ref)."'"; |
|
414 | + $sql .= ", ref_ext = '".$this->db->escape($this->ref_ext)."'"; |
|
415 | + $sql .= ", label = '".$this->db->escape($this->label)."'"; |
|
416 | + $sql .= ", position = ".((int) $this->position); |
|
417 | 417 | |
418 | - $sql .= " WHERE rowid = " . ((int) $this->id); |
|
418 | + $sql .= " WHERE rowid = ".((int) $this->id); |
|
419 | 419 | |
420 | 420 | dol_syslog(__METHOD__, LOG_DEBUG); |
421 | 421 | $resql = $this->db->query($sql); |
422 | 422 | if (!$resql) { |
423 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
423 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
424 | 424 | $error++; |
425 | 425 | } |
426 | 426 | if (!$error) { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $error++; |
469 | 469 | } |
470 | 470 | if ($error) { |
471 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
471 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
472 | 472 | return -1; |
473 | 473 | } |
474 | 474 | |
@@ -493,25 +493,25 @@ discard block |
||
493 | 493 | |
494 | 494 | if (!$error) { |
495 | 495 | // Delete values |
496 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line; |
|
497 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
496 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; |
|
497 | + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
|
498 | 498 | |
499 | - dol_syslog(__METHOD__ . ' - Delete values', LOG_DEBUG); |
|
499 | + dol_syslog(__METHOD__.' - Delete values', LOG_DEBUG); |
|
500 | 500 | $resql = $this->db->query($sql); |
501 | 501 | if (!$resql) { |
502 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
502 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
503 | 503 | $error++; |
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
507 | 507 | if (!$error) { |
508 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
509 | - $sql .= " WHERE rowid = " . ((int) $this->id); |
|
508 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
509 | + $sql .= " WHERE rowid = ".((int) $this->id); |
|
510 | 510 | |
511 | - dol_syslog(__METHOD__ . ' - Delete attribute', LOG_DEBUG); |
|
511 | + dol_syslog(__METHOD__.' - Delete attribute', LOG_DEBUG); |
|
512 | 512 | $resql = $this->db->query($sql); |
513 | 513 | if (!$resql) { |
514 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
514 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
515 | 515 | $error++; |
516 | 516 | } |
517 | 517 | } |
@@ -550,15 +550,15 @@ discard block |
||
550 | 550 | $error++; |
551 | 551 | } |
552 | 552 | if ($error) { |
553 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
553 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
554 | 554 | return -1; |
555 | 555 | } |
556 | 556 | |
557 | 557 | $sql = "SELECT td.rowid, td.fk_product_attribute, td.ref, td.value, td.position"; |
558 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element_line . " AS td"; |
|
559 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->table_element . " AS t ON t.rowid = td." . $this->fk_element; |
|
560 | - $sql .= " WHERE t.rowid = " . ((int) $this->id); |
|
561 | - $sql .= " AND t.entity IN (" . getEntity('product') . ")"; |
|
558 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line." AS td"; |
|
559 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element." AS t ON t.rowid = td.".$this->fk_element; |
|
560 | + $sql .= " WHERE t.rowid = ".((int) $this->id); |
|
561 | + $sql .= " AND t.entity IN (".getEntity('product').")"; |
|
562 | 562 | if ($filters) { |
563 | 563 | $sql .= $filters; |
564 | 564 | } |
@@ -567,8 +567,8 @@ discard block |
||
567 | 567 | dol_syslog(__METHOD__, LOG_DEBUG); |
568 | 568 | $resql = $this->db->query($sql); |
569 | 569 | if (!$resql) { |
570 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
571 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
570 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
571 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
572 | 572 | return -3; |
573 | 573 | } |
574 | 574 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | public function addLine($ref, $value, $position = -1, $notrigger = 0) |
624 | 624 | { |
625 | 625 | global $langs, $user; |
626 | - dol_syslog(__METHOD__ . " id=".$this->id.", ref=".$ref.", value=".$value.", notrigger=".$notrigger); |
|
626 | + dol_syslog(__METHOD__." id=".$this->id.", ref=".$ref.", value=".$value.", notrigger=".$notrigger); |
|
627 | 627 | $error = 0; |
628 | 628 | |
629 | 629 | // Clean parameters |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $error++; |
636 | 636 | } |
637 | 637 | if ($error) { |
638 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
638 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
639 | 639 | return -1; |
640 | 640 | } |
641 | 641 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | { |
685 | 685 | global $user; |
686 | 686 | |
687 | - dol_syslog(__METHOD__ . " lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger"); |
|
687 | + dol_syslog(__METHOD__." lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger"); |
|
688 | 688 | |
689 | 689 | // Clean parameters |
690 | 690 | $lineid = $lineid > 0 ? $lineid : 0; |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | */ |
726 | 726 | public function deleteLine(User $user, $lineid, $notrigger = 0) |
727 | 727 | { |
728 | - dol_syslog(__METHOD__ . " lineid=$lineid, notrigger=$notrigger"); |
|
728 | + dol_syslog(__METHOD__." lineid=$lineid, notrigger=$notrigger"); |
|
729 | 729 | |
730 | 730 | // Clean parameters |
731 | 731 | $lineid = $lineid > 0 ? $lineid : 0; |
@@ -772,19 +772,19 @@ discard block |
||
772 | 772 | $error++; |
773 | 773 | } |
774 | 774 | if ($error) { |
775 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
775 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
776 | 776 | return -1; |
777 | 777 | } |
778 | 778 | |
779 | 779 | $sql = "SELECT COUNT(*) AS count"; |
780 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element_line; |
|
781 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
780 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line; |
|
781 | + $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
|
782 | 782 | |
783 | 783 | dol_syslog(__METHOD__, LOG_DEBUG); |
784 | 784 | $resql = $this->db->query($sql); |
785 | 785 | if (!$resql) { |
786 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
787 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
786 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
787 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
788 | 788 | return -1; |
789 | 789 | } |
790 | 790 | |
@@ -815,21 +815,21 @@ discard block |
||
815 | 815 | $error++; |
816 | 816 | } |
817 | 817 | if ($error) { |
818 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
818 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
819 | 819 | return -1; |
820 | 820 | } |
821 | 821 | |
822 | 822 | $sql = "SELECT COUNT(*) AS count"; |
823 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_attribute_combination2val AS pac2v"; |
|
824 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid"; |
|
825 | - $sql .= " WHERE pac2v.fk_prod_attr = " . ((int) $this->id); |
|
826 | - $sql .= " AND pac.entity IN (" . getEntity('product') . ")"; |
|
823 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_attribute_combination2val AS pac2v"; |
|
824 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid"; |
|
825 | + $sql .= " WHERE pac2v.fk_prod_attr = ".((int) $this->id); |
|
826 | + $sql .= " AND pac.entity IN (".getEntity('product').")"; |
|
827 | 827 | |
828 | 828 | dol_syslog(__METHOD__, LOG_DEBUG); |
829 | 829 | $resql = $this->db->query($sql); |
830 | 830 | if (!$resql) { |
831 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
832 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
831 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
832 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
833 | 833 | return -1; |
834 | 834 | } |
835 | 835 | |
@@ -859,16 +859,16 @@ discard block |
||
859 | 859 | $error++; |
860 | 860 | } |
861 | 861 | if ($error) { |
862 | - dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR); |
|
862 | + dol_syslog(__METHOD__.' '.$this->errorsToString(), LOG_ERR); |
|
863 | 863 | return -1; |
864 | 864 | } |
865 | 865 | |
866 | - $sql = "SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX . "product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->id); |
|
866 | + $sql = "SELECT COUNT(*) AS nb FROM ".MAIN_DB_PREFIX."product_attribute_combination2val WHERE fk_prod_attr = ".((int) $this->id); |
|
867 | 867 | |
868 | 868 | dol_syslog(__METHOD__, LOG_DEBUG); |
869 | 869 | $resql = $this->db->query($sql); |
870 | 870 | if (!$resql) { |
871 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
871 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
872 | 872 | return -1; |
873 | 873 | } |
874 | 874 | |
@@ -892,8 +892,8 @@ discard block |
||
892 | 892 | { |
893 | 893 | // Count number of attributes to reorder (according to choice $renum) |
894 | 894 | $nl = 0; |
895 | - $sql = "SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
896 | - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; |
|
895 | + $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
896 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
897 | 897 | if (!$renum) { |
898 | 898 | $sql .= " AND position = 0"; |
899 | 899 | } else { |
@@ -913,11 +913,11 @@ discard block |
||
913 | 913 | $rows = array(); |
914 | 914 | |
915 | 915 | // We first search all attributes |
916 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
917 | - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; |
|
918 | - $sql .= " ORDER BY position ASC, rowid " . $rowidorder; |
|
916 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
917 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
918 | + $sql .= " ORDER BY position ASC, rowid ".$rowidorder; |
|
919 | 919 | |
920 | - dol_syslog(__METHOD__ . " search all attributes", LOG_DEBUG); |
|
920 | + dol_syslog(__METHOD__." search all attributes", LOG_DEBUG); |
|
921 | 921 | $resql = $this->db->query($sql); |
922 | 922 | if ($resql) { |
923 | 923 | $i = 0; |
@@ -952,8 +952,8 @@ discard block |
||
952 | 952 | { |
953 | 953 | global $hookmanager; |
954 | 954 | |
955 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET position = " . ((int) $position); |
|
956 | - $sql .= " WHERE rowid = " . ((int) $rowid); |
|
955 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET position = ".((int) $position); |
|
956 | + $sql .= " WHERE rowid = ".((int) $rowid); |
|
957 | 957 | |
958 | 958 | dol_syslog(__METHOD__, LOG_DEBUG); |
959 | 959 | if (!$this->db->query($sql)) { |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | */ |
976 | 976 | public function getPositionOfAttribute($rowid) |
977 | 977 | { |
978 | - $sql = "SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
979 | - $sql .= " WHERE rowid=".(int) $rowid." AND entity IN (" . getEntity('product') . ")"; |
|
978 | + $sql = "SELECT position FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
979 | + $sql .= " WHERE rowid=".(int) $rowid." AND entity IN (".getEntity('product').")"; |
|
980 | 980 | |
981 | 981 | dol_syslog(__METHOD__, LOG_DEBUG); |
982 | 982 | $resql = $this->db->query($sql); |
@@ -1039,12 +1039,12 @@ discard block |
||
1039 | 1039 | public function updateAttributePositionUp($rowid, $position) |
1040 | 1040 | { |
1041 | 1041 | if ($position > 1) { |
1042 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET position = " . ((int) $position); |
|
1043 | - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; |
|
1044 | - $sql .= " AND position = " . ((int) ($position - 1)); |
|
1042 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET position = ".((int) $position); |
|
1043 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
1044 | + $sql .= " AND position = ".((int) ($position - 1)); |
|
1045 | 1045 | if ($this->db->query($sql)) { |
1046 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET position = " . ((int) ($position - 1)); |
|
1047 | - $sql .= " WHERE rowid = " . ((int) $rowid); |
|
1046 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET position = ".((int) ($position - 1)); |
|
1047 | + $sql .= " WHERE rowid = ".((int) $rowid); |
|
1048 | 1048 | if (!$this->db->query($sql)) { |
1049 | 1049 | dol_print_error($this->db); |
1050 | 1050 | } |
@@ -1065,12 +1065,12 @@ discard block |
||
1065 | 1065 | public function updateAttributePositionDown($rowid, $position, $max) |
1066 | 1066 | { |
1067 | 1067 | if ($position < $max) { |
1068 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET position = " . ((int) $position); |
|
1069 | - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; |
|
1070 | - $sql .= " AND position = " . ((int) ($position + 1)); |
|
1068 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET position = ".((int) $position); |
|
1069 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
1070 | + $sql .= " AND position = ".((int) ($position + 1)); |
|
1071 | 1071 | if ($this->db->query($sql)) { |
1072 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET position = " . ((int) ($position + 1)); |
|
1073 | - $sql .= " WHERE rowid = " . ((int) $rowid); |
|
1072 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET position = ".((int) ($position + 1)); |
|
1073 | + $sql .= " WHERE rowid = ".((int) $rowid); |
|
1074 | 1074 | if (!$this->db->query($sql)) { |
1075 | 1075 | dol_print_error($this->db); |
1076 | 1076 | } |
@@ -1088,8 +1088,8 @@ discard block |
||
1088 | 1088 | public function getMaxAttributesPosition() |
1089 | 1089 | { |
1090 | 1090 | // Search the last position of attributes |
1091 | - $sql = "SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
1092 | - $sql .= " WHERE entity IN (" . getEntity('product') . ")"; |
|
1091 | + $sql = "SELECT max(position) FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
1092 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
1093 | 1093 | |
1094 | 1094 | dol_syslog(__METHOD__, LOG_DEBUG); |
1095 | 1095 | $resql = $this->db->query($sql); |
@@ -1135,17 +1135,17 @@ discard block |
||
1135 | 1135 | |
1136 | 1136 | $result = ''; |
1137 | 1137 | |
1138 | - $label = img_picto('', $this->picto) . ' <u>' . $langs->trans("ProductAttribute") . '</u>'; |
|
1138 | + $label = img_picto('', $this->picto).' <u>'.$langs->trans("ProductAttribute").'</u>'; |
|
1139 | 1139 | if (isset($this->status)) { |
1140 | - $label .= ' ' . $this->getLibStatut(5); |
|
1140 | + $label .= ' '.$this->getLibStatut(5); |
|
1141 | 1141 | } |
1142 | 1142 | $label .= '<br>'; |
1143 | - $label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
1143 | + $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
1144 | 1144 | if (!empty($this->label)) { |
1145 | - $label .= '<br><b>' . $langs->trans('Label') . ':</b> ' . $this->label; |
|
1145 | + $label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label; |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | - $url = dol_buildpath('/variants/card.php', 1) . '?id=' . $this->id; |
|
1148 | + $url = dol_buildpath('/variants/card.php', 1).'?id='.$this->id; |
|
1149 | 1149 | |
1150 | 1150 | if ($option != 'nolink') { |
1151 | 1151 | // Add param to save lastsearch_values or not |
@@ -1162,20 +1162,20 @@ discard block |
||
1162 | 1162 | if (empty($notooltip)) { |
1163 | 1163 | if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { |
1164 | 1164 | $label = $langs->trans("ShowProductAttribute"); |
1165 | - $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; |
|
1165 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
1166 | 1166 | } |
1167 | - $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; |
|
1168 | - $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"'; |
|
1167 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
1168 | + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
|
1169 | 1169 | } else { |
1170 | - $linkclose = ($morecss ? ' class="' . $morecss . '"' : ''); |
|
1170 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | if ($option == 'nolink' || empty($url)) { |
1174 | 1174 | $linkstart = '<span'; |
1175 | 1175 | } else { |
1176 | - $linkstart = '<a href="' . $url . '"'; |
|
1176 | + $linkstart = '<a href="'.$url.'"'; |
|
1177 | 1177 | } |
1178 | - $linkstart .= $linkclose . '>'; |
|
1178 | + $linkstart .= $linkclose.'>'; |
|
1179 | 1179 | if ($option == 'nolink' || empty($url)) { |
1180 | 1180 | $linkend = '</span>'; |
1181 | 1181 | } else { |
@@ -1186,29 +1186,29 @@ discard block |
||
1186 | 1186 | |
1187 | 1187 | if (empty($this->showphoto_on_popup)) { |
1188 | 1188 | if ($withpicto) { |
1189 | - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
1189 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
1190 | 1190 | } |
1191 | 1191 | } else { |
1192 | 1192 | if ($withpicto) { |
1193 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
1193 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
1194 | 1194 | |
1195 | 1195 | list($class, $module) = explode('@', $this->picto); |
1196 | - $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); |
|
1196 | + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); |
|
1197 | 1197 | $filearray = dol_dir_list($upload_dir, "files"); |
1198 | 1198 | $filename = $filearray[0]['name']; |
1199 | 1199 | if (!empty($filename)) { |
1200 | 1200 | $pospoint = strpos($filearray[0]['name'], '.'); |
1201 | 1201 | |
1202 | - $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); |
|
1203 | - if (!getDolGlobalString(strtoupper($module . '_' . $class) . '_FORMATLISTPHOTOSASUSERS')) { |
|
1204 | - $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo' . $module . '" alt="No photo" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $module . '&entity=' . $conf->entity . '&file=' . urlencode($pathtophoto) . '"></div></div>'; |
|
1202 | + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); |
|
1203 | + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { |
|
1204 | + $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>'; |
|
1205 | 1205 | } else { |
1206 | - $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $module . '&entity=' . $conf->entity . '&file=' . urlencode($pathtophoto) . '"></div>'; |
|
1206 | + $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>'; |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | $result .= '</div>'; |
1210 | 1210 | } else { |
1211 | - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
1211 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
1212 | 1212 | } |
1213 | 1213 | } |
1214 | 1214 | } |
@@ -1332,9 +1332,9 @@ discard block |
||
1332 | 1332 | $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
1333 | 1333 | foreach ($dirtpls as $module => $reldir) { |
1334 | 1334 | if (!empty($module)) { |
1335 | - $tpl = dol_buildpath($reldir . '/productattributevalueline_create.tpl.php'); |
|
1335 | + $tpl = dol_buildpath($reldir.'/productattributevalueline_create.tpl.php'); |
|
1336 | 1336 | } else { |
1337 | - $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_create.tpl.php'; |
|
1337 | + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/productattributevalueline_create.tpl.php'; |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | if (empty($conf->file->strict_mode)) { |
@@ -1383,9 +1383,9 @@ discard block |
||
1383 | 1383 | $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
1384 | 1384 | foreach ($dirtpls as $module => $reldir) { |
1385 | 1385 | if (!empty($module)) { |
1386 | - $tpl = dol_buildpath($reldir . '/productattributevalueline_title.tpl.php'); |
|
1386 | + $tpl = dol_buildpath($reldir.'/productattributevalueline_title.tpl.php'); |
|
1387 | 1387 | } else { |
1388 | - $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_title.tpl.php'; |
|
1388 | + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/productattributevalueline_title.tpl.php'; |
|
1389 | 1389 | } |
1390 | 1390 | if (empty($conf->file->strict_mode)) { |
1391 | 1391 | $res = @include $tpl; |
@@ -1465,9 +1465,9 @@ discard block |
||
1465 | 1465 | $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
1466 | 1466 | foreach ($dirtpls as $module => $reldir) { |
1467 | 1467 | if (!empty($module)) { |
1468 | - $tpl = dol_buildpath($reldir . '/productattributevalueline_view.tpl.php'); |
|
1468 | + $tpl = dol_buildpath($reldir.'/productattributevalueline_view.tpl.php'); |
|
1469 | 1469 | } else { |
1470 | - $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_view.tpl.php'; |
|
1470 | + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/productattributevalueline_view.tpl.php'; |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | if (empty($conf->file->strict_mode)) { |
@@ -1489,9 +1489,9 @@ discard block |
||
1489 | 1489 | $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); |
1490 | 1490 | foreach ($dirtpls as $module => $reldir) { |
1491 | 1491 | if (!empty($module)) { |
1492 | - $tpl = dol_buildpath($reldir . '/productattributevalueline_edit.tpl.php'); |
|
1492 | + $tpl = dol_buildpath($reldir.'/productattributevalueline_edit.tpl.php'); |
|
1493 | 1493 | } else { |
1494 | - $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_edit.tpl.php'; |
|
1494 | + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/productattributevalueline_edit.tpl.php'; |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | if (empty($conf->file->strict_mode)) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $action = GETPOST('action', 'aZ09'); |
55 | 55 | $value = GETPOST('value', 'alpha'); |
56 | 56 | $label = GETPOST('label', 'alpha'); |
57 | -$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
57 | +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
58 | 58 | |
59 | 59 | $param = GETPOST('param', 'alpha'); |
60 | 60 | $cancel = GETPOST('cancel', 'alpha'); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $module = new $classname($db, $specimenthirdparty); |
282 | 282 | '@phan-var-force ModeleAction $module'; |
283 | 283 | if (method_exists($module, 'info')) { |
284 | - print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod |
|
284 | + print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod |
|
285 | 285 | } else { |
286 | 286 | print $module->description; |
287 | 287 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $action = GETPOST('action', 'aZ09'); |
50 | 50 | $value = GETPOST('value', 'alpha'); |
51 | 51 | $label = GETPOST('label', 'alpha'); |
52 | -$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
52 | +$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php |
|
53 | 53 | |
54 | 54 | $param = GETPOST('param', 'alpha'); |
55 | 55 | $cancel = GETPOST('cancel', 'alpha'); |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $sql .= " localtax2 = ".((float) $this->total_localtax2).","; |
572 | 572 | $sql .= " total_ht = ".((float) $this->total_ht).","; |
573 | 573 | $sql .= " total_ttc = ".((float) $this->total_ttc).","; |
574 | - $sql .= " fk_societe_rib = ".(!empty($this->fk_societe_rib) ? ((int) $this->fk_societe_rib) : 'NULL');; |
|
574 | + $sql .= " fk_societe_rib = ".(!empty($this->fk_societe_rib) ? ((int) $this->fk_societe_rib) : 'NULL'); ; |
|
575 | 575 | // TODO Add missing fields |
576 | 576 | $sql .= " WHERE rowid = ".((int) $this->id); |
577 | 577 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | $this->titre = $obj->title; // deprecated |
659 | 659 | $this->title = $obj->title; |
660 | 660 | $this->ref = $obj->title; |
661 | - $this->subtype = $obj->subtype; |
|
661 | + $this->subtype = $obj->subtype; |
|
662 | 662 | $this->suspended = $obj->suspended; |
663 | 663 | $this->total_ht = $obj->total_ht; |
664 | 664 | $this->total_tva = $obj->total_tva; |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | $this->fk_societe_rib = $obj->fk_societe_rib; |
680 | 680 | $this->note_private = $obj->note_private; |
681 | 681 | $this->note_public = $obj->note_public; |
682 | - $this->user_author = $obj->fk_user_author; // deprecated |
|
682 | + $this->user_author = $obj->fk_user_author; // deprecated |
|
683 | 683 | $this->user_creation_id = $obj->fk_user_author; |
684 | 684 | $this->model_pdf = $obj->model_pdf; |
685 | 685 | //$this->special_code = $obj->special_code; |
@@ -778,35 +778,35 @@ discard block |
||
778 | 778 | $objp = $this->db->fetch_object($result); |
779 | 779 | $line = new FactureLigneRec($this->db); |
780 | 780 | |
781 | - $line->id = $objp->rowid; |
|
781 | + $line->id = $objp->rowid; |
|
782 | 782 | $line->rowid = $objp->rowid; |
783 | - $line->fk_facture = $objp->fk_facture; |
|
784 | - $line->fk_parent_line = $objp->fk_parent_line; |
|
783 | + $line->fk_facture = $objp->fk_facture; |
|
784 | + $line->fk_parent_line = $objp->fk_parent_line; |
|
785 | 785 | $line->desc = $objp->description; // Description line |
786 | 786 | $line->description = $objp->description; // Description line |
787 | - $line->ref = $objp->product_ref; // Ref product |
|
787 | + $line->ref = $objp->product_ref; // Ref product |
|
788 | 788 | $line->product_ref = $objp->product_ref; // Ref product |
789 | - $line->libelle = $objp->product_label; // deprecated |
|
789 | + $line->libelle = $objp->product_label; // deprecated |
|
790 | 790 | $line->product_label = $objp->product_label; // Label product |
791 | 791 | $line->product_desc = $objp->product_desc; // Description product |
792 | 792 | $line->product_type = $objp->product_type; // Type of line |
793 | - $line->fk_product_type = $objp->fk_product_type; // Type of product |
|
793 | + $line->fk_product_type = $objp->fk_product_type; // Type of product |
|
794 | 794 | $line->qty = $objp->qty; |
795 | - $line->subprice = $objp->subprice; |
|
795 | + $line->subprice = $objp->subprice; |
|
796 | 796 | |
797 | 797 | $line->label = $objp->custom_label; // @deprecated |
798 | 798 | |
799 | 799 | $line->vat_src_code = $objp->vat_src_code; |
800 | - $line->tva_tx = $objp->tva_tx; |
|
800 | + $line->tva_tx = $objp->tva_tx; |
|
801 | 801 | $line->localtax1_tx = $objp->localtax1_tx; |
802 | 802 | $line->localtax2_tx = $objp->localtax2_tx; |
803 | 803 | $line->localtax1_type = $objp->localtax1_type; |
804 | 804 | $line->localtax2_type = $objp->localtax2_type; |
805 | 805 | $line->remise_percent = $objp->remise_percent; |
806 | 806 | //$line->fk_remise_except = $objp->fk_remise_except; |
807 | - $line->fk_product = $objp->fk_product; |
|
808 | - $line->date_start_fill = $objp->date_start_fill; |
|
809 | - $line->date_end_fill = $objp->date_end_fill; |
|
807 | + $line->fk_product = $objp->fk_product; |
|
808 | + $line->date_start_fill = $objp->date_start_fill; |
|
809 | + $line->date_end_fill = $objp->date_end_fill; |
|
810 | 810 | $line->info_bits = $objp->info_bits; |
811 | 811 | $line->total_ht = $objp->total_ht; |
812 | 812 | $line->total_tva = $objp->total_tva; |
@@ -822,13 +822,13 @@ discard block |
||
822 | 822 | $line->marge_tx = (string) $marginInfos[1]; |
823 | 823 | $line->marque_tx = (string) $marginInfos[2]; |
824 | 824 | $line->rang = $objp->rang; |
825 | - $line->special_code = $objp->special_code; |
|
826 | - $line->fk_unit = $objp->fk_unit; |
|
827 | - $line->fk_contract_line = $objp->fk_contract_line; |
|
825 | + $line->special_code = $objp->special_code; |
|
826 | + $line->fk_unit = $objp->fk_unit; |
|
827 | + $line->fk_contract_line = $objp->fk_contract_line; |
|
828 | 828 | |
829 | 829 | // Ne plus utiliser |
830 | - $line->price = $objp->price; |
|
831 | - $line->remise = $objp->remise; |
|
830 | + $line->price = $objp->price; |
|
831 | + $line->remise = $objp->remise; |
|
832 | 832 | |
833 | 833 | $line->fetch_optionals(); |
834 | 834 | |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | |
1422 | 1422 | $facture->type = self::TYPE_STANDARD; |
1423 | 1423 | $facture->subtype = $facturerec->subtype; |
1424 | - $facture->statut = self::STATUS_DRAFT; // deprecated |
|
1424 | + $facture->statut = self::STATUS_DRAFT; // deprecated |
|
1425 | 1425 | $facture->status = self::STATUS_DRAFT; |
1426 | 1426 | $facture->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. |
1427 | 1427 | $facture->socid = $facturerec->socid; |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | } |
1573 | 1573 | $result .= $linkend; |
1574 | 1574 | global $action; |
1575 | - $hookmanager->initHooks(array($this->element . 'dao')); |
|
1575 | + $hookmanager->initHooks(array($this->element.'dao')); |
|
1576 | 1576 | $parameters = array('id' => $this->id, 'getnomurl' => &$result); |
1577 | 1577 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
1578 | 1578 | if ($reshook > 0) { |
@@ -1831,7 +1831,7 @@ discard block |
||
1831 | 1831 | |
1832 | 1832 | if (empty($option) || $option != 'nolines') { |
1833 | 1833 | // Lines |
1834 | - $nbp = min(1000, GETPOSTINT('nblines') ? GETPOSTINT('nblines') : 5); // We can force the nb of lines to test from command line (but not more than 1000) |
|
1834 | + $nbp = min(1000, GETPOSTINT('nblines') ? GETPOSTINT('nblines') : 5); // We can force the nb of lines to test from command line (but not more than 1000) |
|
1835 | 1835 | $xnbp = 0; |
1836 | 1836 | while ($xnbp < $nbp) { |
1837 | 1837 | $line = new FactureLigne($this->db); |
@@ -2023,7 +2023,7 @@ discard block |
||
2023 | 2023 | $resSuspend = $this->setValueFrom('suspended', 1); |
2024 | 2024 | |
2025 | 2025 | if ($resSuspend <= 0) { |
2026 | - dol_syslog(__METHOD__ . '::setValueFrom Error : ' . $this->error, LOG_ERR); |
|
2026 | + dol_syslog(__METHOD__.'::setValueFrom Error : '.$this->error, LOG_ERR); |
|
2027 | 2027 | return -1; |
2028 | 2028 | } |
2029 | 2029 | } |
@@ -2363,9 +2363,9 @@ discard block |
||
2363 | 2363 | if ($result) { |
2364 | 2364 | $objp = $this->db->fetch_object($result); |
2365 | 2365 | |
2366 | - $this->id = $objp->rowid; |
|
2367 | - $this->fk_facture = $objp->fk_facture; |
|
2368 | - $this->fk_parent_line = $objp->fk_parent_line; |
|
2366 | + $this->id = $objp->rowid; |
|
2367 | + $this->fk_facture = $objp->fk_facture; |
|
2368 | + $this->fk_parent_line = $objp->fk_parent_line; |
|
2369 | 2369 | $this->label = $objp->custom_label; // Label line |
2370 | 2370 | $this->desc = $objp->description; // Description line |
2371 | 2371 | $this->description = $objp->description; // Description line |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | |
312 | 312 | // Check partial / normal lettering case |
313 | 313 | $sql = "SELECT ab.lettering_code, GROUP_CONCAT(DISTINCT ab.rowid SEPARATOR ',') AS bookkeeping_ids"; |
314 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; |
|
315 | - $sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")"; |
|
314 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab"; |
|
315 | + $sql .= " WHERE ab.rowid IN (".$this->db->sanitize(implode(',', $ids)).")"; |
|
316 | 316 | $sql .= " GROUP BY ab.lettering_code"; |
317 | 317 | $sql .= " ORDER BY ab.lettering_code DESC"; |
318 | 318 | |
319 | - dol_syslog(__METHOD__ . " - Check partial / normal lettering case", LOG_DEBUG); |
|
319 | + dol_syslog(__METHOD__." - Check partial / normal lettering case", LOG_DEBUG); |
|
320 | 320 | $resql = $this->db->query($sql); |
321 | 321 | if ($resql) { |
322 | 322 | while ($obj = $this->db->fetch_object($resql)) { |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | } |
332 | 332 | } elseif (!$partial && preg_match('/^[a-z]+$/', $obj->lettering_code)) { |
333 | 333 | // Delete partial lettering code if set normal lettering |
334 | - $sql2 = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; |
|
334 | + $sql2 = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; |
|
335 | 335 | $sql2 .= " lettering_code = NULL"; |
336 | 336 | $sql2 .= ", date_lettering = NULL"; |
337 | - $sql2 .= " WHERE entity IN (" . getEntity('accountancy') . ")"; |
|
338 | - $sql2 .= " AND lettering_code = '" . $this->db->escape($obj->lettering_code) . "'"; |
|
337 | + $sql2 .= " WHERE entity IN (".getEntity('accountancy').")"; |
|
338 | + $sql2 .= " AND lettering_code = '".$this->db->escape($obj->lettering_code)."'"; |
|
339 | 339 | |
340 | - dol_syslog(__METHOD__ . " - Remove partial lettering", LOG_DEBUG); |
|
340 | + dol_syslog(__METHOD__." - Remove partial lettering", LOG_DEBUG); |
|
341 | 341 | $resql2 = $this->db->query($sql2); |
342 | 342 | if (!$resql2) { |
343 | - $this->errors[] = 'Error' . $this->db->lasterror(); |
|
343 | + $this->errors[] = 'Error'.$this->db->lasterror(); |
|
344 | 344 | $error++; |
345 | 345 | break; |
346 | 346 | } |
@@ -348,20 +348,20 @@ discard block |
||
348 | 348 | } |
349 | 349 | $this->db->free($resql); |
350 | 350 | } else { |
351 | - $this->errors[] = 'Error' . $this->db->lasterror(); |
|
351 | + $this->errors[] = 'Error'.$this->db->lasterror(); |
|
352 | 352 | $error++; |
353 | 353 | } |
354 | 354 | |
355 | 355 | if (!$error && !empty($ids)) { |
356 | 356 | // Get next code |
357 | 357 | $sql = "SELECT DISTINCT ab2.lettering_code"; |
358 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; |
|
359 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.subledger_account = ab.subledger_account"; |
|
360 | - $sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")"; |
|
358 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab"; |
|
359 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab2 ON ab2.subledger_account = ab.subledger_account"; |
|
360 | + $sql .= " WHERE ab.rowid IN (".$this->db->sanitize(implode(',', $ids)).")"; |
|
361 | 361 | $sql .= " AND ab2.lettering_code != ''"; |
362 | 362 | $sql .= " ORDER BY ab2.lettering_code DESC"; |
363 | 363 | |
364 | - dol_syslog(__METHOD__ . " - Get next code", LOG_DEBUG); |
|
364 | + dol_syslog(__METHOD__." - Get next code", LOG_DEBUG); |
|
365 | 365 | $resql = $this->db->query($sql); |
366 | 366 | if ($resql) { |
367 | 367 | while ($obj = $this->db->fetch_object($resql)) { |
@@ -376,43 +376,43 @@ discard block |
||
376 | 376 | } |
377 | 377 | $this->db->free($resql); |
378 | 378 | } else { |
379 | - $this->errors[] = 'Error' . $this->db->lasterror(); |
|
379 | + $this->errors[] = 'Error'.$this->db->lasterror(); |
|
380 | 380 | $error++; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Test amount integrity |
384 | 384 | if (!$error && !$partial) { |
385 | - $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; |
|
386 | - $sql .= " rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ") AND lettering_code IS NULL AND subledger_account != ''"; |
|
385 | + $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; |
|
386 | + $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; |
|
387 | 387 | |
388 | - dol_syslog(__METHOD__ . " - Test amount integrity", LOG_DEBUG); |
|
388 | + dol_syslog(__METHOD__." - Test amount integrity", LOG_DEBUG); |
|
389 | 389 | $resql = $this->db->query($sql); |
390 | 390 | if ($resql) { |
391 | 391 | if ($obj = $this->db->fetch_object($resql)) { |
392 | 392 | if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { |
393 | - $this->errors[] = 'Total not exacts ' . round(abs($obj->deb), 2) . ' vs ' . round(abs($obj->cred), 2); |
|
393 | + $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); |
|
394 | 394 | $error++; |
395 | 395 | } |
396 | 396 | } |
397 | 397 | $this->db->free($resql); |
398 | 398 | } else { |
399 | - $this->errors[] = 'Erreur sql' . $this->db->lasterror(); |
|
399 | + $this->errors[] = 'Erreur sql'.$this->db->lasterror(); |
|
400 | 400 | $error++; |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | // Update lettering code |
405 | 405 | if (!$error) { |
406 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; |
|
407 | - $sql .= " lettering_code='" . $this->db->escape($letter) . "'"; |
|
408 | - $sql .= ", date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false |
|
409 | - $sql .= " WHERE rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ") AND lettering_code IS NULL AND subledger_account != ''"; |
|
406 | + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; |
|
407 | + $sql .= " lettering_code='".$this->db->escape($letter)."'"; |
|
408 | + $sql .= ", date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false |
|
409 | + $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; |
|
410 | 410 | |
411 | - dol_syslog(__METHOD__ . " - Update lettering code", LOG_DEBUG); |
|
411 | + dol_syslog(__METHOD__." - Update lettering code", LOG_DEBUG); |
|
412 | 412 | $resql = $this->db->query($sql); |
413 | 413 | if (!$resql) { |
414 | 414 | $error++; |
415 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
415 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
416 | 416 | } else { |
417 | 417 | $affected_rows = $this->db->affected_rows($resql); |
418 | 418 | } |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | if ($error) { |
424 | 424 | $this->db->rollback(); |
425 | 425 | foreach ($this->errors as $errmsg) { |
426 | - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); |
|
427 | - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); |
|
426 | + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
|
427 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
428 | 428 | } |
429 | 429 | return -1 * $error; |
430 | 430 | } else { |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | public function bookkeepingLetteringAll($bookkeeping_ids, $unlettering = false) |
479 | 479 | { |
480 | - dol_syslog(__METHOD__ . " - ", LOG_DEBUG); |
|
480 | + dol_syslog(__METHOD__." - ", LOG_DEBUG); |
|
481 | 481 | |
482 | 482 | $error = 0; |
483 | 483 | $errors = array(); |
@@ -603,16 +603,16 @@ discard block |
||
603 | 603 | |
604 | 604 | // Get all bookkeeping lines |
605 | 605 | $sql = "SELECT DISTINCT ab.doc_type, ab.fk_doc"; |
606 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; |
|
607 | - $sql .= " WHERE ab.entity IN (" . getEntity('accountancy') . ")"; |
|
606 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab"; |
|
607 | + $sql .= " WHERE ab.entity IN (".getEntity('accountancy').")"; |
|
608 | 608 | $sql .= " AND ab.fk_doc > 0"; |
609 | 609 | if (!empty($bookkeeping_ids)) { |
610 | 610 | // Get all bookkeeping lines of piece number |
611 | 611 | $sql .= " AND EXISTS ("; |
612 | 612 | $sql .= " SELECT rowid"; |
613 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS pn"; |
|
614 | - $sql .= " WHERE pn.entity IN (" . getEntity('accountancy') . ")"; |
|
615 | - $sql .= " AND pn.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; |
|
613 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS pn"; |
|
614 | + $sql .= " WHERE pn.entity IN (".getEntity('accountancy').")"; |
|
615 | + $sql .= " AND pn.rowid IN (".$this->db->sanitize(implode(',', $bookkeeping_ids)).")"; |
|
616 | 616 | $sql .= " AND pn.piece_num = ab.piece_num"; |
617 | 617 | $sql .= " )"; |
618 | 618 | } |
@@ -620,10 +620,10 @@ discard block |
||
620 | 620 | $sql .= " AND ab.subledger_account != ''"; |
621 | 621 | } |
622 | 622 | |
623 | - dol_syslog(__METHOD__ . " - Get all bookkeeping lines", LOG_DEBUG); |
|
623 | + dol_syslog(__METHOD__." - Get all bookkeeping lines", LOG_DEBUG); |
|
624 | 624 | $resql = $this->db->query($sql); |
625 | 625 | if (!$resql) { |
626 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
626 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
627 | 627 | return -1; |
628 | 628 | } |
629 | 629 | |
@@ -670,25 +670,25 @@ discard block |
||
670 | 670 | |
671 | 671 | // Get all bookkeeping lines linked |
672 | 672 | $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.debit, ab.credit, ab.lettering_code"; |
673 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; |
|
674 | - $sql .= " WHERE ab.entity IN (" . getEntity('accountancy') . ")"; |
|
673 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab"; |
|
674 | + $sql .= " WHERE ab.entity IN (".getEntity('accountancy').")"; |
|
675 | 675 | $sql .= " AND ("; |
676 | 676 | if (!empty($bank_ids)) { |
677 | 677 | $sql .= " EXISTS ("; |
678 | 678 | $sql .= " SELECT bpn.rowid"; |
679 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS bpn"; |
|
680 | - $sql .= " WHERE bpn.entity IN (" . getEntity('accountancy') . ")"; |
|
679 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS bpn"; |
|
680 | + $sql .= " WHERE bpn.entity IN (".getEntity('accountancy').")"; |
|
681 | 681 | $sql .= " AND bpn.doc_type = 'bank'"; |
682 | - $sql .= " AND bpn.fk_doc IN (" . $this->db->sanitize(implode(',', $bank_ids)) . ")"; |
|
682 | + $sql .= " AND bpn.fk_doc IN (".$this->db->sanitize(implode(',', $bank_ids)).")"; |
|
683 | 683 | $sql .= " AND bpn.piece_num = ab.piece_num"; |
684 | 684 | $sql .= " ) OR "; |
685 | 685 | } |
686 | 686 | $sql .= " EXISTS ("; |
687 | 687 | $sql .= " SELECT dpn.rowid"; |
688 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS dpn"; |
|
689 | - $sql .= " WHERE dpn.entity IN (" . getEntity('accountancy') . ")"; |
|
690 | - $sql .= " AND dpn.doc_type = '" . $this->db->escape($doc_type) . "'"; |
|
691 | - $sql .= " AND dpn.fk_doc IN (" . $this->db->sanitize(implode(',', $doc_ids)) . ")"; |
|
688 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS dpn"; |
|
689 | + $sql .= " WHERE dpn.entity IN (".getEntity('accountancy').")"; |
|
690 | + $sql .= " AND dpn.doc_type = '".$this->db->escape($doc_type)."'"; |
|
691 | + $sql .= " AND dpn.fk_doc IN (".$this->db->sanitize(implode(',', $doc_ids)).")"; |
|
692 | 692 | $sql .= " AND dpn.piece_num = ab.piece_num"; |
693 | 693 | $sql .= " )"; |
694 | 694 | $sql .= ")"; |
@@ -696,10 +696,10 @@ discard block |
||
696 | 696 | $sql .= " AND ab.subledger_account != ''"; |
697 | 697 | } |
698 | 698 | |
699 | - dol_syslog(__METHOD__ . " - Get all bookkeeping lines linked", LOG_DEBUG); |
|
699 | + dol_syslog(__METHOD__." - Get all bookkeeping lines linked", LOG_DEBUG); |
|
700 | 700 | $resql = $this->db->query($sql); |
701 | 701 | if (!$resql) { |
702 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
702 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
703 | 703 | return -1; |
704 | 704 | } |
705 | 705 | |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | */ |
733 | 733 | public function getDocTypeAndFkDocFromBankLines($bank_ids) |
734 | 734 | { |
735 | - dol_syslog(__METHOD__ . " - bank_ids=".json_encode($bank_ids), LOG_DEBUG); |
|
735 | + dol_syslog(__METHOD__." - bank_ids=".json_encode($bank_ids), LOG_DEBUG); |
|
736 | 736 | |
737 | 737 | // Clean parameters |
738 | 738 | $bank_ids = is_array($bank_ids) ? $bank_ids : array(); |
@@ -744,16 +744,16 @@ discard block |
||
744 | 744 | $bookkeeping_lines_by_type = array(); |
745 | 745 | foreach (self::$doc_type_infos as $doc_type => $doc_type_info) { |
746 | 746 | // Get all fk_doc by doc_type from bank ids |
747 | - $sql = "SELECT DISTINCT dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_doc']) . " AS fk_doc"; |
|
748 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['payment_table']) . " AS p"; |
|
749 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['doc_payment_table']) . " AS dp ON dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_payment']) . " = p.rowid"; |
|
750 | - $sql .= " WHERE p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " IN (" . $this->db->sanitize(implode(',', $bank_ids)) . ")"; |
|
751 | - $sql .= " AND dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_doc']) . " > 0"; |
|
747 | + $sql = "SELECT DISTINCT dp.".$this->db->sanitize($doc_type_info['doc_payment_table_fk_doc'])." AS fk_doc"; |
|
748 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->db->sanitize($doc_type_info['payment_table'])." AS p"; |
|
749 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->db->sanitize($doc_type_info['doc_payment_table'])." AS dp ON dp.".$this->db->sanitize($doc_type_info['doc_payment_table_fk_payment'])." = p.rowid"; |
|
750 | + $sql .= " WHERE p.".$this->db->sanitize($doc_type_info['payment_table_fk_bank'])." IN (".$this->db->sanitize(implode(',', $bank_ids)).")"; |
|
751 | + $sql .= " AND dp.".$this->db->sanitize($doc_type_info['doc_payment_table_fk_doc'])." > 0"; |
|
752 | 752 | |
753 | - dol_syslog(__METHOD__ . " - Get all fk_doc by doc_type from list of bank ids for '" . $doc_type . "'", LOG_DEBUG); |
|
753 | + dol_syslog(__METHOD__." - Get all fk_doc by doc_type from list of bank ids for '".$doc_type."'", LOG_DEBUG); |
|
754 | 754 | $resql = $this->db->query($sql); |
755 | 755 | if (!$resql) { |
756 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
756 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
757 | 757 | return -1; |
758 | 758 | } |
759 | 759 | |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | { |
778 | 778 | global $langs; |
779 | 779 | |
780 | - dol_syslog(__METHOD__ . " - bank_ids=".json_encode($document_ids) . ", doc_type=$doc_type", LOG_DEBUG); |
|
780 | + dol_syslog(__METHOD__." - bank_ids=".json_encode($document_ids).", doc_type=$doc_type", LOG_DEBUG); |
|
781 | 781 | |
782 | 782 | // Clean parameters |
783 | 783 | $document_ids = is_array($document_ids) ? $document_ids : array(); |
@@ -799,17 +799,17 @@ discard block |
||
799 | 799 | $bank_ids = array(); |
800 | 800 | |
801 | 801 | // Get all fk_doc by doc_type from bank ids |
802 | - $sql = "SELECT DISTINCT p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " AS fk_doc"; |
|
803 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['payment_table']) . " AS p"; |
|
804 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->db->sanitize($doc_type_info['doc_payment_table']) . " AS dp ON dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_payment']) . " = p.rowid"; |
|
802 | + $sql = "SELECT DISTINCT p.".$this->db->sanitize($doc_type_info['payment_table_fk_bank'])." AS fk_doc"; |
|
803 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->db->sanitize($doc_type_info['payment_table'])." AS p"; |
|
804 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->db->sanitize($doc_type_info['doc_payment_table'])." AS dp ON dp.".$this->db->sanitize($doc_type_info['doc_payment_table_fk_payment'])." = p.rowid"; |
|
805 | 805 | // Implode used on array of int @phan-suppress-next-line PhanTypeMismatchArgumentInternal |
806 | - $sql .= " WHERE dp." . $this->db->sanitize($doc_type_info['doc_payment_table_fk_doc']) . " IN (" . $this->db->sanitize(implode(',', $document_ids)) . ")"; |
|
807 | - $sql .= " AND p." . $this->db->sanitize($doc_type_info['payment_table_fk_bank']) . " > 0"; |
|
806 | + $sql .= " WHERE dp.".$this->db->sanitize($doc_type_info['doc_payment_table_fk_doc'])." IN (".$this->db->sanitize(implode(',', $document_ids)).")"; |
|
807 | + $sql .= " AND p.".$this->db->sanitize($doc_type_info['payment_table_fk_bank'])." > 0"; |
|
808 | 808 | |
809 | - dol_syslog(__METHOD__ . " - Get all bank ids from list of document ids of a type '" . $doc_type . "'", LOG_DEBUG); |
|
809 | + dol_syslog(__METHOD__." - Get all bank ids from list of document ids of a type '".$doc_type."'", LOG_DEBUG); |
|
810 | 810 | $resql = $this->db->query($sql); |
811 | 811 | if (!$resql) { |
812 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
812 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
813 | 813 | return -1; |
814 | 814 | } |
815 | 815 | |
@@ -864,26 +864,26 @@ discard block |
||
864 | 864 | $sql = "SELECT DISTINCT tl2.fk_link, tl2.fk_doc"; |
865 | 865 | $sql .= " FROM ("; |
866 | 866 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset |
867 | - $sql .= " SELECT DISTINCT " . $this->db->ifsql("tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent'])." IS NOT NULL", "tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent']), "tl.".$this->db->sanitize($linked_info['fk_link']))." AS fk_link, tl.".$this->db->sanitize($linked_info['fk_doc'])." AS fk_doc"; |
|
868 | - $sql .= " FROM " . MAIN_DB_PREFIX .$this->db->sanitize($linked_info['table'])." AS tl"; |
|
867 | + $sql .= " SELECT DISTINCT ".$this->db->ifsql("tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent'])." IS NOT NULL", "tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent']), "tl.".$this->db->sanitize($linked_info['fk_link']))." AS fk_link, tl.".$this->db->sanitize($linked_info['fk_doc'])." AS fk_doc"; |
|
868 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->db->sanitize($linked_info['table'])." AS tl"; |
|
869 | 869 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset |
870 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->db->sanitize($linked_info['table_link_line']) . " AS tll ON tll.".$this->db->sanitize($linked_info['fk_table_link_line']) . " = tl.".$this->db->sanitize($linked_info['fk_line_link']); |
|
870 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->db->sanitize($linked_info['table_link_line'])." AS tll ON tll.".$this->db->sanitize($linked_info['fk_table_link_line'])." = tl.".$this->db->sanitize($linked_info['fk_line_link']); |
|
871 | 871 | $sql .= ") AS tl"; |
872 | 872 | $sql .= " LEFT JOIN ("; |
873 | 873 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset |
874 | - $sql .= " SELECT DISTINCT " . $this->db->ifsql("tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent'])." IS NOT NULL", "tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent']), "tl.".$this->db->sanitize($linked_info['fk_link']))." AS fk_link, tl.".$this->db->sanitize($linked_info['fk_doc'])." AS fk_doc"; |
|
875 | - $sql .= " FROM " . MAIN_DB_PREFIX .$this->db->sanitize($linked_info['table'])." AS tl"; |
|
874 | + $sql .= " SELECT DISTINCT ".$this->db->ifsql("tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent'])." IS NOT NULL", "tll.".$this->db->sanitize($linked_info['fk_table_link_line_parent']), "tl.".$this->db->sanitize($linked_info['fk_link']))." AS fk_link, tl.".$this->db->sanitize($linked_info['fk_doc'])." AS fk_doc"; |
|
875 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->db->sanitize($linked_info['table'])." AS tl"; |
|
876 | 876 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset |
877 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $this->db->sanitize($linked_info['table_link_line']) . " AS tll ON tll.".$this->db->sanitize($linked_info['fk_table_link_line']) . " = tl.".$this->db->sanitize($linked_info['fk_line_link']); |
|
877 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->db->sanitize($linked_info['table_link_line'])." AS tll ON tll.".$this->db->sanitize($linked_info['fk_table_link_line'])." = tl.".$this->db->sanitize($linked_info['fk_line_link']); |
|
878 | 878 | $sql .= ") AS tl2 ON tl2.fk_link = tl.fk_link"; |
879 | - $sql .= " WHERE tl.fk_doc IN (" . $this->db->sanitize(implode(',', $document_ids)) . ")"; |
|
879 | + $sql .= " WHERE tl.fk_doc IN (".$this->db->sanitize(implode(',', $document_ids)).")"; |
|
880 | 880 | $sql .= " AND tl2.fk_doc IS NOT NULL"; |
881 | 881 | } |
882 | 882 | |
883 | - dol_syslog(__METHOD__ . " - Get document lines", LOG_DEBUG); |
|
883 | + dol_syslog(__METHOD__." - Get document lines", LOG_DEBUG); |
|
884 | 884 | $resql = $this->db->query($sql); |
885 | 885 | if (!$resql) { |
886 | - $this->errors[] = "Error " . $this->db->lasterror(); |
|
886 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
887 | 887 | return -1; |
888 | 888 | } |
889 | 889 | |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | while ($obj = $this->db->fetch_object($resql)) { |
892 | 892 | $current_document_ids[$obj->fk_doc] = $obj->fk_doc; |
893 | 893 | |
894 | - $link_key = $linked_info['prefix'] . $obj->fk_link; |
|
894 | + $link_key = $linked_info['prefix'].$obj->fk_link; |
|
895 | 895 | $element_by_link[$link_key][$obj->fk_doc] = $obj->fk_doc; |
896 | 896 | $link_by_element[$obj->fk_doc][$link_key] = $link_key; |
897 | 897 | if ($is_fk_link_is_also_fk_doc) { |
@@ -967,8 +967,8 @@ discard block |
||
967 | 967 | |
968 | 968 | if (empty($link_key)) { |
969 | 969 | // Restore list when is the begin of recursive function |
970 | - $link_by_element = $save_link_by_element; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable |
|
971 | - $element_by_link = $save_element_by_link; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable |
|
970 | + $link_by_element = $save_link_by_element; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable |
|
971 | + $element_by_link = $save_element_by_link; // @phan-suppress-current-line PhanPossiblyUndeclaredVariable |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | return $grouped_elements; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | if (empty($this->piece_num)) { |
373 | 373 | $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; |
374 | 374 | $sqlnum .= " FROM ".$this->db->prefix().$this->table_element; |
375 | - $sqlnum .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
375 | + $sqlnum .= " WHERE entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
376 | 376 | |
377 | 377 | $resqlnum = $this->db->query($sqlnum); |
378 | 378 | if ($resqlnum) { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | // Call triggers |
471 | - if (! $error && ! $notrigger) { |
|
471 | + if (!$error && !$notrigger) { |
|
472 | 472 | $result = $this->call_trigger('BOOKKEEPING_CREATE', $user); |
473 | 473 | if ($result < 0) { |
474 | 474 | $error++; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
553 | 553 | |
554 | 554 | global $action; |
555 | - $hookmanager->initHooks(array($this->element . 'dao')); |
|
555 | + $hookmanager->initHooks(array($this->element.'dao')); |
|
556 | 556 | $parameters = array('id' => $this->id, 'getnomurl' => &$result); |
557 | 557 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
558 | 558 | if ($reshook > 0) { |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | if (!$error) { |
720 | 720 | $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element.$mode); |
721 | 721 | // Call triggers |
722 | - if (! $notrigger) { |
|
722 | + if (!$notrigger) { |
|
723 | 723 | $result = $this->call_trigger('BOOKKEEPING_CREATE', $user); |
724 | 724 | if ($result < 0) { |
725 | 725 | $error++; |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | $sql .= " t.date_validated as date_validation"; |
785 | 785 | $sql .= ' FROM '.$this->db->prefix().$this->table_element.$mode.' as t'; |
786 | 786 | $sql .= ' WHERE 1 = 1'; |
787 | - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
787 | + $sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
788 | 788 | if (null !== $ref) { |
789 | 789 | $sql .= " AND t.rowid = ".((int) $ref); |
790 | 790 | } else { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | } |
957 | 957 | } |
958 | 958 | $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t'; |
959 | - $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
959 | + $sql .= ' WHERE entity = '.((int) $conf->entity); // Do not use getEntity for accounting features |
|
960 | 960 | if (count($sqlwhere) > 0) { |
961 | 961 | $sql .= " AND ".implode(" ".$this->db->sanitize($filtermode)." ", $sqlwhere); |
962 | 962 | } |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | $sql .= " t.date_validated as date_validation"; |
1092 | 1092 | $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t'; |
1093 | 1093 | |
1094 | - $sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1094 | + $sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features |
|
1095 | 1095 | if ($showAlreadyExportMovements == 0) { |
1096 | 1096 | $sql .= " AND t.date_export IS NULL"; |
1097 | 1097 | } |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | $sql .= " SUM(t.debit) as debit,"; |
1260 | 1260 | $sql .= " SUM(t.credit) as credit"; |
1261 | 1261 | $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t'; |
1262 | - $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1262 | + $sql .= ' WHERE entity = '.((int) $conf->entity); // Do not use getEntity for accounting features |
|
1263 | 1263 | |
1264 | 1264 | // Manage filter |
1265 | 1265 | if (is_array($filter)) { |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | } |
1488 | 1488 | |
1489 | 1489 | // Call triggers |
1490 | - if (! $error && ! $notrigger) { |
|
1490 | + if (!$error && !$notrigger) { |
|
1491 | 1491 | $result = $this->call_trigger('BOOKKEEPING_MODIFY', $user); |
1492 | 1492 | if ($result < 0) { |
1493 | 1493 | $error++; |
@@ -1580,7 +1580,7 @@ discard block |
||
1580 | 1580 | $this->db->begin(); |
1581 | 1581 | |
1582 | 1582 | // Call triggers |
1583 | - if (! $error && ! $notrigger) { |
|
1583 | + if (!$error && !$notrigger) { |
|
1584 | 1584 | $result = $this->call_trigger('BOOKKEEPING_DELETE', $user); |
1585 | 1585 | if ($result < 0) { |
1586 | 1586 | $error++; |
@@ -1683,7 +1683,7 @@ discard block |
||
1683 | 1683 | if (!empty($journal)) { |
1684 | 1684 | $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; |
1685 | 1685 | } |
1686 | - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1686 | + $sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
1687 | 1687 | // Exclusion of validated entries at the time of deletion |
1688 | 1688 | $sql .= " AND date_validated IS NULL"; |
1689 | 1689 | $sql .= $sql_filter; |
@@ -1730,8 +1730,8 @@ discard block |
||
1730 | 1730 | $sql = "DELETE"; |
1731 | 1731 | $sql .= " FROM ".$this->db->prefix().$this->table_element.$mode; |
1732 | 1732 | $sql .= " WHERE piece_num = ".(int) $piecenum; |
1733 | - $sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion |
|
1734 | - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1733 | + $sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion |
|
1734 | + $sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
1735 | 1735 | $sql .= $sql_filter; |
1736 | 1736 | |
1737 | 1737 | $resql = $this->db->query($sql); |
@@ -1859,7 +1859,7 @@ discard block |
||
1859 | 1859 | } |
1860 | 1860 | $sql .= " FROM ".$this->db->prefix().$this->table_element.$mode; |
1861 | 1861 | $sql .= " WHERE piece_num = ".((int) $piecenum); |
1862 | - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1862 | + $sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
1863 | 1863 | |
1864 | 1864 | dol_syslog(__METHOD__, LOG_DEBUG); |
1865 | 1865 | $result = $this->db->query($sql); |
@@ -1900,7 +1900,7 @@ discard block |
||
1900 | 1900 | global $conf; |
1901 | 1901 | |
1902 | 1902 | $sql = "SELECT MAX(piece_num)+1 as max FROM ".$this->db->prefix().$this->table_element.$mode; |
1903 | - $sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1903 | + $sql .= " WHERE entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
1904 | 1904 | |
1905 | 1905 | dol_syslog(get_class($this)."::getNextNumMvt", LOG_DEBUG); |
1906 | 1906 | |
@@ -1944,7 +1944,7 @@ discard block |
||
1944 | 1944 | } |
1945 | 1945 | $sql .= " FROM ".$this->db->prefix().$this->table_element.$mode; |
1946 | 1946 | $sql .= " WHERE piece_num = ".((int) $piecenum); |
1947 | - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
1947 | + $sql .= " AND entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
1948 | 1948 | |
1949 | 1949 | dol_syslog(__METHOD__, LOG_DEBUG); |
1950 | 1950 | $result = $this->db->query($sql); |
@@ -2009,7 +2009,7 @@ discard block |
||
2009 | 2009 | $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num,"; |
2010 | 2010 | $sql .= " date_validated as date_validation"; |
2011 | 2011 | $sql .= " FROM ".$this->db->prefix().$this->table_element; |
2012 | - $sql .= " WHERE entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
2012 | + $sql .= " WHERE entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
2013 | 2013 | |
2014 | 2014 | dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG); |
2015 | 2015 | |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | |
2088 | 2088 | if (!$error) { |
2089 | 2089 | // Delete if there is an empty line |
2090 | - $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"; |
|
2090 | + $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"; |
|
2091 | 2091 | $resql = $this->db->query($sql); |
2092 | 2092 | if (!$resql) { |
2093 | 2093 | $error++; |
@@ -2105,7 +2105,7 @@ discard block |
||
2105 | 2105 | $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; |
2106 | 2106 | $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; |
2107 | 2107 | $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; |
2108 | - $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); |
|
2108 | + $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); |
|
2109 | 2109 | $sql .= $sql_filter; |
2110 | 2110 | $resql = $this->db->query($sql); |
2111 | 2111 | if (!$resql) { |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | } |
2117 | 2117 | |
2118 | 2118 | if (!$error) { |
2119 | - $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); |
|
2119 | + $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity); |
|
2120 | 2120 | $resql = $this->db->query($sql); |
2121 | 2121 | if (!$resql) { |
2122 | 2122 | $error++; |
@@ -2126,7 +2126,7 @@ discard block |
||
2126 | 2126 | } |
2127 | 2127 | } elseif ($direction == 1) { |
2128 | 2128 | if (!$error) { |
2129 | - $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); |
|
2129 | + $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity); |
|
2130 | 2130 | $resql = $this->db->query($sql); |
2131 | 2131 | if (!$resql) { |
2132 | 2132 | $error++; |
@@ -2144,7 +2144,7 @@ discard block |
||
2144 | 2144 | $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; |
2145 | 2145 | $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; |
2146 | 2146 | $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; |
2147 | - $sql .= ' FROM '.$this->db->prefix().$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); |
|
2147 | + $sql .= ' FROM '.$this->db->prefix().$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity); |
|
2148 | 2148 | $sql .= $sql_filter; |
2149 | 2149 | $resql = $this->db->query($sql); |
2150 | 2150 | if (!$resql) { |
@@ -2155,7 +2155,7 @@ discard block |
||
2155 | 2155 | } |
2156 | 2156 | |
2157 | 2157 | if (!$error) { |
2158 | - $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); |
|
2158 | + $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = '.((int) $conf->entity); |
|
2159 | 2159 | $sql .= $sql_filter; |
2160 | 2160 | $resql = $this->db->query($sql); |
2161 | 2161 | if (!$resql) { |
@@ -2212,7 +2212,7 @@ discard block |
||
2212 | 2212 | $sql .= " AND aa.active = 1"; |
2213 | 2213 | $sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; |
2214 | 2214 | $sql .= " AND asy.rowid = ".((int) $pcgver); |
2215 | - $sql .= " AND ab.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
2215 | + $sql .= " AND ab.entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
2216 | 2216 | $sql .= " ORDER BY account_number ASC"; |
2217 | 2217 | |
2218 | 2218 | dol_syslog(get_class($this)."::select_account", LOG_DEBUG); |
@@ -2276,7 +2276,7 @@ discard block |
||
2276 | 2276 | $sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1"; |
2277 | 2277 | $sql .= " LEFT JOIN ".$this->db->prefix()."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1"; |
2278 | 2278 | $sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'"; |
2279 | - $sql .= " AND aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
2279 | + $sql .= " AND aa.entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
2280 | 2280 | |
2281 | 2281 | dol_syslog(get_class($this)."::select_account", LOG_DEBUG); |
2282 | 2282 | $resql = $this->db->query($sql); |
@@ -2316,7 +2316,7 @@ discard block |
||
2316 | 2316 | $sql .= " AND asy.rowid = ".((int) $pcgver); |
2317 | 2317 | $sql .= " AND aa.active = 1"; |
2318 | 2318 | $sql .= " LEFT JOIN ".$this->db->prefix()."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; |
2319 | - $sql .= " WHERE aa.entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
2319 | + $sql .= " WHERE aa.entity = ".((int) $conf->entity); // Do not use getEntity for accounting features |
|
2320 | 2320 | |
2321 | 2321 | dol_syslog(get_class($this)."::select_account", LOG_DEBUG); |
2322 | 2322 | $resql = $this->db->query($sql); |
@@ -2349,7 +2349,7 @@ discard block |
||
2349 | 2349 | global $conf; |
2350 | 2350 | |
2351 | 2351 | $alias = trim($alias); |
2352 | - $alias = !empty($alias) && strpos($alias, '.') === false ? $alias . "." : $alias; |
|
2352 | + $alias = !empty($alias) && strpos($alias, '.') === false ? $alias."." : $alias; |
|
2353 | 2353 | |
2354 | 2354 | if (!isset(self::$can_modify_bookkeeping_sql_cached[$alias]) || $force) { |
2355 | 2355 | $result = $this->loadFiscalPeriods($force, 'active'); |
@@ -2362,10 +2362,10 @@ discard block |
||
2362 | 2362 | $i = 0; |
2363 | 2363 | foreach ($conf->cache['active_fiscal_period_cached'] as $fiscal_period) { |
2364 | 2364 | $sql_list[$i] = "("; |
2365 | - $sql_list[$i] .= "'".$this->db->idate($fiscal_period['date_start']) . "' <= ".$this->db->sanitize($alias)."doc_date"; |
|
2365 | + $sql_list[$i] .= "'".$this->db->idate($fiscal_period['date_start'])."' <= ".$this->db->sanitize($alias)."doc_date"; |
|
2366 | 2366 | if (!empty($fiscal_period['date_end'])) { |
2367 | 2367 | $sql_list[$i] .= " AND "; |
2368 | - $sql_list[$i] .= $this->db->sanitize($alias)."doc_date <= '" . $this->db->idate($fiscal_period['date_end'])."'"; |
|
2368 | + $sql_list[$i] .= $this->db->sanitize($alias)."doc_date <= '".$this->db->idate($fiscal_period['date_end'])."'"; |
|
2369 | 2369 | } |
2370 | 2370 | $sql_list[$i] .= ")"; |
2371 | 2371 | $i++; |
@@ -2454,17 +2454,17 @@ discard block |
||
2454 | 2454 | // Avoid trunc with dot in accountancy for the compatibility with another accounting software |
2455 | 2455 | $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); |
2456 | 2456 | if (!empty($reference)) { |
2457 | - $accountingLabelOperation .= ' - '. $reference; |
|
2457 | + $accountingLabelOperation .= ' - '.$reference; |
|
2458 | 2458 | } |
2459 | 2459 | if (!empty($labelaccount)) { |
2460 | - $accountingLabelOperation .= ' - '. $labelaccount; |
|
2460 | + $accountingLabelOperation .= ' - '.$labelaccount; |
|
2461 | 2461 | } |
2462 | 2462 | } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) { |
2463 | 2463 | $truncThirdpartyName = 32; |
2464 | 2464 | // Avoid trunc with dot in accountancy for the compatibility with another accounting software |
2465 | 2465 | $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); |
2466 | 2466 | if (!empty($reference)) { |
2467 | - $accountingLabelOperation .= ' - '. $reference; |
|
2467 | + $accountingLabelOperation .= ' - '.$reference; |
|
2468 | 2468 | } |
2469 | 2469 | } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) { |
2470 | 2470 | $truncThirdpartyName = 64; |
@@ -2534,8 +2534,8 @@ discard block |
||
2534 | 2534 | if ($mode == 'active') { |
2535 | 2535 | if (!isset($conf->cache['active_fiscal_period_cached']) || $force) { |
2536 | 2536 | $sql = "SELECT date_start, date_end"; |
2537 | - $sql .= " FROM " . $this->db->prefix() . "accounting_fiscalyear"; |
|
2538 | - $sql .= " WHERE entity = " . ((int) $conf->entity); |
|
2537 | + $sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear"; |
|
2538 | + $sql .= " WHERE entity = ".((int) $conf->entity); |
|
2539 | 2539 | $sql .= " AND statut = 0"; |
2540 | 2540 | |
2541 | 2541 | $resql = $this->db->query($sql); |
@@ -2557,8 +2557,8 @@ discard block |
||
2557 | 2557 | if ($mode == 'closed') { |
2558 | 2558 | if (!isset($conf->cache['closed_fiscal_period_cached']) || $force) { |
2559 | 2559 | $sql = "SELECT date_start, date_end"; |
2560 | - $sql .= " FROM " . $this->db->prefix() . "accounting_fiscalyear"; |
|
2561 | - $sql .= " WHERE entity = " . ((int) $conf->entity); |
|
2560 | + $sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear"; |
|
2561 | + $sql .= " WHERE entity = ".((int) $conf->entity); |
|
2562 | 2562 | $sql .= " AND statut = 1"; |
2563 | 2563 | |
2564 | 2564 | $resql = $this->db->query($sql); |
@@ -2593,10 +2593,10 @@ discard block |
||
2593 | 2593 | $list = array(); |
2594 | 2594 | |
2595 | 2595 | $sql = "SELECT rowid, label, date_start, date_end, statut"; |
2596 | - $sql .= " FROM " . $this->db->prefix() . "accounting_fiscalyear"; |
|
2597 | - $sql .= " WHERE entity = " . ((int) $conf->entity); |
|
2596 | + $sql .= " FROM ".$this->db->prefix()."accounting_fiscalyear"; |
|
2597 | + $sql .= " WHERE entity = ".((int) $conf->entity); |
|
2598 | 2598 | if (!empty($filter)) { |
2599 | - $sql .= " AND (" . $this->db->sanitize($filter, 1, 1, 1) . ')'; |
|
2599 | + $sql .= " AND (".$this->db->sanitize($filter, 1, 1, 1).')'; |
|
2600 | 2600 | } |
2601 | 2601 | $sql .= $this->db->order('date_start', 'ASC'); |
2602 | 2602 | |
@@ -2636,13 +2636,13 @@ discard block |
||
2636 | 2636 | |
2637 | 2637 | $sql = "SELECT YEAR(b.doc_date) as year"; |
2638 | 2638 | for ($i = 1; $i <= 12; $i++) { |
2639 | - $sql .= ", SUM(".$this->db->ifsql("MONTH(b.doc_date) = ".((int) $i), "1", "0") . ") AS month".((int) $i); |
|
2639 | + $sql .= ", SUM(".$this->db->ifsql("MONTH(b.doc_date) = ".((int) $i), "1", "0").") AS month".((int) $i); |
|
2640 | 2640 | } |
2641 | 2641 | $sql .= ", COUNT(b.rowid) as total"; |
2642 | - $sql .= " FROM " . $this->db->prefix() . $this->table_element . " as b"; |
|
2643 | - $sql .= " WHERE b.doc_date >= '" . $this->db->idate($date_start) . "'"; |
|
2644 | - $sql .= " AND b.doc_date <= '" . $this->db->idate($date_end) . "'"; |
|
2645 | - $sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy |
|
2642 | + $sql .= " FROM ".$this->db->prefix().$this->table_element." as b"; |
|
2643 | + $sql .= " WHERE b.doc_date >= '".$this->db->idate($date_start)."'"; |
|
2644 | + $sql .= " AND b.doc_date <= '".$this->db->idate($date_end)."'"; |
|
2645 | + $sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy |
|
2646 | 2646 | |
2647 | 2647 | // Get count for each month into the fiscal period |
2648 | 2648 | if (getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) { |
@@ -2650,7 +2650,7 @@ discard block |
||
2650 | 2650 | $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)"; |
2651 | 2651 | } else { |
2652 | 2652 | // Filter on the unitary flag/date lock on each record |
2653 | - $sql .= " AND date_validated IS NULL"; // not locked |
|
2653 | + $sql .= " AND date_validated IS NULL"; // not locked |
|
2654 | 2654 | } |
2655 | 2655 | |
2656 | 2656 | $sql .= " GROUP BY YEAR(b.doc_date)"; |
@@ -2671,7 +2671,7 @@ discard block |
||
2671 | 2671 | 'total' => (int) $obj->total, |
2672 | 2672 | ); |
2673 | 2673 | for ($i = 1; $i <= 12; $i++) { |
2674 | - $year_list['count'][$i] = (int) $obj->{'month' . $i}; |
|
2674 | + $year_list['count'][$i] = (int) $obj->{'month'.$i}; |
|
2675 | 2675 | } |
2676 | 2676 | |
2677 | 2677 | $list[] = $year_list; |
@@ -2699,11 +2699,11 @@ discard block |
||
2699 | 2699 | $now = dol_now(); |
2700 | 2700 | |
2701 | 2701 | // Specify as export : update field date_validated on selected month/year |
2702 | - $sql = " UPDATE " . $this->db->prefix() . $this->table_element; |
|
2703 | - $sql .= " SET date_validated = '" . $this->db->idate($now) . "'"; |
|
2704 | - $sql .= " WHERE entity = " . ((int) $conf->entity); |
|
2705 | - $sql .= " AND DATE(doc_date) >= '" . $this->db->idate($date_start) . "'"; |
|
2706 | - $sql .= " AND DATE(doc_date) <= '" . $this->db->idate($date_end) . "'"; |
|
2702 | + $sql = " UPDATE ".$this->db->prefix().$this->table_element; |
|
2703 | + $sql .= " SET date_validated = '".$this->db->idate($now)."'"; |
|
2704 | + $sql .= " WHERE entity = ".((int) $conf->entity); |
|
2705 | + $sql .= " AND DATE(doc_date) >= '".$this->db->idate($date_start)."'"; |
|
2706 | + $sql .= " AND DATE(doc_date) <= '".$this->db->idate($date_end)."'"; |
|
2707 | 2707 | $sql .= " AND date_validated IS NULL"; |
2708 | 2708 | |
2709 | 2709 | dol_syslog(__METHOD__, LOG_DEBUG); |
@@ -2736,27 +2736,27 @@ discard block |
||
2736 | 2736 | |
2737 | 2737 | $pcg_type_filter = array(); |
2738 | 2738 | foreach ($accounting_groups_used_for_income_statement as $item) { |
2739 | - $pcg_type_filter[] = "'" . $this->db->escape($item) . "'"; |
|
2739 | + $pcg_type_filter[] = "'".$this->db->escape($item)."'"; |
|
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | $sql = 'SELECT'; |
2743 | 2743 | $sql .= " t.numero_compte,"; |
2744 | 2744 | $sql .= " aa.pcg_type,"; |
2745 | 2745 | $sql .= " (SUM(t.credit) - SUM(t.debit)) as accounting_result"; |
2746 | - $sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t'; |
|
2747 | - $sql .= ' LEFT JOIN ' . $this->db->prefix() . 'accounting_account as aa ON aa.account_number = t.numero_compte'; |
|
2748 | - $sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
2749 | - $sql .= " AND aa.entity = " . ((int) $conf->entity); |
|
2750 | - $sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM ' . $this->db->prefix() . 'accounting_system WHERE rowid = ' . ((int) getDolGlobalInt('CHARTOFACCOUNTS')) . ')'; |
|
2751 | - $sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')'; |
|
2752 | - $sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($date_start) . "'"; |
|
2753 | - $sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($date_end) . "'"; |
|
2746 | + $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t'; |
|
2747 | + $sql .= ' LEFT JOIN '.$this->db->prefix().'accounting_account as aa ON aa.account_number = t.numero_compte'; |
|
2748 | + $sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features |
|
2749 | + $sql .= " AND aa.entity = ".((int) $conf->entity); |
|
2750 | + $sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM '.$this->db->prefix().'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')'; |
|
2751 | + $sql .= ' AND aa.pcg_type IN ('.$this->db->sanitize(implode(',', $pcg_type_filter), 1).')'; |
|
2752 | + $sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($date_start)."'"; |
|
2753 | + $sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($date_end)."'"; |
|
2754 | 2754 | $sql .= ' GROUP BY t.numero_compte, aa.pcg_type'; |
2755 | 2755 | |
2756 | 2756 | $resql = $this->db->query($sql); |
2757 | 2757 | if (!$resql) { |
2758 | - $this->errors[] = 'Error ' . $this->db->lasterror(); |
|
2759 | - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); |
|
2758 | + $this->errors[] = 'Error '.$this->db->lasterror(); |
|
2759 | + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); |
|
2760 | 2760 | } else { |
2761 | 2761 | while ($obj = $this->db->fetch_object($resql)) { |
2762 | 2762 | $income_statement_amount += $obj->accounting_result; |
@@ -2795,7 +2795,7 @@ discard block |
||
2795 | 2795 | return -1; |
2796 | 2796 | } elseif (empty($fiscal_period->id)) { |
2797 | 2797 | $langs->loadLangs(array('errors', 'compta')); |
2798 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $fiscal_period_id . ')'; |
|
2798 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$fiscal_period_id.')'; |
|
2799 | 2799 | return -1; |
2800 | 2800 | } |
2801 | 2801 | |
@@ -2814,7 +2814,7 @@ discard block |
||
2814 | 2814 | return -1; |
2815 | 2815 | } elseif (empty($new_fiscal_period->id)) { |
2816 | 2816 | $langs->loadLangs(array('errors', 'compta')); |
2817 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $new_fiscal_period_id . ')'; |
|
2817 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$new_fiscal_period_id.')'; |
|
2818 | 2818 | return -1; |
2819 | 2819 | } |
2820 | 2820 | |
@@ -2834,7 +2834,7 @@ discard block |
||
2834 | 2834 | $journal_id = max(0, getDolGlobalString('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL')); |
2835 | 2835 | if (empty($journal_id)) { |
2836 | 2836 | $langs->loadLangs(array('errors', 'accountancy')); |
2837 | - $this->errors[] = $langs->trans('ErrorBadParameters') . ' - ' . $langs->trans('Codejournal') . ' (' . $langs->trans('AccountingJournalType9') . ')'; |
|
2837 | + $this->errors[] = $langs->trans('ErrorBadParameters').' - '.$langs->trans('Codejournal').' ('.$langs->trans('AccountingJournalType9').')'; |
|
2838 | 2838 | $error++; |
2839 | 2839 | } |
2840 | 2840 | |
@@ -2848,7 +2848,7 @@ discard block |
||
2848 | 2848 | $error++; |
2849 | 2849 | } elseif ($result == 0) { |
2850 | 2850 | $langs->loadLangs(array('errors', 'accountancy')); |
2851 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('Codejournal') . ' (' . $langs->trans('AccountingJournalType9') . ')'; |
|
2851 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('Codejournal').' ('.$langs->trans('AccountingJournalType9').')'; |
|
2852 | 2852 | $error++; |
2853 | 2853 | } |
2854 | 2854 | } else { |
@@ -2862,7 +2862,7 @@ discard block |
||
2862 | 2862 | $pcg_type_filter = array(); |
2863 | 2863 | $tmp = array_merge($accounting_groups_used_for_balance_sheet_account, $accounting_groups_used_for_income_statement); |
2864 | 2864 | foreach ($tmp as $item) { |
2865 | - $pcg_type_filter[] = "'" . $this->db->escape($item) . "'"; |
|
2865 | + $pcg_type_filter[] = "'".$this->db->escape($item)."'"; |
|
2866 | 2866 | } |
2867 | 2867 | |
2868 | 2868 | $sql = 'SELECT'; |
@@ -2872,14 +2872,14 @@ discard block |
||
2872 | 2872 | } |
2873 | 2873 | $sql .= " aa.pcg_type,"; |
2874 | 2874 | $sql .= " (SUM(t.credit) - SUM(t.debit)) as opening_balance"; |
2875 | - $sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t'; |
|
2876 | - $sql .= ' LEFT JOIN ' . $this->db->prefix() . 'accounting_account as aa ON aa.account_number = t.numero_compte'; |
|
2877 | - $sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
2878 | - $sql .= " AND aa.entity = ". ((int) $conf->entity); |
|
2875 | + $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t'; |
|
2876 | + $sql .= ' LEFT JOIN '.$this->db->prefix().'accounting_account as aa ON aa.account_number = t.numero_compte'; |
|
2877 | + $sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features |
|
2878 | + $sql .= " AND aa.entity = ".((int) $conf->entity); |
|
2879 | 2879 | $sql .= ' AND aa.fk_pcg_version IN (SELECT pcg_version FROM '.$this->db->prefix().'accounting_system WHERE rowid = '.((int) getDolGlobalInt('CHARTOFACCOUNTS')).')'; |
2880 | - $sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')'; |
|
2881 | - $sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'"; |
|
2882 | - $sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'"; |
|
2880 | + $sql .= ' AND aa.pcg_type IN ('.$this->db->sanitize(implode(',', $pcg_type_filter), 1).')'; |
|
2881 | + $sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($fiscal_period->date_start)."'"; |
|
2882 | + $sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($fiscal_period->date_end)."'"; |
|
2883 | 2883 | $sql .= ' GROUP BY t.numero_compte, aa.pcg_type'; |
2884 | 2884 | if ($separate_auxiliary_account) { |
2885 | 2885 | $sql .= " , NULLIF(t.subledger_account, '')"; |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | |
2890 | 2890 | $resql = $this->db->query($sql); |
2891 | 2891 | if (!$resql) { |
2892 | - $this->errors[] = 'Error ' . $this->db->lasterror(); |
|
2893 | - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); |
|
2892 | + $this->errors[] = 'Error '.$this->db->lasterror(); |
|
2893 | + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); |
|
2894 | 2894 | |
2895 | 2895 | $error++; |
2896 | 2896 | } else { |
@@ -2919,14 +2919,14 @@ discard block |
||
2919 | 2919 | $bookkeeping->subledger_account = $obj->subledger_account; |
2920 | 2920 | $sql = 'SELECT'; |
2921 | 2921 | $sql .= " subledger_label"; |
2922 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
2923 | - $sql .= " WHERE subledger_account = '" . $this->db->escape($obj->subledger_account) . "'"; |
|
2922 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
2923 | + $sql .= " WHERE subledger_account = '".$this->db->escape($obj->subledger_account)."'"; |
|
2924 | 2924 | $sql .= " ORDER BY doc_date DESC"; |
2925 | 2925 | $sql .= " LIMIT 1"; |
2926 | 2926 | $result = $this->db->query($sql); |
2927 | 2927 | if (!$result) { |
2928 | - $this->errors[] = 'Error: ' . $this->db->lasterror(); |
|
2929 | - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
2928 | + $this->errors[] = 'Error: '.$this->db->lasterror(); |
|
2929 | + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); |
|
2930 | 2930 | $error++; |
2931 | 2931 | } |
2932 | 2932 | $objtmp = $this->db->fetch_object($result); |
@@ -2983,14 +2983,14 @@ discard block |
||
2983 | 2983 | $bookkeeping->subledger_account = $obj->subledger_account; |
2984 | 2984 | $sql = 'SELECT'; |
2985 | 2985 | $sql .= " subledger_label"; |
2986 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; |
|
2987 | - $sql .= " WHERE subledger_account = '" . $this->db->escape($obj->subledger_account) . "'"; |
|
2986 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
|
2987 | + $sql .= " WHERE subledger_account = '".$this->db->escape($obj->subledger_account)."'"; |
|
2988 | 2988 | $sql .= " ORDER BY doc_date DESC"; |
2989 | 2989 | $sql .= " LIMIT 1"; |
2990 | 2990 | $result = $this->db->query($sql); |
2991 | 2991 | if (!$result) { |
2992 | - $this->errors[] = 'Error: ' . $this->db->lasterror(); |
|
2993 | - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
2992 | + $this->errors[] = 'Error: '.$this->db->lasterror(); |
|
2993 | + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); |
|
2994 | 2994 | $error++; |
2995 | 2995 | } |
2996 | 2996 | $objtmp = $this->db->fetch_object($result); |
@@ -3063,7 +3063,7 @@ discard block |
||
3063 | 3063 | return -1; |
3064 | 3064 | } elseif (empty($fiscal_period->id)) { |
3065 | 3065 | $langs->loadLangs(array('errors', 'compta')); |
3066 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $fiscal_period_id . ')'; |
|
3066 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$fiscal_period_id.')'; |
|
3067 | 3067 | return -1; |
3068 | 3068 | } |
3069 | 3069 | |
@@ -3082,7 +3082,7 @@ discard block |
||
3082 | 3082 | return -1; |
3083 | 3083 | } elseif (empty($new_fiscal_period->id)) { |
3084 | 3084 | $langs->loadLangs(array('errors', 'compta')); |
3085 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('FiscalPeriod') . ' (' . $new_fiscal_period_id . ')'; |
|
3085 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('FiscalPeriod').' ('.$new_fiscal_period_id.')'; |
|
3086 | 3086 | return -1; |
3087 | 3087 | } |
3088 | 3088 | |
@@ -3102,7 +3102,7 @@ discard block |
||
3102 | 3102 | return -1; |
3103 | 3103 | } elseif ($result == 0) { |
3104 | 3104 | $langs->loadLangs(array('errors', 'accountancy')); |
3105 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('InventoryJournal'); |
|
3105 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('InventoryJournal'); |
|
3106 | 3106 | return -1; |
3107 | 3107 | } |
3108 | 3108 | |
@@ -3110,18 +3110,18 @@ discard block |
||
3110 | 3110 | $this->db->begin(); |
3111 | 3111 | |
3112 | 3112 | $sql = 'SELECT t.rowid'; |
3113 | - $sql .= ' FROM ' . $this->db->prefix() . $this->table_element . ' as t'; |
|
3114 | - $sql .= ' WHERE t.entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features |
|
3115 | - $sql .= " AND code_journal = '" . $this->db->escape($inventory_journal->code) . "'"; |
|
3116 | - $sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($date_start) . "'"; |
|
3117 | - $sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($date_end) . "'"; |
|
3118 | - $sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'"; |
|
3119 | - $sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'"; |
|
3113 | + $sql .= ' FROM '.$this->db->prefix().$this->table_element.' as t'; |
|
3114 | + $sql .= ' WHERE t.entity = '.((int) $conf->entity); // Do not use getEntity for accounting features |
|
3115 | + $sql .= " AND code_journal = '".$this->db->escape($inventory_journal->code)."'"; |
|
3116 | + $sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($date_start)."'"; |
|
3117 | + $sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($date_end)."'"; |
|
3118 | + $sql .= " AND DATE(t.doc_date) >= '".$this->db->idate($fiscal_period->date_start)."'"; |
|
3119 | + $sql .= " AND DATE(t.doc_date) <= '".$this->db->idate($fiscal_period->date_end)."'"; |
|
3120 | 3120 | |
3121 | 3121 | $resql = $this->db->query($sql); |
3122 | 3122 | if (!$resql) { |
3123 | - $this->errors[] = 'Error ' . $this->db->lasterror(); |
|
3124 | - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); |
|
3123 | + $this->errors[] = 'Error '.$this->db->lasterror(); |
|
3124 | + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); |
|
3125 | 3125 | |
3126 | 3126 | $error++; |
3127 | 3127 | } else { |
@@ -3136,7 +3136,7 @@ discard block |
||
3136 | 3136 | break; |
3137 | 3137 | } elseif ($result == 0) { |
3138 | 3138 | $langs->loadLangs(array('errors', 'accountancy')); |
3139 | - $this->errors[] = $langs->trans('ErrorRecordNotFound') . ' - ' . $langs->trans('LineId') . ': ' . $obj->rowid; |
|
3139 | + $this->errors[] = $langs->trans('ErrorRecordNotFound').' - '.$langs->trans('LineId').': '.$obj->rowid; |
|
3140 | 3140 | $error++; |
3141 | 3141 | break; |
3142 | 3142 | } |