@@ -90,8 +90,7 @@ discard block |
||
90 | 90 | $this->db->free($resql); |
91 | 91 | |
92 | 92 | return 1; |
93 | - } |
|
94 | - else |
|
93 | + } else |
|
95 | 94 | { |
96 | 95 | $this->error="Error ".$this->db->lasterror(); |
97 | 96 | return -1; |
@@ -135,8 +134,7 @@ discard block |
||
135 | 134 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); |
136 | 135 | $this->fk_expeditiondet=$id_line_expdet; |
137 | 136 | return $this->id; |
138 | - } |
|
139 | - else |
|
137 | + } else |
|
140 | 138 | { |
141 | 139 | foreach($this->errors as $errmsg) |
142 | 140 | { |
@@ -166,8 +164,7 @@ discard block |
||
166 | 164 | if ($db->query($sql)) |
167 | 165 | { |
168 | 166 | return 1; |
169 | - } |
|
170 | - else |
|
167 | + } else |
|
171 | 168 | { |
172 | 169 | return -1; |
173 | 170 | } |
@@ -230,8 +227,7 @@ discard block |
||
230 | 227 | } |
231 | 228 | $db->free($resql); |
232 | 229 | return $ret; |
233 | - } |
|
234 | - else |
|
230 | + } else |
|
235 | 231 | { |
236 | 232 | dol_print_error($db); |
237 | 233 | return -1; |
@@ -35,9 +35,15 @@ discard block |
||
35 | 35 | |
36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
37 | 37 | require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; |
38 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
39 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
40 | -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
|
38 | +if (! empty($conf->propal->enabled)) { |
|
39 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
40 | +} |
|
41 | +if (! empty($conf->commande->enabled)) { |
|
42 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
43 | +} |
|
44 | +if (! empty($conf->productbatch->enabled)) { |
|
45 | + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; |
|
46 | +} |
|
41 | 47 | |
42 | 48 | |
43 | 49 | /** |
@@ -243,14 +249,12 @@ discard block |
||
243 | 249 | if ( $numref != "") |
244 | 250 | { |
245 | 251 | return $numref; |
246 | - } |
|
247 | - else |
|
252 | + } else |
|
248 | 253 | { |
249 | 254 | dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); |
250 | 255 | return ""; |
251 | 256 | } |
252 | - } |
|
253 | - else |
|
257 | + } else |
|
254 | 258 | { |
255 | 259 | print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); |
256 | 260 | return ""; |
@@ -276,7 +280,9 @@ discard block |
||
276 | 280 | // Clean parameters |
277 | 281 | $this->brouillon = 1; |
278 | 282 | $this->tracking_number = dol_sanitizeFileName($this->tracking_number); |
279 | - if (empty($this->fk_project)) $this->fk_project = 0; |
|
283 | + if (empty($this->fk_project)) { |
|
284 | + $this->fk_project = 0; |
|
285 | + } |
|
280 | 286 | |
281 | 287 | $this->user = $user; |
282 | 288 | |
@@ -357,8 +363,7 @@ discard block |
||
357 | 363 | { |
358 | 364 | $error++; |
359 | 365 | } |
360 | - } |
|
361 | - else |
|
366 | + } else |
|
362 | 367 | { // with batch management |
363 | 368 | if (! $this->create_line_batch($this->lines[$i],$this->lines[$i]->array_options) > 0) |
364 | 369 | { |
@@ -397,8 +402,7 @@ discard block |
||
397 | 402 | { |
398 | 403 | $this->db->commit(); |
399 | 404 | return $this->id; |
400 | - } |
|
401 | - else |
|
405 | + } else |
|
402 | 406 | { |
403 | 407 | foreach($this->errors as $errmsg) |
404 | 408 | { |
@@ -408,24 +412,21 @@ discard block |
||
408 | 412 | $this->db->rollback(); |
409 | 413 | return -1*$error; |
410 | 414 | } |
411 | - } |
|
412 | - else |
|
415 | + } else |
|
413 | 416 | { |
414 | 417 | $error++; |
415 | 418 | $this->error=$this->db->lasterror()." - sql=$sql"; |
416 | 419 | $this->db->rollback(); |
417 | 420 | return -3; |
418 | 421 | } |
419 | - } |
|
420 | - else |
|
422 | + } else |
|
421 | 423 | { |
422 | 424 | $error++; |
423 | 425 | $this->error=$this->db->lasterror()." - sql=$sql"; |
424 | 426 | $this->db->rollback(); |
425 | 427 | return -2; |
426 | 428 | } |
427 | - } |
|
428 | - else |
|
429 | + } else |
|
429 | 430 | { |
430 | 431 | $error++; |
431 | 432 | $this->error=$this->db->error()." - sql=$sql"; |
@@ -491,24 +492,28 @@ discard block |
||
491 | 492 | if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0) |
492 | 493 | { |
493 | 494 | $error++; |
494 | - } |
|
495 | - else |
|
495 | + } else |
|
496 | 496 | { |
497 | 497 | // create shipment batch lines for stockLocation |
498 | 498 | foreach ($tab as $detbatch) |
499 | 499 | { |
500 | 500 | if ($detbatch->entrepot_id == $stockLocation){ |
501 | - if (! ($detbatch->create($line_id) >0)) // Create an expeditionlinebatch |
|
501 | + if (! ($detbatch->create($line_id) >0)) { |
|
502 | + // Create an expeditionlinebatch |
|
502 | 503 | { |
503 | 504 | $error++; |
504 | 505 | } |
506 | + } |
|
505 | 507 | } |
506 | 508 | } |
507 | 509 | } |
508 | 510 | } |
509 | 511 | |
510 | - if (! $error) return 1; |
|
511 | - else return -1; |
|
512 | + if (! $error) { |
|
513 | + return 1; |
|
514 | + } else { |
|
515 | + return -1; |
|
516 | + } |
|
512 | 517 | } |
513 | 518 | |
514 | 519 | /** |
@@ -525,7 +530,9 @@ discard block |
||
525 | 530 | global $conf; |
526 | 531 | |
527 | 532 | // Check parameters |
528 | - if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; |
|
533 | + if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) { |
|
534 | + return -1; |
|
535 | + } |
|
529 | 536 | |
530 | 537 | $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet, e.billed"; |
531 | 538 | $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; |
@@ -541,10 +548,18 @@ discard block |
||
541 | 548 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; |
542 | 549 | $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as s ON e.fk_shipping_method = s.rowid'; |
543 | 550 | $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
544 | - if ($id) $sql.= " AND e.rowid=".$id; |
|
545 | - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; |
|
546 | - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
547 | - if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; |
|
551 | + if ($id) { |
|
552 | + $sql.= " AND e.rowid=".$id; |
|
553 | + } |
|
554 | + if ($ref) { |
|
555 | + $sql.= " AND e.ref='".$this->db->escape($ref)."'"; |
|
556 | + } |
|
557 | + if ($ref_ext) { |
|
558 | + $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; |
|
559 | + } |
|
560 | + if ($ref_int) { |
|
561 | + $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; |
|
562 | + } |
|
548 | 563 | |
549 | 564 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
550 | 565 | $result = $this->db->query($sql); |
@@ -601,7 +616,9 @@ discard block |
||
601 | 616 | |
602 | 617 | $this->db->free($result); |
603 | 618 | |
604 | - if ($this->statut == 0) $this->brouillon = 1; |
|
619 | + if ($this->statut == 0) { |
|
620 | + $this->brouillon = 1; |
|
621 | + } |
|
605 | 622 | |
606 | 623 | // Tracking url |
607 | 624 | $this->getUrlTrackingStatus($obj->tracking_number); |
@@ -624,15 +641,13 @@ discard block |
||
624 | 641 | } |
625 | 642 | |
626 | 643 | return 1; |
627 | - } |
|
628 | - else |
|
644 | + } else |
|
629 | 645 | { |
630 | 646 | dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR); |
631 | 647 | $this->error='Delivery with id '.$id.' not found'; |
632 | 648 | return 0; |
633 | 649 | } |
634 | - } |
|
635 | - else |
|
650 | + } else |
|
636 | 651 | { |
637 | 652 | $this->error=$this->db->error(); |
638 | 653 | return -1; |
@@ -681,11 +696,12 @@ discard block |
||
681 | 696 | $result=$soc->set_as_client(); |
682 | 697 | |
683 | 698 | // Define new ref |
684 | - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life |
|
699 | + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { |
|
700 | + // empty should not happened, but when it occurs, the test save life |
|
685 | 701 | { |
686 | 702 | $numref = $this->getNextNumRef($soc); |
687 | 703 | } |
688 | - else |
|
704 | + } else |
|
689 | 705 | { |
690 | 706 | $numref = "EXP".$this->id; |
691 | 707 | } |
@@ -737,12 +753,13 @@ discard block |
||
737 | 753 | if (empty($obj->edbrowid)) |
738 | 754 | { |
739 | 755 | $qty = $obj->qty; |
740 | - } |
|
741 | - else |
|
756 | + } else |
|
742 | 757 | { |
743 | 758 | $qty = $obj->edbqty; |
744 | 759 | } |
745 | - if ($qty <= 0) continue; |
|
760 | + if ($qty <= 0) { |
|
761 | + continue; |
|
762 | + } |
|
746 | 763 | dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); |
747 | 764 | |
748 | 765 | //var_dump($this->lines[$i]); |
@@ -761,8 +778,7 @@ discard block |
||
761 | 778 | $this->errors = array_merge($this->errors, $mouvS->errors); |
762 | 779 | break; |
763 | 780 | } |
764 | - } |
|
765 | - else |
|
781 | + } else |
|
766 | 782 | { |
767 | 783 | // line with batch detail |
768 | 784 | |
@@ -777,8 +793,7 @@ discard block |
||
777 | 793 | } |
778 | 794 | } |
779 | 795 | } |
780 | - } |
|
781 | - else |
|
796 | + } else |
|
782 | 797 | { |
783 | 798 | $this->db->rollback(); |
784 | 799 | $this->error=$this->db->error(); |
@@ -848,8 +863,7 @@ discard block |
||
848 | 863 | { |
849 | 864 | $this->db->commit(); |
850 | 865 | return 1; |
851 | - } |
|
852 | - else |
|
866 | + } else |
|
853 | 867 | { |
854 | 868 | foreach($this->errors as $errmsg) |
855 | 869 | { |
@@ -885,16 +899,17 @@ discard block |
||
885 | 899 | if ($result > 0) |
886 | 900 | { |
887 | 901 | return $result; |
888 | - } |
|
889 | - else |
|
902 | + } else |
|
890 | 903 | { |
891 | 904 | $this->error=$delivery->error; |
892 | 905 | return $result; |
893 | 906 | } |
907 | + } else { |
|
908 | + return 0; |
|
894 | 909 | } |
895 | - else return 0; |
|
910 | + } else { |
|
911 | + return 0; |
|
896 | 912 | } |
897 | - else return 0; |
|
898 | 913 | } |
899 | 914 | |
900 | 915 | /** |
@@ -942,9 +957,9 @@ discard block |
||
942 | 957 | if ($entrepot_id > 0) { |
943 | 958 | $product->load_stock('warehouseopen'); |
944 | 959 | $product_stock = $product->stock_warehouse[$entrepot_id]->real; |
960 | + } else { |
|
961 | + $product_stock = $product->stock_reel; |
|
945 | 962 | } |
946 | - else |
|
947 | - $product_stock = $product->stock_reel; |
|
948 | 963 | |
949 | 964 | $product_type=$product->type; |
950 | 965 | if ($product_type == 0 && $product_stock < $qty) |
@@ -965,8 +980,10 @@ discard block |
||
965 | 980 | } |
966 | 981 | |
967 | 982 | // extrafields |
968 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used |
|
983 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) { |
|
984 | + // For avoid conflicts if trigger used |
|
969 | 985 | $line->array_options = $array_options; |
986 | + } |
|
970 | 987 | |
971 | 988 | $this->lines[$num] = $line; |
972 | 989 | } |
@@ -1032,8 +1049,10 @@ discard block |
||
1032 | 1049 | $line->detail_batch=$tab; |
1033 | 1050 | |
1034 | 1051 | // extrafields |
1035 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used |
|
1052 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) { |
|
1053 | + // For avoid conflicts if trigger used |
|
1036 | 1054 | $line->array_options = $array_options; |
1055 | + } |
|
1037 | 1056 | |
1038 | 1057 | //var_dump($line); |
1039 | 1058 | $this->lines[$num] = $line; |
@@ -1055,25 +1074,63 @@ discard block |
||
1055 | 1074 | |
1056 | 1075 | // Clean parameters |
1057 | 1076 | |
1058 | - if (isset($this->ref)) $this->ref=trim($this->ref); |
|
1059 | - if (isset($this->entity)) $this->entity=trim($this->entity); |
|
1060 | - if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); |
|
1061 | - if (isset($this->socid)) $this->socid=trim($this->socid); |
|
1062 | - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); |
|
1063 | - if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); |
|
1064 | - if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); |
|
1065 | - if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); |
|
1066 | - if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); |
|
1067 | - if (isset($this->statut)) $this->statut=(int) $this->statut; |
|
1068 | - if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); |
|
1069 | - if (isset($this->trueWidth)) $this->trueWidth=trim($this->trueWidth); |
|
1070 | - if (isset($this->trueHeight)) $this->trueHeight=trim($this->trueHeight); |
|
1071 | - if (isset($this->size_units)) $this->size_units=trim($this->size_units); |
|
1072 | - if (isset($this->weight_units)) $this->weight_units=trim($this->weight_units); |
|
1073 | - if (isset($this->trueWeight)) $this->weight=trim($this->trueWeight); |
|
1074 | - if (isset($this->note_private)) $this->note=trim($this->note_private); |
|
1075 | - if (isset($this->note_public)) $this->note=trim($this->note_public); |
|
1076 | - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); |
|
1077 | + if (isset($this->ref)) { |
|
1078 | + $this->ref=trim($this->ref); |
|
1079 | + } |
|
1080 | + if (isset($this->entity)) { |
|
1081 | + $this->entity=trim($this->entity); |
|
1082 | + } |
|
1083 | + if (isset($this->ref_customer)) { |
|
1084 | + $this->ref_customer=trim($this->ref_customer); |
|
1085 | + } |
|
1086 | + if (isset($this->socid)) { |
|
1087 | + $this->socid=trim($this->socid); |
|
1088 | + } |
|
1089 | + if (isset($this->fk_user_author)) { |
|
1090 | + $this->fk_user_author=trim($this->fk_user_author); |
|
1091 | + } |
|
1092 | + if (isset($this->fk_user_valid)) { |
|
1093 | + $this->fk_user_valid=trim($this->fk_user_valid); |
|
1094 | + } |
|
1095 | + if (isset($this->fk_delivery_address)) { |
|
1096 | + $this->fk_delivery_address=trim($this->fk_delivery_address); |
|
1097 | + } |
|
1098 | + if (isset($this->shipping_method_id)) { |
|
1099 | + $this->shipping_method_id=trim($this->shipping_method_id); |
|
1100 | + } |
|
1101 | + if (isset($this->tracking_number)) { |
|
1102 | + $this->tracking_number=trim($this->tracking_number); |
|
1103 | + } |
|
1104 | + if (isset($this->statut)) { |
|
1105 | + $this->statut=(int) $this->statut; |
|
1106 | + } |
|
1107 | + if (isset($this->trueDepth)) { |
|
1108 | + $this->trueDepth=trim($this->trueDepth); |
|
1109 | + } |
|
1110 | + if (isset($this->trueWidth)) { |
|
1111 | + $this->trueWidth=trim($this->trueWidth); |
|
1112 | + } |
|
1113 | + if (isset($this->trueHeight)) { |
|
1114 | + $this->trueHeight=trim($this->trueHeight); |
|
1115 | + } |
|
1116 | + if (isset($this->size_units)) { |
|
1117 | + $this->size_units=trim($this->size_units); |
|
1118 | + } |
|
1119 | + if (isset($this->weight_units)) { |
|
1120 | + $this->weight_units=trim($this->weight_units); |
|
1121 | + } |
|
1122 | + if (isset($this->trueWeight)) { |
|
1123 | + $this->weight=trim($this->trueWeight); |
|
1124 | + } |
|
1125 | + if (isset($this->note_private)) { |
|
1126 | + $this->note=trim($this->note_private); |
|
1127 | + } |
|
1128 | + if (isset($this->note_public)) { |
|
1129 | + $this->note=trim($this->note_public); |
|
1130 | + } |
|
1131 | + if (isset($this->modelpdf)) { |
|
1132 | + $this->modelpdf=trim($this->modelpdf); |
|
1133 | + } |
|
1077 | 1134 | |
1078 | 1135 | |
1079 | 1136 | |
@@ -1138,8 +1195,7 @@ discard block |
||
1138 | 1195 | } |
1139 | 1196 | $this->db->rollback(); |
1140 | 1197 | return -1*$error; |
1141 | - } |
|
1142 | - else |
|
1198 | + } else |
|
1143 | 1199 | { |
1144 | 1200 | $this->db->commit(); |
1145 | 1201 | return 1; |
@@ -1230,8 +1286,7 @@ discard block |
||
1230 | 1286 | $error++;$this->errors=$this->errors + $mouvS->errors; |
1231 | 1287 | break; |
1232 | 1288 | } |
1233 | - } |
|
1234 | - else |
|
1289 | + } else |
|
1235 | 1290 | { |
1236 | 1291 | // We increment stock of batches |
1237 | 1292 | // We use warehouse selected for each line |
@@ -1244,11 +1299,13 @@ discard block |
||
1244 | 1299 | break; |
1245 | 1300 | } |
1246 | 1301 | } |
1247 | - if ($error) break; // break for loop incase of error |
|
1302 | + if ($error) { |
|
1303 | + break; |
|
1304 | + } |
|
1305 | + // break for loop incase of error |
|
1248 | 1306 | } |
1249 | 1307 | } |
1250 | - } |
|
1251 | - else |
|
1308 | + } else |
|
1252 | 1309 | { |
1253 | 1310 | $error++;$this->errors[]="Error ".$this->db->lasterror(); |
1254 | 1311 | } |
@@ -1272,7 +1329,9 @@ discard block |
||
1272 | 1329 | { |
1273 | 1330 | // Delete linked object |
1274 | 1331 | $res = $this->deleteObjectLinked(); |
1275 | - if ($res < 0) $error++; |
|
1332 | + if ($res < 0) { |
|
1333 | + $error++; |
|
1334 | + } |
|
1276 | 1335 | |
1277 | 1336 | if (! $error) |
1278 | 1337 | { |
@@ -1285,10 +1344,12 @@ discard block |
||
1285 | 1344 | { |
1286 | 1345 | $this->fetch_origin(); |
1287 | 1346 | $origin=$this->origin; |
1288 | - if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress" |
|
1347 | + if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) { |
|
1348 | + // If order source of shipment is "shipment in progress" |
|
1289 | 1349 | { |
1290 | 1350 | // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" |
1291 | 1351 | $this->$origin->loadExpeditions(); |
1352 | + } |
|
1292 | 1353 | //var_dump($this->$origin->expeditions);exit; |
1293 | 1354 | if (count($this->$origin->expeditions) <= 0) |
1294 | 1355 | { |
@@ -1325,35 +1386,30 @@ discard block |
||
1325 | 1386 | } |
1326 | 1387 | |
1327 | 1388 | return 1; |
1328 | - } |
|
1329 | - else |
|
1389 | + } else |
|
1330 | 1390 | { |
1331 | 1391 | $this->db->rollback(); |
1332 | 1392 | return -1; |
1333 | 1393 | } |
1334 | - } |
|
1335 | - else |
|
1394 | + } else |
|
1336 | 1395 | { |
1337 | 1396 | $this->error=$this->db->lasterror()." - sql=$sql"; |
1338 | 1397 | $this->db->rollback(); |
1339 | 1398 | return -3; |
1340 | 1399 | } |
1341 | - } |
|
1342 | - else |
|
1400 | + } else |
|
1343 | 1401 | { |
1344 | 1402 | $this->error=$this->db->lasterror()." - sql=$sql"; |
1345 | 1403 | $this->db->rollback(); |
1346 | 1404 | return -2; |
1347 | 1405 | } |
1348 | - } |
|
1349 | - else |
|
1406 | + } else |
|
1350 | 1407 | { |
1351 | 1408 | $this->error=$this->db->lasterror()." - sql=$sql"; |
1352 | 1409 | $this->db->rollback(); |
1353 | 1410 | return -1; |
1354 | 1411 | } |
1355 | - } |
|
1356 | - else |
|
1412 | + } else |
|
1357 | 1413 | { |
1358 | 1414 | $this->db->rollback(); |
1359 | 1415 | return -1; |
@@ -1506,8 +1562,7 @@ discard block |
||
1506 | 1562 | if ($originline != $obj->fk_origin_line) |
1507 | 1563 | { |
1508 | 1564 | $line->detail_batch = $newdetailbatch; |
1509 | - } |
|
1510 | - else |
|
1565 | + } else |
|
1511 | 1566 | { |
1512 | 1567 | $line->detail_batch = array_merge($line->detail_batch, $newdetailbatch); |
1513 | 1568 | } |
@@ -1518,8 +1573,7 @@ discard block |
||
1518 | 1573 | { |
1519 | 1574 | $this->lines[$lineindex] = $line; |
1520 | 1575 | $lineindex++; |
1521 | - } |
|
1522 | - else |
|
1576 | + } else |
|
1523 | 1577 | { |
1524 | 1578 | $line->total_ht += $tabprice[0]; |
1525 | 1579 | $line->total_localtax1 += $tabprice[9]; |
@@ -1533,8 +1587,7 @@ discard block |
||
1533 | 1587 | } |
1534 | 1588 | $this->db->free($resql); |
1535 | 1589 | return 1; |
1536 | - } |
|
1537 | - else |
|
1590 | + } else |
|
1538 | 1591 | { |
1539 | 1592 | $this->error=$this->db->error(); |
1540 | 1593 | return -3; |
@@ -1567,14 +1620,12 @@ discard block |
||
1567 | 1620 | |
1568 | 1621 | $this->db->commit(); |
1569 | 1622 | return 1; |
1570 | - } |
|
1571 | - else |
|
1623 | + } else |
|
1572 | 1624 | { |
1573 | 1625 | $this->db->rollback(); |
1574 | 1626 | return -1; |
1575 | 1627 | } |
1576 | - } |
|
1577 | - else |
|
1628 | + } else |
|
1578 | 1629 | { |
1579 | 1630 | $this->error='ErrorDeleteLineNotAllowedByObjectStatus'; |
1580 | 1631 | return -2; |
@@ -1604,14 +1655,20 @@ discard block |
||
1604 | 1655 | |
1605 | 1656 | $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; |
1606 | 1657 | |
1607 | - if ($short) return $url; |
|
1658 | + if ($short) { |
|
1659 | + return $url; |
|
1660 | + } |
|
1608 | 1661 | |
1609 | 1662 | if ($option !== 'nolink') |
1610 | 1663 | { |
1611 | 1664 | // Add param to save lastsearch_values or not |
1612 | 1665 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
1613 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
1614 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
1666 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
1667 | + $add_save_lastsearch_values=1; |
|
1668 | + } |
|
1669 | + if ($add_save_lastsearch_values) { |
|
1670 | + $url.='&save_lastsearch_values=1'; |
|
1671 | + } |
|
1615 | 1672 | } |
1616 | 1673 | |
1617 | 1674 | $linkclose=''; |
@@ -1630,8 +1687,12 @@ discard block |
||
1630 | 1687 | $linkend='</a>'; |
1631 | 1688 | |
1632 | 1689 | $result .= $linkstart; |
1633 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
1634 | - if ($withpicto != 2) $result.= $this->ref; |
|
1690 | + if ($withpicto) { |
|
1691 | + $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
1692 | + } |
|
1693 | + if ($withpicto != 2) { |
|
1694 | + $result.= $this->ref; |
|
1695 | + } |
|
1635 | 1696 | $result .= $linkend; |
1636 | 1697 | |
1637 | 1698 | return $result; |
@@ -1663,33 +1724,49 @@ discard block |
||
1663 | 1724 | |
1664 | 1725 | if ($mode==0) |
1665 | 1726 | { |
1666 | - if ($statut==0) return $langs->trans($this->statuts[$statut]); |
|
1667 | - elseif ($statut==1) return $langs->trans($this->statuts[$statut]); |
|
1668 | - elseif ($statut==2) return $langs->trans($this->statuts[$statut]); |
|
1669 | - } |
|
1670 | - elseif ($mode==1) |
|
1671 | - { |
|
1672 | - if ($statut==0) return $langs->trans($this->statutshorts[$statut]); |
|
1673 | - elseif ($statut==1) return $langs->trans($this->statutshorts[$statut]); |
|
1674 | - elseif ($statut==2) return $langs->trans($this->statutshorts[$statut]); |
|
1675 | - } |
|
1676 | - elseif ($mode == 3) |
|
1677 | - { |
|
1678 | - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
1679 | - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
1680 | - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
1681 | - } |
|
1682 | - elseif ($mode == 4) |
|
1683 | - { |
|
1684 | - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); |
|
1685 | - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
1686 | - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); |
|
1687 | - } |
|
1688 | - elseif ($mode == 5) |
|
1689 | - { |
|
1690 | - if ($statut==0) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
1691 | - elseif ($statut==1) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
1692 | - elseif ($statut==2) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
1727 | + if ($statut==0) { |
|
1728 | + return $langs->trans($this->statuts[$statut]); |
|
1729 | + } elseif ($statut==1) { |
|
1730 | + return $langs->trans($this->statuts[$statut]); |
|
1731 | + } elseif ($statut==2) { |
|
1732 | + return $langs->trans($this->statuts[$statut]); |
|
1733 | + } |
|
1734 | + } elseif ($mode==1) |
|
1735 | + { |
|
1736 | + if ($statut==0) { |
|
1737 | + return $langs->trans($this->statutshorts[$statut]); |
|
1738 | + } elseif ($statut==1) { |
|
1739 | + return $langs->trans($this->statutshorts[$statut]); |
|
1740 | + } elseif ($statut==2) { |
|
1741 | + return $langs->trans($this->statutshorts[$statut]); |
|
1742 | + } |
|
1743 | + } elseif ($mode == 3) |
|
1744 | + { |
|
1745 | + if ($statut==0) { |
|
1746 | + return img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
1747 | + } elseif ($statut==1) { |
|
1748 | + return img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
1749 | + } elseif ($statut==2) { |
|
1750 | + return img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
1751 | + } |
|
1752 | + } elseif ($mode == 4) |
|
1753 | + { |
|
1754 | + if ($statut==0) { |
|
1755 | + return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); |
|
1756 | + } elseif ($statut==1) { |
|
1757 | + return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
1758 | + } elseif ($statut==2) { |
|
1759 | + return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); |
|
1760 | + } |
|
1761 | + } elseif ($mode == 5) |
|
1762 | + { |
|
1763 | + if ($statut==0) { |
|
1764 | + return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); |
|
1765 | + } elseif ($statut==1) { |
|
1766 | + return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); |
|
1767 | + } elseif ($statut==2) { |
|
1768 | + return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); |
|
1769 | + } |
|
1693 | 1770 | } |
1694 | 1771 | } |
1695 | 1772 | |
@@ -1795,14 +1872,12 @@ discard block |
||
1795 | 1872 | { |
1796 | 1873 | $this->date_delivery = $date_livraison; |
1797 | 1874 | return 1; |
1798 | - } |
|
1799 | - else |
|
1875 | + } else |
|
1800 | 1876 | { |
1801 | 1877 | $this->error=$this->db->error(); |
1802 | 1878 | return -1; |
1803 | 1879 | } |
1804 | - } |
|
1805 | - else |
|
1880 | + } else |
|
1806 | 1881 | { |
1807 | 1882 | return -2; |
1808 | 1883 | } |
@@ -1853,7 +1928,9 @@ discard block |
||
1853 | 1928 | |
1854 | 1929 | $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; |
1855 | 1930 | $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; |
1856 | - if ($id!='') $sql.= " WHERE em.rowid=".$id; |
|
1931 | + if ($id!='') { |
|
1932 | + $sql.= " WHERE em.rowid=".$id; |
|
1933 | + } |
|
1857 | 1934 | |
1858 | 1935 | $resql = $this->db->query($sql); |
1859 | 1936 | if ($resql) |
@@ -1888,8 +1965,7 @@ discard block |
||
1888 | 1965 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; |
1889 | 1966 | $sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; |
1890 | 1967 | $resql = $this->db->query($sql); |
1891 | - } |
|
1892 | - else |
|
1968 | + } else |
|
1893 | 1969 | { |
1894 | 1970 | $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; |
1895 | 1971 | $sql.= " code='".$this->db->escape($this->update['code'])."'"; |
@@ -1899,7 +1975,9 @@ discard block |
||
1899 | 1975 | $sql.= " WHERE rowid=".$id; |
1900 | 1976 | $resql = $this->db->query($sql); |
1901 | 1977 | } |
1902 | - if ($resql < 0) dol_print_error($this->db,''); |
|
1978 | + if ($resql < 0) { |
|
1979 | + dol_print_error($this->db,''); |
|
1980 | + } |
|
1903 | 1981 | } |
1904 | 1982 | |
1905 | 1983 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -1965,8 +2043,7 @@ discard block |
||
1965 | 2043 | { |
1966 | 2044 | $url = str_replace('{TRACKID}', $value, $tracking); |
1967 | 2045 | $this->tracking_url = sprintf('<a target="_blank" href="%s">'.($value?$value:'url').'</a>',$url,$url); |
1968 | - } |
|
1969 | - else |
|
2046 | + } else |
|
1970 | 2047 | { |
1971 | 2048 | $this->tracking_url = $value; |
1972 | 2049 | } |
@@ -2051,12 +2128,13 @@ discard block |
||
2051 | 2128 | if (empty($obj->edbrowid)) |
2052 | 2129 | { |
2053 | 2130 | $qty = $obj->qty; |
2054 | - } |
|
2055 | - else |
|
2131 | + } else |
|
2056 | 2132 | { |
2057 | 2133 | $qty = $obj->edbqty; |
2058 | 2134 | } |
2059 | - if ($qty <= 0) continue; |
|
2135 | + if ($qty <= 0) { |
|
2136 | + continue; |
|
2137 | + } |
|
2060 | 2138 | dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); |
2061 | 2139 | |
2062 | 2140 | $mouvS = new MouvementStock($this->db); |
@@ -2073,8 +2151,7 @@ discard block |
||
2073 | 2151 | $this->errors = $mouvS->errors; |
2074 | 2152 | $error++; break; |
2075 | 2153 | } |
2076 | - } |
|
2077 | - else |
|
2154 | + } else |
|
2078 | 2155 | { |
2079 | 2156 | // line with batch detail |
2080 | 2157 | |
@@ -2087,8 +2164,7 @@ discard block |
||
2087 | 2164 | } |
2088 | 2165 | } |
2089 | 2166 | } |
2090 | - } |
|
2091 | - else |
|
2167 | + } else |
|
2092 | 2168 | { |
2093 | 2169 | $this->error=$this->db->lasterror(); |
2094 | 2170 | $error++; |
@@ -2103,8 +2179,7 @@ discard block |
||
2103 | 2179 | $error++; |
2104 | 2180 | } |
2105 | 2181 | } |
2106 | - } |
|
2107 | - else |
|
2182 | + } else |
|
2108 | 2183 | { |
2109 | 2184 | dol_print_error($this->db); |
2110 | 2185 | $error++; |
@@ -2114,8 +2189,7 @@ discard block |
||
2114 | 2189 | { |
2115 | 2190 | $this->db->commit(); |
2116 | 2191 | return 1; |
2117 | - } |
|
2118 | - else |
|
2192 | + } else |
|
2119 | 2193 | { |
2120 | 2194 | $this->db->rollback(); |
2121 | 2195 | return -1; |
@@ -2158,8 +2232,7 @@ discard block |
||
2158 | 2232 | if (empty($error)) { |
2159 | 2233 | $this->db->commit(); |
2160 | 2234 | return 1; |
2161 | - } |
|
2162 | - else |
|
2235 | + } else |
|
2163 | 2236 | { |
2164 | 2237 | $this->db->rollback(); |
2165 | 2238 | return -1; |
@@ -2223,12 +2296,13 @@ discard block |
||
2223 | 2296 | if (empty($obj->edbrowid)) |
2224 | 2297 | { |
2225 | 2298 | $qty = $obj->qty; |
2226 | - } |
|
2227 | - else |
|
2299 | + } else |
|
2228 | 2300 | { |
2229 | 2301 | $qty = $obj->edbqty; |
2230 | 2302 | } |
2231 | - if ($qty <= 0) continue; |
|
2303 | + if ($qty <= 0) { |
|
2304 | + continue; |
|
2305 | + } |
|
2232 | 2306 | dol_syslog(get_class($this)."::reopen expedition movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); |
2233 | 2307 | |
2234 | 2308 | //var_dump($this->lines[$i]); |
@@ -2246,8 +2320,7 @@ discard block |
||
2246 | 2320 | $this->errors = $mouvS->errors; |
2247 | 2321 | $error++; break; |
2248 | 2322 | } |
2249 | - } |
|
2250 | - else |
|
2323 | + } else |
|
2251 | 2324 | { |
2252 | 2325 | // line with batch detail |
2253 | 2326 | |
@@ -2260,8 +2333,7 @@ discard block |
||
2260 | 2333 | } |
2261 | 2334 | } |
2262 | 2335 | } |
2263 | - } |
|
2264 | - else |
|
2336 | + } else |
|
2265 | 2337 | { |
2266 | 2338 | $this->error=$this->db->lasterror(); |
2267 | 2339 | $error++; |
@@ -2285,8 +2357,7 @@ discard block |
||
2285 | 2357 | { |
2286 | 2358 | $this->db->commit(); |
2287 | 2359 | return 1; |
2288 | - } |
|
2289 | - else |
|
2360 | + } else |
|
2290 | 2361 | { |
2291 | 2362 | $this->db->rollback(); |
2292 | 2363 | return -1; |
@@ -2533,8 +2604,7 @@ discard block |
||
2533 | 2604 | $this->db->free($result); |
2534 | 2605 | |
2535 | 2606 | return 1; |
2536 | - } |
|
2537 | - else |
|
2607 | + } else |
|
2538 | 2608 | { |
2539 | 2609 | $this->errors[] = $this->db->lasterror(); |
2540 | 2610 | $this->error = $this->db->lasterror(); |
@@ -2562,7 +2632,9 @@ discard block |
||
2562 | 2632 | return -1; |
2563 | 2633 | } |
2564 | 2634 | // Clean parameters |
2565 | - if (empty($this->entrepot_id)) $this->entrepot_id='null'; |
|
2635 | + if (empty($this->entrepot_id)) { |
|
2636 | + $this->entrepot_id='null'; |
|
2637 | + } |
|
2566 | 2638 | |
2567 | 2639 | $this->db->begin(); |
2568 | 2640 | |
@@ -2617,8 +2689,7 @@ discard block |
||
2617 | 2689 | |
2618 | 2690 | $this->db->rollback(); |
2619 | 2691 | return -1*$error; |
2620 | - } |
|
2621 | - else |
|
2692 | + } else |
|
2622 | 2693 | { |
2623 | 2694 | $error++; |
2624 | 2695 | } |
@@ -2658,9 +2729,11 @@ discard block |
||
2658 | 2729 | if (! $error && $this->db->query($sql)) |
2659 | 2730 | { |
2660 | 2731 | // Remove extrafields |
2661 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
2732 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
2733 | + // For avoid conflicts if trigger used |
|
2662 | 2734 | { |
2663 | 2735 | $result=$this->deleteExtraFields(); |
2736 | + } |
|
2664 | 2737 | if ($result < 0) |
2665 | 2738 | { |
2666 | 2739 | $this->errors[]=$this->error; |
@@ -2678,8 +2751,7 @@ discard block |
||
2678 | 2751 | } |
2679 | 2752 | // End call triggers |
2680 | 2753 | } |
2681 | - } |
|
2682 | - else |
|
2754 | + } else |
|
2683 | 2755 | { |
2684 | 2756 | $this->errors[]=$this->db->lasterror()." - sql=$sql"; |
2685 | 2757 | $error++; |
@@ -2688,8 +2760,7 @@ discard block |
||
2688 | 2760 | if (! $error) { |
2689 | 2761 | $this->db->commit(); |
2690 | 2762 | return 1; |
2691 | - } |
|
2692 | - else |
|
2763 | + } else |
|
2693 | 2764 | { |
2694 | 2765 | foreach($this->errors as $errmsg) |
2695 | 2766 | { |
@@ -2719,21 +2790,24 @@ discard block |
||
2719 | 2790 | $this->db->begin(); |
2720 | 2791 | |
2721 | 2792 | // Clean parameters |
2722 | - if (empty($this->qty)) $this->qty=0; |
|
2793 | + if (empty($this->qty)) { |
|
2794 | + $this->qty=0; |
|
2795 | + } |
|
2723 | 2796 | $qty=price2num($this->qty); |
2724 | 2797 | $remainingQty = 0; |
2725 | 2798 | $batch = null; |
2726 | 2799 | $batch_id = null; |
2727 | 2800 | $expedition_batch_id = null; |
2728 | - if (is_array($this->detail_batch)) // array of ExpeditionLineBatch |
|
2801 | + if (is_array($this->detail_batch)) { |
|
2802 | + // array of ExpeditionLineBatch |
|
2729 | 2803 | { |
2730 | 2804 | if (count($this->detail_batch) > 1) |
2731 | 2805 | { |
2732 | 2806 | dol_syslog(get_class($this).'::update only possible for one batch', LOG_ERR); |
2807 | + } |
|
2733 | 2808 | $this->errors[]='ErrorBadParameters'; |
2734 | 2809 | $error++; |
2735 | - } |
|
2736 | - else |
|
2810 | + } else |
|
2737 | 2811 | { |
2738 | 2812 | $batch = $this->detail_batch[0]->batch; |
2739 | 2813 | $batch_id = $this->detail_batch[0]->fk_origin_stock; |
@@ -2746,8 +2820,7 @@ discard block |
||
2746 | 2820 | } |
2747 | 2821 | $qty = price2num($this->detail_batch[0]->qty); |
2748 | 2822 | } |
2749 | - } |
|
2750 | - else if (! empty($this->detail_batch)) |
|
2823 | + } else if (! empty($this->detail_batch)) |
|
2751 | 2824 | { |
2752 | 2825 | $batch = $this->detail_batch->batch; |
2753 | 2826 | $batch_id = $this->detail_batch->fk_origin_stock; |
@@ -2788,8 +2861,7 @@ discard block |
||
2788 | 2861 | { |
2789 | 2862 | $this->errors[]=$this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; |
2790 | 2863 | $error++; |
2791 | - } |
|
2792 | - else |
|
2864 | + } else |
|
2793 | 2865 | { |
2794 | 2866 | // caculate new total line qty |
2795 | 2867 | foreach ($lotArray as $lot) |
@@ -2862,9 +2934,11 @@ discard block |
||
2862 | 2934 | |
2863 | 2935 | if (! $error) |
2864 | 2936 | { |
2865 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
2937 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
2938 | + // For avoid conflicts if trigger used |
|
2866 | 2939 | { |
2867 | 2940 | $result=$this->insertExtraFields(); |
2941 | + } |
|
2868 | 2942 | if ($result < 0) |
2869 | 2943 | { |
2870 | 2944 | $this->errors[]=$this->error; |
@@ -2887,8 +2961,7 @@ discard block |
||
2887 | 2961 | if (!$error) { |
2888 | 2962 | $this->db->commit(); |
2889 | 2963 | return 1; |
2890 | - } |
|
2891 | - else |
|
2964 | + } else |
|
2892 | 2965 | { |
2893 | 2966 | foreach($this->errors as $errmsg) |
2894 | 2967 | { |
@@ -73,12 +73,16 @@ discard block |
||
73 | 73 | |
74 | 74 | //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; |
75 | 75 | $this->where.= " AND c.entity = ".$conf->entity; |
76 | - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
76 | + if (!$user->rights->societe->client->voir && !$this->socid) { |
|
77 | + $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
78 | + } |
|
77 | 79 | if ($this->socid) |
78 | 80 | { |
79 | 81 | $this->where.=" AND c.fk_soc = ".$this->socid; |
80 | 82 | } |
81 | - if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; |
|
83 | + if ($this->userid > 0) { |
|
84 | + $this->where.=' AND c.fk_user_author = '.$this->userid; |
|
85 | + } |
|
82 | 86 | } |
83 | 87 | |
84 | 88 | /** |
@@ -94,7 +98,9 @@ discard block |
||
94 | 98 | |
95 | 99 | $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; |
96 | 100 | $sql.= " FROM ".$this->from; |
97 | - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | + if (!$user->rights->societe->client->voir && !$this->socid) { |
|
102 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | + } |
|
98 | 104 | $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; |
99 | 105 | $sql.= " AND ".$this->where; |
100 | 106 | $sql.= " GROUP BY dm"; |
@@ -116,7 +122,9 @@ discard block |
||
116 | 122 | |
117 | 123 | $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; |
118 | 124 | $sql.= " FROM ".$this->from; |
119 | - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
125 | + if (!$user->rights->societe->client->voir && !$this->socid) { |
|
126 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
127 | + } |
|
120 | 128 | $sql.= " WHERE ".$this->where; |
121 | 129 | $sql.= " GROUP BY dm"; |
122 | 130 | $sql.= $this->db->order('dm','DESC'); |
@@ -135,7 +143,9 @@ discard block |
||
135 | 143 | |
136 | 144 | $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; |
137 | 145 | $sql.= " FROM ".$this->from; |
138 | - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
146 | + if (!$user->rights->societe->client->voir && !$this->socid) { |
|
147 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
148 | + } |
|
139 | 149 | $sql.= " WHERE ".$this->where; |
140 | 150 | $sql.= " GROUP BY year"; |
141 | 151 | $sql.= $this->db->order('year','DESC'); |
@@ -110,18 +110,33 @@ discard block |
||
110 | 110 | |
111 | 111 | // If the internal user must only see his customers, force searching by him |
112 | 112 | $search_sale = 0; |
113 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
113 | + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { |
|
114 | + $search_sale = DolibarrApiAccess::$user->id; |
|
115 | + } |
|
114 | 116 | |
115 | 117 | $sql = "SELECT t.rowid"; |
116 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
118 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { |
|
119 | + $sql .= ", sc.fk_soc, sc.fk_user"; |
|
120 | + } |
|
121 | + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
117 | 122 | $sql.= " FROM ".MAIN_DB_PREFIX."expedition as t"; |
118 | 123 | |
119 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
124 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { |
|
125 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
126 | + } |
|
127 | + // We need this table joined to the select in order to filter by sale |
|
120 | 128 | |
121 | 129 | $sql.= ' WHERE t.entity IN ('.getEntity('expedition').')'; |
122 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
123 | - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
124 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
130 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { |
|
131 | + $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
132 | + } |
|
133 | + if ($socids) { |
|
134 | + $sql.= " AND t.fk_soc IN (".$socids.")"; |
|
135 | + } |
|
136 | + if ($search_sale > 0) { |
|
137 | + $sql.= " AND t.rowid = sc.fk_soc"; |
|
138 | + } |
|
139 | + // Join for the needed table to filter by sale |
|
125 | 140 | // Insert sale filter |
126 | 141 | if ($search_sale > 0) |
127 | 142 | { |
@@ -166,8 +181,7 @@ discard block |
||
166 | 181 | } |
167 | 182 | $i++; |
168 | 183 | } |
169 | - } |
|
170 | - else { |
|
184 | + } else { |
|
171 | 185 | throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); |
172 | 186 | } |
173 | 187 | if( ! count($obj_ret)) { |
@@ -397,8 +411,7 @@ discard block |
||
397 | 411 | $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); |
398 | 412 | if ($updateRes > 0) { |
399 | 413 | return $this->get($id); |
400 | - } |
|
401 | - else |
|
414 | + } else |
|
402 | 415 | { |
403 | 416 | throw new RestException(405, $this->shipment->error); |
404 | 417 | } |
@@ -427,15 +440,16 @@ discard block |
||
427 | 440 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
428 | 441 | } |
429 | 442 | foreach($request_data as $field => $value) { |
430 | - if ($field == 'id') continue; |
|
443 | + if ($field == 'id') { |
|
444 | + continue; |
|
445 | + } |
|
431 | 446 | $this->shipment->$field = $value; |
432 | 447 | } |
433 | 448 | |
434 | 449 | if ($this->shipment->update(DolibarrApiAccess::$user) > 0) |
435 | 450 | { |
436 | 451 | return $this->get($id); |
437 | - } |
|
438 | - else |
|
452 | + } else |
|
439 | 453 | { |
440 | 454 | throw new RestException(500, $this->shipment->error); |
441 | 455 | } |
@@ -658,8 +672,9 @@ discard block |
||
658 | 672 | { |
659 | 673 | $shipment = array(); |
660 | 674 | foreach (Shipments::$FIELDS as $field) { |
661 | - if (!isset($data[$field])) |
|
662 | - throw new RestException(400, "$field field missing"); |
|
675 | + if (!isset($data[$field])) { |
|
676 | + throw new RestException(400, "$field field missing"); |
|
677 | + } |
|
663 | 678 | $shipment[$field] = $data[$field]; |
664 | 679 | } |
665 | 680 | return $shipment; |
@@ -44,10 +44,18 @@ discard block |
||
44 | 44 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
45 | 45 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; |
46 | 46 | require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; |
47 | -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
48 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
49 | -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
50 | -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; |
|
47 | +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { |
|
48 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
49 | +} |
|
50 | +if (! empty($conf->propal->enabled)) { |
|
51 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
52 | +} |
|
53 | +if (! empty($conf->commande->enabled)) { |
|
54 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
55 | +} |
|
56 | +if (! empty($conf->productbatch->enabled)) { |
|
57 | + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; |
|
58 | +} |
|
51 | 59 | if (! empty($conf->projet->enabled)) { |
52 | 60 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
53 | 61 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
@@ -56,26 +64,41 @@ discard block |
||
56 | 64 | // Load translation files required by the page |
57 | 65 | $langs->loadLangs(array("sendings","companies","bills",'deliveries','orders','stocks','other','propal')); |
58 | 66 | |
59 | -if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); |
|
60 | -if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); |
|
67 | +if (!empty($conf->incoterm->enabled)) { |
|
68 | + $langs->load('incoterm'); |
|
69 | +} |
|
70 | +if (! empty($conf->productbatch->enabled)) { |
|
71 | + $langs->load('productbatch'); |
|
72 | +} |
|
61 | 73 | |
62 | 74 | $origin = GETPOST('origin','alpha')?GETPOST('origin','alpha'):'expedition'; // Example: commande, propal |
63 | 75 | $origin_id = GETPOST('id','int')?GETPOST('id','int'):''; |
64 | 76 | $id = $origin_id; |
65 | -if (empty($origin_id)) $origin_id = GETPOST('origin_id','int'); // Id of order or propal |
|
66 | -if (empty($origin_id)) $origin_id = GETPOST('object_id','int'); // Id of order or propal |
|
77 | +if (empty($origin_id)) { |
|
78 | + $origin_id = GETPOST('origin_id','int'); |
|
79 | +} |
|
80 | +// Id of order or propal |
|
81 | +if (empty($origin_id)) { |
|
82 | + $origin_id = GETPOST('object_id','int'); |
|
83 | +} |
|
84 | +// Id of order or propal |
|
67 | 85 | $ref=GETPOST('ref','alpha'); |
68 | 86 | $line_id = GETPOST('lineid','int')?GETPOST('lineid','int'):''; |
69 | 87 | |
70 | 88 | // Security check |
71 | 89 | $socid=''; |
72 | -if ($user->societe_id) $socid=$user->societe_id; |
|
90 | +if ($user->societe_id) { |
|
91 | + $socid=$user->societe_id; |
|
92 | +} |
|
73 | 93 | |
74 | -if ($origin == 'expedition') $result=restrictedArea($user, $origin, $id); |
|
75 | -else { |
|
94 | +if ($origin == 'expedition') { |
|
95 | + $result=restrictedArea($user, $origin, $id); |
|
96 | +} else { |
|
76 | 97 | $result=restrictedArea($user, 'expedition'); |
77 | - if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden(); |
|
78 | -} |
|
98 | + if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { |
|
99 | + accessforbidden(); |
|
100 | + } |
|
101 | + } |
|
79 | 102 | |
80 | 103 | $action = GETPOST('action','alpha'); |
81 | 104 | $confirm = GETPOST('confirm','alpha'); |
@@ -113,7 +136,9 @@ discard block |
||
113 | 136 | |
114 | 137 | $parameters=array(); |
115 | 138 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
116 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
139 | +if ($reshook < 0) { |
|
140 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
141 | +} |
|
117 | 142 | |
118 | 143 | if (empty($reshook)) |
119 | 144 | { |
@@ -167,7 +192,9 @@ discard block |
||
167 | 192 | // Fill array 'array_options' with data from update form |
168 | 193 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
169 | 194 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); |
170 | - if ($ret < 0) $error++; |
|
195 | + if ($ret < 0) { |
|
196 | + $error++; |
|
197 | + } |
|
171 | 198 | |
172 | 199 | if (! $error) |
173 | 200 | { |
@@ -180,8 +207,9 @@ discard block |
||
180 | 207 | } |
181 | 208 | } |
182 | 209 | |
183 | - if ($error) |
|
184 | - $action = 'edit_extras'; |
|
210 | + if ($error) { |
|
211 | + $action = 'edit_extras'; |
|
212 | + } |
|
185 | 213 | } |
186 | 214 | |
187 | 215 | // Create shipment |
@@ -243,12 +271,14 @@ discard block |
||
243 | 271 | $stockLocation="ent1".$i."_0"; |
244 | 272 | $qty = "qtyl".$i; |
245 | 273 | |
246 | - if ($objectsrc->lines[$i]->product_tobatch) // If product need a batch number |
|
274 | + if ($objectsrc->lines[$i]->product_tobatch) { |
|
275 | + // If product need a batch number |
|
247 | 276 | { |
248 | 277 | if (isset($_POST[$batch])) |
249 | 278 | { |
250 | 279 | //shipment line with batch-enable product |
251 | 280 | $qty .= '_'.$j; |
281 | + } |
|
252 | 282 | while (isset($_POST[$batch])) |
253 | 283 | { |
254 | 284 | // save line of detail into sub_qty |
@@ -268,8 +298,7 @@ discard block |
||
268 | 298 | $batch_line[$i]['ix_l']=GETPOST($idl,'int'); |
269 | 299 | |
270 | 300 | $totalqty+=$subtotalqty; |
271 | - } |
|
272 | - else |
|
301 | + } else |
|
273 | 302 | { |
274 | 303 | // No detail were provided for lots |
275 | 304 | if (! empty($_POST[$qty])) |
@@ -280,8 +309,7 @@ discard block |
||
280 | 309 | setEventMessages($langs->trans("StockIsRequiredToChooseWhichLotToUse"), null, 'errors'); |
281 | 310 | } |
282 | 311 | } |
283 | - } |
|
284 | - else if (isset($_POST[$stockLocation])) |
|
312 | + } else if (isset($_POST[$stockLocation])) |
|
285 | 313 | { |
286 | 314 | //shipment line from multiple stock locations |
287 | 315 | $qty .= '_'.$j; |
@@ -298,12 +326,13 @@ discard block |
||
298 | 326 | $stockLocation="ent1".$i."_".$j; |
299 | 327 | $qty = "qtyl".$i.'_'.$j; |
300 | 328 | } |
301 | - } |
|
302 | - else |
|
329 | + } else |
|
303 | 330 | { |
304 | 331 | //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; |
305 | 332 | //shipment line for product with no batch management and no multiple stock location |
306 | - if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); |
|
333 | + if (GETPOST($qty,'int') > 0) { |
|
334 | + $totalqty+=GETPOST($qty,'int'); |
|
335 | + } |
|
307 | 336 | } |
308 | 337 | |
309 | 338 | // Extrafields |
@@ -320,10 +349,13 @@ discard block |
||
320 | 349 | |
321 | 350 | //var_dump($batch_line[2]); |
322 | 351 | |
323 | - if ($totalqty > 0) // There is at least one thing to ship |
|
352 | + if ($totalqty > 0) { |
|
353 | + // There is at least one thing to ship |
|
324 | 354 | { |
325 | 355 | //var_dump($_POST);exit; |
326 | - for ($i = 0; $i < $num; $i++) |
|
356 | + for ($i = 0; |
|
357 | + } |
|
358 | + $i < $num; $i++) |
|
327 | 359 | { |
328 | 360 | $qty = "qtyl".$i; |
329 | 361 | if (! isset($batch_line[$i])) |
@@ -345,16 +377,19 @@ discard block |
||
345 | 377 | } |
346 | 378 | } |
347 | 379 | } |
348 | - } |
|
349 | - else |
|
380 | + } else |
|
350 | 381 | { |
351 | 382 | if (GETPOST($qty,'int') > 0 || (GETPOST($qty,'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) |
352 | 383 | { |
353 | 384 | $ent = "entl".$i; |
354 | 385 | $idl = "idl".$i; |
355 | 386 | $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); |
356 | - if ($entrepot_id < 0) $entrepot_id=''; |
|
357 | - if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; |
|
387 | + if ($entrepot_id < 0) { |
|
388 | + $entrepot_id=''; |
|
389 | + } |
|
390 | + if (! ($objectsrc->lines[$i]->fk_product > 0)) { |
|
391 | + $entrepot_id = 0; |
|
392 | + } |
|
358 | 393 | |
359 | 394 | $ret=$object->addline($entrepot_id, GETPOST($idl,'int'), GETPOST($qty,'int'), $array_options[$i]); |
360 | 395 | if ($ret < 0) |
@@ -364,8 +399,7 @@ discard block |
||
364 | 399 | } |
365 | 400 | } |
366 | 401 | } |
367 | - } |
|
368 | - else |
|
402 | + } else |
|
369 | 403 | { |
370 | 404 | // batch mode |
371 | 405 | if ($batch_line[$i]['qty']>0) |
@@ -381,7 +415,9 @@ discard block |
||
381 | 415 | } |
382 | 416 | // Fill array 'array_options' with data from add form |
383 | 417 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
384 | - if ($ret < 0) $error++; |
|
418 | + if ($ret < 0) { |
|
419 | + $error++; |
|
420 | + } |
|
385 | 421 | |
386 | 422 | if (! $error) |
387 | 423 | { |
@@ -392,8 +428,7 @@ discard block |
||
392 | 428 | $error++; |
393 | 429 | } |
394 | 430 | } |
395 | - } |
|
396 | - else |
|
431 | + } else |
|
397 | 432 | { |
398 | 433 | setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("QtyToShip").'/'.$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); |
399 | 434 | $error++; |
@@ -404,8 +439,7 @@ discard block |
||
404 | 439 | $db->commit(); |
405 | 440 | header("Location: card.php?id=".$object->id); |
406 | 441 | exit; |
407 | - } |
|
408 | - else |
|
442 | + } else |
|
409 | 443 | { |
410 | 444 | $db->rollback(); |
411 | 445 | $_GET["commande_id"]=GETPOST('commande_id','int'); |
@@ -423,14 +457,11 @@ discard block |
||
423 | 457 | { |
424 | 458 | header("Location: ".DOL_URL_ROOT.'/livraison/card.php?action=create_delivery&id='.$result); |
425 | 459 | exit; |
426 | - } |
|
427 | - else |
|
460 | + } else |
|
428 | 461 | { |
429 | 462 | setEventMessages($object->error, $object->errors, 'errors'); |
430 | 463 | } |
431 | - } |
|
432 | - |
|
433 | - else if ($action == 'confirm_valid' && $confirm == 'yes' && |
|
464 | + } else if ($action == 'confirm_valid' && $confirm == 'yes' && |
|
434 | 465 | ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) |
435 | 466 | || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) |
436 | 467 | ) |
@@ -443,16 +474,19 @@ discard block |
||
443 | 474 | { |
444 | 475 | $langs->load("errors"); |
445 | 476 | setEventMessages($langs->trans($object->error), null, 'errors'); |
446 | - } |
|
447 | - else |
|
477 | + } else |
|
448 | 478 | { |
449 | 479 | // Define output language |
450 | 480 | if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
451 | 481 | { |
452 | 482 | $outputlangs = $langs; |
453 | 483 | $newlang = ''; |
454 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
455 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
484 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
485 | + $newlang = GETPOST('lang_id','aZ09'); |
|
486 | + } |
|
487 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
488 | + $newlang = $object->thirdparty->default_lang; |
|
489 | + } |
|
456 | 490 | if (! empty($newlang)) { |
457 | 491 | $outputlangs = new Translate("", $conf); |
458 | 492 | $outputlangs->setDefaultLang($newlang); |
@@ -461,20 +495,19 @@ discard block |
||
461 | 495 | $ret = $object->fetch($id); // Reload to get new records |
462 | 496 | |
463 | 497 | $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
464 | - if ($result < 0) dol_print_error($db,$result); |
|
498 | + if ($result < 0) { |
|
499 | + dol_print_error($db,$result); |
|
500 | + } |
|
465 | 501 | } |
466 | 502 | } |
467 | - } |
|
468 | - |
|
469 | - else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) |
|
503 | + } else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) |
|
470 | 504 | { |
471 | 505 | $result = $object->delete(); |
472 | 506 | if ($result > 0) |
473 | 507 | { |
474 | 508 | header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); |
475 | 509 | exit; |
476 | - } |
|
477 | - else |
|
510 | + } else |
|
478 | 511 | { |
479 | 512 | setEventMessages($object->error, $object->errors, 'errors'); |
480 | 513 | } |
@@ -516,19 +549,29 @@ discard block |
||
516 | 549 | { |
517 | 550 | $error=0; |
518 | 551 | |
519 | - if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number','alpha')); |
|
520 | - if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url','int')); |
|
552 | + if ($action == 'settracking_number') { |
|
553 | + $object->tracking_number = trim(GETPOST('tracking_number','alpha')); |
|
554 | + } |
|
555 | + if ($action == 'settracking_url') { |
|
556 | + $object->tracking_url = trim(GETPOST('tracking_url','int')); |
|
557 | + } |
|
521 | 558 | if ($action == 'settrueWeight') { |
522 | 559 | $object->trueWeight = trim(GETPOST('trueWeight','int')); |
523 | 560 | $object->weight_units = GETPOST('weight_units','int'); |
524 | 561 | } |
525 | - if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth','int')); |
|
562 | + if ($action == 'settrueWidth') { |
|
563 | + $object->trueWidth = trim(GETPOST('trueWidth','int')); |
|
564 | + } |
|
526 | 565 | if ($action == 'settrueHeight'){ |
527 | 566 | $object->trueHeight = trim(GETPOST('trueHeight','int')); |
528 | 567 | $object->size_units = GETPOST('size_units','int'); |
529 | 568 | } |
530 | - if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth','int')); |
|
531 | - if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id','int')); |
|
569 | + if ($action == 'settrueDepth') { |
|
570 | + $object->trueDepth = trim(GETPOST('trueDepth','int')); |
|
571 | + } |
|
572 | + if ($action == 'setshipping_method_id') { |
|
573 | + $object->shipping_method_id = trim(GETPOST('shipping_method_id','int')); |
|
574 | + } |
|
532 | 575 | |
533 | 576 | if (! $error) |
534 | 577 | { |
@@ -541,9 +584,7 @@ discard block |
||
541 | 584 | } |
542 | 585 | |
543 | 586 | $action=""; |
544 | - } |
|
545 | - |
|
546 | - elseif ($action == 'classifybilled') |
|
587 | + } elseif ($action == 'classifybilled') |
|
547 | 588 | { |
548 | 589 | $object->fetch($id); |
549 | 590 | $result = $object->set_billed(); |
@@ -551,9 +592,7 @@ discard block |
||
551 | 592 | header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); |
552 | 593 | exit(); |
553 | 594 | } |
554 | - } |
|
555 | - |
|
556 | - elseif ($action == 'classifyclosed') |
|
595 | + } elseif ($action == 'classifyclosed') |
|
557 | 596 | { |
558 | 597 | $object->fetch($id); |
559 | 598 | $result = $object->setClosed(); |
@@ -587,8 +626,7 @@ discard block |
||
587 | 626 | $error++; |
588 | 627 | } |
589 | 628 | } |
590 | - } |
|
591 | - else |
|
629 | + } else |
|
592 | 630 | { |
593 | 631 | // delete single warehouse line |
594 | 632 | $line->id = $line_id; |
@@ -604,8 +642,7 @@ discard block |
||
604 | 642 | if(! $error) { |
605 | 643 | header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); |
606 | 644 | exit(); |
607 | - } |
|
608 | - else |
|
645 | + } else |
|
609 | 646 | { |
610 | 647 | setEventMessages($line->error, $line->errors, 'errors'); |
611 | 648 | } |
@@ -625,9 +662,11 @@ discard block |
||
625 | 662 | $num_prod = count($lines); |
626 | 663 | for ($i = 0 ; $i < $num_prod ; $i++) |
627 | 664 | { |
628 | - if ($lines[$i]->id == $line_id) // we have found line to update |
|
665 | + if ($lines[$i]->id == $line_id) { |
|
666 | + // we have found line to update |
|
629 | 667 | { |
630 | 668 | $line = new ExpeditionLigne($db); |
669 | + } |
|
631 | 670 | // Extrafields Lines |
632 | 671 | $extrafieldsline = new ExtraFields($db); |
633 | 672 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
@@ -651,16 +690,20 @@ discard block |
||
651 | 690 | $batch_qty = GETPOST($qty, 'int'); |
652 | 691 | if (! empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty)) |
653 | 692 | { |
654 | - if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) // $line is ExpeditionLine |
|
693 | + if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) { |
|
694 | + // $line is ExpeditionLine |
|
655 | 695 | { |
656 | 696 | if ($lines[$i]->entrepot_id != 0) |
657 | 697 | { |
658 | 698 | // allow update line entrepot_id if not multi warehouse shipping |
659 | 699 | $line->entrepot_id = $lotStock->warehouseid; |
700 | + } |
|
660 | 701 | } |
661 | 702 | |
662 | 703 | // detail_batch can be an object with keys, or an array of ExpeditionLineBatch |
663 | - if (empty($line->detail_batch)) $line->detail_batch=new stdClass(); |
|
704 | + if (empty($line->detail_batch)) { |
|
705 | + $line->detail_batch=new stdClass(); |
|
706 | + } |
|
664 | 707 | |
665 | 708 | $line->detail_batch->fk_origin_stock = $batch_id; |
666 | 709 | $line->detail_batch->batch = $lotStock->batch; |
@@ -671,8 +714,7 @@ discard block |
||
671 | 714 | setEventMessages($line->error, $line->errors, 'errors'); |
672 | 715 | $error++; |
673 | 716 | } |
674 | - } |
|
675 | - else |
|
717 | + } else |
|
676 | 718 | { |
677 | 719 | setEventMessages($lotStock->error, $lotStock->errors, 'errors'); |
678 | 720 | $error++; |
@@ -700,8 +742,7 @@ discard block |
||
700 | 742 | { |
701 | 743 | $lineIdToAddLot = $line_id; |
702 | 744 | } |
703 | - } |
|
704 | - else if (count($lines[$i]->details_entrepot) > 1) |
|
745 | + } else if (count($lines[$i]->details_entrepot) > 1) |
|
705 | 746 | { |
706 | 747 | // multi warehouse shipment lines |
707 | 748 | foreach ($lines[$i]->details_entrepot as $detail_entrepot) |
@@ -725,14 +766,12 @@ discard block |
||
725 | 766 | setEventMessages($line->error, $line->errors, 'errors'); |
726 | 767 | $error++; |
727 | 768 | } |
728 | - } |
|
729 | - else |
|
769 | + } else |
|
730 | 770 | { |
731 | 771 | setEventMessages($line->error, $line->errors, 'errors'); |
732 | 772 | $error++; |
733 | 773 | } |
734 | - } |
|
735 | - else |
|
774 | + } else |
|
736 | 775 | { |
737 | 776 | // create new line with new lot |
738 | 777 | $line->origin_line_id = $lines[$i]->origin_line_id; |
@@ -748,15 +787,13 @@ discard block |
||
748 | 787 | $error++; |
749 | 788 | } |
750 | 789 | } |
751 | - } |
|
752 | - else |
|
790 | + } else |
|
753 | 791 | { |
754 | 792 | setEventMessages($lotStock->error, $lotStock->errors, 'errors'); |
755 | 793 | $error++; |
756 | 794 | } |
757 | 795 | } |
758 | - } |
|
759 | - else |
|
796 | + } else |
|
760 | 797 | { |
761 | 798 | if ($lines[$i]->fk_product > 0) |
762 | 799 | { |
@@ -775,8 +812,7 @@ discard block |
||
775 | 812 | } |
776 | 813 | unset($_POST[$stockLocation]); |
777 | 814 | unset($_POST[$qty]); |
778 | - } |
|
779 | - else if (count($lines[$i]->details_entrepot) > 1) |
|
815 | + } else if (count($lines[$i]->details_entrepot) > 1) |
|
780 | 816 | { |
781 | 817 | // multi warehouse shipment lines |
782 | 818 | foreach ($lines[$i]->details_entrepot as $detail_entrepot) |
@@ -800,8 +836,7 @@ discard block |
||
800 | 836 | } |
801 | 837 | } |
802 | 838 | } |
803 | - } |
|
804 | - else // Product no predefined |
|
839 | + } else // Product no predefined |
|
805 | 840 | { |
806 | 841 | $qty = "qtyl".$line_id; |
807 | 842 | $line->id = $line_id; |
@@ -824,10 +859,12 @@ discard block |
||
824 | 859 | // Define output language |
825 | 860 | $outputlangs = $langs; |
826 | 861 | $newlang = ''; |
827 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) |
|
828 | - $newlang = GETPOST('lang_id','aZ09'); |
|
829 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) |
|
830 | - $newlang = $object->thirdparty->default_lang; |
|
862 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
863 | + $newlang = GETPOST('lang_id','aZ09'); |
|
864 | + } |
|
865 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
866 | + $newlang = $object->thirdparty->default_lang; |
|
867 | + } |
|
831 | 868 | if (! empty($newlang)) { |
832 | 869 | $outputlangs = new Translate("", $conf); |
833 | 870 | $outputlangs->setDefaultLang($newlang); |
@@ -836,15 +873,12 @@ discard block |
||
836 | 873 | $ret = $object->fetch($object->id); // Reload to get new records |
837 | 874 | $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
838 | 875 | } |
839 | - } |
|
840 | - else |
|
876 | + } else |
|
841 | 877 | { |
842 | 878 | header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition |
843 | 879 | exit(); |
844 | 880 | } |
845 | - } |
|
846 | - |
|
847 | - else if ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('cancel','alpha') == $langs->trans('Cancel')) { |
|
881 | + } else if ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('cancel','alpha') == $langs->trans('Cancel')) { |
|
848 | 882 | header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition |
849 | 883 | exit(); |
850 | 884 | } |
@@ -852,7 +886,9 @@ discard block |
||
852 | 886 | include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
853 | 887 | |
854 | 888 | // Actions to send emails |
855 | - if (empty($id)) $id=$facid; |
|
889 | + if (empty($id)) { |
|
890 | + $id=$facid; |
|
891 | + } |
|
856 | 892 | $trigger_name='SHIPPING_SENTBYMAIL'; |
857 | 893 | $paramname='id'; |
858 | 894 | $mode='emailfromshipment'; |
@@ -899,15 +935,19 @@ discard block |
||
899 | 935 | $classname = ucfirst($origin); |
900 | 936 | |
901 | 937 | $object = new $classname($db); |
902 | - if ($object->fetch($origin_id)) // This include the fetch_lines |
|
938 | + if ($object->fetch($origin_id)) { |
|
939 | + // This include the fetch_lines |
|
903 | 940 | { |
904 | 941 | $soc = new Societe($db); |
942 | + } |
|
905 | 943 | $soc->fetch($object->socid); |
906 | 944 | |
907 | 945 | $author = new User($db); |
908 | 946 | $author->fetch($object->user_author_id); |
909 | 947 | |
910 | - if (! empty($conf->stock->enabled)) $entrepot = new Entrepot($db); |
|
948 | + if (! empty($conf->stock->enabled)) { |
|
949 | + $entrepot = new Entrepot($db); |
|
950 | + } |
|
911 | 951 | |
912 | 952 | print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; |
913 | 953 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -939,9 +979,13 @@ discard block |
||
939 | 979 | |
940 | 980 | // Ref client |
941 | 981 | print '<tr><td>'; |
942 | - if ($origin == 'commande') print $langs->trans('RefCustomerOrder'); |
|
943 | - else if ($origin == 'propal') print $langs->trans('RefCustomerOrder'); |
|
944 | - else print $langs->trans('RefCustomer'); |
|
982 | + if ($origin == 'commande') { |
|
983 | + print $langs->trans('RefCustomerOrder'); |
|
984 | + } else if ($origin == 'propal') { |
|
985 | + print $langs->trans('RefCustomerOrder'); |
|
986 | + } else { |
|
987 | + print $langs->trans('RefCustomer'); |
|
988 | + } |
|
945 | 989 | print '</td><td colspan="3">'; |
946 | 990 | print '<input type="text" name="ref_customer" value="'.$object->ref_client.'" />'; |
947 | 991 | print '</td>'; |
@@ -956,8 +1000,12 @@ discard block |
||
956 | 1000 | if (! empty($conf->projet->enabled)) |
957 | 1001 | { |
958 | 1002 | $projectid = GETPOST('projectid','int')?GETPOST('projectid','int'):0; |
959 | - if(empty($projectid) && ! empty($object->fk_project)) $projectid = $object->fk_project; |
|
960 | - if ($origin == 'project') $projectid = ($originid ? $originid : 0); |
|
1003 | + if(empty($projectid) && ! empty($object->fk_project)) { |
|
1004 | + $projectid = $object->fk_project; |
|
1005 | + } |
|
1006 | + if ($origin == 'project') { |
|
1007 | + $projectid = ($originid ? $originid : 0); |
|
1008 | + } |
|
961 | 1009 | |
962 | 1010 | $langs->load("projects"); |
963 | 1011 | print '<tr>'; |
@@ -1019,7 +1067,9 @@ discard block |
||
1019 | 1067 | print '<td colspan="3">'; |
1020 | 1068 | $expe->fetch_delivery_methods(); |
1021 | 1069 | print $form->selectarray("shipping_method_id", $expe->meths, GETPOST('shipping_method_id','int'),1,0,0,"",1); |
1022 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1070 | + if ($user->admin) { |
|
1071 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1072 | + } |
|
1023 | 1073 | print "</td></tr>\n"; |
1024 | 1074 | |
1025 | 1075 | // Tracking number |
@@ -1123,8 +1173,7 @@ discard block |
||
1123 | 1173 | if (empty($conf->productbatch->enabled)) |
1124 | 1174 | { |
1125 | 1175 | print '<td align="left">'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')</td>'; |
1126 | - } |
|
1127 | - else |
|
1176 | + } else |
|
1128 | 1177 | { |
1129 | 1178 | print '<td align="left">'.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' ('.$langs->trans("Stock").')</td>'; |
1130 | 1179 | } |
@@ -1144,16 +1193,22 @@ discard block |
||
1144 | 1193 | $type=$line->product_type?$line->product_type:$line->fk_product_type; |
1145 | 1194 | // Try to enhance type detection using date_start and date_end for free lines where type |
1146 | 1195 | // was not saved. |
1147 | - if (! empty($line->date_start)) $type=1; |
|
1148 | - if (! empty($line->date_end)) $type=1; |
|
1196 | + if (! empty($line->date_start)) { |
|
1197 | + $type=1; |
|
1198 | + } |
|
1199 | + if (! empty($line->date_end)) { |
|
1200 | + $type=1; |
|
1201 | + } |
|
1149 | 1202 | |
1150 | 1203 | print '<!-- line '.$line->rowid.' for product -->'."\n"; |
1151 | 1204 | print '<tr class="oddeven">'."\n"; |
1152 | 1205 | |
1153 | 1206 | // Product label |
1154 | - if ($line->fk_product > 0) // If predefined product |
|
1207 | + if ($line->fk_product > 0) { |
|
1208 | + // If predefined product |
|
1155 | 1209 | { |
1156 | 1210 | $product->fetch($line->fk_product); |
1211 | + } |
|
1157 | 1212 | $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch |
1158 | 1213 | //var_dump($product->stock_warehouse[1]); |
1159 | 1214 | |
@@ -1180,12 +1235,14 @@ discard block |
||
1180 | 1235 | } |
1181 | 1236 | |
1182 | 1237 | print '</td>'; |
1183 | - } |
|
1184 | - else |
|
1238 | + } else |
|
1185 | 1239 | { |
1186 | 1240 | print "<td>"; |
1187 | - if ($type==1) $text = img_object($langs->trans('Service'),'service'); |
|
1188 | - else $text = img_object($langs->trans('Product'),'product'); |
|
1241 | + if ($type==1) { |
|
1242 | + $text = img_object($langs->trans('Service'),'service'); |
|
1243 | + } else { |
|
1244 | + $text = img_object($langs->trans('Product'),'product'); |
|
1245 | + } |
|
1189 | 1246 | |
1190 | 1247 | if (! empty($line->label)) { |
1191 | 1248 | $text.= ' <strong>'.$line->label.'</strong>'; |
@@ -1217,42 +1274,50 @@ discard block |
||
1217 | 1274 | if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
1218 | 1275 | { |
1219 | 1276 | $quantityToBeDelivered = 0; |
1220 | - } |
|
1221 | - else |
|
1277 | + } else |
|
1222 | 1278 | { |
1223 | 1279 | $quantityToBeDelivered = $quantityAsked - $quantityDelivered; |
1224 | 1280 | } |
1225 | 1281 | $warehouse_id = GETPOST('entrepot_id','int'); |
1226 | 1282 | |
1227 | 1283 | $warehouseObject = null; |
1228 | - if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection |
|
1284 | + if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) { |
|
1285 | + // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection |
|
1229 | 1286 | { |
1230 | 1287 | print '<!-- Case warehouse already known or product not a predefined product -->'; |
1288 | + } |
|
1231 | 1289 | //ship from preselected location |
1232 | 1290 | $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number |
1233 | 1291 | $deliverableQty=min($quantityToBeDelivered, $stock); |
1234 | - if ($deliverableQty < 0) $deliverableQty = 0; |
|
1292 | + if ($deliverableQty < 0) { |
|
1293 | + $deliverableQty = 0; |
|
1294 | + } |
|
1235 | 1295 | if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) |
1236 | 1296 | { |
1237 | 1297 | // Quantity to send |
1238 | 1298 | print '<td align="center">'; |
1239 | 1299 | if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
1240 | 1300 | { |
1241 | - if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); |
|
1301 | + if (GETPOST('qtyl'.$indiceAsked, 'int')) { |
|
1302 | + $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int'); |
|
1303 | + } |
|
1242 | 1304 | print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">'; |
1243 | 1305 | print '<input name="qtyl'.$indiceAsked.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">'; |
1306 | + } else { |
|
1307 | + print $langs->trans("NA"); |
|
1244 | 1308 | } |
1245 | - else print $langs->trans("NA"); |
|
1246 | 1309 | print '</td>'; |
1247 | 1310 | |
1248 | 1311 | // Stock |
1249 | 1312 | if (! empty($conf->stock->enabled)) |
1250 | 1313 | { |
1251 | 1314 | print '<td align="left">'; |
1252 | - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? |
|
1315 | + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { |
|
1316 | + // Type of product need stock change ? |
|
1253 | 1317 | { |
1254 | 1318 | // Show warehouse combo list |
1255 | 1319 | $ent = "entl".$indiceAsked; |
1320 | + } |
|
1256 | 1321 | $idl = "idl".$indiceAsked; |
1257 | 1322 | $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; |
1258 | 1323 | if ($line->fk_product > 0) |
@@ -1268,8 +1333,7 @@ discard block |
||
1268 | 1333 | } |
1269 | 1334 | } |
1270 | 1335 | } |
1271 | - } |
|
1272 | - else |
|
1336 | + } else |
|
1273 | 1337 | { |
1274 | 1338 | print $langs->trans("Service"); |
1275 | 1339 | } |
@@ -1300,15 +1364,16 @@ discard block |
||
1300 | 1364 | } |
1301 | 1365 | } |
1302 | 1366 | } |
1303 | - } |
|
1304 | - else |
|
1367 | + } else |
|
1305 | 1368 | { |
1306 | 1369 | // Product need lot |
1307 | 1370 | print '<td></td><td></td></tr>'; // end line and start a new one for lot/serial |
1308 | 1371 | print '<!-- Case product need lot -->'; |
1309 | 1372 | |
1310 | 1373 | $staticwarehouse=new Entrepot($db); |
1311 | - if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); |
|
1374 | + if ($warehouse_id > 0) { |
|
1375 | + $staticwarehouse->fetch($warehouse_id); |
|
1376 | + } |
|
1312 | 1377 | |
1313 | 1378 | $subj=0; |
1314 | 1379 | // Define nb of lines suggested for this order line |
@@ -1323,10 +1388,13 @@ discard block |
||
1323 | 1388 | print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">'; |
1324 | 1389 | if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) |
1325 | 1390 | { |
1326 | - foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch |
|
1391 | + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) { |
|
1392 | + // $dbatch is instance of Productbatch |
|
1327 | 1393 | { |
1328 | 1394 | //var_dump($dbatch); |
1329 | - $batchStock = + $dbatch->qty; // To get a numeric |
|
1395 | + $batchStock = + $dbatch->qty; |
|
1396 | + } |
|
1397 | + // To get a numeric |
|
1330 | 1398 | $deliverableQty = min($quantityToBeDelivered,$batchStock); |
1331 | 1399 | print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested)?$bc[$var]:'').'>'; |
1332 | 1400 | print '<td colspan="3" ></td><td align="center">'; |
@@ -1356,8 +1424,7 @@ discard block |
||
1356 | 1424 | $subj++; |
1357 | 1425 | print '</td></tr>'; |
1358 | 1426 | } |
1359 | - } |
|
1360 | - else |
|
1427 | + } else |
|
1361 | 1428 | { |
1362 | 1429 | print '<!-- Case there is no details of lot at all -->'; |
1363 | 1430 | print '<tr class="oddeven"><td colspan="3"></td><td align="center">'; |
@@ -1369,8 +1436,7 @@ discard block |
||
1369 | 1436 | print '</td></tr>'; |
1370 | 1437 | } |
1371 | 1438 | } |
1372 | - } |
|
1373 | - else |
|
1439 | + } else |
|
1374 | 1440 | { |
1375 | 1441 | // ship from multiple locations |
1376 | 1442 | if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) |
@@ -1390,9 +1456,11 @@ discard block |
||
1390 | 1456 | } |
1391 | 1457 | } |
1392 | 1458 | $tmpwarehouseObject=new Entrepot($db); |
1393 | - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock |
|
1459 | + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { |
|
1460 | + // $stock_warehouse is product_stock |
|
1394 | 1461 | { |
1395 | 1462 | $tmpwarehouseObject->fetch($warehouse_id); |
1463 | + } |
|
1396 | 1464 | if ($stock_warehouse->real > 0) |
1397 | 1465 | { |
1398 | 1466 | $stock = + $stock_warehouse->real; // Convert it to number |
@@ -1405,8 +1473,9 @@ discard block |
||
1405 | 1473 | { |
1406 | 1474 | print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">'; |
1407 | 1475 | print '<input name="ent1'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$warehouse_id.'">'; |
1476 | + } else { |
|
1477 | + print $langs->trans("NA"); |
|
1408 | 1478 | } |
1409 | - else print $langs->trans("NA"); |
|
1410 | 1479 | print '</td>'; |
1411 | 1480 | |
1412 | 1481 | // Stock |
@@ -1419,8 +1488,7 @@ discard block |
||
1419 | 1488 | |
1420 | 1489 | print '<!-- Show details of stock -->'; |
1421 | 1490 | print '('.$stock.')'; |
1422 | - } |
|
1423 | - else |
|
1491 | + } else |
|
1424 | 1492 | { |
1425 | 1493 | print $langs->trans("Service"); |
1426 | 1494 | } |
@@ -1459,8 +1527,7 @@ discard block |
||
1459 | 1527 | } |
1460 | 1528 | } |
1461 | 1529 | } |
1462 | - } |
|
1463 | - else |
|
1530 | + } else |
|
1464 | 1531 | { |
1465 | 1532 | print '<!-- Case warehouse not already known and product need lot -->'; |
1466 | 1533 | print '<td></td><td></td></tr>'; // end line and start a new one for lot/serial |
@@ -1490,7 +1557,9 @@ discard block |
||
1490 | 1557 | //var_dump($dbatch); |
1491 | 1558 | $batchStock = + $dbatch->qty; // To get a numeric |
1492 | 1559 | $deliverableQty = min($quantityToBeDelivered,$batchStock); |
1493 | - if ($deliverableQty < 0) $deliverableQty = 0; |
|
1560 | + if ($deliverableQty < 0) { |
|
1561 | + $deliverableQty = 0; |
|
1562 | + } |
|
1494 | 1563 | print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested)?$bc[$var]:'').'><td colspan="3"></td><td align="center">'; |
1495 | 1564 | print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">'; |
1496 | 1565 | print '</td>'; |
@@ -1505,8 +1574,11 @@ discard block |
||
1505 | 1574 | //print '|'.$line->fk_product.'|'.$dbatch->batch.'|<br>'; |
1506 | 1575 | print $langs->trans("Batch").': '; |
1507 | 1576 | $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); |
1508 | - if ($result > 0) print $productlotObject->getNomUrl(1); |
|
1509 | - else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; |
|
1577 | + if ($result > 0) { |
|
1578 | + print $productlotObject->getNomUrl(1); |
|
1579 | + } else { |
|
1580 | + print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; |
|
1581 | + } |
|
1510 | 1582 | print ' ('.$dbatch->qty.')'; |
1511 | 1583 | $quantityToBeDelivered -= $deliverableQty; |
1512 | 1584 | if ($quantityToBeDelivered < 0) |
@@ -1520,9 +1592,11 @@ discard block |
||
1520 | 1592 | } |
1521 | 1593 | } |
1522 | 1594 | } |
1523 | - if ($subj == 0) // Line not shown yet, we show it |
|
1595 | + if ($subj == 0) { |
|
1596 | + // Line not shown yet, we show it |
|
1524 | 1597 | { |
1525 | 1598 | print '<!-- line not shown yet, we show it -->'; |
1599 | + } |
|
1526 | 1600 | print '<tr class="oddeven"><td colspan="3" ></td><td align="center">'; |
1527 | 1601 | if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
1528 | 1602 | { |
@@ -1532,8 +1606,7 @@ discard block |
||
1532 | 1606 | $disabled='disabled="disabled"'; |
1533 | 1607 | } |
1534 | 1608 | print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled?' '.$disabled:'').'> '; |
1535 | - } |
|
1536 | - else |
|
1609 | + } else |
|
1537 | 1610 | { |
1538 | 1611 | print $langs->trans("NA"); |
1539 | 1612 | } |
@@ -1548,14 +1621,15 @@ discard block |
||
1548 | 1621 | $warehouseObject=new Entrepot($db); |
1549 | 1622 | $warehouseObject->fetch($warehouse_selected_id); |
1550 | 1623 | print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle); |
1551 | - } |
|
1552 | - else |
|
1624 | + } else |
|
1553 | 1625 | { |
1554 | - if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow"); |
|
1555 | - else print ''; |
|
1626 | + if ($line->fk_product) { |
|
1627 | + print img_warning().' '.$langs->trans("StockTooLow"); |
|
1628 | + } else { |
|
1629 | + print ''; |
|
1630 | + } |
|
1556 | 1631 | } |
1557 | - } |
|
1558 | - else |
|
1632 | + } else |
|
1559 | 1633 | { |
1560 | 1634 | print $langs->trans("Service"); |
1561 | 1635 | } |
@@ -1597,21 +1671,20 @@ discard block |
||
1597 | 1671 | print '</form>'; |
1598 | 1672 | |
1599 | 1673 | print '<br>'; |
1600 | - } |
|
1601 | - else |
|
1674 | + } else |
|
1602 | 1675 | { |
1603 | 1676 | dol_print_error($db); |
1604 | 1677 | } |
1605 | 1678 | } |
1606 | -} |
|
1607 | -else if ($id || $ref) |
|
1608 | -/* *************************************************************************** */ |
|
1679 | +} else if ($id || $ref) { |
|
1680 | + /* *************************************************************************** */ |
|
1609 | 1681 | /* */ |
1610 | 1682 | /* Edit and view mode */ |
1611 | 1683 | /* */ |
1612 | 1684 | /* *************************************************************************** */ |
1613 | 1685 | { |
1614 | 1686 | $lines = $object->lines; |
1687 | +} |
|
1615 | 1688 | |
1616 | 1689 | $num_prod = count($lines); |
1617 | 1690 | |
@@ -1648,8 +1721,7 @@ discard block |
||
1648 | 1721 | if ($objectref == 'PROV') |
1649 | 1722 | { |
1650 | 1723 | $numref = $object->getNextNumRef($soc); |
1651 | - } |
|
1652 | - else |
|
1724 | + } else |
|
1653 | 1725 | { |
1654 | 1726 | $numref = $object->ref; |
1655 | 1727 | } |
@@ -1675,8 +1747,11 @@ discard block |
||
1675 | 1747 | // Call Hook formConfirm |
1676 | 1748 | $parameters = array(); |
1677 | 1749 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
1678 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
1679 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
1750 | + if (empty($reshook)) { |
|
1751 | + $formconfirm.=$hookmanager->resPrint; |
|
1752 | + } elseif ($reshook > 0) { |
|
1753 | + $formconfirm=$hookmanager->resPrint; |
|
1754 | + } |
|
1680 | 1755 | |
1681 | 1756 | // Print form confirm |
1682 | 1757 | print $formconfirm; |
@@ -1785,7 +1860,9 @@ discard block |
||
1785 | 1860 | print $langs->trans('DateDeliveryPlanned'); |
1786 | 1861 | print '</td>'; |
1787 | 1862 | |
1788 | - if ($action != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; |
|
1863 | + if ($action != 'editdate_livraison') { |
|
1864 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; |
|
1865 | + } |
|
1789 | 1866 | print '</tr></table>'; |
1790 | 1867 | print '</td><td colspan="2">'; |
1791 | 1868 | if ($action == 'editdate_livraison') |
@@ -1796,8 +1873,7 @@ discard block |
||
1796 | 1873 | print $form->selectDate($object->date_delivery?$object->date_delivery:-1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); |
1797 | 1874 | print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; |
1798 | 1875 | print '</form>'; |
1799 | - } |
|
1800 | - else |
|
1876 | + } else |
|
1801 | 1877 | { |
1802 | 1878 | print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhour') : ' '; |
1803 | 1879 | } |
@@ -1820,8 +1896,7 @@ discard block |
||
1820 | 1896 | print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">'; |
1821 | 1897 | print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; |
1822 | 1898 | print '</form>'; |
1823 | - } |
|
1824 | - else |
|
1899 | + } else |
|
1825 | 1900 | { |
1826 | 1901 | print $object->trueWeight; |
1827 | 1902 | print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units,"weight"):''; |
@@ -1830,11 +1905,15 @@ discard block |
||
1830 | 1905 | // Calculated |
1831 | 1906 | if ($totalWeight > 0) |
1832 | 1907 | { |
1833 | - if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; |
|
1908 | + if (!empty($object->trueWeight)) { |
|
1909 | + print ' ('.$langs->trans("SumOfProductWeights").': '; |
|
1910 | + } |
|
1834 | 1911 | //print $totalWeight.' '.measuring_units_string(0,"weight"); |
1835 | 1912 | print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); |
1836 | 1913 | //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; |
1837 | - if (!empty($object->trueWeight)) print ')'; |
|
1914 | + if (!empty($object->trueWeight)) { |
|
1915 | + print ')'; |
|
1916 | + } |
|
1838 | 1917 | } |
1839 | 1918 | print '</td></tr>'; |
1840 | 1919 | |
@@ -1857,8 +1936,7 @@ discard block |
||
1857 | 1936 | print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">'; |
1858 | 1937 | print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; |
1859 | 1938 | print '</form>'; |
1860 | - } |
|
1861 | - else |
|
1939 | + } else |
|
1862 | 1940 | { |
1863 | 1941 | print $object->trueHeight; |
1864 | 1942 | print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string($object->height_units,"size"):''; |
@@ -1891,16 +1969,21 @@ discard block |
||
1891 | 1969 | { |
1892 | 1970 | //print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); |
1893 | 1971 | print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); |
1972 | + } else { |
|
1973 | + print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); |
|
1894 | 1974 | } |
1895 | - else print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); |
|
1896 | 1975 | } |
1897 | 1976 | if ($totalVolume > 0) |
1898 | 1977 | { |
1899 | - if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; |
|
1978 | + if ($calculatedVolume) { |
|
1979 | + print ' ('.$langs->trans("SumOfProductVolumes").': '; |
|
1980 | + } |
|
1900 | 1981 | //print $totalVolume.' '.measuring_units_string(0,"volume"); |
1901 | 1982 | print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); |
1902 | 1983 | //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; |
1903 | - if ($calculatedVolume) print ')'; |
|
1984 | + if ($calculatedVolume) { |
|
1985 | + print ')'; |
|
1986 | + } |
|
1904 | 1987 | } |
1905 | 1988 | print "</td>\n"; |
1906 | 1989 | print '</tr>'; |
@@ -1924,7 +2007,9 @@ discard block |
||
1924 | 2007 | print $langs->trans('SendingMethod'); |
1925 | 2008 | print '</td>'; |
1926 | 2009 | |
1927 | - if ($action != 'editshipping_method_id') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshipping_method_id&id='.$object->id.'">'.img_edit($langs->trans('SetSendingMethod'),1).'</a></td>'; |
|
2010 | + if ($action != 'editshipping_method_id') { |
|
2011 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshipping_method_id&id='.$object->id.'">'.img_edit($langs->trans('SetSendingMethod'),1).'</a></td>'; |
|
2012 | + } |
|
1928 | 2013 | print '</tr></table>'; |
1929 | 2014 | print '</td><td colspan="2">'; |
1930 | 2015 | if ($action == 'editshipping_method_id') |
@@ -1934,11 +2019,12 @@ discard block |
||
1934 | 2019 | print '<input type="hidden" name="action" value="setshipping_method_id">'; |
1935 | 2020 | $object->fetch_delivery_methods(); |
1936 | 2021 | print $form->selectarray("shipping_method_id",$object->meths,$object->shipping_method_id,1,0,0,"",1); |
1937 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
2022 | + if ($user->admin) { |
|
2023 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
2024 | + } |
|
1938 | 2025 | print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; |
1939 | 2026 | print '</form>'; |
1940 | - } |
|
1941 | - else |
|
2027 | + } else |
|
1942 | 2028 | { |
1943 | 2029 | if ($object->shipping_method_id > 0) |
1944 | 2030 | { |
@@ -1962,16 +2048,18 @@ discard block |
||
1962 | 2048 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
1963 | 2049 | print $langs->trans('IncotermLabel'); |
1964 | 2050 | print '<td><td align="right">'; |
1965 | - if ($user->rights->expedition->creer) print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; |
|
1966 | - else print ' '; |
|
2051 | + if ($user->rights->expedition->creer) { |
|
2052 | + print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; |
|
2053 | + } else { |
|
2054 | + print ' '; |
|
2055 | + } |
|
1967 | 2056 | print '</td></tr></table>'; |
1968 | 2057 | print '</td>'; |
1969 | 2058 | print '<td colspan="3">'; |
1970 | 2059 | if ($action != 'editincoterm') |
1971 | 2060 | { |
1972 | 2061 | print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); |
1973 | - } |
|
1974 | - else |
|
2062 | + } else |
|
1975 | 2063 | { |
1976 | 2064 | print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); |
1977 | 2065 | } |
@@ -2019,14 +2107,17 @@ discard block |
||
2019 | 2107 | if ($action == 'editline') |
2020 | 2108 | { |
2021 | 2109 | $editColspan = 3; |
2022 | - if (empty($conf->stock->enabled)) $editColspan--; |
|
2023 | - if (empty($conf->productbatch->enabled)) $editColspan--; |
|
2110 | + if (empty($conf->stock->enabled)) { |
|
2111 | + $editColspan--; |
|
2112 | + } |
|
2113 | + if (empty($conf->productbatch->enabled)) { |
|
2114 | + $editColspan--; |
|
2115 | + } |
|
2024 | 2116 | print '<td align="center" colspan="'. $editColspan . '">'; |
2025 | 2117 | if ($object->statut <= 1) |
2026 | 2118 | { |
2027 | 2119 | print $langs->trans("QtyToShip").' - '; |
2028 | - } |
|
2029 | - else |
|
2120 | + } else |
|
2030 | 2121 | { |
2031 | 2122 | print $langs->trans("QtyShipped").' - '; |
2032 | 2123 | } |
@@ -2039,14 +2130,12 @@ discard block |
||
2039 | 2130 | print $langs->trans("Batch"); |
2040 | 2131 | } |
2041 | 2132 | print '</td>'; |
2042 | - } |
|
2043 | - else |
|
2133 | + } else |
|
2044 | 2134 | { |
2045 | 2135 | if ($object->statut <= 1) |
2046 | 2136 | { |
2047 | 2137 | print '<td align="center">'.$langs->trans("QtyToShip").'</td>'; |
2048 | - } |
|
2049 | - else |
|
2138 | + } else |
|
2050 | 2139 | { |
2051 | 2140 | print '<td align="center">'.$langs->trans("QtyShipped").'</td>'; |
2052 | 2141 | } |
@@ -2077,8 +2166,12 @@ discard block |
||
2077 | 2166 | $object->fetch_thirdparty(); |
2078 | 2167 | $outputlangs = $langs; |
2079 | 2168 | $newlang=''; |
2080 | - if (empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); |
|
2081 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
2169 | + if (empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
2170 | + $newlang=GETPOST('lang_id','aZ09'); |
|
2171 | + } |
|
2172 | + if (empty($newlang)) { |
|
2173 | + $newlang=$object->thirdparty->default_lang; |
|
2174 | + } |
|
2082 | 2175 | if (! empty($newlang)) |
2083 | 2176 | { |
2084 | 2177 | $outputlangs = new Translate("",$conf); |
@@ -2150,9 +2243,9 @@ discard block |
||
2150 | 2243 | $prod = new Product($db); |
2151 | 2244 | $prod->fetch($lines[$i]->fk_product); |
2152 | 2245 | $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; |
2246 | + } else { |
|
2247 | + $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); |
|
2153 | 2248 | } |
2154 | - else |
|
2155 | - $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label); |
|
2156 | 2249 | |
2157 | 2250 | print '<td>'; |
2158 | 2251 | |
@@ -2171,12 +2264,14 @@ discard block |
||
2171 | 2264 | print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?'<br>'.dol_htmlentitiesbr($lines[$i]->description):''; |
2172 | 2265 | } |
2173 | 2266 | print "</td>\n"; |
2174 | - } |
|
2175 | - else |
|
2267 | + } else |
|
2176 | 2268 | { |
2177 | 2269 | print "<td>"; |
2178 | - if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service'); |
|
2179 | - else $text = img_object($langs->trans('Product'),'product'); |
|
2270 | + if ($lines[$i]->product_type == Product::TYPE_SERVICE) { |
|
2271 | + $text = img_object($langs->trans('Service'),'service'); |
|
2272 | + } else { |
|
2273 | + $text = img_object($langs->trans('Product'),'product'); |
|
2274 | + } |
|
2180 | 2275 | |
2181 | 2276 | if (! empty($lines[$i]->label)) { |
2182 | 2277 | $text.= ' <strong>'.$lines[$i]->label.'</strong>'; |
@@ -2203,10 +2298,15 @@ discard block |
||
2203 | 2298 | $j = 0; |
2204 | 2299 | foreach($val as $shipmentline_id=> $shipmentline_var) |
2205 | 2300 | { |
2206 | - if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments" |
|
2301 | + if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { |
|
2302 | + continue; |
|
2303 | + } |
|
2304 | + // We want to show only "other shipments" |
|
2207 | 2305 | |
2208 | 2306 | $j++; |
2209 | - if ($j > 1) print '<br>'; |
|
2307 | + if ($j > 1) { |
|
2308 | + print '<br>'; |
|
2309 | + } |
|
2210 | 2310 | $shipment_static->fetch($shipmentline_var['shipment_id']); |
2211 | 2311 | print $shipment_static->getNomUrl(1); |
2212 | 2312 | print ' - '.$shipmentline_var['qty_shipped']; |
@@ -2252,8 +2352,7 @@ discard block |
||
2252 | 2352 | // Batch number managment |
2253 | 2353 | print '<td>' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). '</td>'; |
2254 | 2354 | print '</tr>'; |
2255 | - } |
|
2256 | - else if (! empty($conf->stock->enabled)) |
|
2355 | + } else if (! empty($conf->stock->enabled)) |
|
2257 | 2356 | { |
2258 | 2357 | if ($lines[$i]->fk_product > 0) |
2259 | 2358 | { |
@@ -2268,8 +2367,7 @@ discard block |
||
2268 | 2367 | // Batch number managment |
2269 | 2368 | print '<td> - ' . $langs->trans("NA") . '</td>'; |
2270 | 2369 | print '</tr>'; |
2271 | - } |
|
2272 | - else if (count($lines[$i]->details_entrepot) > 1) |
|
2370 | + } else if (count($lines[$i]->details_entrepot) > 1) |
|
2273 | 2371 | { |
2274 | 2372 | print '<!-- case edit 3 -->'; |
2275 | 2373 | foreach ($lines[$i]->details_entrepot as $detail_entrepot) |
@@ -2283,14 +2381,12 @@ discard block |
||
2283 | 2381 | print '<td> - ' . $langs->trans("NA") . '</td>'; |
2284 | 2382 | print '</tr>'; |
2285 | 2383 | } |
2286 | - } |
|
2287 | - else |
|
2384 | + } else |
|
2288 | 2385 | { |
2289 | 2386 | print '<!-- case edit 4 -->'; |
2290 | 2387 | print '<tr><td colspan="3">'.$langs->trans("NotEnoughStock").'</td></tr>'; |
2291 | 2388 | } |
2292 | - } |
|
2293 | - else |
|
2389 | + } else |
|
2294 | 2390 | { |
2295 | 2391 | print '<!-- case edit 5 -->'; |
2296 | 2392 | print '<tr>'; |
@@ -2304,8 +2400,7 @@ discard block |
||
2304 | 2400 | } |
2305 | 2401 | } |
2306 | 2402 | print '</table></td>'; |
2307 | - } |
|
2308 | - else |
|
2403 | + } else |
|
2309 | 2404 | { |
2310 | 2405 | // Qty to ship or shipped |
2311 | 2406 | print '<td align="center">'.$lines[$i]->qty_shipped.'</td>'; |
@@ -2319,8 +2414,7 @@ discard block |
||
2319 | 2414 | $entrepot = new Entrepot($db); |
2320 | 2415 | $entrepot->fetch($lines[$i]->entrepot_id); |
2321 | 2416 | print $entrepot->getNomUrl(1); |
2322 | - } |
|
2323 | - else if (count($lines[$i]->details_entrepot) > 1) |
|
2417 | + } else if (count($lines[$i]->details_entrepot) > 1) |
|
2324 | 2418 | { |
2325 | 2419 | $detail = ''; |
2326 | 2420 | foreach ($lines[$i]->details_entrepot as $detail_entrepot) |
@@ -2347,17 +2441,18 @@ discard block |
||
2347 | 2441 | if ($lines[$i]->product_tobatch) |
2348 | 2442 | { |
2349 | 2443 | $detail = ''; |
2350 | - foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch |
|
2444 | + foreach ($lines[$i]->detail_batch as $dbatch) { |
|
2445 | + // $dbatch is instance of ExpeditionLineBatch |
|
2351 | 2446 | { |
2352 | 2447 | $detail.= $langs->trans("Batch").': '.$dbatch->batch; |
2448 | + } |
|
2353 | 2449 | $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); |
2354 | 2450 | $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); |
2355 | 2451 | $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty; |
2356 | 2452 | $detail.= '<br>'; |
2357 | 2453 | } |
2358 | 2454 | print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); |
2359 | - } |
|
2360 | - else |
|
2455 | + } else |
|
2361 | 2456 | { |
2362 | 2457 | print $langs->trans("NA"); |
2363 | 2458 | } |
@@ -2370,14 +2465,20 @@ discard block |
||
2370 | 2465 | |
2371 | 2466 | // Weight |
2372 | 2467 | print '<td align="center">'; |
2373 | - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); |
|
2374 | - else print ' '; |
|
2468 | + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { |
|
2469 | + print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); |
|
2470 | + } else { |
|
2471 | + print ' '; |
|
2472 | + } |
|
2375 | 2473 | print '</td>'; |
2376 | 2474 | |
2377 | 2475 | // Volume |
2378 | 2476 | print '<td align="center">'; |
2379 | - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); |
|
2380 | - else print ' '; |
|
2477 | + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { |
|
2478 | + print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); |
|
2479 | + } else { |
|
2480 | + print ' '; |
|
2481 | + } |
|
2381 | 2482 | print '</td>'; |
2382 | 2483 | |
2383 | 2484 | // Size |
@@ -2388,8 +2489,7 @@ discard block |
||
2388 | 2489 | print '<td align="center" colspan="2" valign="middle">'; |
2389 | 2490 | print '<input type="submit" class="button" id="savelinebutton" name="save" value="' . $langs->trans("Save") . '"><br>'; |
2390 | 2491 | print '<input type="submit" class="button" id="cancellinebutton" name="cancel" value="' . $langs->trans("Cancel") . '"><br>'; |
2391 | - } |
|
2392 | - else if ($object->statut == 0) |
|
2492 | + } else if ($object->statut == 0) |
|
2393 | 2493 | { |
2394 | 2494 | // edit-delete buttons |
2395 | 2495 | print '<td class="linecoledit" align="center">'; |
@@ -2418,8 +2518,7 @@ discard block |
||
2418 | 2518 | if ($action == 'editline' && $lines[$i]->id == $line_id) |
2419 | 2519 | { |
2420 | 2520 | print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); |
2421 | - } |
|
2422 | - else |
|
2521 | + } else |
|
2423 | 2522 | { |
2424 | 2523 | print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); |
2425 | 2524 | } |
@@ -2460,8 +2559,7 @@ discard block |
||
2460 | 2559 | || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) |
2461 | 2560 | { |
2462 | 2561 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>'; |
2463 | - } |
|
2464 | - else |
|
2562 | + } else |
|
2465 | 2563 | { |
2466 | 2564 | print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>'; |
2467 | 2565 | } |
@@ -2471,11 +2569,12 @@ discard block |
||
2471 | 2569 | // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) |
2472 | 2570 | if ($object->statut == Expedition::STATUS_CLOSED && $user->rights->expedition->creer) |
2473 | 2571 | { |
2474 | - if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? |
|
2572 | + if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { |
|
2573 | + // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? |
|
2475 | 2574 | { |
2476 | 2575 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ClassifyUnbilled").'</a>'; |
2477 | 2576 | } |
2478 | - else |
|
2577 | + } else |
|
2479 | 2578 | { |
2480 | 2579 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>'; |
2481 | 2580 | } |
@@ -2487,8 +2586,9 @@ discard block |
||
2487 | 2586 | if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) |
2488 | 2587 | { |
2489 | 2588 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'; |
2589 | + } else { |
|
2590 | + print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a>'; |
|
2490 | 2591 | } |
2491 | - else print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a>'; |
|
2492 | 2592 | } |
2493 | 2593 | |
2494 | 2594 | // Create bill |
@@ -2515,9 +2615,11 @@ discard block |
||
2515 | 2615 | { |
2516 | 2616 | $label="Close"; $paramaction='classifyclosed'; // = Transferred/Received |
2517 | 2617 | // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders |
2518 | - if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? |
|
2618 | + if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { |
|
2619 | + // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? |
|
2519 | 2620 | { |
2520 | 2621 | $label="ClassifyBilled"; |
2622 | + } |
|
2521 | 2623 | $paramaction='classifybilled'; |
2522 | 2624 | } |
2523 | 2625 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$paramaction.'">'.$langs->trans($label).'</a>'; |
@@ -43,8 +43,10 @@ |
||
43 | 43 | $ilink++; |
44 | 44 | |
45 | 45 | $trclass='oddeven'; |
46 | - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; |
|
47 | -?> |
|
46 | + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { |
|
47 | + $trclass.=' liste_sub_total'; |
|
48 | + } |
|
49 | + ?> |
|
48 | 50 | <tr class="<?php echo $trclass; ?>"> |
49 | 51 | <td><?php echo $langs->trans("Shipment"); ?></td> |
50 | 52 | <td><?php echo $objectlink->getNomUrl(1); ?></td> |
@@ -37,9 +37,15 @@ discard block |
||
37 | 37 | require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
39 | 39 | } |
40 | -if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; |
|
41 | -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
42 | -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
40 | +if (! empty($conf->stock->enabled)) { |
|
41 | + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; |
|
42 | +} |
|
43 | +if (! empty($conf->propal->enabled)) { |
|
44 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
45 | +} |
|
46 | +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { |
|
47 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
48 | +} |
|
43 | 49 | |
44 | 50 | // Load translation files required by the page |
45 | 51 | $langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm')); |
@@ -50,7 +56,9 @@ discard block |
||
50 | 56 | |
51 | 57 | // Security check |
52 | 58 | $socid=0; |
53 | -if (! empty($user->societe_id)) $socid=$user->societe_id; |
|
59 | +if (! empty($user->societe_id)) { |
|
60 | + $socid=$user->societe_id; |
|
61 | +} |
|
54 | 62 | $result=restrictedArea($user,'commande',$id); |
55 | 63 | |
56 | 64 | $object = new Commande($db); |
@@ -71,7 +79,9 @@ discard block |
||
71 | 79 | |
72 | 80 | $parameters = array('socid' => $socid); |
73 | 81 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
74 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
82 | +if ($reshook < 0) { |
|
83 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
84 | +} |
|
75 | 85 | |
76 | 86 | if (empty($reshook)) |
77 | 87 | { |
@@ -107,8 +117,9 @@ discard block |
||
107 | 117 | $object = new Commande($db); |
108 | 118 | $object->fetch($id); |
109 | 119 | $result=$object->set_date_livraison($user,$datelivraison); |
110 | - if ($result < 0) |
|
111 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
120 | + if ($result < 0) { |
|
121 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
122 | + } |
|
112 | 123 | } |
113 | 124 | /* |
114 | 125 | if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) |
@@ -125,24 +136,27 @@ discard block |
||
125 | 136 | $object = new Commande($db); |
126 | 137 | $object->fetch($id); |
127 | 138 | $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); |
128 | - if ($result < 0) |
|
129 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
139 | + if ($result < 0) { |
|
140 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
141 | + } |
|
130 | 142 | } |
131 | 143 | |
132 | 144 | if ($action == 'setavailability' && $user->rights->commande->creer) { |
133 | 145 | $object = new Commande($db); |
134 | 146 | $object->fetch($id); |
135 | 147 | $result=$object->availability(GETPOST('availability_id')); |
136 | - if ($result < 0) |
|
137 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
148 | + if ($result < 0) { |
|
149 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
150 | + } |
|
138 | 151 | } |
139 | 152 | |
140 | 153 | if ($action == 'setdemandreason' && $user->rights->commande->creer) { |
141 | 154 | $object = new Commande($db); |
142 | 155 | $object->fetch($id); |
143 | 156 | $result=$object->demand_reason(GETPOST('demand_reason_id')); |
144 | - if ($result < 0) |
|
145 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
157 | + if ($result < 0) { |
|
158 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
159 | + } |
|
146 | 160 | } |
147 | 161 | |
148 | 162 | if ($action == 'setconditions' && $user->rights->commande->creer) |
@@ -150,8 +164,9 @@ discard block |
||
150 | 164 | $object = new Commande($db); |
151 | 165 | $object->fetch($id); |
152 | 166 | $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); |
153 | - if ($result < 0) |
|
154 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
167 | + if ($result < 0) { |
|
168 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
169 | + } |
|
155 | 170 | } |
156 | 171 | |
157 | 172 | // Set incoterm |
@@ -168,8 +183,9 @@ discard block |
||
168 | 183 | $object = new Commande($db); |
169 | 184 | $object->fetch($id); |
170 | 185 | $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int')); |
171 | - if ($result < 0) |
|
172 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
186 | + if ($result < 0) { |
|
187 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
188 | + } |
|
173 | 189 | } |
174 | 190 | |
175 | 191 | // warehouse |
@@ -177,8 +193,9 @@ discard block |
||
177 | 193 | $object = new Commande($db); |
178 | 194 | $object->fetch($id); |
179 | 195 | $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); |
180 | - if ($result < 0) |
|
181 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
196 | + if ($result < 0) { |
|
197 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
198 | + } |
|
182 | 199 | } |
183 | 200 | |
184 | 201 | if ($action == 'update_extras') |
@@ -188,7 +205,9 @@ discard block |
||
188 | 205 | // Fill array 'array_options' with data from update form |
189 | 206 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
190 | 207 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); |
191 | - if ($ret < 0) $error++; |
|
208 | + if ($ret < 0) { |
|
209 | + $error++; |
|
210 | + } |
|
192 | 211 | |
193 | 212 | if (! $error) |
194 | 213 | { |
@@ -201,8 +220,9 @@ discard block |
||
201 | 220 | } |
202 | 221 | } |
203 | 222 | |
204 | - if ($error) |
|
205 | - $action = 'edit_extras'; |
|
223 | + if ($error) { |
|
224 | + $action = 'edit_extras'; |
|
225 | + } |
|
206 | 226 | } |
207 | 227 | |
208 | 228 | if ($action == 'set_thirdparty' && $user->rights->commande->creer) |
@@ -261,8 +281,11 @@ discard block |
||
261 | 281 | // Call Hook formConfirm |
262 | 282 | $parameters = array(); |
263 | 283 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
264 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
265 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
284 | + if (empty($reshook)) { |
|
285 | + $formconfirm.=$hookmanager->resPrint; |
|
286 | + } elseif ($reshook > 0) { |
|
287 | + $formconfirm=$hookmanager->resPrint; |
|
288 | + } |
|
266 | 289 | |
267 | 290 | // Print form confirm |
268 | 291 | print $formconfirm; |
@@ -286,8 +309,9 @@ discard block |
||
286 | 309 | $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
287 | 310 | if ($user->rights->commande->creer) |
288 | 311 | { |
289 | - if ($action != 'classify') |
|
290 | - $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
312 | + if ($action != 'classify') { |
|
313 | + $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
314 | + } |
|
291 | 315 | if ($action == 'classify') { |
292 | 316 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
293 | 317 | $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
@@ -362,7 +386,9 @@ discard block |
||
362 | 386 | print $langs->trans('DateDeliveryPlanned'); |
363 | 387 | print '</td>'; |
364 | 388 | |
365 | - if ($action != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; |
|
389 | + if ($action != 'editdate_livraison') { |
|
390 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; |
|
391 | + } |
|
366 | 392 | print '</tr></table>'; |
367 | 393 | print '</td><td colspan="2">'; |
368 | 394 | if ($action == 'editdate_livraison') |
@@ -373,8 +399,7 @@ discard block |
||
373 | 399 | print $form->selectDate($object->date_livraison>0?$object->date_livraison:-1, 'liv_', '', '', '', "setdatedelivery"); |
374 | 400 | print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; |
375 | 401 | print '</form>'; |
376 | - } |
|
377 | - else |
|
402 | + } else |
|
378 | 403 | { |
379 | 404 | print dol_print_date($object->date_livraison,'daytext'); |
380 | 405 | if ($object->hasDelay() && ! empty($object->date_livraison)) { |
@@ -393,8 +418,9 @@ discard block |
||
393 | 418 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
394 | 419 | print $langs->trans('SendingMethod'); |
395 | 420 | print '</td>'; |
396 | - if ($action != 'editshippingmethod' && $user->rights->expedition->creer) |
|
397 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>'; |
|
421 | + if ($action != 'editshippingmethod' && $user->rights->expedition->creer) { |
|
422 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>'; |
|
423 | + } |
|
398 | 424 | print '</tr></table>'; |
399 | 425 | print '</td><td colspan="2">'; |
400 | 426 | if ($action == 'editshippingmethod') { |
@@ -413,8 +439,9 @@ discard block |
||
413 | 439 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
414 | 440 | print $langs->trans('Warehouse'); |
415 | 441 | print '</td>'; |
416 | - if ($action != 'editwarehouse' && $user->rights->commande->creer) |
|
417 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&id='.$object->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>'; |
|
442 | + if ($action != 'editwarehouse' && $user->rights->commande->creer) { |
|
443 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&id='.$object->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>'; |
|
444 | + } |
|
418 | 445 | print '</tr></table>'; |
419 | 446 | print '</td><td colspan="2">'; |
420 | 447 | if ($action == 'editwarehouse') { |
@@ -469,8 +496,9 @@ discard block |
||
469 | 496 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
470 | 497 | print $langs->trans('AvailabilityPeriod'); |
471 | 498 | print '</td>'; |
472 | - if ($action != 'editavailability') |
|
473 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editavailability&id=' . $object->id . '">' . img_edit($langs->trans('SetAvailability'), 1) . '</a></td>'; |
|
499 | + if ($action != 'editavailability') { |
|
500 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editavailability&id=' . $object->id . '">' . img_edit($langs->trans('SetAvailability'), 1) . '</a></td>'; |
|
501 | + } |
|
474 | 502 | print '</tr></table>'; |
475 | 503 | print '</td><td colspan="3">'; |
476 | 504 | if ($action == 'editavailability') { |
@@ -485,8 +513,9 @@ discard block |
||
485 | 513 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
486 | 514 | print $langs->trans('Source'); |
487 | 515 | print '</td>'; |
488 | - if ($action != 'editdemandreason') |
|
489 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editdemandreason&id=' . $object->id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . '</a></td>'; |
|
516 | + if ($action != 'editdemandreason') { |
|
517 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editdemandreason&id=' . $object->id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . '</a></td>'; |
|
518 | + } |
|
490 | 519 | print '</tr></table>'; |
491 | 520 | print '</td><td colspan="3">'; |
492 | 521 | if ($action == 'editdemandreason') { |
@@ -519,16 +548,18 @@ discard block |
||
519 | 548 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
520 | 549 | print $langs->trans('IncotermLabel'); |
521 | 550 | print '<td><td align="right">'; |
522 | - if ($user->rights->commande->creer) print '<a href="'.$_SERVER['PHP_SELF'].'/expedition/shipment.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; |
|
523 | - else print ' '; |
|
551 | + if ($user->rights->commande->creer) { |
|
552 | + print '<a href="'.$_SERVER['PHP_SELF'].'/expedition/shipment.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; |
|
553 | + } else { |
|
554 | + print ' '; |
|
555 | + } |
|
524 | 556 | print '</td></tr></table>'; |
525 | 557 | print '</td>'; |
526 | 558 | print '<td colspan="3">'; |
527 | 559 | if ($action != 'editincoterm') |
528 | 560 | { |
529 | 561 | print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); |
530 | - } |
|
531 | - else |
|
562 | + } else |
|
532 | 563 | { |
533 | 564 | print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); |
534 | 565 | } |
@@ -576,14 +607,18 @@ discard block |
||
576 | 607 | print '</tr>'; |
577 | 608 | |
578 | 609 | // Amount Local Taxes |
579 | - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 |
|
610 | + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { |
|
611 | + // Localtax1 |
|
580 | 612 | { |
581 | 613 | print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; |
614 | + } |
|
582 | 615 | print '<td>' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
583 | 616 | } |
584 | - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF |
|
617 | + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { |
|
618 | + // Localtax2 IRPF |
|
585 | 619 | { |
586 | 620 | print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; |
621 | + } |
|
587 | 622 | print '<td>' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
588 | 623 | } |
589 | 624 | |
@@ -634,8 +669,7 @@ discard block |
||
634 | 669 | if (! empty($conf->stock->enabled)) |
635 | 670 | { |
636 | 671 | print '<td align="center">'.$langs->trans("RealStock").'</td>'; |
637 | - } |
|
638 | - else |
|
672 | + } else |
|
639 | 673 | { |
640 | 674 | print '<td> </td>'; |
641 | 675 | } |
@@ -653,8 +687,12 @@ discard block |
||
653 | 687 | |
654 | 688 | // Try to enhance type detection using date_start and date_end for free lines where type |
655 | 689 | // was not saved. |
656 | - if (! empty($objp->date_start)) $type=1; |
|
657 | - if (! empty($objp->date_end)) $type=1; |
|
690 | + if (! empty($objp->date_start)) { |
|
691 | + $type=1; |
|
692 | + } |
|
693 | + if (! empty($objp->date_end)) { |
|
694 | + $type=1; |
|
695 | + } |
|
658 | 696 | |
659 | 697 | print '<tr class="oddeven">'; |
660 | 698 | |
@@ -673,8 +711,12 @@ discard block |
||
673 | 711 | |
674 | 712 | $outputlangs = $langs; |
675 | 713 | $newlang=''; |
676 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
677 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
714 | + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) { |
|
715 | + $newlang=$_REQUEST['lang_id']; |
|
716 | + } |
|
717 | + if (empty($newlang)) { |
|
718 | + $newlang=$object->thirdparty->default_lang; |
|
719 | + } |
|
678 | 720 | if (! empty($newlang)) |
679 | 721 | { |
680 | 722 | $outputlangs = new Translate("",$conf); |
@@ -682,9 +724,9 @@ discard block |
||
682 | 724 | } |
683 | 725 | |
684 | 726 | $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
727 | + } else { |
|
728 | + $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
685 | 729 | } |
686 | - else |
|
687 | - $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
688 | 730 | |
689 | 731 | print '<td>'; |
690 | 732 | print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne |
@@ -710,12 +752,14 @@ discard block |
||
710 | 752 | } |
711 | 753 | |
712 | 754 | print '</td>'; |
713 | - } |
|
714 | - else |
|
755 | + } else |
|
715 | 756 | { |
716 | 757 | print "<td>"; |
717 | - if ($type==1) $text = img_object($langs->trans('Service'),'service'); |
|
718 | - else $text = img_object($langs->trans('Product'),'product'); |
|
758 | + if ($type==1) { |
|
759 | + $text = img_object($langs->trans('Service'),'service'); |
|
760 | + } else { |
|
761 | + $text = img_object($langs->trans('Product'),'product'); |
|
762 | + } |
|
719 | 763 | |
720 | 764 | if (! empty($objp->label)) { |
721 | 765 | $text.= ' <strong>'.$objp->label.'</strong>'; |
@@ -747,8 +791,7 @@ discard block |
||
747 | 791 | $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; |
748 | 792 | $toBeShippedTotal += $toBeShipped[$objp->fk_product]; |
749 | 793 | print $toBeShipped[$objp->fk_product]; |
750 | - } |
|
751 | - else |
|
794 | + } else |
|
752 | 795 | { |
753 | 796 | print '0 ('.$langs->trans("Service").')'; |
754 | 797 | } |
@@ -770,8 +813,7 @@ discard block |
||
770 | 813 | print ' '.img_warning($langs->trans("StockTooLow")); |
771 | 814 | } |
772 | 815 | print '</td>'; |
773 | - } |
|
774 | - else |
|
816 | + } else |
|
775 | 817 | { |
776 | 818 | print '<td> </td>'; |
777 | 819 | } |
@@ -815,8 +857,7 @@ discard block |
||
815 | 857 | } |
816 | 858 | |
817 | 859 | print "</table>"; |
818 | - } |
|
819 | - else |
|
860 | + } else |
|
820 | 861 | { |
821 | 862 | dol_print_error($db); |
822 | 863 | } |
@@ -842,8 +883,7 @@ discard block |
||
842 | 883 | { |
843 | 884 | print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend")); |
844 | 885 | } |
845 | - } |
|
846 | - else |
|
886 | + } else |
|
847 | 887 | { |
848 | 888 | print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateShipment").'</a>'; |
849 | 889 | } |
@@ -906,8 +946,7 @@ discard block |
||
906 | 946 | print '</div>'; |
907 | 947 | |
908 | 948 | $somethingshown=1; |
909 | - } |
|
910 | - else |
|
949 | + } else |
|
911 | 950 | { |
912 | 951 | print '<div class="tabsAction">'; |
913 | 952 | print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateShipment").'</a>'; |
@@ -916,8 +955,7 @@ discard block |
||
916 | 955 | } |
917 | 956 | |
918 | 957 | show_list_sending_receive('commande',$object->id); |
919 | - } |
|
920 | - else |
|
958 | + } else |
|
921 | 959 | { |
922 | 960 | /* Order not found */ |
923 | 961 | setEventMessages($langs->trans("NonExistentOrder"), null, 'errors'); |
@@ -60,8 +60,12 @@ discard block |
||
60 | 60 | $offset = $conf->liste_limit * $page; |
61 | 61 | $pageprev = $page - 1; |
62 | 62 | $pagenext = $page + 1; |
63 | -if (! $sortorder) $sortorder="ASC"; |
|
64 | -if (! $sortfield) $sortfield="name"; |
|
63 | +if (! $sortorder) { |
|
64 | + $sortorder="ASC"; |
|
65 | +} |
|
66 | +if (! $sortfield) { |
|
67 | + $sortfield="name"; |
|
68 | +} |
|
65 | 69 | |
66 | 70 | $object = new Expedition($db); |
67 | 71 | |
@@ -175,12 +179,10 @@ discard block |
||
175 | 179 | $permtoedit = $user->rights->expedition->creer; |
176 | 180 | $param = '&id=' . $object->id; |
177 | 181 | include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
178 | - } |
|
179 | - else{ |
|
182 | + } else{ |
|
180 | 183 | dol_print_error($db); |
181 | 184 | } |
182 | -} |
|
183 | -else{ |
|
185 | +} else{ |
|
184 | 186 | header('Location: index.php'); |
185 | 187 | exit; |
186 | 188 | } |
@@ -41,7 +41,9 @@ |
||
41 | 41 | |
42 | 42 | // Security check |
43 | 43 | $socid=''; |
44 | -if ($user->societe_id) $socid=$user->societe_id; |
|
44 | +if ($user->societe_id) { |
|
45 | + $socid=$user->societe_id; |
|
46 | +} |
|
45 | 47 | $result=restrictedArea($user, $origin, $origin_id); |
46 | 48 | |
47 | 49 | $object = new Expedition($db); |