@@ -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(); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | // Clean data |
367 | 367 | // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); |
368 | 368 | |
369 | - if ($this->jobposition->create(DolibarrApiAccess::$user)<0) { |
|
369 | + if ($this->jobposition->create(DolibarrApiAccess::$user) < 0) { |
|
370 | 370 | throw new RestException(500, "Error creating jobposition", array_merge(array($this->jobposition->error), $this->jobposition->errors)); |
371 | 371 | } |
372 | 372 | return $this->jobposition->id; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | // Clean data |
399 | 399 | // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); |
400 | 400 | |
401 | - if ($this->candidature->create(DolibarrApiAccess::$user)<0) { |
|
401 | + if ($this->candidature->create(DolibarrApiAccess::$user) < 0) { |
|
402 | 402 | throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors)); |
403 | 403 | } |
404 | 404 | return $this->candidature->id; |
@@ -371,15 +371,15 @@ |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | - * Create candidature object |
|
375 | - * |
|
376 | - * @param array $request_data Request datas |
|
377 | - * @return int ID of candidature |
|
378 | - * |
|
379 | - * @throws RestException |
|
380 | - * |
|
381 | - * @url POST candidature/ |
|
382 | - */ |
|
374 | + * Create candidature object |
|
375 | + * |
|
376 | + * @param array $request_data Request datas |
|
377 | + * @return int ID of candidature |
|
378 | + * |
|
379 | + * @throws RestException |
|
380 | + * |
|
381 | + * @url POST candidature/ |
|
382 | + */ |
|
383 | 383 | public function postCandidature($request_data = null) |
384 | 384 | { |
385 | 385 | if (!DolibarrApiAccess::$user->hasRight('recruitment', 'recruitmentjobposition', 'write')) { |
@@ -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 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | // phpcs:enable |
153 | 153 | global $user, $conf, $langs, $file; |
154 | 154 | // create a temporary object, the final output will be generated in footer |
155 | - $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs) . ' - Dolibarr ' . DOL_VERSION); |
|
156 | - $this->workbook->getProperties()->setTitle($outputlangs->trans("Import") . ' - ' . $file); |
|
157 | - $this->workbook->getProperties()->setSubject($outputlangs->trans("Import") . ' - ' . $file); |
|
158 | - $this->workbook->getProperties()->setDescription($outputlangs->trans("Import") . ' - ' . $file); |
|
155 | + $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION); |
|
156 | + $this->workbook->getProperties()->setTitle($outputlangs->trans("Import").' - '.$file); |
|
157 | + $this->workbook->getProperties()->setSubject($outputlangs->trans("Import").' - '.$file); |
|
158 | + $this->workbook->getProperties()->setDescription($outputlangs->trans("Import").' - '.$file); |
|
159 | 159 | |
160 | 160 | $this->workbook->setActiveSheetIndex(0); |
161 | 161 | $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet")); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | global $langs; |
249 | 249 | $ret = 1; |
250 | 250 | |
251 | - dol_syslog(get_class($this) . "::open_file file=" . $file); |
|
251 | + dol_syslog(get_class($this)."::open_file file=".$file); |
|
252 | 252 | |
253 | 253 | $reader = new Xlsx(); |
254 | 254 | $this->workbook = $reader->load($file); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | |
402 | 402 | // Define $tablewithentity_cache[$tablename] if not already defined |
403 | 403 | if (!isset($tablewithentity_cache[$tablename])) { // keep this test with "isset" |
404 | - dol_syslog("Check if table " . $tablename . " has an entity field"); |
|
404 | + dol_syslog("Check if table ".$tablename." has an entity field"); |
|
405 | 405 | $resql = $this->db->DDLDescTable($tablename, 'entity'); |
406 | 406 | if ($resql) { |
407 | 407 | $obj = $this->db->fetch_object($resql); |
@@ -474,12 +474,12 @@ discard block |
||
474 | 474 | $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); |
475 | 475 | $class = $objimport->array_import_convertvalue[0][$val]['class']; |
476 | 476 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
477 | - if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval] != '') { |
|
478 | - $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval]; |
|
477 | + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') { |
|
478 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; |
|
479 | 479 | } else { |
480 | 480 | $resultload = dol_include_once($file); |
481 | 481 | if (empty($resultload)) { |
482 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
482 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
483 | 483 | break; |
484 | 484 | } |
485 | 485 | $classinstance = new $class($this->db); |
@@ -521,12 +521,12 @@ discard block |
||
521 | 521 | $param_array = array('', '', $newval); |
522 | 522 | call_user_func_array(array($classinstance, $method), $param_array); |
523 | 523 | } |
524 | - $this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval] = $classinstance->id; |
|
524 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] = $classinstance->id; |
|
525 | 525 | |
526 | 526 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
527 | 527 | if ($classinstance->id != '') { // id may be 0, it is a found value |
528 | 528 | $newval = $classinstance->id; |
529 | - } elseif (! $error) { |
|
529 | + } elseif (!$error) { |
|
530 | 530 | if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { |
531 | 531 | $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
532 | 532 | } elseif (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { |
@@ -553,19 +553,19 @@ discard block |
||
553 | 553 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
554 | 554 | $codefromfield = $objimport->array_import_convertvalue[0][$val]['codefromfield']; |
555 | 555 | $code = $arrayrecord[$arrayfield[$codefromfield]]['val']; |
556 | - if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval] != '') { |
|
557 | - $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval]; |
|
556 | + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval] != '') { |
|
557 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval]; |
|
558 | 558 | } else { |
559 | 559 | $resultload = dol_include_once($file); |
560 | 560 | if (empty($resultload)) { |
561 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method . ', code=' . $code); |
|
561 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', code='.$code); |
|
562 | 562 | break; |
563 | 563 | } |
564 | 564 | $classinstance = new $class($this->db); |
565 | 565 | // Try the fetch from code and ref |
566 | 566 | $param_array = array('', $newval, $code); |
567 | 567 | call_user_func_array(array($classinstance, $method), $param_array); |
568 | - $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval] = $classinstance->id; |
|
568 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval] = $classinstance->id; |
|
569 | 569 | if ($classinstance->id > 0) { // we found record |
570 | 570 | $newval = $classinstance->id; |
571 | 571 | } else { |
@@ -589,19 +589,19 @@ discard block |
||
589 | 589 | $class = $objimport->array_import_convertvalue[0][$val]['class']; |
590 | 590 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
591 | 591 | $units = $objimport->array_import_convertvalue[0][$val]['units']; |
592 | - if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval] != '') { |
|
593 | - $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval]; |
|
592 | + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '') { |
|
593 | + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]; |
|
594 | 594 | } else { |
595 | 595 | $resultload = dol_include_once($file); |
596 | 596 | if (empty($resultload)) { |
597 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method . ', units=' . $units); |
|
597 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); |
|
598 | 598 | break; |
599 | 599 | } |
600 | 600 | $classinstance = new $class($this->db); |
601 | 601 | // Try the fetch from code or ref |
602 | 602 | call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); |
603 | 603 | $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); |
604 | - $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval] = $scaleorid; |
|
604 | + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; |
|
605 | 605 | //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; |
606 | 606 | if ($classinstance->id > 0) { // we found record |
607 | 607 | $newval = $scaleorid ? $scaleorid : 0; |
@@ -693,12 +693,12 @@ discard block |
||
693 | 693 | $method = $objimport->array_import_convertvalue[0][$val]['method']; |
694 | 694 | $resultload = dol_include_once($file); |
695 | 695 | if (empty($resultload)) { |
696 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
696 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
697 | 697 | break; |
698 | 698 | } |
699 | 699 | $classinstance = new $class($this->db); |
700 | 700 | $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $arrayfield, $key)); |
701 | - $newval = $res; // We get new value computed. |
|
701 | + $newval = $res; // We get new value computed. |
|
702 | 702 | } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { |
703 | 703 | $newval = price2num($newval); |
704 | 704 | } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') { |
@@ -721,16 +721,16 @@ discard block |
||
721 | 721 | $table = $reg[2]; |
722 | 722 | $filter = !empty($reg[3]) ? substr($reg[3], 1) : ''; |
723 | 723 | |
724 | - $cachekey = $field . '@' . $table; |
|
724 | + $cachekey = $field.'@'.$table; |
|
725 | 725 | if (!empty($filter)) { |
726 | - $cachekey .= ':' . $filter; |
|
726 | + $cachekey .= ':'.$filter; |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | // Load content of field@table into cache array |
730 | 730 | if (!is_array($this->cachefieldtable[$cachekey])) { // If content of field@table not already loaded into cache |
731 | - $sql = "SELECT " . $field . " as aliasfield FROM " . $table; |
|
731 | + $sql = "SELECT ".$field." as aliasfield FROM ".$table; |
|
732 | 732 | if (!empty($filter)) { |
733 | - $sql .= ' WHERE ' . $filter; |
|
733 | + $sql .= ' WHERE '.$filter; |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | $resql = $this->db->query($sql); |
@@ -753,14 +753,14 @@ discard block |
||
753 | 753 | if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { |
754 | 754 | $tableforerror = $table; |
755 | 755 | if (!empty($filter)) { |
756 | - $tableforerror .= ':' . $filter; |
|
756 | + $tableforerror .= ':'.$filter; |
|
757 | 757 | } |
758 | 758 | $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); |
759 | 759 | $this->errors[$error]['type'] = 'FOREIGNKEY'; |
760 | 760 | $errorforthistable++; |
761 | 761 | $error++; |
762 | 762 | } |
763 | - } elseif (!preg_match('/' . $objimport->array_import_regex[0][$val] . '/i', $newval)) { |
|
763 | + } elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { |
|
764 | 764 | // If test is just a static regex |
765 | 765 | //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."<br>"; |
766 | 766 | $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); |
@@ -787,11 +787,11 @@ discard block |
||
787 | 787 | if (isModEnabled("socialnetworks") && strpos($fieldname, "socialnetworks") !== false) { |
788 | 788 | if (!in_array("socialnetworks", $listfields)) { |
789 | 789 | $listfields[] = "socialnetworks"; |
790 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
790 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
791 | 791 | $listvalues[$socialkey] = ''; |
792 | 792 | } |
793 | 793 | if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { |
794 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
794 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array. Example socialkey=19 |
|
795 | 795 | $socialnetwork = explode("_", $fieldname)[1]; |
796 | 796 | if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { |
797 | 797 | $json = new stdClass(); |
@@ -830,18 +830,18 @@ discard block |
||
830 | 830 | continue; // Not a field of current table |
831 | 831 | } |
832 | 832 | if ($val == 'user->id') { |
833 | - $listfields[] = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); |
|
833 | + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); |
|
834 | 834 | $listvalues[] = ((int) $user->id); |
835 | 835 | } elseif (preg_match('/^lastrowid-/', $val)) { |
836 | 836 | $tmp = explode('-', $val); |
837 | 837 | $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; |
838 | - $keyfield = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); |
|
838 | + $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); |
|
839 | 839 | $listfields[] = $keyfield; |
840 | 840 | $listvalues[] = $lastinsertid; |
841 | 841 | //print $key."-".$val."-".$listfields."-".$listvalues."<br>";exit; |
842 | 842 | } elseif (preg_match('/^const-/', $val)) { |
843 | 843 | $tmp = explode('-', $val, 2); |
844 | - $listfields[] = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); |
|
844 | + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); |
|
845 | 845 | $listvalues[] = "'".$this->db->escape($tmp[1])."'"; |
846 | 846 | } elseif (preg_match('/^rule-/', $val)) { |
847 | 847 | $fieldname = $key; |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | $method = $objimport->array_import_convertvalue[0][$fieldname]['method']; |
853 | 853 | $resultload = dol_include_once($file); |
854 | 854 | if (empty($resultload)) { |
855 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
855 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
856 | 856 | break; |
857 | 857 | } |
858 | 858 | $classinstance = new $class($this->db); |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | } |
867 | 867 | } |
868 | 868 | } else { |
869 | - $this->errors[$error]['lib'] = 'Bad value of profile setup ' . $val . ' for array_import_fieldshidden'; |
|
869 | + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; |
|
870 | 870 | $this->errors[$error]['type'] = 'Import profile setup'; |
871 | 871 | $error++; |
872 | 872 | } |
@@ -886,19 +886,19 @@ discard block |
||
886 | 886 | $fname = 'rowid'; |
887 | 887 | if (strpos($tablename, '_categorie_') !== false) { |
888 | 888 | $is_table_category_link = true; |
889 | - $fname='*'; |
|
889 | + $fname = '*'; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | if (!empty($updatekeys)) { |
893 | 893 | // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) |
894 | 894 | |
895 | 895 | if (empty($lastinsertid)) { // No insert done yet for a parent table |
896 | - $sqlSelect = "SELECT ".$fname." FROM " . $tablename; |
|
896 | + $sqlSelect = "SELECT ".$fname." FROM ".$tablename; |
|
897 | 897 | |
898 | 898 | $data = array_combine($listfields, $listvalues); |
899 | 899 | |
900 | - $where = array(); // filters to forge SQL request |
|
901 | - $filters = array(); // filters to forge output error message |
|
900 | + $where = array(); // filters to forge SQL request |
|
901 | + $filters = array(); // filters to forge output error message |
|
902 | 902 | foreach ($updatekeys as $key) { |
903 | 903 | $col = $objimport->array_import_updatekeys[0][$key]; |
904 | 904 | $key = preg_replace('/^.*\./i', '', $key); |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | $where[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; |
924 | 924 | $filters[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; |
925 | 925 | } |
926 | - $sqlSelect .= " WHERE " . implode(' AND ', $where); |
|
926 | + $sqlSelect .= " WHERE ".implode(' AND ', $where); |
|
927 | 927 | |
928 | 928 | $resql = $this->db->query($sqlSelect); |
929 | 929 | if ($resql) { |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record |
953 | 953 | // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. |
954 | 954 | // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' |
955 | - $sqlSelect = "SELECT rowid FROM " . $tablename; |
|
955 | + $sqlSelect = "SELECT rowid FROM ".$tablename; |
|
956 | 956 | |
957 | 957 | |
958 | 958 | if (empty($keyfield)) { |
@@ -986,34 +986,34 @@ discard block |
||
986 | 986 | // We db escape social network field because he isn't in field creation |
987 | 987 | if (in_array("socialnetworks", $listfields)) { |
988 | 988 | $socialkey = array_search("socialnetworks", $listfields); |
989 | - $tmpsql = $listvalues[$socialkey]; |
|
989 | + $tmpsql = $listvalues[$socialkey]; |
|
990 | 990 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
991 | 991 | } |
992 | 992 | |
993 | 993 | // Build SQL UPDATE request |
994 | - $sqlstart = "UPDATE " . $tablename; |
|
994 | + $sqlstart = "UPDATE ".$tablename; |
|
995 | 995 | |
996 | 996 | $data = array_combine($listfields, $listvalues); |
997 | 997 | $set = array(); |
998 | 998 | foreach ($data as $key => $val) { |
999 | 999 | $set[] = $key." = ".$val; |
1000 | 1000 | } |
1001 | - $sqlstart .= " SET " . implode(', ', $set); |
|
1001 | + $sqlstart .= " SET ".implode(', ', $set); |
|
1002 | 1002 | |
1003 | 1003 | if (empty($keyfield)) { |
1004 | 1004 | $keyfield = 'rowid'; |
1005 | 1005 | } |
1006 | - $sqlend = " WHERE " . $keyfield . " = ".((int) $lastinsertid); |
|
1006 | + $sqlend = " WHERE ".$keyfield." = ".((int) $lastinsertid); |
|
1007 | 1007 | |
1008 | 1008 | if ($is_table_category_link) { |
1009 | - $sqlend = " WHERE " . implode(' AND ', $where); |
|
1009 | + $sqlend = " WHERE ".implode(' AND ', $where); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | if (!empty($tablewithentity_cache[$tablename])) { |
1013 | 1013 | $sqlend .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; |
1014 | 1014 | } |
1015 | 1015 | |
1016 | - $sql = $sqlstart . $sqlend; |
|
1016 | + $sql = $sqlstart.$sqlend; |
|
1017 | 1017 | |
1018 | 1018 | // Run update request |
1019 | 1019 | $resql = $this->db->query($sql); |
@@ -1034,22 +1034,22 @@ discard block |
||
1034 | 1034 | // We db escape social network field because he isn't in field creation |
1035 | 1035 | if (in_array("socialnetworks", $listfields)) { |
1036 | 1036 | $socialkey = array_search("socialnetworks", $listfields); |
1037 | - $tmpsql = $listvalues[$socialkey]; |
|
1037 | + $tmpsql = $listvalues[$socialkey]; |
|
1038 | 1038 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | // Build SQL INSERT request |
1042 | - $sqlstart = "INSERT INTO " . $tablename . "(" . implode(", ", $listfields) . ", import_key"; |
|
1043 | - $sqlend = ") VALUES(" . implode(', ', $listvalues) . ", '" . $this->db->escape($importid) . "'"; |
|
1042 | + $sqlstart = "INSERT INTO ".$tablename."(".implode(", ", $listfields).", import_key"; |
|
1043 | + $sqlend = ") VALUES(".implode(', ', $listvalues).", '".$this->db->escape($importid)."'"; |
|
1044 | 1044 | if (!empty($tablewithentity_cache[$tablename])) { |
1045 | 1045 | $sqlstart .= ", entity"; |
1046 | - $sqlend .= ", " . $conf->entity; |
|
1046 | + $sqlend .= ", ".$conf->entity; |
|
1047 | 1047 | } |
1048 | 1048 | if (!empty($objimport->array_import_tables_creator[0][$alias])) { |
1049 | - $sqlstart .= ", " . $objimport->array_import_tables_creator[0][$alias]; |
|
1050 | - $sqlend .= ", " . $user->id; |
|
1049 | + $sqlstart .= ", ".$objimport->array_import_tables_creator[0][$alias]; |
|
1050 | + $sqlend .= ", ".$user->id; |
|
1051 | 1051 | } |
1052 | - $sql = $sqlstart . $sqlend . ")"; |
|
1052 | + $sql = $sqlstart.$sqlend.")"; |
|
1053 | 1053 | //dol_syslog("import_xlsx.modules", LOG_DEBUG); |
1054 | 1054 | |
1055 | 1055 | // 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)); |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; |
483 | 483 | if ($classinstance->id != '') { // id may be 0, it is a found value |
484 | 484 | $newval = $classinstance->id; |
485 | - } elseif (! $error) { |
|
485 | + } elseif (!$error) { |
|
486 | 486 | if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { |
487 | 487 | $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', num2Alpha($key - 1), $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); |
488 | 488 | } elseif (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | } |
655 | 655 | $classinstance = new $class($this->db); |
656 | 656 | $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $arrayfield, ($key - 1))); |
657 | - $newval = $res; // We get new value computed. |
|
657 | + $newval = $res; // We get new value computed. |
|
658 | 658 | } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { |
659 | 659 | $newval = price2num($newval); |
660 | 660 | } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'accountingaccount') { |
@@ -743,12 +743,12 @@ discard block |
||
743 | 743 | if (isModEnabled("socialnetworks") && strpos($fieldname, "socialnetworks") !== false) { |
744 | 744 | if (!in_array("socialnetworks", $listfields)) { |
745 | 745 | $listfields[] = "socialnetworks"; |
746 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
746 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
747 | 747 | $listvalues[$socialkey] = ''; |
748 | 748 | } |
749 | 749 | //var_dump($newval); var_dump($arrayrecord[($key - 1)]['type']); |
750 | 750 | if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { |
751 | - $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
751 | + $socialkey = array_search("socialnetworks", $listfields); // Return position of 'socialnetworks' key in array |
|
752 | 752 | //var_dump('sk='.$socialkey); // socialkey=19 |
753 | 753 | $socialnetwork = explode("_", $fieldname)[1]; |
754 | 754 | if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | $method = $objimport->array_import_convertvalue[0][$fieldname]['method']; |
810 | 810 | $resultload = dol_include_once($file); |
811 | 811 | if (empty($resultload)) { |
812 | - dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); |
|
812 | + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); |
|
813 | 813 | break; |
814 | 814 | } |
815 | 815 | $classinstance = new $class($this->db); |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $fname = 'rowid'; |
844 | 844 | if (strpos($tablename, '_categorie_') !== false) { |
845 | 845 | $is_table_category_link = true; |
846 | - $fname='*'; |
|
846 | + $fname = '*'; |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | if (!empty($updatekeys)) { |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | if (empty($lastinsertid)) { // No insert done yet for a parent table |
853 | 853 | $sqlSelect = "SELECT ".$fname." FROM ".$tablename; |
854 | 854 | $data = array_combine($listfields, $listvalues); |
855 | - $where = array(); // filters to forge SQL request |
|
856 | - $filters = array(); // filters to forge output error message |
|
855 | + $where = array(); // filters to forge SQL request |
|
856 | + $filters = array(); // filters to forge output error message |
|
857 | 857 | foreach ($updatekeys as $key) { |
858 | 858 | $col = $objimport->array_import_updatekeys[0][$key]; |
859 | 859 | $key = preg_replace('/^.*\./i', '', $key); |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | // We db escape social network field because he isn't in field creation |
941 | 941 | if (in_array("socialnetworks", $listfields)) { |
942 | 942 | $socialkey = array_search("socialnetworks", $listfields); |
943 | - $tmpsql = $listvalues[$socialkey]; |
|
943 | + $tmpsql = $listvalues[$socialkey]; |
|
944 | 944 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
945 | 945 | } |
946 | 946 | |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | $sqlend = " WHERE ".$keyfield." = ".((int) $lastinsertid); |
961 | 961 | |
962 | 962 | if ($is_table_category_link) { |
963 | - $sqlend = " WHERE " . implode(' AND ', $where); |
|
963 | + $sqlend = " WHERE ".implode(' AND ', $where); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | if (!empty($tablewithentity_cache[$tablename])) { |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | // We db escape social network field because he isn't in field creation |
989 | 989 | if (in_array("socialnetworks", $listfields)) { |
990 | 990 | $socialkey = array_search("socialnetworks", $listfields); |
991 | - $tmpsql = $listvalues[$socialkey]; |
|
991 | + $tmpsql = $listvalues[$socialkey]; |
|
992 | 992 | $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; |
993 | 993 | } |
994 | 994 |
@@ -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,28 +69,39 @@ 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(); |
84 | 91 | foreach ($object->fields as $key => $val) { |
85 | - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; |
|
86 | -} |
|
92 | + if ($val['searchall']) { |
|
93 | + $fieldstosearchall['t.'.$key] = $val['label']; |
|
94 | + } |
|
95 | + } |
|
87 | 96 | |
88 | 97 | // Definition of fields for list |
89 | 98 | $arrayfields = array(); |
90 | 99 | foreach ($object->fields as $key => $val) { |
91 | 100 | // If $val['visible']==0, then we never show the field |
92 | - 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']); |
|
93 | -} |
|
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 | + } |
|
94 | 105 | //var_dump($object->fields); |
95 | 106 | // Extra fields |
96 | 107 | if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { |
@@ -114,14 +125,18 @@ discard block |
||
114 | 125 | $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete; |
115 | 126 | |
116 | 127 | // Security check |
117 | -if (empty($conf->stocktransfer->enabled)) accessforbidden('Module not enabled'); |
|
128 | +if (empty($conf->stocktransfer->enabled)) { |
|
129 | + accessforbidden('Module not enabled'); |
|
130 | +} |
|
118 | 131 | $socid = 0; |
119 | 132 | if ($user->socid > 0) { // Protection if external user |
120 | 133 | //$socid = $user->socid; |
121 | 134 | accessforbidden(); |
122 | 135 | } |
123 | 136 | //$result = restrictedArea($user, 'stocktransfer', $id, ''); |
124 | -if (!$permissiontoread) accessforbidden(); |
|
137 | +if (!$permissiontoread) { |
|
138 | + accessforbidden(); |
|
139 | +} |
|
125 | 140 | |
126 | 141 | |
127 | 142 | |
@@ -134,7 +149,9 @@ discard block |
||
134 | 149 | |
135 | 150 | $parameters = array(); |
136 | 151 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
137 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
152 | +if ($reshook < 0) { |
|
153 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
154 | +} |
|
138 | 155 | |
139 | 156 | if (empty($reshook)) { |
140 | 157 | // Selection of new fields |
@@ -191,19 +208,32 @@ discard block |
||
191 | 208 | $sql .= $hookmanager->resPrint; |
192 | 209 | $sql = preg_replace('/,\s*$/', '', $sql); |
193 | 210 | $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; |
194 | -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
195 | -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
196 | -else $sql .= " WHERE 1 = 1"; |
|
211 | +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { |
|
212 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
213 | +} |
|
214 | +if ($object->ismultientitymanaged == 1) { |
|
215 | + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
216 | +} else { |
|
217 | + $sql .= " WHERE 1 = 1"; |
|
218 | +} |
|
197 | 219 | foreach ($search as $key => $val) { |
198 | - if ($key == 'status' && $search[$key] == -1) continue; |
|
220 | + if ($key == 'status' && $search[$key] == -1) { |
|
221 | + continue; |
|
222 | + } |
|
199 | 223 | $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); |
200 | 224 | if (strpos($object->fields[$key]['type'], 'integer:') === 0) { |
201 | - if ($search[$key] == '-1') $search[$key] = ''; |
|
225 | + if ($search[$key] == '-1') { |
|
226 | + $search[$key] = ''; |
|
227 | + } |
|
202 | 228 | $mode_search = 2; |
203 | 229 | } |
204 | - 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); |
|
205 | 236 | } |
206 | -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
207 | 237 | //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); |
208 | 238 | // Add where from extra fields |
209 | 239 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
@@ -245,7 +275,9 @@ discard block |
||
245 | 275 | if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { |
246 | 276 | $num = $nbtotalofrecords; |
247 | 277 | } else { |
248 | - if ($limit) $sql .= $db->plimit($limit + 1, $offset); |
|
278 | + if ($limit) { |
|
279 | + $sql .= $db->plimit($limit + 1, $offset); |
|
280 | + } |
|
249 | 281 | |
250 | 282 | $resql = $db->query($sql); |
251 | 283 | if (!$resql) { |
@@ -288,13 +320,22 @@ discard block |
||
288 | 320 | $arrayofselected = is_array($toselect) ? $toselect : array(); |
289 | 321 | |
290 | 322 | $param = ''; |
291 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
292 | -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 | +} |
|
293 | 329 | foreach ($search as $key => $val) { |
294 | - if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
295 | - 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); |
|
296 | 338 | } |
297 | -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
298 | 339 | // Add $param from extra fields |
299 | 340 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
300 | 341 | |
@@ -305,12 +346,18 @@ discard block |
||
305 | 346 | //'builddoc'=>$langs->trans("PDFMerge"), |
306 | 347 | //'presend'=>$langs->trans("SendByMail"), |
307 | 348 | ); |
308 | -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
309 | -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 | +} |
|
310 | 355 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
311 | 356 | |
312 | 357 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
313 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
358 | +if ($optioncss != '') { |
|
359 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
360 | +} |
|
314 | 361 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
315 | 362 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
316 | 363 | print '<input type="hidden" name="action" value="list">'; |
@@ -331,7 +378,9 @@ discard block |
||
331 | 378 | include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; |
332 | 379 | |
333 | 380 | if ($search_all) { |
334 | - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
381 | + foreach ($fieldstosearchall as $key => $val) { |
|
382 | + $fieldstosearchall[$key] = $langs->trans($val); |
|
383 | + } |
|
335 | 384 | print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; |
336 | 385 | } |
337 | 386 | |
@@ -342,8 +391,11 @@ discard block |
||
342 | 391 | |
343 | 392 | $parameters = array(); |
344 | 393 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
345 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
346 | -else $moreforfilter = $hookmanager->resPrint; |
|
394 | +if (empty($reshook)) { |
|
395 | + $moreforfilter .= $hookmanager->resPrint; |
|
396 | +} else { |
|
397 | + $moreforfilter = $hookmanager->resPrint; |
|
398 | +} |
|
347 | 399 | |
348 | 400 | if (!empty($moreforfilter)) { |
349 | 401 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
@@ -364,16 +416,24 @@ discard block |
||
364 | 416 | print '<tr class="liste_titre">'; |
365 | 417 | foreach ($object->fields as $key => $val) { |
366 | 418 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
367 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
368 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
369 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
370 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
419 | + if ($key == 'status') { |
|
420 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
421 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
422 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
423 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
424 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
425 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
426 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
427 | + } |
|
371 | 428 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
372 | 429 | print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; |
373 | - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); |
|
374 | - elseif (strpos($val['type'], 'integer:') === 0) { |
|
430 | + if (is_array($val['arrayofkeyval'])) { |
|
431 | + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); |
|
432 | + } elseif (strpos($val['type'], 'integer:') === 0) { |
|
375 | 433 | print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); |
376 | - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; |
|
434 | + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { |
|
435 | + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; |
|
436 | + } |
|
377 | 437 | print '</td>'; |
378 | 438 | } |
379 | 439 | } |
@@ -397,10 +457,15 @@ discard block |
||
397 | 457 | print '<tr class="liste_titre">'; |
398 | 458 | foreach ($object->fields as $key => $val) { |
399 | 459 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
400 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
401 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
402 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
403 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
460 | + if ($key == 'status') { |
|
461 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
462 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
463 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
464 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
465 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
466 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
467 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
468 | + } |
|
404 | 469 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
405 | 470 | print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; |
406 | 471 | } |
@@ -433,7 +498,10 @@ discard block |
||
433 | 498 | $totalarray = array(); |
434 | 499 | while ($i < ($limit ? min($num, $limit) : $num)) { |
435 | 500 | $obj = $db->fetch_object($resql); |
436 | - if (empty($obj)) break; // Should not happen |
|
501 | + if (empty($obj)) { |
|
502 | + break; |
|
503 | + } |
|
504 | + // Should not happen |
|
437 | 505 | |
438 | 506 | // Store properties in $object |
439 | 507 | $object->setVarsFromFetchObj($obj); |
@@ -442,31 +510,48 @@ discard block |
||
442 | 510 | print '<tr class="oddeven">'; |
443 | 511 | foreach ($object->fields as $key => $val) { |
444 | 512 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
445 | - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
446 | - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
513 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
514 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
515 | + } elseif ($key == 'status') { |
|
516 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
517 | + } |
|
447 | 518 | |
448 | - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
449 | - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
519 | + if (in_array($val['type'], array('timestamp'))) { |
|
520 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
521 | + } elseif ($key == 'ref') { |
|
522 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
523 | + } |
|
450 | 524 | |
451 | - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
525 | + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { |
|
526 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
527 | + } |
|
452 | 528 | //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; |
453 | 529 | |
454 | 530 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
455 | 531 | print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; |
456 | - if ($key == 'status') print $object->getLibStatut(5); |
|
457 | - else { |
|
532 | + if ($key == 'status') { |
|
533 | + print $object->getLibStatut(5); |
|
534 | + } else { |
|
458 | 535 | print $object->showOutputField($val, $key, $object->$key, ''); |
459 | 536 | if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) { |
460 | 537 | $date_prevue_depart = $object->$key; |
461 | 538 | $date_prevue_depart_plus_delai = $date_prevue_depart; |
462 | - 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'); |
|
463 | - if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
539 | + if ($object->lead_time_for_warning > 0) { |
|
540 | + $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
541 | + } |
|
542 | + if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) { |
|
543 | + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
544 | + } |
|
464 | 545 | } |
465 | 546 | } |
466 | 547 | print '</td>'; |
467 | - if (!$i) $totalarray['nbfield']++; |
|
548 | + if (!$i) { |
|
549 | + $totalarray['nbfield']++; |
|
550 | + } |
|
468 | 551 | if (!empty($val['isameasure'])) { |
469 | - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
552 | + if (!$i) { |
|
553 | + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
554 | + } |
|
470 | 555 | $totalarray['val']['t.'.$key] += $object->$key; |
471 | 556 | } |
472 | 557 | } |
@@ -481,11 +566,15 @@ discard block |
||
481 | 566 | print '<td class="nowrap center">'; |
482 | 567 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
483 | 568 | $selected = 0; |
484 | - if (in_array($object->id, $arrayofselected)) $selected = 1; |
|
569 | + if (in_array($object->id, $arrayofselected)) { |
|
570 | + $selected = 1; |
|
571 | + } |
|
485 | 572 | print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; |
486 | 573 | } |
487 | 574 | print '</td>'; |
488 | - if (!$i) $totalarray['nbfield']++; |
|
575 | + if (!$i) { |
|
576 | + $totalarray['nbfield']++; |
|
577 | + } |
|
489 | 578 | |
490 | 579 | print '</tr>'."\n"; |
491 | 580 | |
@@ -498,7 +587,10 @@ discard block |
||
498 | 587 | // If no record found |
499 | 588 | if ($num == 0) { |
500 | 589 | $colspan = 1; |
501 | - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
590 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { |
|
591 | + $colspan++; |
|
592 | + } |
|
593 | + } |
|
502 | 594 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
503 | 595 | } |
504 | 596 | |
@@ -516,7 +608,9 @@ discard block |
||
516 | 608 | |
517 | 609 | if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { |
518 | 610 | $hidegeneratedfilelistifempty = 1; |
519 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; |
|
611 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { |
|
612 | + $hidegeneratedfilelistifempty = 0; |
|
613 | + } |
|
520 | 614 | |
521 | 615 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
522 | 616 | $formfile = new FormFile($db); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
96 | 96 | */ |
97 | - public $fields=array( |
|
97 | + public $fields = array( |
|
98 | 98 | 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'comment'=>"Id"), |
99 | 99 | 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"Help text for amount",), |
100 | 100 | 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'css'=>'maxwidth75imp', 'help'=>"Help text for quantity",), |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | |
450 | 450 | global $conf, $user, $langs; |
451 | 451 | |
452 | - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
|
453 | - include_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; |
|
454 | - include_once DOL_DOCUMENT_ROOT . '/product/stock/stocktransfer/class/stocktransfer.class.php'; |
|
452 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
453 | + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
|
454 | + include_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php'; |
|
455 | 455 | |
456 | 456 | $p = new Product($this->db); |
457 | 457 | $p->fetch($this->fk_product); |
@@ -128,8 +128,12 @@ discard block |
||
128 | 128 | |
129 | 129 | $this->db = $db; |
130 | 130 | |
131 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; |
|
132 | - if (!isModEnabled('multicompany') && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; |
|
131 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { |
|
132 | + $this->fields['rowid']['visible'] = 0; |
|
133 | + } |
|
134 | + if (!isModEnabled('multicompany') && isset($this->fields['entity'])) { |
|
135 | + $this->fields['entity']['enabled'] = 0; |
|
136 | + } |
|
133 | 137 | |
134 | 138 | // Example to show how to set values of fields definition dynamically |
135 | 139 | /*if ($user->rights->stocktransfer->stocktransferline->read) { |
@@ -188,7 +192,9 @@ discard block |
||
188 | 192 | |
189 | 193 | // Load source object |
190 | 194 | $result = $object->fetchCommon($fromid); |
191 | - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); |
|
195 | + if ($result > 0 && !empty($object->table_element_line)) { |
|
196 | + $object->fetchLines(); |
|
197 | + } |
|
192 | 198 | |
193 | 199 | // get lines so they will be clone |
194 | 200 | //foreach($this->lines as $line) |
@@ -235,8 +241,9 @@ discard block |
||
235 | 241 | if (!$error) { |
236 | 242 | // copy external contacts if same company |
237 | 243 | if (property_exists($this, 'socid') && $this->socid == $object->socid) { |
238 | - if ($this->copy_linked_contact($object, 'external') < 0) |
|
239 | - $error++; |
|
244 | + if ($this->copy_linked_contact($object, 'external') < 0) { |
|
245 | + $error++; |
|
246 | + } |
|
240 | 247 | } |
241 | 248 | } |
242 | 249 | |
@@ -262,7 +269,9 @@ discard block |
||
262 | 269 | public function fetch($id, $ref = null) |
263 | 270 | { |
264 | 271 | $result = $this->fetchCommon($id, $ref); |
265 | - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); |
|
272 | + if ($result > 0 && !empty($this->table_element_line)) { |
|
273 | + $this->fetchLines(); |
|
274 | + } |
|
266 | 275 | return $result; |
267 | 276 | } |
268 | 277 | |
@@ -302,8 +311,11 @@ discard block |
||
302 | 311 | $sql = 'SELECT '; |
303 | 312 | $sql .= $this->getFieldList(); |
304 | 313 | $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
305 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; |
|
306 | - else $sql .= ' WHERE 1 = 1'; |
|
314 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
|
315 | + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; |
|
316 | + } else { |
|
317 | + $sql .= ' WHERE 1 = 1'; |
|
318 | + } |
|
307 | 319 | // Manage filter |
308 | 320 | $sqlwhere = array(); |
309 | 321 | if (count($filter) > 0) { |
@@ -550,8 +562,12 @@ discard block |
||
550 | 562 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
551 | 563 | $sql .= " SET ref = '".$this->db->escape($num)."',"; |
552 | 564 | $sql .= " status = ".self::STATUS_VALIDATED; |
553 | - if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',"; |
|
554 | - if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".((int) $user->id); |
|
565 | + if (!empty($this->fields['date_validation'])) { |
|
566 | + $sql .= ", date_validation = '".$this->db->idate($now)."',"; |
|
567 | + } |
|
568 | + if (!empty($this->fields['fk_user_valid'])) { |
|
569 | + $sql .= ", fk_user_valid = ".((int) $user->id); |
|
570 | + } |
|
555 | 571 | $sql .= " WHERE rowid = ".((int) $this->id); |
556 | 572 | |
557 | 573 | dol_syslog(get_class($this)."::validate()", LOG_DEBUG); |
@@ -565,7 +581,9 @@ discard block |
||
565 | 581 | if (!$error && !$notrigger) { |
566 | 582 | // Call trigger |
567 | 583 | $result = $this->call_trigger('STOCKTRANSFERLINE_VALIDATE', $user); |
568 | - if ($result < 0) $error++; |
|
584 | + if ($result < 0) { |
|
585 | + $error++; |
|
586 | + } |
|
569 | 587 | // End call triggers |
570 | 588 | } |
571 | 589 | } |
@@ -707,7 +725,10 @@ discard block |
||
707 | 725 | { |
708 | 726 | global $conf, $langs, $hookmanager; |
709 | 727 | |
710 | - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
728 | + if (!empty($conf->dol_no_mouse_hover)) { |
|
729 | + $notooltip = 1; |
|
730 | + } |
|
731 | + // Force disable tooltips |
|
711 | 732 | |
712 | 733 | $result = ''; |
713 | 734 | |
@@ -723,8 +744,12 @@ discard block |
||
723 | 744 | if ($option != 'nolink') { |
724 | 745 | // Add param to save lastsearch_values or not |
725 | 746 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
726 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
727 | - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
747 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
|
748 | + $add_save_lastsearch_values = 1; |
|
749 | + } |
|
750 | + if ($add_save_lastsearch_values) { |
|
751 | + $url .= '&save_lastsearch_values=1'; |
|
752 | + } |
|
728 | 753 | } |
729 | 754 | |
730 | 755 | $linkclose = ''; |
@@ -735,7 +760,9 @@ discard block |
||
735 | 760 | } |
736 | 761 | $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
737 | 762 | $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
738 | - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
763 | + } else { |
|
764 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
765 | + } |
|
739 | 766 | |
740 | 767 | $linkstart = '<a href="'.$url.'"'; |
741 | 768 | $linkstart .= $linkclose.'>'; |
@@ -744,7 +771,9 @@ discard block |
||
744 | 771 | $result .= $linkstart; |
745 | 772 | |
746 | 773 | if (empty($this->showphoto_on_popup)) { |
747 | - if ($withpicto) $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); |
|
774 | + if ($withpicto) { |
|
775 | + $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); |
|
776 | + } |
|
748 | 777 | } else { |
749 | 778 | if ($withpicto) { |
750 | 779 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
@@ -770,7 +799,9 @@ discard block |
||
770 | 799 | } |
771 | 800 | } |
772 | 801 | |
773 | - if ($withpicto != 2) $result .= $this->ref; |
|
802 | + if ($withpicto != 2) { |
|
803 | + $result .= $this->ref; |
|
804 | + } |
|
774 | 805 | |
775 | 806 | $result .= $linkend; |
776 | 807 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
@@ -779,8 +810,11 @@ discard block |
||
779 | 810 | $hookmanager->initHooks(array('stocktransferlinedao')); |
780 | 811 | $parameters = array('id'=>$this->id, 'getnomurl'=>$result); |
781 | 812 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
782 | - if ($reshook > 0) $result = $hookmanager->resPrint; |
|
783 | - else $result .= $hookmanager->resPrint; |
|
813 | + if ($reshook > 0) { |
|
814 | + $result = $hookmanager->resPrint; |
|
815 | + } else { |
|
816 | + $result .= $hookmanager->resPrint; |
|
817 | + } |
|
784 | 818 | |
785 | 819 | return $result; |
786 | 820 | } |
@@ -820,7 +854,9 @@ discard block |
||
820 | 854 | |
821 | 855 | $statusType = 'status'.$status; |
822 | 856 | //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; |
823 | - if ($status == self::STATUS_CANCELED) $statusType = 'status6'; |
|
857 | + if ($status == self::STATUS_CANCELED) { |
|
858 | + $statusType = 'status6'; |
|
859 | + } |
|
824 | 860 | |
825 | 861 | return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); |
826 | 862 | } |
@@ -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 | } |