@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | if ($line->fk_product) { |
649 | 649 | $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - strlen($line->subprice) - 10 - 1; |
650 | 650 | $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0); |
651 | - $this->printer->text($line->ref . $spaces . $line->qty . str_pad(price($line->subprice), 10, ' ', STR_PAD_LEFT) . ' ' . str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT) . "\n"); |
|
651 | + $this->printer->text($line->ref.$spaces.$line->qty.str_pad(price($line->subprice), 10, ' ', STR_PAD_LEFT).' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); |
|
652 | 652 | $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n \n"); |
653 | 653 | } else { |
654 | 654 | $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - strlen($line->subprice) - 10 - 1; |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); |
718 | 718 | break; |
719 | 719 | case 'DOL_PRINT_CURR_DATE': |
720 | - if (strlen($vals[$tplline]['value'])<2) $this->printer->text(date('d/m/Y H:i:s')."\n"); |
|
720 | + if (strlen($vals[$tplline]['value']) < 2) $this->printer->text(date('d/m/Y H:i:s')."\n"); |
|
721 | 721 | else $this->printer->text(date($vals[$tplline]['value'])."\n"); |
722 | 722 | break; |
723 | 723 | case 'DOL_LINE_FEED': |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $this->printer->getPrintConnector() -> write("\x1e"); |
804 | 804 | break; |
805 | 805 | case 'DOL_BEEP_ALTERNATIVE': //if DOL_BEEP not works |
806 | - $this->printer->getPrintConnector() -> write(Printer::ESC . "B" . chr(4) . chr(1)); |
|
806 | + $this->printer->getPrintConnector() -> write(Printer::ESC."B".chr(4).chr(1)); |
|
807 | 807 | break; |
808 | 808 | case 'DOL_PRINT_ORDER_LINES': |
809 | 809 | foreach ($object->lines as $line) { |
@@ -717,8 +717,11 @@ |
||
717 | 717 | $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); |
718 | 718 | break; |
719 | 719 | case 'DOL_PRINT_CURR_DATE': |
720 | - if (strlen($vals[$tplline]['value'])<2) $this->printer->text(date('d/m/Y H:i:s')."\n"); |
|
721 | - else $this->printer->text(date($vals[$tplline]['value'])."\n"); |
|
720 | + if (strlen($vals[$tplline]['value'])<2) { |
|
721 | + $this->printer->text(date('d/m/Y H:i:s')."\n"); |
|
722 | + } else { |
|
723 | + $this->printer->text(date($vals[$tplline]['value'])."\n"); |
|
724 | + } |
|
722 | 725 | break; |
723 | 726 | case 'DOL_LINE_FEED': |
724 | 727 | $this->printer->feed(); |
@@ -894,7 +894,10 @@ |
||
894 | 894 | if ($num_rows == 1) { |
895 | 895 | $res = $this->db->fetch_object($resql); |
896 | 896 | $lastinsertid = $res->rowid; |
897 | - if ($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists |
|
897 | + if ($is_table_category_link) { |
|
898 | + $lastinsertid = 'linktable'; |
|
899 | + } |
|
900 | + // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists |
|
898 | 901 | $last_insert_id_array[$tablename] = $lastinsertid; |
899 | 902 | } elseif ($num_rows > 1) { |
900 | 903 | $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
30 | 30 | use PhpOffice\PhpSpreadsheet\Style\Alignment; |
31 | 31 | |
32 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/import/modules_import.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | // phpcs:enable |
141 | 141 | global $user, $conf, $langs, $file; |
142 | 142 | // create a temporary object, the final output will be generated in footer |
143 | - $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs) . ' - Dolibarr ' . DOL_VERSION); |
|
144 | - $this->workbook->getProperties()->setTitle($outputlangs->trans("Import") . ' - ' . $file); |
|
145 | - $this->workbook->getProperties()->setSubject($outputlangs->trans("Import") . ' - ' . $file); |
|
146 | - $this->workbook->getProperties()->setDescription($outputlangs->trans("Import") . ' - ' . $file); |
|
143 | + $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION); |
|
144 | + $this->workbook->getProperties()->setTitle($outputlangs->trans("Import").' - '.$file); |
|
145 | + $this->workbook->getProperties()->setSubject($outputlangs->trans("Import").' - '.$file); |
|
146 | + $this->workbook->getProperties()->setDescription($outputlangs->trans("Import").' - '.$file); |
|
147 | 147 | |
148 | 148 | $this->workbook->setActiveSheetIndex(0); |
149 | 149 | $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet")); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | global $langs; |
237 | 237 | $ret = 1; |
238 | 238 | |
239 | - dol_syslog(get_class($this) . "::open_file file=" . $file); |
|
239 | + dol_syslog(get_class($this)."::open_file file=".$file); |
|
240 | 240 | |
241 | 241 | $reader = new Xlsx(); |
242 | 242 | $this->workbook = $reader->load($file); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | // Define $tablewithentity_cache[$tablename] if not already defined |
391 | 391 | if (!isset($tablewithentity_cache[$tablename])) { // keep this test with "isset" |
392 | - dol_syslog("Check if table " . $tablename . " has an entity field"); |
|
392 | + dol_syslog("Check if table ".$tablename." has an entity field"); |
|
393 | 393 | $resql = $this->db->DDLDescTable($tablename, 'entity'); |
394 | 394 | if ($resql) { |
395 | 395 | $obj = $this->db->fetch_object($resql); |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); |
463 | 463 | $class = $objimport->array_import_convertvalue[0][$val]['class']; |
464 | 464 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
465 | - if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval] != '') { |
|
466 | - $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval]; |
|
465 | + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') { |
|
466 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
|
467 | 467 | } else { |
468 | 468 | $resultload = dol_include_once($file); |
469 | 469 | if (empty($resultload)) { |
470 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
470 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
471 | 471 | break; |
472 | 472 | } |
473 | 473 | $classinstance = new $class($this->db); |
@@ -509,12 +509,12 @@ discard block |
||
509 | 509 | $param_array = array('', '', $newval); |
510 | 510 | call_user_func_array(array($classinstance, $method), $param_array); |
511 | 511 | } |
512 | - $this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval] = $classinstance->id; |
|
512 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] = $classinstance->id; |
|
513 | 513 | |
514 | 514 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
515 | 515 | if ($classinstance->id != '') { // id may be 0, it is a found value |
516 | 516 | $newval = $classinstance->id; |
517 | - } elseif (! $error) { |
|
517 | + } elseif (!$error) { |
|
518 | 518 | if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { |
519 | 519 | $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
520 | 520 | } elseif (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
542 | 542 | $codefromfield = $objimport->array_import_convertvalue[0][$val]['codefromfield']; |
543 | 543 | $code = $arrayrecord[$arrayfield[$codefromfield]]['val']; |
544 | - if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval] != '') { |
|
545 | - $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval]; |
|
544 | + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval] != '') { |
|
545 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval]; |
|
546 | 546 | } else { |
547 | 547 | $resultload = dol_include_once($file); |
548 | 548 | if (empty($resultload)) { |
549 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method . ', code=' . $code); |
|
549 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', code='.$code); |
|
550 | 550 | break; |
551 | 551 | } |
552 | 552 | $classinstance = new $class($this->db); |
553 | 553 | // Try the fetch from code and ref |
554 | 554 | $param_array = array('', $newval, $code); |
555 | 555 | call_user_func_array(array($classinstance, $method), $param_array); |
556 | - $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval] = $classinstance->id; |
|
556 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval] = $classinstance->id; |
|
557 | 557 | if ($classinstance->id > 0) { // we found record |
558 | 558 | $newval = $classinstance->id; |
559 | 559 | } else { |
@@ -577,19 +577,19 @@ discard block |
||
577 | 577 | $class = $objimport->array_import_convertvalue[0][$val]['class']; |
578 | 578 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
579 | 579 | $units = $objimport->array_import_convertvalue[0][$val]['units']; |
580 | - if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval] != '') { |
|
581 | - $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval]; |
|
580 | + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '') { |
|
581 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]; |
|
582 | 582 | } else { |
583 | 583 | $resultload = dol_include_once($file); |
584 | 584 | if (empty($resultload)) { |
585 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method . ', units=' . $units); |
|
585 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); |
|
586 | 586 | break; |
587 | 587 | } |
588 | 588 | $classinstance = new $class($this->db); |
589 | 589 | // Try the fetch from code or ref |
590 | 590 | call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); |
591 | 591 | $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); |
592 | - $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval] = $scaleorid; |
|
592 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; |
|
593 | 593 | //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; |
594 | 594 | if ($classinstance->id > 0) { // we found record |
595 | 595 | $newval = $scaleorid ? $scaleorid : 0; |
@@ -681,13 +681,13 @@ discard block |
||
681 | 681 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
682 | 682 | $resultload = dol_include_once($file); |
683 | 683 | if (empty($resultload)) { |
684 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
684 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
685 | 685 | break; |
686 | 686 | } |
687 | 687 | $classinstance = new $class($this->db); |
688 | 688 | $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $arrayfield, $key)); |
689 | 689 | if (empty($classinstance->error) && empty($classinstance->errors)) { |
690 | - $newval = $res; // We get new value computed. |
|
690 | + $newval = $res; // We get new value computed. |
|
691 | 691 | } else { |
692 | 692 | $this->errors[$error]['type'] = 'CLASSERROR'; |
693 | 693 | $this->errors[$error]['lib'] = implode( |
@@ -719,16 +719,16 @@ discard block |
||
719 | 719 | $table = $reg[2]; |
720 | 720 | $filter = !empty($reg[3]) ? substr($reg[3], 1) : ''; |
721 | 721 | |
722 | - $cachekey = $field . '@' . $table; |
|
722 | + $cachekey = $field.'@'.$table; |
|
723 | 723 | if (!empty($filter)) { |
724 | - $cachekey .= ':' . $filter; |
|
724 | + $cachekey .= ':'.$filter; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // Load content of field@table into cache array |
728 | 728 | if (!is_array($this->cachefieldtable[$cachekey])) { // If content of field@table not already loaded into cache |
729 | - $sql = "SELECT " . $field . " as aliasfield FROM " . $table; |
|
729 | + $sql = "SELECT ".$field." as aliasfield FROM ".$table; |
|
730 | 730 | if (!empty($filter)) { |
731 | - $sql .= ' WHERE ' . $filter; |
|
731 | + $sql .= ' WHERE '.$filter; |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | $resql = $this->db->query($sql); |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { |
752 | 752 | $tableforerror = $table; |
753 | 753 | if (!empty($filter)) { |
754 | - $tableforerror .= ':' . $filter; |
|
754 | + $tableforerror .= ':'.$filter; |
|
755 | 755 | } |
756 | 756 | $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); |
757 | 757 | $this->errors[$error]['type'] = 'FOREIGNKEY'; |
758 | 758 | $errorforthistable++; |
759 | 759 | $error++; |
760 | 760 | } |
761 | - } elseif (!preg_match('/' . $objimport->array_import_regex[0][$val] . '/i', $newval)) { |
|
761 | + } elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { |
|
762 | 762 | // If test is just a static regex |
763 | 763 | //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."<br>"; |
764 | 764 | $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); |
@@ -785,11 +785,11 @@ discard block |
||
785 | 785 | if (isModEnabled("socialnetworks") && strpos($fieldname, "socialnetworks") !== false) { |
786 | 786 | if (!in_array("socialnetworks", $listfields)) { |
787 | 787 | $listfields[] = "socialnetworks"; |
788 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
788 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
789 | 789 | $listvalues[$socialkey] = ''; |
790 | 790 | } |
791 | 791 | if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { |
792 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
792 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
793 | 793 | $socialnetwork = explode("_", $fieldname)[1]; |
794 | 794 | if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { |
795 | 795 | $json = new stdClass(); |
@@ -828,18 +828,18 @@ discard block |
||
828 | 828 | continue; // Not a field of current table |
829 | 829 | } |
830 | 830 | if ($val == 'user->id') { |
831 | - $listfields[] = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); |
|
831 | + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); |
|
832 | 832 | $listvalues[] = ((int) $user->id); |
833 | 833 | } elseif (preg_match('/^lastrowid-/', $val)) { |
834 | 834 | $tmp = explode('-', $val); |
835 | 835 | $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; |
836 | - $keyfield = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); |
|
836 | + $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); |
|
837 | 837 | $listfields[] = $keyfield; |
838 | 838 | $listvalues[] = $lastinsertid; |
839 | 839 | //print $key."-".$val."-".$listfields."-".$listvalues."<br>";exit; |
840 | 840 | } elseif (preg_match('/^const-/', $val)) { |
841 | 841 | $tmp = explode('-', $val, 2); |
842 | - $listfields[] = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); |
|
842 | + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); |
|
843 | 843 | $listvalues[] = "'".$this->db->escape($tmp[1])."'"; |
844 | 844 | } elseif (preg_match('/^rule-/', $val)) { |
845 | 845 | $fieldname = $key; |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | $method = $objimport->array_import_convertvalue[0][$fieldname]['method']; |
851 | 851 | $resultload = dol_include_once($file); |
852 | 852 | if (empty($resultload)) { |
853 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
853 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
854 | 854 | break; |
855 | 855 | } |
856 | 856 | $classinstance = new $class($this->db); |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | } |
873 | 873 | } |
874 | 874 | } else { |
875 | - $this->errors[$error]['lib'] = 'Bad value of profile setup ' . $val . ' for array_import_fieldshidden'; |
|
875 | + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; |
|
876 | 876 | $this->errors[$error]['type'] = 'Import profile setup'; |
877 | 877 | $error++; |
878 | 878 | } |
@@ -892,19 +892,19 @@ discard block |
||
892 | 892 | $fname = 'rowid'; |
893 | 893 | if (strpos($tablename, '_categorie_') !== false) { |
894 | 894 | $is_table_category_link = true; |
895 | - $fname='*'; |
|
895 | + $fname = '*'; |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | if (!empty($updatekeys)) { |
899 | 899 | // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) |
900 | 900 | |
901 | 901 | if (empty($lastinsertid)) { // No insert done yet for a parent table |
902 | - $sqlSelect = "SELECT ".$fname." FROM " . $tablename; |
|
902 | + $sqlSelect = "SELECT ".$fname." FROM ".$tablename; |
|
903 | 903 | |
904 | 904 | $data = array_combine($listfields, $listvalues); |
905 | 905 | |
906 | - $where = array(); // filters to forge SQL request |
|
907 | - $filters = array(); // filters to forge output error message |
|
906 | + $where = array(); // filters to forge SQL request |
|
907 | + $filters = array(); // filters to forge output error message |
|
908 | 908 | foreach ($updatekeys as $key) { |
909 | 909 | $col = $objimport->array_import_updatekeys[0][$key]; |
910 | 910 | $key = preg_replace('/^.*\./i', '', $key); |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | $where[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; |
930 | 930 | $filters[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; |
931 | 931 | } |
932 | - $sqlSelect .= " WHERE " . implode(' AND ', $where); |
|
932 | + $sqlSelect .= " WHERE ".implode(' AND ', $where); |
|
933 | 933 | |
934 | 934 | $resql = $this->db->query($sqlSelect); |
935 | 935 | if ($resql) { |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record |
959 | 959 | // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. |
960 | 960 | // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' |
961 | - $sqlSelect = "SELECT rowid FROM " . $tablename; |
|
961 | + $sqlSelect = "SELECT rowid FROM ".$tablename; |
|
962 | 962 | |
963 | 963 | |
964 | 964 | if (empty($keyfield)) { |
@@ -992,34 +992,34 @@ discard block |
||
992 | 992 | // We db escape social network field because he isn't in field creation |
993 | 993 | if (in_array("socialnetworks", $listfields)) { |
994 | 994 | $socialkey = array_search("socialnetworks", $listfields); |
995 | - $tmpsql = $listvalues[$socialkey]; |
|
995 | + $tmpsql = $listvalues[$socialkey]; |
|
996 | 996 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
997 | 997 | } |
998 | 998 | |
999 | 999 | // Build SQL UPDATE request |
1000 | - $sqlstart = "UPDATE " . $tablename; |
|
1000 | + $sqlstart = "UPDATE ".$tablename; |
|
1001 | 1001 | |
1002 | 1002 | $data = array_combine($listfields, $listvalues); |
1003 | 1003 | $set = array(); |
1004 | 1004 | foreach ($data as $key => $val) { |
1005 | 1005 | $set[] = $key." = ".$val; |
1006 | 1006 | } |
1007 | - $sqlstart .= " SET " . implode(', ', $set); |
|
1007 | + $sqlstart .= " SET ".implode(', ', $set); |
|
1008 | 1008 | |
1009 | 1009 | if (empty($keyfield)) { |
1010 | 1010 | $keyfield = 'rowid'; |
1011 | 1011 | } |
1012 | - $sqlend = " WHERE " . $keyfield . " = ".((int) $lastinsertid); |
|
1012 | + $sqlend = " WHERE ".$keyfield." = ".((int) $lastinsertid); |
|
1013 | 1013 | |
1014 | 1014 | if ($is_table_category_link) { |
1015 | - $sqlend = " WHERE " . implode(' AND ', $where); |
|
1015 | + $sqlend = " WHERE ".implode(' AND ', $where); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | if (!empty($tablewithentity_cache[$tablename])) { |
1019 | 1019 | $sqlend .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - $sql = $sqlstart . $sqlend; |
|
1022 | + $sql = $sqlstart.$sqlend; |
|
1023 | 1023 | |
1024 | 1024 | // Run update request |
1025 | 1025 | $resql = $this->db->query($sql); |
@@ -1040,22 +1040,22 @@ discard block |
||
1040 | 1040 | // We db escape social network field because he isn't in field creation |
1041 | 1041 | if (in_array("socialnetworks", $listfields)) { |
1042 | 1042 | $socialkey = array_search("socialnetworks", $listfields); |
1043 | - $tmpsql = $listvalues[$socialkey]; |
|
1043 | + $tmpsql = $listvalues[$socialkey]; |
|
1044 | 1044 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | // Build SQL INSERT request |
1048 | - $sqlstart = "INSERT INTO " . $tablename . "(" . implode(", ", $listfields) . ", import_key"; |
|
1049 | - $sqlend = ") VALUES(" . implode(', ', $listvalues) . ", '" . $this->db->escape($importid) . "'"; |
|
1048 | + $sqlstart = "INSERT INTO ".$tablename."(".implode(", ", $listfields).", import_key"; |
|
1049 | + $sqlend = ") VALUES(".implode(', ', $listvalues).", '".$this->db->escape($importid)."'"; |
|
1050 | 1050 | if (!empty($tablewithentity_cache[$tablename])) { |
1051 | 1051 | $sqlstart .= ", entity"; |
1052 | - $sqlend .= ", " . $conf->entity; |
|
1052 | + $sqlend .= ", ".$conf->entity; |
|
1053 | 1053 | } |
1054 | 1054 | if (!empty($objimport->array_import_tables_creator[0][$alias])) { |
1055 | - $sqlstart .= ", " . $objimport->array_import_tables_creator[0][$alias]; |
|
1056 | - $sqlend .= ", " . $user->id; |
|
1055 | + $sqlstart .= ", ".$objimport->array_import_tables_creator[0][$alias]; |
|
1056 | + $sqlend .= ", ".$user->id; |
|
1057 | 1057 | } |
1058 | - $sql = $sqlstart . $sqlend . ")"; |
|
1058 | + $sql = $sqlstart.$sqlend.")"; |
|
1059 | 1059 | //dol_syslog("import_xlsx.modules", LOG_DEBUG); |
1060 | 1060 | |
1061 | 1061 | // Run insert request |
@@ -894,7 +894,10 @@ |
||
894 | 894 | if ($num_rows == 1) { |
895 | 895 | $res = $this->db->fetch_object($resql); |
896 | 896 | $lastinsertid = $res->rowid; |
897 | - if ($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists |
|
897 | + if ($is_table_category_link) { |
|
898 | + $lastinsertid = 'linktable'; |
|
899 | + } |
|
900 | + // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists |
|
898 | 901 | $last_insert_id_array[$tablename] = $lastinsertid; |
899 | 902 | } elseif ($num_rows > 1) { |
900 | 903 | $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
471 | 471 | if ($classinstance->id != '') { // id may be 0, it is a found value |
472 | 472 | $newval = $classinstance->id; |
473 | - } elseif (! $error) { |
|
473 | + } elseif (!$error) { |
|
474 | 474 | if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { |
475 | 475 | $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', num2Alpha($key - 1), $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
476 | 476 | } elseif (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | $classinstance = new $class($this->db); |
644 | 644 | $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $arrayfield, ($key - 1))); |
645 | 645 | if (empty($classinstance->error) && empty($classinstance->errors)) { |
646 | - $newval = $res; // We get new value computed. |
|
646 | + $newval = $res; // We get new value computed. |
|
647 | 647 | } else { |
648 | 648 | $this->errors[$error]['type'] = 'CLASSERROR'; |
649 | 649 | $this->errors[$error]['lib'] = implode( |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | if (isModEnabled("socialnetworks") && strpos($fieldname, "socialnetworks") !== false) { |
742 | 742 | if (!in_array("socialnetworks", $listfields)) { |
743 | 743 | $listfields[] = "socialnetworks"; |
744 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
744 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
745 | 745 | $listvalues[$socialkey] = ''; |
746 | 746 | } |
747 | 747 | //var_dump($newval); var_dump($arrayrecord[($key - 1)]['type']); |
748 | 748 | if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { |
749 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
749 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
750 | 750 | //var_dump('sk='.$socialkey); // socialkey=19 |
751 | 751 | $socialnetwork = explode("_", $fieldname)[1]; |
752 | 752 | if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | $method = $objimport->array_import_convertvalue[0][$fieldname]['method']; |
808 | 808 | $resultload = dol_include_once($file); |
809 | 809 | if (empty($resultload)) { |
810 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
810 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
811 | 811 | break; |
812 | 812 | } |
813 | 813 | $classinstance = new $class($this->db); |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $fname = 'rowid'; |
852 | 852 | if (strpos($tablename, '_categorie_') !== false) { |
853 | 853 | $is_table_category_link = true; |
854 | - $fname='*'; |
|
854 | + $fname = '*'; |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | if (!empty($updatekeys)) { |
@@ -860,8 +860,8 @@ discard block |
||
860 | 860 | if (empty($lastinsertid)) { // No insert done yet for a parent table |
861 | 861 | $sqlSelect = "SELECT ".$fname." FROM ".$tablename; |
862 | 862 | $data = array_combine($listfields, $listvalues); |
863 | - $where = array(); // filters to forge SQL request |
|
864 | - $filters = array(); // filters to forge output error message |
|
863 | + $where = array(); // filters to forge SQL request |
|
864 | + $filters = array(); // filters to forge output error message |
|
865 | 865 | foreach ($updatekeys as $key) { |
866 | 866 | $col = $objimport->array_import_updatekeys[0][$key]; |
867 | 867 | $key = preg_replace('/^.*\./i', '', $key); |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | // We db escape social network field because he isn't in field creation |
949 | 949 | if (in_array("socialnetworks", $listfields)) { |
950 | 950 | $socialkey = array_search("socialnetworks", $listfields); |
951 | - $tmpsql = $listvalues[$socialkey]; |
|
951 | + $tmpsql = $listvalues[$socialkey]; |
|
952 | 952 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
953 | 953 | } |
954 | 954 | |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | $sqlend = " WHERE ".$keyfield." = ".((int) $lastinsertid); |
969 | 969 | |
970 | 970 | if ($is_table_category_link) { |
971 | - $sqlend = " WHERE " . implode(' AND ', $where); |
|
971 | + $sqlend = " WHERE ".implode(' AND ', $where); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | if (!empty($tablewithentity_cache[$tablename])) { |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | // We db escape social network field because he isn't in field creation |
997 | 997 | if (in_array("socialnetworks", $listfields)) { |
998 | 998 | $socialkey = array_search("socialnetworks", $listfields); |
999 | - $tmpsql = $listvalues[$socialkey]; |
|
999 | + $tmpsql = $listvalues[$socialkey]; |
|
1000 | 1000 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
1001 | 1001 | } |
1002 | 1002 |
@@ -335,7 +335,7 @@ |
||
335 | 335 | print '<tr class="oddeven" height="24">'; |
336 | 336 | print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>'; |
337 | 337 | print '<td class="right">'.$val['nb'].'</td>'; |
338 | - print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%</td>'; |
|
338 | + print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']) : "0").'%</td>'; |
|
339 | 339 | print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>'; |
340 | 340 | print '<td class="right opacitylow" style="'.((!isset($val['total_diff']) || $val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%</td>'; |
341 | 341 | print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>'; |
@@ -46,18 +46,26 @@ discard block |
||
46 | 46 | $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
47 | 47 | $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_contact.php', 1).'?id='.$object->id; |
48 | 48 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
49 | - if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; |
|
49 | + if ($nbContact > 0) { |
|
50 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; |
|
51 | + } |
|
50 | 52 | $head[$h][2] = 'contact'; |
51 | 53 | $h++; |
52 | 54 | } |
53 | 55 | |
54 | 56 | if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { |
55 | 57 | $nbNote = 0; |
56 | - if (!empty($object->note_private)) $nbNote++; |
|
57 | - if (!empty($object->note_public)) $nbNote++; |
|
58 | + if (!empty($object->note_private)) { |
|
59 | + $nbNote++; |
|
60 | + } |
|
61 | + if (!empty($object->note_public)) { |
|
62 | + $nbNote++; |
|
63 | + } |
|
58 | 64 | $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_note.php', 1).'?id='.$object->id; |
59 | 65 | $head[$h][1] = $langs->trans('Notes'); |
60 | - if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); |
|
66 | + if ($nbNote > 0) { |
|
67 | + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); |
|
68 | + } |
|
61 | 69 | $head[$h][2] = 'note'; |
62 | 70 | $h++; |
63 | 71 | } |
@@ -69,7 +77,9 @@ discard block |
||
69 | 77 | $nbLinks = Link::count($db, $object->element, $object->id); |
70 | 78 | $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_document.php", 1).'?id='.$object->id; |
71 | 79 | $head[$h][1] = $langs->trans('Documents'); |
72 | - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
80 | + if (($nbFiles + $nbLinks) > 0) { |
|
81 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
82 | + } |
|
73 | 83 | $head[$h][2] = 'document'; |
74 | 84 | $h++; |
75 | 85 |
@@ -494,7 +494,7 @@ |
||
494 | 494 | if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) { |
495 | 495 | $date_prevue_depart = $object->$key; |
496 | 496 | $date_prevue_depart_plus_delai = $date_prevue_depart; |
497 | - if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
497 | + if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart).' + '.$object->lead_time_for_warning.' day'); |
|
498 | 498 | if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
499 | 499 | } |
500 | 500 | } |
@@ -69,15 +69,22 @@ discard block |
||
69 | 69 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
70 | 70 | |
71 | 71 | // Default sort order (if not yet defined by previous GETPOST) |
72 | -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
73 | -if (!$sortorder) $sortorder = "ASC"; |
|
72 | +if (!$sortfield) { |
|
73 | + $sortfield = "t.".key($object->fields); |
|
74 | +} |
|
75 | +// Set here default search field. By default 1st field in definition. |
|
76 | +if (!$sortorder) { |
|
77 | + $sortorder = "ASC"; |
|
78 | +} |
|
74 | 79 | |
75 | 80 | // Initialize array of search criterias |
76 | 81 | $search_all = GETPOST('search_all', 'alphanohtml') ? trim(GETPOST('search_all', 'alphanohtml')) : trim(GETPOST('sall', 'alphanohtml')); |
77 | 82 | $search = array(); |
78 | 83 | foreach ($object->fields as $key => $val) { |
79 | - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
80 | -} |
|
84 | + if (GETPOST('search_'.$key, 'alpha') !== '') { |
|
85 | + $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
86 | + } |
|
87 | + } |
|
81 | 88 | |
82 | 89 | // List of fields to search into when doing a "search in all" |
83 | 90 | $fieldstosearchall = array(); |
@@ -91,8 +98,10 @@ discard block |
||
91 | 98 | $arrayfields = array(); |
92 | 99 | foreach ($object->fields as $key => $val) { |
93 | 100 | // If $val['visible']==0, then we never show the field |
94 | - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>(verifCond($val['enabled']) && ($val['visible'] != 3)), 'position'=>$val['position']); |
|
95 | -} |
|
101 | + if (!empty($val['visible'])) { |
|
102 | + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>(verifCond($val['enabled']) && ($val['visible'] != 3)), 'position'=>$val['position']); |
|
103 | + } |
|
104 | + } |
|
96 | 105 | //var_dump($object->fields); |
97 | 106 | // Extra fields |
98 | 107 | if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { |
@@ -116,14 +125,18 @@ discard block |
||
116 | 125 | $permissiontodelete = $user->hasRight('stocktransfer', 'stocktransfer', 'delete'); |
117 | 126 | |
118 | 127 | // Security check |
119 | -if (empty($conf->stocktransfer->enabled)) accessforbidden('Module not enabled'); |
|
128 | +if (empty($conf->stocktransfer->enabled)) { |
|
129 | + accessforbidden('Module not enabled'); |
|
130 | +} |
|
120 | 131 | $socid = 0; |
121 | 132 | if ($user->socid > 0) { // Protection if external user |
122 | 133 | //$socid = $user->socid; |
123 | 134 | accessforbidden(); |
124 | 135 | } |
125 | 136 | //$result = restrictedArea($user, 'stocktransfer', $id, ''); |
126 | -if (!$permissiontoread) accessforbidden(); |
|
137 | +if (!$permissiontoread) { |
|
138 | + accessforbidden(); |
|
139 | +} |
|
127 | 140 | |
128 | 141 | |
129 | 142 | |
@@ -136,7 +149,9 @@ discard block |
||
136 | 149 | |
137 | 150 | $parameters = array(); |
138 | 151 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
139 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
152 | +if ($reshook < 0) { |
|
153 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
154 | +} |
|
140 | 155 | |
141 | 156 | if (empty($reshook)) { |
142 | 157 | // Selection of new fields |
@@ -196,18 +211,29 @@ discard block |
||
196 | 211 | if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { |
197 | 212 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
198 | 213 | } |
199 | -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
200 | -else $sql .= " WHERE 1 = 1"; |
|
214 | +if ($object->ismultientitymanaged == 1) { |
|
215 | + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
216 | +} else { |
|
217 | + $sql .= " WHERE 1 = 1"; |
|
218 | +} |
|
201 | 219 | foreach ($search as $key => $val) { |
202 | - if ($key == 'status' && $search[$key] == -1) continue; |
|
220 | + if ($key == 'status' && $search[$key] == -1) { |
|
221 | + continue; |
|
222 | + } |
|
203 | 223 | $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); |
204 | 224 | if (strpos($object->fields[$key]['type'], 'integer:') === 0) { |
205 | - if ($search[$key] == '-1') $search[$key] = ''; |
|
225 | + if ($search[$key] == '-1') { |
|
226 | + $search[$key] = ''; |
|
227 | + } |
|
206 | 228 | $mode_search = 2; |
207 | 229 | } |
208 | - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
230 | + if ($search[$key] != '') { |
|
231 | + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
232 | + } |
|
233 | + } |
|
234 | +if ($search_all) { |
|
235 | + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
209 | 236 | } |
210 | -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
211 | 237 | //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); |
212 | 238 | // Add where from extra fields |
213 | 239 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
@@ -249,7 +275,9 @@ discard block |
||
249 | 275 | if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { |
250 | 276 | $num = $nbtotalofrecords; |
251 | 277 | } else { |
252 | - if ($limit) $sql .= $db->plimit($limit + 1, $offset); |
|
278 | + if ($limit) { |
|
279 | + $sql .= $db->plimit($limit + 1, $offset); |
|
280 | + } |
|
253 | 281 | |
254 | 282 | $resql = $db->query($sql); |
255 | 283 | if (!$resql) { |
@@ -292,13 +320,22 @@ discard block |
||
292 | 320 | $arrayofselected = is_array($toselect) ? $toselect : array(); |
293 | 321 | |
294 | 322 | $param = ''; |
295 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
296 | -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.((int) $limit); |
|
323 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
324 | + $param .= '&contextpage='.urlencode($contextpage); |
|
325 | +} |
|
326 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
327 | + $param .= '&limit='.((int) $limit); |
|
328 | +} |
|
297 | 329 | foreach ($search as $key => $val) { |
298 | - if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
299 | - else $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
330 | + if (is_array($search[$key]) && count($search[$key])) { |
|
331 | + foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
332 | + } else { |
|
333 | + $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
334 | + } |
|
335 | + } |
|
336 | +if ($optioncss != '') { |
|
337 | + $param .= '&optioncss='.urlencode($optioncss); |
|
300 | 338 | } |
301 | -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
302 | 339 | // Add $param from extra fields |
303 | 340 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
304 | 341 | |
@@ -309,12 +346,18 @@ discard block |
||
309 | 346 | //'builddoc'=>$langs->trans("PDFMerge"), |
310 | 347 | //'presend'=>$langs->trans("SendByMail"), |
311 | 348 | ); |
312 | -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
313 | -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); |
|
349 | +if ($permissiontodelete) { |
|
350 | + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
351 | +} |
|
352 | +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { |
|
353 | + $arrayofmassactions = array(); |
|
354 | +} |
|
314 | 355 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
315 | 356 | |
316 | 357 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
317 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
358 | +if ($optioncss != '') { |
|
359 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
360 | +} |
|
318 | 361 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
319 | 362 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
320 | 363 | print '<input type="hidden" name="action" value="list">'; |
@@ -336,7 +379,9 @@ discard block |
||
336 | 379 | include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; |
337 | 380 | |
338 | 381 | if ($search_all) { |
339 | - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
382 | + foreach ($fieldstosearchall as $key => $val) { |
|
383 | + $fieldstosearchall[$key] = $langs->trans($val); |
|
384 | + } |
|
340 | 385 | print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; |
341 | 386 | } |
342 | 387 | |
@@ -347,8 +392,11 @@ discard block |
||
347 | 392 | |
348 | 393 | $parameters = array(); |
349 | 394 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
350 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
351 | -else $moreforfilter = $hookmanager->resPrint; |
|
395 | +if (empty($reshook)) { |
|
396 | + $moreforfilter .= $hookmanager->resPrint; |
|
397 | +} else { |
|
398 | + $moreforfilter = $hookmanager->resPrint; |
|
399 | +} |
|
352 | 400 | |
353 | 401 | if (!empty($moreforfilter)) { |
354 | 402 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
@@ -369,10 +417,15 @@ discard block |
||
369 | 417 | print '<tr class="liste_titre">'; |
370 | 418 | foreach ($object->fields as $key => $val) { |
371 | 419 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
372 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
373 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
374 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
375 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
420 | + if ($key == 'status') { |
|
421 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
422 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
423 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
424 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
425 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
426 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
427 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
428 | + } |
|
376 | 429 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
377 | 430 | print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; |
378 | 431 | if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { |
@@ -405,10 +458,15 @@ discard block |
||
405 | 458 | print '<tr class="liste_titre">'; |
406 | 459 | foreach ($object->fields as $key => $val) { |
407 | 460 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
408 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
409 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
410 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
411 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
461 | + if ($key == 'status') { |
|
462 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
463 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
464 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
465 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
466 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
467 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
468 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
469 | + } |
|
412 | 470 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
413 | 471 | print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; |
414 | 472 | } |
@@ -441,7 +499,10 @@ discard block |
||
441 | 499 | $totalarray = array(); |
442 | 500 | while ($i < ($limit ? min($num, $limit) : $num)) { |
443 | 501 | $obj = $db->fetch_object($resql); |
444 | - if (empty($obj)) break; // Should not happen |
|
502 | + if (empty($obj)) { |
|
503 | + break; |
|
504 | + } |
|
505 | + // Should not happen |
|
445 | 506 | |
446 | 507 | // Store properties in $object |
447 | 508 | $object->setVarsFromFetchObj($obj); |
@@ -450,31 +511,48 @@ discard block |
||
450 | 511 | print '<tr class="oddeven">'; |
451 | 512 | foreach ($object->fields as $key => $val) { |
452 | 513 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
453 | - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
454 | - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
514 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
515 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
516 | + } elseif ($key == 'status') { |
|
517 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
518 | + } |
|
455 | 519 | |
456 | - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
457 | - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
520 | + if (in_array($val['type'], array('timestamp'))) { |
|
521 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
522 | + } elseif ($key == 'ref') { |
|
523 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
524 | + } |
|
458 | 525 | |
459 | - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
526 | + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { |
|
527 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
528 | + } |
|
460 | 529 | //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; |
461 | 530 | |
462 | 531 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
463 | 532 | print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; |
464 | - if ($key == 'status') print $object->getLibStatut(5); |
|
465 | - else { |
|
533 | + if ($key == 'status') { |
|
534 | + print $object->getLibStatut(5); |
|
535 | + } else { |
|
466 | 536 | print $object->showOutputField($val, $key, $object->$key, ''); |
467 | 537 | if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) { |
468 | 538 | $date_prevue_depart = $object->$key; |
469 | 539 | $date_prevue_depart_plus_delai = $date_prevue_depart; |
470 | - if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
471 | - if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
540 | + if ($object->lead_time_for_warning > 0) { |
|
541 | + $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
542 | + } |
|
543 | + if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) { |
|
544 | + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
545 | + } |
|
472 | 546 | } |
473 | 547 | } |
474 | 548 | print '</td>'; |
475 | - if (!$i) $totalarray['nbfield']++; |
|
549 | + if (!$i) { |
|
550 | + $totalarray['nbfield']++; |
|
551 | + } |
|
476 | 552 | if (!empty($val['isameasure'])) { |
477 | - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
553 | + if (!$i) { |
|
554 | + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
555 | + } |
|
478 | 556 | $totalarray['val']['t.'.$key] += $object->$key; |
479 | 557 | } |
480 | 558 | } |
@@ -489,11 +567,15 @@ discard block |
||
489 | 567 | print '<td class="nowrap center">'; |
490 | 568 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
491 | 569 | $selected = 0; |
492 | - if (in_array($object->id, $arrayofselected)) $selected = 1; |
|
570 | + if (in_array($object->id, $arrayofselected)) { |
|
571 | + $selected = 1; |
|
572 | + } |
|
493 | 573 | print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; |
494 | 574 | } |
495 | 575 | print '</td>'; |
496 | - if (!$i) $totalarray['nbfield']++; |
|
576 | + if (!$i) { |
|
577 | + $totalarray['nbfield']++; |
|
578 | + } |
|
497 | 579 | |
498 | 580 | print '</tr>'."\n"; |
499 | 581 | |
@@ -506,7 +588,10 @@ discard block |
||
506 | 588 | // If no record found |
507 | 589 | if ($num == 0) { |
508 | 590 | $colspan = 1; |
509 | - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
591 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { |
|
592 | + $colspan++; |
|
593 | + } |
|
594 | + } |
|
510 | 595 | print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
511 | 596 | } |
512 | 597 | |
@@ -524,7 +609,9 @@ discard block |
||
524 | 609 | |
525 | 610 | if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { |
526 | 611 | $hidegeneratedfilelistifempty = 1; |
527 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; |
|
612 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { |
|
613 | + $hidegeneratedfilelistifempty = 0; |
|
614 | + } |
|
528 | 615 | |
529 | 616 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
530 | 617 | $formfile = new FormFile($db); |
@@ -455,17 +455,17 @@ |
||
455 | 455 | // Rôles |
456 | 456 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "internal"'); |
457 | 457 | $res = $this->db->fetch_object($resql); |
458 | - $nextid=$this->getNextId(); |
|
458 | + $nextid = $this->getNextId(); |
|
459 | 459 | if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)'); |
460 | 460 | |
461 | 461 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STFROM" AND element = "StockTransfer" AND source = "external"'); |
462 | 462 | $res = $this->db->fetch_object($resql); |
463 | - $nextid=$this->getNextId(); |
|
463 | + $nextid = $this->getNextId(); |
|
464 | 464 | if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)'); |
465 | 465 | |
466 | 466 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "external"'); |
467 | 467 | $res = $this->db->fetch_object($resql); |
468 | - $nextid=$this->getNextId(); |
|
468 | + $nextid = $this->getNextId(); |
|
469 | 469 | if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)'); |
470 | 470 | |
471 | 471 | return $this->_init($sql, $options); |
@@ -426,7 +426,10 @@ discard block |
||
426 | 426 | global $conf, $langs; |
427 | 427 | |
428 | 428 | $result = $this->_load_tables('/install/mysql/tables/', 'stocktransfer'); |
429 | - if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') |
|
429 | + if ($result < 0) { |
|
430 | + return -1; |
|
431 | + } |
|
432 | + // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') |
|
430 | 433 | |
431 | 434 | // Permissions |
432 | 435 | $this->remove($options); |
@@ -437,17 +440,23 @@ discard block |
||
437 | 440 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "internal"'); |
438 | 441 | $res = $this->db->fetch_object($resql); |
439 | 442 | $nextid=$this->getNextId(); |
440 | - if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)'); |
|
443 | + if (empty($res)) { |
|
444 | + $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)'); |
|
445 | + } |
|
441 | 446 | |
442 | 447 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STFROM" AND element = "StockTransfer" AND source = "external"'); |
443 | 448 | $res = $this->db->fetch_object($resql); |
444 | 449 | $nextid=$this->getNextId(); |
445 | - if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)'); |
|
450 | + if (empty($res)) { |
|
451 | + $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)'); |
|
452 | + } |
|
446 | 453 | |
447 | 454 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "external"'); |
448 | 455 | $res = $this->db->fetch_object($resql); |
449 | 456 | $nextid=$this->getNextId(); |
450 | - if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)'); |
|
457 | + if (empty($res)) { |
|
458 | + $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)'); |
|
459 | + } |
|
451 | 460 | |
452 | 461 | return $this->_init($sql, $options); |
453 | 462 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * \ingroup stocktransfer |
24 | 24 | * \brief File of class to manage StockTransfer numbering rules standard |
25 | 25 | */ |
26 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -134,8 +134,11 @@ discard block |
||
134 | 134 | $resql = $db->query($sql); |
135 | 135 | if ($resql) { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max = 0; |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max = 0; |
|
141 | + } |
|
139 | 142 | } else { |
140 | 143 | dol_syslog("mod_stocktransfer_standard::getNextValue", LOG_DEBUG); |
141 | 144 | return -1; |
@@ -145,8 +148,13 @@ discard block |
||
145 | 148 | $date = $object->date_creation; |
146 | 149 | $yymm = strftime("%y%m", $date); |
147 | 150 | |
148 | - if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
149 | - else $num = sprintf("%04s", $max + 1); |
|
151 | + if ($max >= (pow(10, 4) - 1)) { |
|
152 | + $num = $max + 1; |
|
153 | + } |
|
154 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | + else { |
|
156 | + $num = sprintf("%04s", $max + 1); |
|
157 | + } |
|
150 | 158 | |
151 | 159 | dol_syslog("mod_stocktransfer_standard::getNextValue return ".$this->prefix.$yymm."-".$num); |
152 | 160 | return $this->prefix.$yymm."-".$num; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * \brief File containing class for advanced numbering model of StockTransfer |
28 | 28 | */ |
29 | 29 | |
30 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |