42require
'../main.inc.php';
52require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
53require_once DOL_DOCUMENT_ROOT .
'/expedition/class/expedition.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
56require_once DOL_DOCUMENT_ROOT .
'/core/lib/sendings.lib.php';
57require_once DOL_DOCUMENT_ROOT .
'/core/modules/expedition/modules_expedition.php';
58require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
59require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
60require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/productlot.class.php';
61require_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
63 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
66 require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
69 require_once DOL_DOCUMENT_ROOT .
'/product/class/productbatch.class.php';
72 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
73 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
77$langs->loadLangs(array(
"sendings",
"companies",
"bills",
'orders',
'stocks',
'other',
'propal',
'productbatch'));
80 $langs->load(
'incoterm');
83 $langs->load(
'productbatch');
87$origin =
GETPOST(
'origin',
'alpha');
92if (empty($origin_id) && !empty($origin)) {
95if (empty($origin_id) && !empty($origin)) {
104$action =
GETPOST(
'action',
'alpha');
105$confirm =
GETPOST(
'confirm',
'alpha');
106$cancel =
GETPOST(
'cancel',
'alpha');
109$backtopage =
GETPOST(
'backtopage',
'alpha');
120$extrafields->fetch_name_optionals_label(
$object->table_element);
121$extrafields->fetch_name_optionals_label(
$object->table_element_line);
122$extrafields->fetch_name_optionals_label($objectorder->table_element_line);
125include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
127if (empty($origin) && !empty(
$object->origin_type) &&
$object->origin_id > 0) {
128 $origin =
$object->origin_type;
129} elseif (empty($origin) && is_string(
$object->origin) &&
$object->origin !==
'' &&
$object->origin_id > 0) {
132if (empty($origin_id) &&
$object->origin_id > 0) {
133 $origin_id =
$object->origin_id;
135$origin_type = is_string($origin) ? $origin :
'';
138$usercanread = $user->hasRight(
"expedition",
"lire");
139$usercancreate = $user->hasRight(
"expedition",
"creer");
140$usercandelete = $user->hasRight(
"expedition",
"supprimer");
143$hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
153 $socid = $user->socid;
158$permissiondellink = $user->hasRight(
'expedition',
'delivery',
'creer');
159$permissiontoadd = $user->hasRight(
'expedition',
'creer');
160$permissiontoedit = $usercancreate;
161$permissiontoeditextra = $permissiontoadd;
162if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
164 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
167$upload_dir =
$conf->expedition->dir_output .
'/sending';
173$shipping_method_id =
null;
183$parameters = array();
184$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
186 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
189if (empty($reshook)) {
190 $backurlforlist = DOL_URL_ROOT.
'/expedition/list.php';
192 if (empty($backtopage) || ($cancel && empty($id))) {
193 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
194 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
195 $backtopage = $backurlforlist;
197 $backtopage = DOL_URL_ROOT.
'/expedition/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
203 if (!empty($backtopageforcancel)) {
204 header(
"Location: ".$backtopageforcancel);
206 } elseif (!empty($backtopage)) {
207 header(
"Location: ".$backtopage);
215 if ($origin_id > 0) {
216 if ($origin ==
'commande') {
217 header(
"Location: " . DOL_URL_ROOT .
'/expedition/shipment.php?id=' . ((
int) $origin_id));
226 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
229 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
232 if ($action ==
'setdraft' && $permissiontoadd) {
234 $result =
$object->setDraft($user, 0);
238 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
243 if ($action ==
'reopen' && $permissiontoadd) {
249 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
255 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
259 if ($action ==
'classin' && $permissiontoadd) {
267 if ($action ==
'setref_customer' && $permissiontoadd) {
273 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPPING_MODIFY');
276 $action =
'editref_customer';
278 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
283 if ($action ==
'update_extras' && $permissiontoeditextra) {
286 $attribute_name =
GETPOST(
'attribute',
'aZ09');
289 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
296 $result =
$object->updateExtraField($attribute_name,
'SHIPPING_MODIFY');
304 $action =
'edit_extras';
309 if ($action ==
'add' && $permissiontoadd) {
312 if ($origin && $origin_id > 0) {
314 $classname = ucfirst($origin);
315 $objectsrc =
new $classname($db);
316 '@phan-var-force Facture|Commande $objectsrc';
317 $objectsrc->fetch($origin_id);
318 $object->socid = $objectsrc->socid;
323 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
332 $object->origin_type = $origin_type;
333 $object->origin_id = $origin_id;
343 $object->date_delivery = $date_delivery;
344 $object->date_shipping = $date_shipping;
351 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
356 $ret = $extrafields->setOptionalsFromPost(
null, $object);
370 if ($origin && $origin_id > 0) {
372 $object->origin_type = $origin_type;
373 $object->origin_id = $origin_id;
383 $object->date_delivery = $date_delivery;
384 $object->date_shipping = $date_shipping;
391 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
394 $classname = ucfirst(
$object->origin_type);
395 $objectsrc =
new $classname($db);
396 '@phan-var-force Facture|Commande $objectsrc';
397 $objectsrc->fetch(
$object->origin_id);
399 $object->socid = $objectsrc->socid;
400 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
404 $batch_line = array();
405 $stockLine = array();
406 $array_options = array();
408 $num = count($objectsrc->lines);
411 $product_batch_used = array();
413 for ($i = 0; $i < $num; $i++) {
421 $batch =
"batchl" . $i .
"_0";
422 $stockLocation =
"ent1" . $i .
"_0";
425 $is_batch_or_serial = 0;
426 if (!empty($objectsrc->lines[$i]->fk_product)) {
427 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
428 if ($resultFetch < 0) {
429 setEventMessages($product->error, $product->errors,
'errors');
431 $is_batch_or_serial = $product->status_batch;
435 if (
isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
442 $sub_qty[$j][
'id_batch'] =
GETPOSTINT($batch);
443 $subtotalqty += $sub_qty[$j][
'q'];
445 if ($is_batch_or_serial == 2 && ($sub_qty[$j][
'q'] > 1 || ($sub_qty[$j][
'q'] > 0 && in_array($sub_qty[$j][
'id_batch'], $product_batch_used)))) {
446 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
451 if ($is_batch_or_serial == 2 && $sub_qty[$j][
'q'] > 0) {
453 $product_batch_used[$j] = $sub_qty[$j][
'id_batch'];
457 $batch =
"batchl" . $i .
"_" . $j;
458 $qty =
"qtyl" . $i .
'_' . $j;
461 $batch_line[$i][
'detail'] = $sub_qty;
462 $batch_line[$i][
'qty'] = $subtotalqty;
465 $totalqty += $subtotalqty;
472 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse") .
' (' . $langs->trans(
"Line") .
' ' .
GETPOSTINT($idl) .
')',
null,
'errors');
482 $stockLine[$i][$j][
'warehouse_id'] =
GETPOSTINT($stockLocation);
483 $stockLine[$i][$j][
'ix_l'] =
GETPOSTINT($idl);
489 $stockLocation =
"ent1" . $i .
"_" . $j;
490 $qty =
"qtyl" . $i .
'_' . $j;
501 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
502 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i + 1),
null,
'errors');
508 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
510 if (isset($extrafields->attributes[
$object->table_element_line][
'label']) && is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
512 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
513 unset($_POST[
"options_" . $key]);
518 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
519 $selected_subtotal_lines =
GETPOST(
'subtotal_toselect',
'array:int');
520 for ($i = 0; $i < $num; $i++) {
523 if (!isset($batch_line[$i])) {
525 if (isset($stockLine[$i])) {
527 $nbstockline = count($stockLine[$i]);
528 for ($j = 0; $j < $nbstockline; $j++) {
529 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
530 $ret =
$object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], (
float) $stockLine[$i][$j][
'qty'], $array_options[$i]);
542 if ($entrepot_id < 0) {
545 if (!($objectsrc->lines[$i]->fk_product > 0)) {
556 if (
isModEnabled(
'subtotals') && $objectsrc->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && in_array($objectsrc->lines[$i]->id, $selected_subtotal_lines)) {
557 $object->addSubtotalLine($langs, $objectsrc->lines[$i]->desc, (
int) $objectsrc->lines[$i]->qty, $objectsrc->lines[$i]->extraparams, $objectsrc->lines[$i]->id);
562 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
563 $origin_line_id = (int) $batch_line[$i][
'ix_l'];
565 $res = $origin_line->fetch($origin_line_id);
568 setEventMessages($origin_line->error, $origin_line->errors,
'errors');
570 $ret =
$object->addline_batch($batch_line[$i], $array_options[$i], $origin_line);
579 $ret = $extrafields->setOptionalsFromPost(
null, $object);
592 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
594 $labelfieldmissing .=
'/' . $langs->transnoentitiesnoconv(
"Warehouse");
596 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
603 foreach (
$object->lines as $line) {
604 $objectsrc_line =
new $objectsrc->class_element_line($db);
605 '@phan-var-force CommonObjectLine $objectsrc_line';
606 $objectsrc_line->fetch($line->origin_line_id);
607 $line->extraparams = $objectsrc_line->extraparams;
608 $line->setExtraParameters();
610 header(
"Location: card.php?id=" .
$object->id);
617 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
621 $result =
$object->create_delivery($user);
625 header(
"Location: " . DOL_URL_ROOT .
'/delivery/card.php?action=create_delivery&token=' .
newToken() .
'&id=' . $result);
633 $action ==
'confirm_valid' && $confirm ==
'yes' && ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
634 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
638 $result =
$object->valid($user);
645 $outputlangs = $langs;
648 $newlang =
GETPOST(
'lang_id',
'aZ09');
651 $newlang =
$object->thirdparty->default_lang;
653 if (!empty($newlang)) {
655 $outputlangs->setDefaultLang($newlang);
660 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
666 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
667 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
668 $result =
$object->cancel($user, 0, (
bool) $also_update_stock);
674 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
675 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
677 $result =
$object->delete($user, 0, (
bool) $also_update_stock);
679 header(
"Location: " . DOL_URL_ROOT .
'/expedition/index.php');
693 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $permissiontoadd) {
694 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
697 $object->line_order(
true,
'ASC',
false);
699 $outputlangs = $langs;
702 $newlang =
GETPOST(
'lang_id',
'aZ09');
705 $newlang =
$object->thirdparty->default_lang;
707 if (!empty($newlang)) {
709 $outputlangs->setDefaultLang($newlang);
713 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
716 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
721 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
723 $result =
$object->deleteLine($user, $lineid);
728 $outputlangs = $langs;
731 $newlang =
GETPOST(
'lang_id',
'aZ09');
734 $newlang =
$object->thirdparty->default_lang;
736 if (!empty($newlang)) {
738 $outputlangs->setDefaultLang($newlang);
742 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
745 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
750 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
751 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
753 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
758 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
759 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
761 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
766 } elseif ($action ==
'setdate_livraison' && $user->hasRight(
'expedition',
'creer')) {
770 $result =
$object->setDeliveryDate($user, $datedelivery);
774 } elseif ($action ==
'setdate_shipping' && $user->hasRight(
'expedition',
'creer')) {
778 $result =
$object->setShippingDate($user, $dateshipping);
782 } elseif (in_array($action, array(
'settracking_number',
'settracking_url',
'settrueWeight',
'settrueWidth',
'settrueHeight',
'settrueDepth',
'setshipping_method_id')) && $user->hasRight(
'expedition',
'creer')) {
786 if ($action ==
'settracking_number') {
787 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
788 $object->tracking_number = preg_replace(
'/\s+/',
'',
$object->tracking_number);
790 if ($action ==
'settracking_url') {
791 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'restricthtml'));
794 if ($action ==
'settrueWeight') {
798 if ($action ==
'settrueWidth') {
801 if ($action ==
'settrueHeight') {
805 if ($action ==
'settrueDepth') {
808 if ($action ==
'setshipping_method_id') {
812 if (
$object->update($user) >= 0) {
813 header(
"Location: card.php?id=" .
$object->id);
818 } elseif ($action ==
'classifybilled' && $permissiontoadd) {
820 $result =
$object->setBilled();
822 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
826 } elseif ($action ==
'classifyclosed' && $permissiontoadd) {
828 $result =
$object->setClosed();
830 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
834 } elseif ($action ==
'deleteline' && !empty($line_id) && $permissiontoadd) {
840 $line->fk_expedition =
$object->id;
842 $num_prod = count($lines);
843 for ($i = 0; $i < $num_prod; $i++) {
844 if ($lines[$i]->
id == $line_id) {
847 if (is_array($lines[$i]->details_entrepot) && count($lines[$i]->details_entrepot) > 1) {
849 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
850 $line->id = $details_entrepot->line_id;
851 if (!$error && $line->delete($user) < 0) {
857 $line->id = $line_id;
858 if (!$error && $line->delete($user) < 0) {
863 unset($_POST[
"lineid"]);
867 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
870 setEventMessages($line->error, $line->errors,
'errors');
872 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') != $langs->trans(
"Cancel")) {
877 if (!
$object->fetch($id) > 0) {
878 dol_print_error($db);
882 $qty =
GETPOST(
'qty',
'alpha');
885 $element_type =
'shipping';
891 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
892 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
894 if (is_array($extralabelsline)) {
896 foreach ($extralabelsline as $key => $value) {
897 unset($_POST[
"options_" . $key]);
906 $result =
$object->updatelinefree(
GETPOSTINT(
'lineid'), (
float) $qty, $element_type, $fk_product,
GETPOSTINT(
'units'), $rang, $description, $fk_parent, 0, $array_options);
911 $outputlangs = $langs;
914 $newlang =
GETPOST(
'lang_id',
'aZ09');
917 $newlang =
$object->thirdparty->default_lang;
919 if (!empty($newlang)) {
921 $outputlangs->setDefaultLang($newlang);
922 $outputlangs->load(
'products');
926 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
928 unset($_POST[
'qty']);
929 unset($_POST[
'units']);
934 } elseif ($origin && $origin_id > 0) {
942 $num_prod = count($lines);
943 for ($i = 0; $i < $num_prod; $i++) {
944 if ($lines[$i]->
id == $line_id) {
945 $update_done =
false;
947 $line->fk_expedition =
$object->id;
950 $line->array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
952 if (is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
953 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
954 unset($_POST[
"options_" . $key]);
957 $line->fk_product = $lines[$i]->fk_product;
958 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
960 foreach ($lines[$i]->detail_batch as $detail_batch) {
962 $batch =
"batchl" . $detail_batch->fk_expeditiondet .
"_" . $detail_batch->fk_origin_stock;
963 $qty =
"qtyl" . $detail_batch->fk_expeditiondet .
'_' . $detail_batch->id;
966 if (!empty($batch_id)) {
967 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
968 if ($lines[$i]->entrepot_id != 0) {
970 $line->entrepot_id = $lotStock->warehouseid;
974 if (empty($line->detail_batch)) {
975 $line->detail_batch =
new stdClass();
978 $line->detail_batch->fk_origin_stock = $batch_id;
979 $line->detail_batch->batch = $lotStock->batch;
980 $line->detail_batch->id = $detail_batch->id;
981 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
982 $line->detail_batch->qty = $batch_qty;
983 if ($line->update($user) < 0) {
984 setEventMessages($line->error, $line->errors,
'errors');
990 setEventMessages($lotStock->error, $lotStock->errors,
'errors');
994 unset($_POST[$batch]);
999 $batch =
"batchl" . $line_id .
"_0";
1000 $qty =
"qtyl" . $line_id .
"_0";
1003 $lineIdToAddLot = 0;
1004 if ($batch_qty > 0 && !empty($batch_id)) {
1005 if ($lotStock->fetch($batch_id) > 0) {
1007 if ($lines[$i]->entrepot_id > 0) {
1009 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
1010 $lineIdToAddLot = $line_id;
1012 } elseif (count($lines[$i]->details_entrepot) > 1) {
1014 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1015 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
1016 $lineIdToAddLot = $detail_entrepot->line_id;
1020 if ($lineIdToAddLot) {
1022 if ($line->fetch($lineIdToAddLot) > 0) {
1023 $line->detail_batch->fk_origin_stock = $batch_id;
1024 $line->detail_batch->batch = $lotStock->batch;
1025 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
1026 $line->detail_batch->qty = $batch_qty;
1027 if ($line->update($user) < 0) {
1028 setEventMessages($line->error, $line->errors,
'errors');
1031 $update_done =
true;
1034 setEventMessages($line->error, $line->errors,
'errors');
1039 $line->origin_line_id = $lines[$i]->origin_line_id;
1040 $line->entrepot_id = $lotStock->warehouseid;
1042 $line->detail_batch[0]->fk_origin_stock = $batch_id;
1043 $line->detail_batch[0]->batch = $lotStock->batch;
1044 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
1045 $line->detail_batch[0]->qty = $batch_qty;
1046 if (
$object->create_line_batch($line, $line->array_options) < 0) {
1050 $update_done =
true;
1054 setEventMessages($lotStock->error, $lotStock->errors,
'errors');
1059 if ($lines[$i]->fk_product > 0) {
1061 if ($lines[$i]->entrepot_id == 0) {
1063 $stockLocation =
"entl" . $line_id;
1064 $qty =
"qtyl" . $line_id;
1065 $line->id = $line_id;
1066 $line->entrepot_id =
GETPOSTINT((
string) $stockLocation);
1068 if ($line->update($user) < 0) {
1069 setEventMessages($line->error, $line->errors,
'errors');
1072 $update_done =
true;
1074 unset($_POST[$stockLocation]);
1075 unset($_POST[$qty]);
1076 } elseif ($lines[$i]->entrepot_id > 0) {
1078 $stockLocation =
"entl" . $line_id;
1079 $qty =
"qtyl" . $line_id;
1080 $line->id = $line_id;
1081 $line->entrepot_id =
GETPOSTINT($stockLocation);
1083 if ($line->update($user) < 0) {
1084 setEventMessages($line->error, $line->errors,
'errors');
1087 $update_done =
true;
1089 unset($_POST[$stockLocation]);
1090 unset($_POST[$qty]);
1091 } elseif (count($lines[$i]->details_entrepot) > 1) {
1093 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1095 $stockLocation =
"entl" . $detail_entrepot->line_id;
1096 $qty =
"qtyl" . $detail_entrepot->line_id;
1098 if (!empty($warehouse)) {
1099 $line->id = $detail_entrepot->line_id;
1100 $line->entrepot_id = $warehouse;
1102 if ($line->update($user) < 0) {
1103 setEventMessages($line->error, $line->errors,
'errors');
1106 $update_done =
true;
1109 unset($_POST[$stockLocation]);
1110 unset($_POST[$qty]);
1114 $qty =
"qtyl" . $line_id;
1115 $line->id = $line_id;
1117 $line->entrepot_id = 0;
1118 if ($line->update($user) < 0) {
1119 setEventMessages($line->error, $line->errors,
'errors');
1122 $update_done =
true;
1124 unset($_POST[$qty]);
1128 $qty =
"qtyl" . $line_id;
1129 $line->id = $line_id;
1131 $line->entrepot_id = 0;
1132 if ($line->update($user) < 0) {
1133 setEventMessages($line->error, $line->errors,
'errors');
1136 $update_done =
true;
1138 unset($_POST[$qty]);
1142 if (empty($update_done)) {
1143 $line->id = $lines[$i]->id;
1144 $resultInsertExtraFields = $line->insertExtraFields();
1145 if ($resultInsertExtraFields < 0) {
1146 setEventMessages($line->error, $line->errors,
'errors');
1148 } elseif ($resultInsertExtraFields > 0) {
1149 $update_done =
true;
1153 if (empty($update_done) && !$error) {
1154 setEventMessages($langs->trans(
'NoShipmentLineChangeDetected'),
null,
'warnings');
1159 unset($_POST[
"lineid"]);
1164 $outputlangs = $langs;
1167 $newlang =
GETPOST(
'lang_id',
'aZ09');
1170 $newlang =
$object->thirdparty->default_lang;
1172 if (!empty($newlang)) {
1174 $outputlangs->setDefaultLang($newlang);
1178 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1181 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1185 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1186 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1188 } elseif ($action ==
'addline' && !$origin &&
getDolGlobalString(
'SHIPMENT_STANDALONE') && $usercancreate) {
1189 $langs->load(
'errors');
1195 $fk_elementdet =
'';
1196 $element_type =
'shipping';
1202 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
1203 if ($prod_entry_mode ==
'free') {
1208 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1216 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1217 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1219 if (is_array($extralabelsline)) {
1221 foreach ($extralabelsline as $key => $value) {
1222 unset($_POST[
"options_".$key]);
1226 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1227 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1232 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1236 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1239 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1240 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1244 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1245 if ($combinations =
GETPOST(
'combinations',
'array')) {
1249 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1250 $idprod = $res->fk_product_child;
1251 $fk_product = $idprod;
1253 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1259 if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1261 if (!empty($idprod) && $idprod > 0) {
1263 $prod->fetch($idprod);
1264 $desc =
$prod->label;
1265 $description = $desc;
1268 $outputlangs = $langs;
1270 if (
GETPOST(
'lang_id',
'aZ09')) {
1271 $newlang =
GETPOST(
'lang_id',
'aZ09');
1273 if (empty($newlang)) {
1274 $newlang =
$object->thirdparty->default_lang;
1276 if (!empty($newlang)) {
1278 $outputlangs->setDefaultLang($newlang);
1281 $description = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1283 $description =
$prod->description;
1288 $description = $line_desc;
1295 $outputlangs = $langs;
1297 if (
GETPOST(
'lang_id',
'alpha')) {
1298 $newlang =
GETPOST(
'lang_id',
'alpha');
1300 if (empty($newlang)) {
1301 $newlang =
$object->thirdparty->default_lang;
1303 if (!empty($newlang)) {
1305 $outputlangs->setDefaultLang($newlang);
1306 $outputlangs->load(
'products');
1308 if (!empty(
$prod->customcode)) {
1309 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.
$prod->customcode;
1311 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1314 if (!empty(
$prod->country_code)) {
1315 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry(
$prod->country_code,
'', $db, $outputlangs, 0);
1318 if (!empty(
$prod->customcode)) {
1319 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.
$prod->customcode;
1321 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1324 if (!empty(
$prod->country_code)) {
1325 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry(
$prod->country_code,
'', $db, $langs, 0);
1331 $type =
$prod->type;
1332 $fk_unit =
$prod->fk_unit;
1334 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1337 $fk_unit =
GETPOST(
'units',
'alpha');
1338 $description = $desc;
1339 $fk_elementdet =
'';
1344 $result =
$object->addlinefree((
float) $qty, $element_type, $idprod, $fk_unit, min($rank, count(
$object->lines) + 1), $description, $fk_parent, $array_options);
1351 $outputlangs = $langs;
1352 $newlang =
GETPOST(
'lang_id',
'alpha');
1354 $newlang =
$object->thirdparty->default_lang;
1356 if (!empty($newlang)) {
1358 $outputlangs->setDefaultLang($newlang);
1360 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1363 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1367 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $permissiontoadd) {
1368 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
1372 $outputlangs = $langs;
1375 $newlang =
GETPOST(
'lang_id',
'aZ09');
1378 $newlang =
$object->thirdparty->default_lang;
1380 if (!empty($newlang)) {
1382 $outputlangs->setDefaultLang($newlang);
1384 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1387 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1392 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $permissiontoadd) {
1393 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
1397 $outputlangs = $langs;
1400 $newlang =
GETPOST(
'lang_id',
'aZ09');
1403 $newlang =
$object->thirdparty->default_lang;
1405 if (!empty($newlang)) {
1407 $outputlangs->setDefaultLang($newlang);
1409 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1412 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1419 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
1425 $triggersendname =
'SHIPPING_SENTBYMAIL';
1427 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
1428 $mode =
'emailfromshipment';
1429 $trackid =
'shi' .
$object->id;
1430 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
1437$title =
$object->ref .
' - ' . $langs->trans(
"Card");
1438if ($action ==
'create') {
1439 $title = $langs->trans(
"NewSending");
1442$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
1444llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-expedition page-card');
1446if (empty($action)) {
1450$form =
new Form($db);
1456 $formproject =
null;
1459$product_static =
new Product($db);
1461$warehousestatic =
new Entrepot($db);
1466 print
'<br>' .$langs->trans(
"ShipmentCreationIsDoneFromOrder");
1473if ($action ==
'create' && $usercancreate) {
1481 $res = $soc->fetch($socid);
1484 $shipping_method_id = $soc->shipping_method_id;
1485 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1486 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1488 print
'<form name="crea_expedition" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
1489 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1490 print
'<input type="hidden" name="action" value="add">';
1491 print
'<input type="hidden" name="changecompany" value="0">';
1492 print
'<input type="hidden" name="originid" value="' .
$id .
'">';
1493 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
1497 print
'<table class="border centpercent">';
1501 print
'<td class="fieldrequired">' . $langs->trans(
'ThirdParty') .
'</td>';
1504 print $soc->getNomUrl(1);
1505 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1508 print
'<td class="valuefieldcreate">';
1509 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1513 $(document).ready(function() {
1514 $("#socid").change(function() {
1515 console.log("We have changed the company - Reload page");
1516 var socid = $(this).val();
1518 $("input[name=action]").val("create");
1519 $("input[name=changecompany]").val("1");
1520 $("form[name=crea_expedition]").submit();
1525 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1531 if (
isModEnabled(
'project') && is_object($formproject)) {
1533 if (empty($projectid) && !empty(
$object->fk_project)) {
1534 $projectid = (int)
$object->fk_project;
1537 $langs->load(
"projects");
1539 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1540 print img_picto(
'',
'project',
'class="pictofixedwidth"');
1541 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1542 print
' <a class="paddingleft" href="' . DOL_URL_ROOT .
'/projet/card.php?socid=' . $soc->id .
'&action=create&status=1&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?action=create&socid=' . $soc->id) .
'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
1548 print
'<tr><td>'.$langs->trans(
"DateShipping").
'</td>';
1549 print
'<td colspan="3">';
1550 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1551 $date_shipping = ($date_shipping ? $date_shipping :
$object->date_shipping);
1552 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1557 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1558 print
'<td colspan="3">';
1559 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1560 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1561 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1567 print $langs->trans(
"Weight");
1568 print
'</td><td colspan="3">';
1569 print img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1570 print
'<input name="weight" size="4" value="' .
GETPOST(
'weight') .
'"> ';
1571 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units'), 0, 2);
1572 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1573 print $form->textwithpicto($text, $htmltext);
1578 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1579 print
' </td><td colspan="3">';
1580 print img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1581 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1582 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1583 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1585 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1586 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1587 print $form->textwithpicto($text, $htmltext);
1591 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1592 print
'<td colspan="3">';
1593 $expe->fetch_delivery_methods();
1594 print img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1595 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1597 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1599 print
"</td></tr>\n";
1602 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1603 print
'<td colspan="3">';
1604 print img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1605 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1606 print
"</td></tr>\n";
1609 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1610 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
1611 print $hookmanager->resPrint;
1613 if (empty($reshook)) {
1615 if (
$object->fetch_optionals() > 0) {
1616 $expe->array_options = array_merge($expe->array_options,
$object->array_options);
1618 print $expe->showOptionals($extrafields,
'edit', $parameters);
1624 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1625 print
'<td colspan="3" class="maxwidthonsmartphone">';
1626 print img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1627 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1632 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1634 if (is_array($list) && count($list) > 1) {
1635 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1636 print
'<td colspan="3">';
1637 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1638 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1639 print
"</td></tr>\n";
1645 print
'<td class="tdtop">';
1646 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext);
1648 print
'<td valign="top" colspan="2">';
1649 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1650 print $doleditor->Create(1);
1653 if (!$user->socid) {
1655 print
'<td class="tdtop">';
1656 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext);
1658 print
'<td valign="top" colspan="2">';
1659 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1660 print $doleditor->Create(1);
1668 print $form->buttonsSaveCancel(
"CreateDraft");
1671 } elseif ($origin) {
1672 $classname = ucfirst($origin);
1674 $object =
new $classname($db);
1676 '@phan-var-force Commande|Facture $object';
1679 if (
$object->fetch($origin_id)) {
1683 $author =
new User($db);
1684 $author->fetch(
$object->user_author_id);
1690 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
1691 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1692 print
'<input type="hidden" name="action" value="add">';
1693 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
1694 print
'<input type="hidden" name="origin_id" value="' .
$object->id .
'">';
1696 print
'<input type="hidden" name="entrepot_id" value="' .
GETPOSTINT(
'entrepot_id') .
'">';
1701 print
'<table class="border centpercent">';
1704 print
'<tr><td class="titlefieldcreate fieldrequired">';
1706 print $langs->trans(
"RefOrder");
1709 print $langs->trans(
"RefProposal");
1711 print
'</td><td colspan="3">';
1718 if ($origin ==
'commande') {
1719 print $langs->trans(
'RefCustomerOrder');
1720 } elseif ($origin ==
'propal') {
1721 print $langs->trans(
'RefCustomerOrder');
1723 print $langs->trans(
'RefCustomer');
1725 print
'</td><td colspan="3">';
1726 print
'<input type="text" name="ref_customer" value="' .
$object->ref_client .
'" />';
1731 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Company') .
'</td>';
1732 print
'<td colspan="3">' . $soc->getNomUrl(1) .
'</td>';
1733 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1737 if (
isModEnabled(
'project') && is_object($formproject)) {
1739 if (empty($projectid) && !empty(
$object->fk_project)) {
1740 $projectid = (int)
$object->fk_project;
1742 if ($origin ==
'project') {
1745 $langs->load(
"projects");
1747 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1748 print img_picto(
'',
'project',
'class="pictofixedwidth"');
1749 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1750 print
' <a class="paddingleft" href="' . DOL_URL_ROOT .
'/projet/card.php?socid=' . $soc->id .
'&action=create&status=1&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?action=create&socid=' . $soc->id) .
'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
1756 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
1757 print
'<td colspan="3">';
1758 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1759 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1760 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1765 print
'<tr><td>' . $langs->trans(
"DateShipping") .
'</td>';
1766 print
'<td colspan="3">';
1767 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1769 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1774 print
'<tr><td>' . $langs->trans(
"NotePublic") .
'</td>';
1775 print
'<td colspan="3">';
1776 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1777 print $doleditor->Create(1);
1781 if (
$object->note_private && !$user->socid) {
1782 print
'<tr><td>' . $langs->trans(
"NotePrivate") .
'</td>';
1783 print
'<td colspan="3">';
1784 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1785 print $doleditor->Create(1);
1791 print $langs->trans(
"Weight");
1792 print
'</td><td colspan="3">';
1793 print img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1796 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOST(
'weight_units'), 0, 2);
1797 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1798 print $form->textwithpicto($text, $htmltext);
1803 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1804 print
' </td><td colspan="3">';
1805 print img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1806 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1807 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1808 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1810 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1811 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1812 print $form->textwithpicto($text, $htmltext);
1816 print
"<tr><td>" . $langs->trans(
"DeliveryMethod") .
"</td>";
1817 print
'<td colspan="3">';
1818 $expe->fetch_delivery_methods();
1819 print img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1820 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1822 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1824 print
"</td></tr>\n";
1827 print
"<tr><td>" . $langs->trans(
"TrackingNumber") .
"</td>";
1828 print
'<td colspan="3">';
1829 print img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1830 print
'<input name="tracking_number" size="20" value="' .
GETPOST(
'tracking_number',
'alpha') .
'">';
1831 print
"</td></tr>\n";
1836 print
'<td><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1) .
'</label></td>';
1837 print
'<td colspan="3" class="maxwidthonsmartphone">';
1838 print img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1839 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1844 include_once DOL_DOCUMENT_ROOT .
'/core/modules/expedition/modules_expedition.php';
1846 if (is_array($list) && count($list) > 1) {
1847 print
"<tr><td>" . $langs->trans(
"DefaultModel") .
"</td>";
1848 print
'<td colspan="3">';
1849 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1850 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1851 print
"</td></tr>\n";
1859 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && !empty($extrafields->attributes[
$object->table_element][
'label'])) {
1860 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
1861 if (array_key_exists(
'options_'.$key, $objectsav->array_options)) {
1862 $object->array_options[
'options_'.$key] = $objectsav->array_options[
'options_'.$key];
1866 $parameters = array(
1867 'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
1871 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1881 $numAsked = count(
$object->lines);
1883 print
'<script type="text/javascript">' .
"\n";
1884 print
'jQuery(document).ready(function() {' .
"\n";
1885 print
'jQuery("#autofill").click(function() {';
1887 while ($i < $numAsked) {
1888 print
'jQuery("#qtyl' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1890 print
'jQuery("#qtyl' . $i .
'_' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1894 print
'return false; });' .
"\n";
1895 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);' .
"\n";
1896 print
'return false; });' .
"\n";
1898 print
'</script>' .
"\n";
1902 print
'<div class="div-table-responsive-no-min">';
1903 print
'<table class="noborder centpercent">';
1908 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1910 $title_lines_to_disable = array();
1915 $title_lines_to_disable =
$object->getDisabledShippmentSubtotalLines();
1917 $selectedLines =
GETPOST(
'subtotal_toselect',
'array:int');
1918 foreach (
$object->lines as $line) {
1919 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1920 $show_check_add_buttons =
true;
1925 print
'<tr class="liste_titre">';
1927 if (isset($show_check_add_buttons)) {
1928 print $form->showCheckAddButtons(
'checkforselect');
1930 print $langs->trans(
"Description");
1932 print
'<td class="center">' . $langs->trans(
"QtyOrdered") .
'</td>';
1933 print
'<td class="center">' . $langs->trans(
"QtyShipped") .
'</td>';
1934 print
'<td class="center">' . $langs->trans(
"QtyToShip");
1936 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">' . img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"') .
'</a>';
1941 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">' . img_picto($langs->trans(
"Reset"),
'eraser') .
'</span>';
1945 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' (' . $langs->trans(
"Stock") .
')</td>';
1947 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' / ' . $langs->trans(
"Batch") .
' (' . $langs->trans(
"Stock") .
')</td>';
1951 print
'<td class="left">' . $langs->trans(
'StockEntryDate') .
'</td>';
1957 $warehousePicking = array();
1959 if ($warehouse_id > 0) {
1960 $warehousePicking[] = $warehouse_id;
1962 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1966 while ($indiceAsked < $numAsked) {
1969 $line =
$object->lines[$indiceAsked];
1971 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1972 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1974 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1977 if (empty($reshook) && $line->special_code != SUBTOTALS_SPECIAL_CODE) {
1979 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1981 if (!empty($line->date_start)) {
1984 if (!empty($line->date_end)) {
1988 print
'<!-- line for order line ' . $line->id .
' -->' .
"\n";
1989 print
'<tr class="oddeven" id="row-' . $line->id .
'">' .
"\n";
1991 $qtyProdCom = $line->qty;
1992 $productChildrenNb = 0;
1994 if ($line->fk_product > 0) {
1995 $res = $product->fetch($line->fk_product);
1997 dol_print_error($db, $product->error, $product->errors);
2000 $productChildrenNb = $product->hasFatherOrChild(1);
2002 if ($productChildrenNb > 0) {
2003 $product->loadStockForVirtualProduct(
'warehouseopen', $qtyProdCom);
2005 $product->load_stock(
'warehouseopen');
2010 print
'<a name="' . $line->id .
'"></a>';
2013 $product_static->type = $line->fk_product_type;
2014 $product_static->id = $line->fk_product;
2015 $product_static->ref = $line->ref;
2016 $product_static->status = $line->product_tosell;
2017 $product_static->status_buy = $line->product_tobuy;
2018 $product_static->status_batch = $line->product_tobatch;
2020 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
2022 $text = $product_static->getNomUrl(1);
2023 $text .=
' - ' . (!empty($line->label) ? $line->label : $line->product_label);
2025 $description .= empty($product->stockable_product) ? $langs->trans(
'StockDisabled') : $langs->trans(
'StockEnabled');
2026 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2029 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
2032 if ($showdescinproductdesc) {
2033 print ($line->desc && $line->desc != $line->product_label) ?
'<br>' .
dol_htmlentitiesbr($line->desc) :
'';
2038 $srcLine->id = $line->id;
2039 $srcLine->fetch_optionals();
2040 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
2041 $lineExtrafieldsHtml = $expLine->showOptionals($extrafields,
'edit', array(), (
string) $indiceAsked,
'',
'1',
'line');
2042 if (!empty($lineExtrafieldsHtml)) {
2043 print
'<div style="padding-top: 10px" id="extrafield_lines_area_create_' . $indiceAsked .
'" name="extrafield_lines_area_create_' . $indiceAsked .
'">';
2044 print $lineExtrafieldsHtml;
2052 $text = img_object($langs->trans(
'Service'),
'service');
2054 $text = img_object($langs->trans(
'Product'),
'product');
2057 if (!empty($line->label)) {
2058 $text .=
' <strong>' . $line->label .
'</strong>';
2059 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
2061 print $text .
' ' . nl2br($line->desc);
2065 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
2069 $srcLine->id = $line->id;
2070 $srcLine->fetch_optionals();
2071 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
2072 $lineExtrafieldsHtml = $expLine->showOptionals($extrafields,
'edit', array(), (
string) $indiceAsked,
'',
'1',
'line');
2073 if (!empty($lineExtrafieldsHtml)) {
2074 print
'<div style="padding-top: 10px" id="extrafield_lines_area_create_' . $indiceAsked .
'" name="extrafield_lines_area_create_' . $indiceAsked .
'">';
2075 print $lineExtrafieldsHtml;
2088 print
'<td class="center">' . $line->qty;
2089 print
'<input name="qtyasked' . $indiceAsked .
'" id="qtyasked' . $indiceAsked .
'" type="hidden" value="' . $line->qty .
'">';
2091 print
' ' . $unit_order .
'</td>';
2095 print
'<td class="center">';
2096 $quantityDelivered = isset(
$object->expeditions[$line->id]) ?
$object->expeditions[$line->id] :
'';
2097 print $quantityDelivered;
2098 print
'<input name="qtydelivered' . $indiceAsked .
'" id="qtydelivered' . $indiceAsked .
'" type="hidden" value="' . $quantityDelivered .
'">';
2099 if ($quantityDelivered) {
2100 print
' ' . $unit_order .
'</td>';
2104 $quantityAsked = $line->qty;
2106 $quantityToBeDelivered = 0;
2108 if (is_numeric($quantityDelivered)) {
2109 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
2111 $quantityToBeDelivered = $quantityAsked;
2115 $warehouseObject =
null;
2116 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !
isModEnabled(
'stock')) {
2117 print
'<!-- Case warehouse already known or product not a predefined product -->';
2119 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
2121 $deliverableQty = $quantityToBeDelivered;
2123 $deliverableQty = min($quantityToBeDelivered, $stock);
2125 if ($deliverableQty < 0) {
2126 $deliverableQty = 0;
2128 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2130 print
'<td class="center">';
2133 $deliverableQty =
GETPOSTFLOAT(
'qtyl'.$indiceAsked,
'MS');
2135 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2136 $qtylValue = $deliverableQty;
2139 } elseif (is_numeric($qtylValue)) {
2141 $qtylValue =
price($qtylValue);
2143 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" class="qtyl right" type="text" size="4" value="' . $qtylValue .
'">';
2146 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2147 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2150 print $langs->trans(
"NA");
2156 print
'<td class="left">';
2159 $ent =
"entl" . $indiceAsked;
2160 $idl =
"idl" . $indiceAsked;
2162 if ($line->fk_product > 0) {
2163 print
'<!-- Show warehouse selection -->';
2169 if ($productChildrenNb > 0) {
2170 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, 0,
'', 0, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2172 if ($product->stockable_product == Product::ENABLED_STOCK) {
2173 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2175 print img_warning() .
' ' . $langs->trans(
'StockDisabled');
2179 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
2181 if ($stock < $quantityToBeDelivered) {
2182 print
' ' . img_warning($langs->trans(
"StockTooLow"));
2187 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span><input name="entl' . $indiceAsked .
'" id="entl' . $indiceAsked .
'" type="hidden" value="0">';
2198 $product->get_sousproduits_arbo();
2199 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2200 if (count($prods_arbo) > 0) {
2201 foreach ($prods_arbo as $key => $value) {
2204 if ($value[
'stock'] < $value[
'stock_alert']) {
2205 $img = img_warning($langs->trans(
"StockTooLow"));
2207 print
"<tr class=\"oddeven\"><td> ->
2208 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2209 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2210 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2220 print
'<td></td><td></td>';
2225 print
'<!-- Case product need lot -->';
2227 $staticwarehouse =
new Entrepot($db);
2228 if ($warehouse_id > 0) {
2229 $staticwarehouse->fetch($warehouse_id);
2235 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2236 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2240 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
2241 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2242 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2244 $batchStock = +$dbatch->qty;
2245 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2248 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2249 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2251 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2252 $alreadyQtyBatchSetted[$line->fk_product] = array();
2255 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2256 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2259 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2262 if ($deliverableQty < 0) {
2263 $deliverableQty = 0;
2266 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2268 $deliverableQty =
GETPOST($inputName,
'int');
2271 $tooltipClass = $tooltipTitle =
'';
2272 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2273 $tooltipClass =
' classfortooltip';
2274 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2276 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2278 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2280 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2281 print
'<td colspan="3" ></td><td class="center">';
2282 $qtylValue = $deliverableQty;
2285 } elseif (is_numeric($qtylValue)) {
2286 $qtylValue =
price($qtylValue);
2288 print
'<input class="qtyl ' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="' . $qtylValue .
'">';
2291 print
'<!-- Show details of lot -->';
2292 print
'<td class="left">';
2294 print $staticwarehouse->getNomUrl(0) .
' / ';
2296 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2299 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
2301 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2304 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2306 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
2310 $quantityToBeDelivered -= $deliverableQty;
2311 if ($quantityToBeDelivered < 0) {
2312 $quantityToBeDelivered = 0;
2317 print
'<td>' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2322 print
'<!-- Case there is no details of lot at all -->';
2323 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2324 print
'<input class="qtyl right" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="0" disabled="disabled"> ';
2327 print
'<td class="left">';
2328 print img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
2338 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2339 print
'<!-- Case warehouse not already known and product does not need lot -->';
2340 print
'<td></td><td></td>';
2344 print
'</tr>' .
"\n";
2346 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2351 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2352 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2356 $tmpwarehouseObject =
new Entrepot($db);
2357 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2359 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2364 $tmpwarehouseObject->fetch($warehouse_id);
2365 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2366 $stock = +$stock_warehouse->real;
2367 $deliverableQty = min($quantityToBeDelivered, $stock);
2368 $deliverableQty = max(0, $deliverableQty);
2370 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2371 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked=' . $indiceAsked .
') -->';
2377 $tooltipClass = $tooltipTitle =
'';
2378 if ($productChildrenNb <= 0) {
2379 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2380 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
2382 if (!isset($alreadyQtySetted[$line->fk_product])) {
2383 $alreadyQtySetted[$line->fk_product] = array();
2386 $deliverableQty = min($quantityToBeDelivered, $stock);
2389 if ($deliverableQty < 0) {
2390 $deliverableQty = 0;
2393 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2394 $tooltipClass =
' classfortooltip';
2395 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2397 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
2400 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2403 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
2407 $qtylValue = $deliverableQty;
2410 } elseif (is_numeric($qtylValue)) {
2411 $qtylValue =
price($qtylValue);
2413 print
'<input class="qtyl' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="text" size="4" value="' . $qtylValue .
'">';
2414 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_id .
'">';
2417 print
'<input name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2420 print $langs->trans(
"NA");
2425 print
'<td class="left">';
2427 if ($product->stockable_product == Product::ENABLED_STOCK || $productChildrenNb > 0) {
2428 print $tmpwarehouseObject->getNomUrl(0) .
' ';
2429 if ($productChildrenNb <= 0) {
2430 print
'<!-- Show details of stock -->';
2431 print
'(' . $stock .
')';
2434 print img_warning() .
' ' . $langs->trans(
'StockDisabled');
2437 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2440 $quantityToBeDelivered -= $deliverableQty;
2441 if ($quantityToBeDelivered < 0) {
2442 $quantityToBeDelivered = 0;
2453 $product->get_sousproduits_arbo();
2454 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2455 if (count($prods_arbo) > 0) {
2456 foreach ($prods_arbo as $key => $value) {
2459 if ($value[
'stock'] < $value[
'stock_alert']) {
2460 $img = img_warning($langs->trans(
"StockTooLow"));
2462 print
'<tr class"oddeven"><td>';
2463 print
" ->
2464 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2465 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2466 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2475 print
'<!-- Case warehouse not already known and product need lot -->';
2476 print
'<td></td><td></td>';
2483 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2485 $tmpwarehouseObject =
new Entrepot($db);
2490 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2491 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2492 $nbofsuggested += count($stock_warehouse->detail_batch);
2496 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2498 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2503 $tmpwarehouseObject->fetch($warehouse_id);
2504 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2505 foreach ($stock_warehouse->detail_batch as $dbatch) {
2506 $batchStock = +$dbatch->qty;
2507 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2508 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2510 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2511 $alreadyQtyBatchSetted[$line->fk_product] = array();
2514 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2515 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2518 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2521 if ($deliverableQty < 0) {
2522 $deliverableQty = 0;
2525 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2530 $tooltipClass = $tooltipTitle =
'';
2531 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2532 $tooltipClass =
' classfortooltip';
2533 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2535 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2537 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2539 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'><td colspan="3"></td><td class="center">';
2540 $qtylValue = $deliverableQty;
2543 } elseif (is_numeric($qtylValue)) {
2544 $qtylValue =
price($qtylValue);
2546 print
'<input class="qtyl right ' . $tooltipClass .
'" title="' . $tooltipTitle .
'" name="' . $inputName .
'" id="' . $inputName .
'" type="text" size="4" value="' . $qtylValue .
'">';
2549 print
'<td class="left">';
2551 print $tmpwarehouseObject->getNomUrl(0) .
' / ';
2553 print
'<!-- Show details of lot -->';
2554 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2555 print
'<input name="entl' . $indiceAsked .
'_'.$subj.
'" type="hidden" value="' . $tmpwarehouseObject->id .
'">';
2558 print $langs->trans(
"Batch") .
': ';
2559 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
2561 print $productlotObject->getNomUrl(1);
2563 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
2566 print
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2569 print
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2571 print
' (' . $dbatch->qty .
')';
2572 $quantityToBeDelivered -= $deliverableQty;
2573 if ($quantityToBeDelivered < 0) {
2574 $quantityToBeDelivered = 0;
2580 print
'<td class="left">' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2588 $warehouse_selected_id =
GETPOSTINT(
'entrepot_id');
2590 print
'<!-- line not shown yet, we show it -->';
2591 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2596 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2597 $disabled =
'disabled="disabled"';
2598 $alt =
'Product need serial or batch number';
2600 if ($warehouse_selected_id <= 0) {
2601 $disabled =
'disabled="disabled"';
2604 if ($product->stockable_product == Product::ENABLED_STOCK) {
2607 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').($alt ?
' title="'.dolPrintHTMLForAttribute($alt).
'"' :
'').
'> ';
2609 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
2615 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2616 $disabled =
'disabled="disabled"';
2618 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$quantityToBeDelivered.
'"'.($disabled ?
' '.$disabled :
'').
'> ';
2622 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="0">';
2624 print $langs->trans(
"NA");
2628 print
'<td class="left">';
2631 if (($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK)) {
2632 $warehouseObject =
new Entrepot($db);
2633 $warehouseObject->fetch($warehouse_selected_id);
2634 print img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
2636 if ($line->fk_product) {
2637 if ($product->stockable_product != Product::ENABLED_STOCK) {
2638 print img_warning() .
' ' . $langs->trans(
'StockDisabled');
2640 print img_warning() .
' ' . $langs->trans(
'StockTooLow');
2647 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2656 } elseif (empty($reshook) && $line->special_code == SUBTOTALS_SPECIAL_CODE && !in_array($line->id, $title_lines_to_disable)) {
2657 require
dol_buildpath(
'/core/tpl/subtotalline_select.tpl.php');
2668 print $form->buttonsSaveCancel(
"Create");
2674 dol_print_error($db);
2678 '@phan-var-force Expedition $object';
2684 $num_prod = count($lines);
2687 $typeobject =
$object->origin;
2688 $origin = (string)
$object->origin;
2689 $origin_id =
$object->origin_id;
2697 $res =
$object->fetch_optionals();
2700 print
dol_get_fiche_head($head,
'shipping', $langs->trans(
"Shipment"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2705 if ($action ==
'delete') {
2706 $formquestion = array();
2708 $formquestion = array(
2710 'type' =>
'onecolumn',
2711 'value' => img_warning().
' <strong>'.$langs->trans(
'WarningShipmentDeleteStockMovement').
'</strong>',
2714 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
2715 'name' =>
'alsoUpdateStock',
2716 'type' =>
'checkbox',
2721 $formconfirm = $form->formconfirm(
2722 $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
2723 $langs->trans(
'DeleteSending'),
2724 $langs->trans(
"ConfirmDeleteSending",
$object->ref),
2734 if ($action ==
'ask_subtotal_deleteline') {
2736 $langs->load(
"subtotals");
2737 $title =
"DeleteSubtotalLine";
2738 $question =
"ConfirmDeleteSubtotalLine";
2739 if (
GETPOST(
'type') ==
'title') {
2740 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2741 $title =
"DeleteTitleLine";
2742 $question =
"ConfirmDeleteTitleLine";
2744 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2748 if ($action ==
'valid') {
2749 $objectref = substr(
$object->ref, 1, 4);
2750 if ($objectref ==
'PROV') {
2751 $numref =
$object->getNextNumRef($soc);
2753 $numref = (string)
$object->ref;
2756 $text = $langs->trans(
"ConfirmValidateSending", $numref);
2758 $text .=
'<br>' . img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementWillBeRecorded") .
'.';
2760 $text .=
'<br>' . img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementNotYetRecorded") .
'.';
2764 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2765 $notify =
new Notify($db);
2767 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE',
$object->socid, $object);
2770 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 260);
2774 if ($action ==
'cancel') {
2775 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending",
$object->ref),
'confirm_cancel',
'', 0, 1);
2779 if ($action ==
'sign') {
2780 $text = $langs->trans(
'ConfirmSignShipping');
2782 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2783 $notify =
new Notify($db);
2785 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2790 'name' =>
'signed_status',
2791 'select_show_empty' => 0,
2792 'label' =>
'<span class="fieldrequired">' . $langs->trans(
'SignStatus') .
'</span>',
2793 'values' =>
$object->getSignedStatusLocalisedArray()
2795 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'SignShipping'), $text,
'confirm_sign', $formquestion, 0, 1);
2799 if ($action ==
'unsign') {
2800 $text = $langs->trans(
'ConfirmUnsignShipping');
2802 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2803 $notify =
new Notify($db);
2805 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2807 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnsignShipping'), $text,
'confirm_unsign',
'', 0, 1);
2811 $parameters = array(
'formConfirm' => $formconfirm);
2812 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2813 if (empty($reshook)) {
2814 $formconfirm .= $hookmanager->resPrint;
2815 } elseif ($reshook > 0) {
2816 $formconfirm = $hookmanager->resPrint;
2824 $tmparray =
$object->getTotalWeightVolume();
2825 $totalWeight = $tmparray[
'weight'];
2826 $totalVolume = $tmparray[
'volume'];
2828 if (!empty($typeobject) && $typeobject ===
'commande' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2830 $objectsrc->fetch(
$object->origin_object->id);
2832 if (!empty($typeobject) && $typeobject ===
'propal' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2833 $objectsrc =
new Propal($db);
2834 $objectsrc->fetch(
$object->origin_object->id);
2838 $linkback =
'<a href="' . DOL_URL_ROOT .
'/expedition/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2839 $morehtmlref =
'<div class="refidno">';
2841 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
2842 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string' . (isset(
$conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
2845 $morehtmlref .=
'<br>' .
$object->thirdparty->getNomUrl(1);
2848 if ($origin && $origin_id > 0) {
2850 $langs->load(
"projects");
2851 $morehtmlref .=
'<br>';
2853 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2854 if ($action !=
'classify') {
2855 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2857 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $objectsrc->socid, (
string) $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2859 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2861 $proj->fetch($objectsrc->fk_project);
2862 $morehtmlref .= $proj->getNomUrl(1);
2864 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2872 $langs->load(
"projects");
2873 $morehtmlref .=
'<br>';
2874 if ($permissiontoadd) {
2875 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2876 if ($action !=
'classify') {
2877 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2879 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2881 if (!empty(
$object->fk_project)) {
2883 $proj->fetch(
$object->fk_project);
2884 $morehtmlref .= $proj->getNomUrl(1);
2886 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2893 $morehtmlref .=
'</div>';
2894 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2896 print
'<div class="fichecenter">';
2897 print
'<div class="fichehalfleft">';
2898 print
'<div class="underbanner clearboth"></div>';
2900 print
'<table class="border tableforfield centpercent">';
2903 if (!empty($typeobject) && $typeobject ==
'commande' &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2905 print $langs->trans(
"RefOrder") .
'</td>';
2907 print $objectsrc->getNomUrl(1,
'commande');
2911 if (!empty($typeobject) && $typeobject ==
'propal' &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2913 print $langs->trans(
"RefProposal") .
'</td>';
2915 print $objectsrc->getNomUrl(1,
'expedition');
2921 print
'<tr><td class="titlefieldmiddle">' . $langs->trans(
"DateCreation") .
'</td>';
2926 print
'<tr><td height="10">';
2927 print
'<table class="nobordernopadding centpercent"><tr><td>';
2928 print $langs->trans(
'DateDeliveryPlanned');
2930 if ($action !=
'editdate_livraison') {
2931 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editdate_livraison&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->trans(
'SetDeliveryDate'), 1) .
'</a></td>';
2933 print
'</tr></table>';
2935 if ($action ==
'editdate_livraison') {
2936 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2937 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2938 print
'<input type="hidden" name="action" value="setdate_livraison">';
2939 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2940 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2949 print
'<tr><td height="10">';
2950 print
'<table class="nobordernopadding centpercent"><tr><td>';
2951 print $langs->trans(
'DateShipping');
2953 if ($action !=
'editdate_shipping') {
2954 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editdate_shipping&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->trans(
'SetShippingDate'), 1) .
'</a></td>';
2956 print
'</tr></table>';
2958 if ($action ==
'editdate_shipping') {
2959 print
'<form name="setdate_shipping" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2960 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2961 print
'<input type="hidden" name="action" value="setdate_shipping">';
2962 print $form->selectDate(
$object->date_shipping ?
$object->date_shipping : -1,
'ship_', 1, 1, 0,
"setdate_shipping", 1, 0);
2963 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2973 print $form->editfieldkey(
"Weight",
'trueWeight',
$object->trueWeight, $object, $user->hasRight(
'expedition',
'creer'));
2976 if ($action ==
'edittrueWeight') {
2977 print
'<form name="settrueweight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2978 print
'<input name="action" value="settrueWeight" type="hidden">';
2979 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
2980 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2981 print
'<input id="trueWeight" name="trueWeight" value="' .
$object->trueWeight .
'" type="text" class="width50 valignmiddle">';
2982 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2983 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
2984 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
2992 if ($totalWeight > 0) {
2993 if (!empty(
$object->trueWeight)) {
2994 print
' (' . $langs->trans(
"SumOfProductWeights") .
': ';
2997 if (!empty(
$object->trueWeight)) {
3004 print
'<tr><td>' . $form->editfieldkey(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3005 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer'));
3010 print
'<tr><td>' . $form->editfieldkey(
"Height",
'trueHeight',
$object->trueHeight, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3011 if ($action ==
'edittrueHeight') {
3012 print
'<form name="settrueHeight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
3013 print
'<input name="action" value="settrueHeight" type="hidden">';
3014 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
3015 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3016 print
'<input id="trueHeight" name="trueHeight" value="' .
$object->trueHeight .
'" type="text" class="width50">';
3017 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
3018 print
' <input class="button smallpaddingimp" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
3019 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
3029 print
'<tr><td>' . $form->editfieldkey(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3030 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer'));
3036 print $langs->trans(
"Volume");
3039 $calculatedVolume = 0;
3043 $volumeUnit =
$object->size_units * 3;
3046 if ($calculatedVolume > 0) {
3047 if ($volumeUnit < 50) {
3053 if ($totalVolume > 0) {
3054 if ($calculatedVolume) {
3055 print
' (' . $langs->trans(
"SumOfProductVolumes") .
': ';
3059 if ($calculatedVolume) {
3068 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3073 print
'<div class="fichehalfright">';
3074 print
'<div class="underbanner clearboth"></div>';
3076 print
'<table class="border centpercent tableforfield">';
3080 print
'<table class="nobordernopadding centpercent"><tr><td>';
3081 print $langs->trans(
'SendingMethod');
3084 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
3085 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editshipping_method_id&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->trans(
'SetSendingMethod'), 1) .
'</a></td>';
3087 print
'</tr></table>';
3089 if ($action ==
'editshipping_method_id') {
3090 print
'<form name="setshipping_method_id" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3091 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3092 print
'<input type="hidden" name="action" value="setshipping_method_id">';
3093 $object->fetch_delivery_methods();
3094 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
3096 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3098 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
3101 if (
$object->shipping_method_id > 0) {
3103 $code = $langs->getLabelFromKey($db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
3104 print $langs->trans(
"SendingMethod" . strtoupper($code));
3111 print
'<tr><td class="titlefieldmiddle">' . $form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3112 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url, $object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring',
$object->tracking_number);
3118 print
'<table class="nobordernopadding centpercent"><tr><td>';
3119 print $langs->trans(
'IncotermLabel');
3120 print
'<td><td class="right">';
3121 if ($permissiontoadd) {
3122 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/expedition/card.php?id=' .
$object->id .
'&action=editincoterm&token=' .
newToken() .
'">' . img_edit() .
'</a>';
3126 print
'</td></tr></table>';
3129 if ($action !=
'editincoterm') {
3130 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3132 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3138 $parameters = array();
3139 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
3140 print $hookmanager->resPrint;
3147 print
'<div class="clearboth"></div>';
3156 if (!empty(
$object->table_element_line)) {
3158 $result =
$object->getLinesArray();
3160 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
3161 <input type="hidden" name="token" value="' .
newToken().
'">
3162 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3163 <input type="hidden" name="mode" value="">
3164 <input type="hidden" name="page_y" value="">
3165 <input type="hidden" name="id" value="' .
$object->id.
'">
3168 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
3169 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3172 print
'<div class="div-table-responsive-no-min">';
3173 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3174 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3182 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
3183 if ($action !=
'editline') {
3186 $parameters = array();
3187 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3189 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
3191 if (empty($reshook)) {
3197 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3208 if ($action ==
'editline') {
3209 print
' <form name="updateline" id="updateline" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $line_id .
'" method="POST">
3210 <input type="hidden" name="token" value="' .
newToken() .
'">
3211 <input type="hidden" name="action" value="updateline">
3212 <input type="hidden" name="mode" value="">
3213 <input type="hidden" name="id" value="' .
$object->id .
'">
3218 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3221 print
'<div class="div-table-responsive-no-min">';
3222 print
'<table class="noborder centpercent" id="tablelines" >';
3224 print
'<tr class="liste_titre">';
3227 print
'<td width="5" class="center linecolnum"> </td>';
3230 print
'<td class="linecoldescription" >' . $langs->trans(
"Products") .
'</td>';
3232 print
'<td class="center linecolqty">' . $langs->trans(
"QtyOrdered") .
'</td>';
3233 if ($origin_id > 0) {
3234 print
'<td class="center linecolqtyinothershipments">' . $langs->trans(
"QtyInOtherShipments") .
'</td>';
3236 if ($action ==
'editline') {
3244 print
'<td class="center linecoleditlineotherinfo" colspan="' . $editColspan .
'">';
3246 print $langs->trans(
"QtyToShip");
3248 print $langs->trans(
"QtyShipped");
3251 print
' - ' . $langs->trans(
"WarehouseSource");
3254 print
' - ' . $langs->trans(
"Batch");
3259 print
'<td class="center linecolqtytoship">' . $langs->trans(
"QtyToShip") .
'</td>';
3261 print
'<td class="center linecolqtyshipped">' . $langs->trans(
"QtyShipped") .
'</td>';
3264 print
'<td class="left linecolwarehousesource">' . $langs->trans(
"WarehouseSource") .
'</td>';
3268 print
'<td class="left linecolbatch">' . $langs->trans(
"Batch") .
'</td>';
3271 print
'<td class="center linecolweight">' . $langs->trans(
"CalculatedWeight") .
'</td>';
3272 print
'<td class="center linecolvolume">' . $langs->trans(
"CalculatedVolume") .
'</td>';
3275 print
'<td class="linecoledit"></td>';
3276 print
'<td class="linecoldelete" width="10"></td>';
3277 print
'<td class="linecolmove"></td>';
3282 $outputlangs = $langs;
3287 if (
GETPOST(
'lang_id',
'aZ09')) {
3288 $newlang =
GETPOST(
'lang_id',
'aZ09');
3290 if (empty($newlang)) {
3291 $newlang =
$object->thirdparty->default_lang;
3293 if (!empty($newlang)) {
3295 $outputlangs->setDefaultLang($newlang);
3299 $origin = (string) $origin;
3300 if (empty($origin) || $origin ==
'order') {
3301 $origin =
'commande';
3305 if (!in_array($origin, array(
'supplier_proposal',
'supplier_order',
'commande_fournisseur',
'facture_fourn',
'propal',
'commande',
'facture'))) {
3306 dol_print_error($db,
'Bad value for parameter origin in expedition/card.php');
3311 $alreadysent = array();
3312 if ($origin_id > 0) {
3313 $tablenametouse = (($origin ==
'supplier_order') ?
'commande_fournisseur' : (($origin ==
'facture_fourn') ?
'facture_fourn_' : $origin));
3315 $sql =
"SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end, obj.special_code";
3316 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot";
3317 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
3318 $sql .=
', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch';
3319 $sql .=
', p.description as product_desc';
3320 $sql .=
" FROM " . MAIN_DB_PREFIX .
"expeditiondet as ed";
3321 $sql .=
", " . MAIN_DB_PREFIX .
"expedition as e";
3322 $sql .=
", " . MAIN_DB_PREFIX . $db->sanitize($tablenametouse) .
"det as obj";
3323 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product as p ON obj.fk_product = p.rowid";
3324 $sql .=
" WHERE e.entity IN (" .
getEntity(
'expedition') .
")";
3325 $sql .=
" AND obj.fk_" . $db->sanitize((
string) $origin) .
" = " . ((int) $origin_id);
3326 $sql .=
" AND obj.rowid = ed.fk_elementdet";
3327 $sql .=
" AND ed.fk_expedition = e.rowid";
3329 $sql .=
" ORDER BY obj.fk_product";
3331 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
3332 $resql = $db->query($sql);
3334 $num = $db->num_rows($resql);
3338 $obj = $db->fetch_object($resql);
3341 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
3342 'shipment_ref' => $obj->shipment_ref,
3343 'shipment_id' => $obj->shipment_id,
3344 'warehouse' => $obj->fk_entrepot,
3345 'qty_shipped' => $obj->qty_shipped,
3346 'product_tosell' => $obj->product_tosell,
3347 'product_tobuy' => $obj->product_tobuy,
3348 'product_tobatch' => $obj->product_tobatch,
3349 'date_valid' => $db->jdate($obj->date_valid),
3350 'date_delivery' => $db->jdate($obj->date_delivery));
3361 $conf->cache[
'product'] = array();
3362 $conf->cache[
'warehouse'] = array();
3363 for ($i = 0; $i < $num_prod; $i++) {
3364 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
3365 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
3367 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
3370 if (empty($reshook) && $lines[$i]->product_type !=
"9") {
3371 print
'<!-- origin line id = ' . $lines[$i]->origin_line_id .
' -->';
3372 print
'<tr class="oddeven" id="row-' . $lines[$i]->id .
'" data-id="' . $lines[$i]->id .
'" data-element="' . $lines[$i]->element .
'" >';
3374 $line->fetch_optionals();
3378 print
'<td class="center linecolnum">' . ($i + 1) .
'</td>';
3382 if ($lines[$i]->fk_product > 0) {
3385 $product_id = $lines[$i]->fk_product;
3386 if (!isset(
$conf->cache[
'product'][$product_id])) {
3388 $prod->fetch($product_id);
3389 $conf->cache[
'product'][$product_id] =
$prod;
3391 $prod =
$conf->cache[
'product'][$product_id];
3393 $label = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"label"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
3395 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
3398 print
'<td class="linecoldescription">';
3401 $product_static->type = $lines[$i]->fk_product_type;
3402 $product_static->id = $lines[$i]->fk_product;
3403 $product_static->ref = $lines[$i]->ref;
3404 $product_static->status = $lines[$i]->product_tosell;
3405 $product_static->status_buy = $lines[$i]->product_tobuy;
3406 $product_static->status_batch = $lines[$i]->product_tobatch;
3408 $product_static->weight = $lines[$i]->weight;
3409 $product_static->weight_units = $lines[$i]->weight_units;
3410 $product_static->length = $lines[$i]->length;
3411 $product_static->length_units = $lines[$i]->length_units;
3412 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
3413 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
3414 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
3415 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
3416 $product_static->surface = $lines[$i]->surface;
3417 $product_static->surface_units = $lines[$i]->surface_units;
3418 $product_static->volume = $lines[$i]->volume;
3419 $product_static->volume_units = $lines[$i]->volume_units;
3420 $product_static->stockable_product = $lines[$i]->stockable_product;
3422 $text = $product_static->getNomUrl(1);
3423 $text .=
' - ' . $label;
3425 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
3426 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
3430 $lineExtrafieldsHtml = $line->showOptionals($extrafields, ($action ==
'editline' && $line->id == $line_id) ?
'edit' :
'view', array(),
'',
'',
'1',
'line');
3431 if (!empty($lineExtrafieldsHtml)) {
3432 print
'<div style="padding-top: 10px" id="extrafield_lines_area_' . $line->id .
'" name="extrafield_lines_area_' . $line->id .
'">';
3433 print $lineExtrafieldsHtml;
3438 print
'<td class="linecoldescription" >';
3440 $text = img_object($langs->trans(
'Service'),
'service');
3442 $text = img_object($langs->trans(
'Product'),
'product');
3445 if (!empty($lines[$i]->label)) {
3446 $text .=
' <strong>' . $lines[$i]->label .
'</strong>';
3447 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
3449 print $text .
' ' . nl2br($lines[$i]->
description);
3453 $lineExtrafieldsHtml = $line->showOptionals($extrafields, ($action ==
'editline' && $line->id == $line_id) ?
'edit' :
'view', array(),
'',
'',
'1',
'line');
3454 if (!empty($lineExtrafieldsHtml)) {
3455 print
'<div style="padding-top: 10px" id="extrafield_lines_area_' . $line->id .
'" name="extrafield_lines_area_' . $line->id .
'">';
3456 print $lineExtrafieldsHtml;
3468 print
'<td class="center linecolqty">' . $lines[$i]->qty_asked .
' ' . $unit_order .
'</td>';
3471 if ($origin_id > 0) {
3472 print
'<td class="linecolqtyinothershipments center nowrap">';
3474 $qtyalreadysent = 0;
3475 foreach ($alreadysent as $key => $val) {
3476 if ($lines[$i]->fk_elementdet == $key) {
3478 foreach ($val as $shipmentline_id => $shipmentline_var) {
3479 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
3485 $htmltooltip .=
'<br>';
3487 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
3488 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
3489 $htmltooltip .=
' - ' . $shipmentline_var[
'qty_shipped'];
3490 $htmltooltip .=
' - ' . $langs->trans(
"DateValidation") .
' : ' . (empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
3497 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
3500 $htmltooltip = $langs->trans(
"QtyInOtherShipments") .
'...<br><br>' . $htmltooltip .
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
3504 print $form->textwithpicto((
string) $qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip' . $lines[$i]->id);
3508 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3510 print
'<td colspan="' . $editColspan .
'" class="center"><table class="nobordernopadding centpercent">';
3511 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
3512 print
'<!-- case edit 1 -->';
3514 foreach ($lines[$i]->detail_batch as $detail_batch) {
3517 print
'<td><input class="qtyl right" name="qtyl' . $detail_batch->fk_expeditiondet .
'_' . $detail_batch->id .
'" id="qtyl' . $line_id .
'_' . $detail_batch->id .
'" type="text" size="4" value="' . $detail_batch->qty .
'"></td>';
3519 if ($lines[$i]->entrepot_id == 0) {
3521 $line->fetch($detail_batch->fk_expeditiondet);
3523 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
3524 print
'<td>' . $formproduct->selectLotStock($detail_batch->fk_origin_stock,
'batchl' . $detail_batch->fk_expeditiondet .
'_' . $detail_batch->fk_origin_stock,
'', 1, 0, $lines[$i]->fk_product, $entrepot_id) .
'</td>';
3530 print
'<td><input class="qtyl" name="qtyl' . $line_id .
'_0" id="qtyl' . $line_id .
'_0" type="text" size="4" value="0"></td>';
3532 print
'<td>' . $formproduct->selectLotStock(
'',
'batchl' . $line_id .
'_0',
'', 1, 0, $lines[$i]->fk_product) .
'</td>';
3535 if ($lines[$i]->fk_product > 0) {
3536 if ($lines[$i]->entrepot_id > 0) {
3537 print
'<!-- case edit 2 -->';
3540 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'">' . $unit_order .
'</td>';
3542 print
'<td>' . $formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl' . $line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3546 print
' - ' . $langs->trans(
"NA");
3550 } elseif (count($lines[$i]->details_entrepot) > 1) {
3551 print
'<!-- case edit 3 -->';
3552 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3555 print
'<td><input class="qtyl right" name="qtyl' . $detail_entrepot->line_id .
'" id="qtyl' . $detail_entrepot->line_id .
'" type="text" size="4" value="' . $detail_entrepot->qty_shipped .
'">' . $unit_order .
'</td>';
3557 print
'<td>' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl' . $detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3561 print
' - ' . $langs->trans(
"NA");
3567 print
'<!-- case edit 4 -->';
3570 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3571 print
'<td><span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span></td>';
3575 print
'<!-- case edit 5 -->';
3576 print
'<tr><td colspan="3">' . $langs->trans(
"ErrorStockIsNotEnough") .
'</td></tr>';
3579 print
'<!-- case edit 6 -->';
3582 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'">' . $unit_order .
'</td>';
3590 print
'<!-- case edit 7 -->';
3593 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3601 print
'</table></td>';
3604 print
'<td class="linecolqtytoship center">' . $lines[$i]->qty_shipped .
' ' . $unit_order .
'</td>';
3608 print
'<td class="linecolwarehousesource tdoverflowmax200">';
3610 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
3611 } elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) {
3612 $warehouse_id = $lines[$i]->entrepot_id;
3613 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
3615 $warehouse->fetch($warehouse_id);
3616 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3618 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
3620 print $warehouse->getNomUrl(1);
3621 } elseif (count($lines[$i]->details_entrepot) > 1) {
3623 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3624 $warehouse_id = $detail_entrepot->entrepot_id;
3625 if ($warehouse_id > 0) {
3626 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
3628 $warehouse->fetch($warehouse_id);
3629 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3631 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
3633 $detail .= $langs->trans(
"DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped) .
'<br>';
3636 print $form->textwithtooltip(img_picto(
'',
'object_stock') .
' ' . $langs->trans(
"DetailWarehouseNumber"), $detail);
3637 } elseif (count($lines[$i]->detail_children ?? []) > 1) {
3639 foreach ($lines[$i]->detail_children as $child_product_id => $child_stock_list) {
3640 foreach ($child_stock_list as $warehouse_id => $total_qty) {
3642 $child_product_label =
'';
3643 if (!isset(
$conf->cache[
'product'][$child_product_id])) {
3644 $child_product =
new Product($db);
3645 $child_product->fetch($child_product_id);
3646 $conf->cache[
'product'][$child_product_id] = $child_product;
3648 $child_product =
$conf->cache[
'product'][$child_product_id];
3650 $child_product_label = $child_product->ref .
' ' . $child_product->label;
3653 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
3654 $child_warehouse =
new Entrepot($db);
3655 $child_warehouse->fetch($warehouse_id);
3656 $conf->cache[
'warehouse'][$warehouse_id] = $child_warehouse;
3658 $child_warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
3660 $detail .= $langs->trans(
'DetailChildrenFormat', $child_product_label, $child_warehouse->label,
price2num($total_qty,
'MS')) .
'<br>';
3663 print $form->textwithtooltip(img_picto(
'',
'object_stock') .
' ' . $langs->trans(
'DetailWarehouseNumber'), $detail);
3670 if (isset($lines[$i]->detail_batch)) {
3671 print
'<!-- Detail of lot -->';
3672 print
'<td class="linecolbatch">';
3673 if ($lines[$i]->product_tobatch) {
3675 foreach ($lines[$i]->detail_batch as $dbatch) {
3676 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
3678 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
3681 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
3683 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
3686 print $form->textwithtooltip(img_picto(
'',
'object_barcode') .
' ' . $langs->trans(
"DetailBatchNumber"), $detail);
3688 print $langs->trans(
"NA");
3692 print
'<td class="linecolbatch" ></td>';
3698 print
'<td class="center linecolweight">';
3700 print $lines[$i]->weight * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
3707 print
'<td class="center linecolvolume">';
3709 print $lines[$i]->volume * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
3720 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3721 print
'<td class="center" colspan="2" valign="middle">';
3722 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="' . $langs->trans(
"Save") .
'"><br>';
3723 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="' . $langs->trans(
"Cancel") .
'"><br>';
3726 print
'<td class="linecolmove tdlineupdown center"></td>';
3728 } elseif ($showmovecol) {
3729 $edit_url = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id;
3731 $product_id = $lines[$i]->fk_product;
3732 if (!isset(
$conf->cache[
'product'][$product_id])) {
3734 $product->fetch($product_id);
3735 $conf->cache[
'product'][$product_id] = $product;
3737 $product =
$conf->cache[
'product'][$product_id];
3740 if ($product->hasFatherOrChild(1)) {
3746 print
'<td class="linecoledit center">';
3747 print
'<a class="editfielda reposition" href="' . $edit_url .
'">' . img_edit() .
'</a>';
3749 print
'<td class="linecoldelete" width="10">';
3750 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id .
'">' . img_delete() .
'</a>';
3752 print
'<td class="linecolmove tdlineupdown center">';
3753 if ($usercancreate && $num_prod > 1) {
3755 print
'<a class="lineupdown" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=up&token=' .
newToken() .
'&rowid=' . $lines[$i]->id .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
3757 if ($i < $num_prod - 1) {
3758 print
'<a class="lineupdown" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=down&token=' .
newToken() .
'&rowid=' . $lines[$i]->id .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
3763 if (isset($rowExtrafieldsStart, $rowExtrafieldsView, $rowEnd)) {
3764 print $rowExtrafieldsStart;
3765 print $rowExtrafieldsView;
3770 } elseif (empty($reshook) && $lines[$i]->product_type ==
"9") {
3772 $objectsrc->fetch($lines[$i]->origin_line_id);
3773 if ($objectsrc->special_code == SUBTOTALS_SPECIAL_CODE) {
3775 require
dol_buildpath(
'/core/tpl/subtotal_expedition_view.tpl.php');
3780 if (empty($num_prod)) {
3781 print
'<tr><td colspan="8"><span class="opacitymedium">' . $langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")) .
'</span></td></tr>';
3787 if ($action ==
'editline') {
3798 if (($user->socid == 0) && ($action !=
'presend') && ($action !=
'editline')) {
3799 print
'<div class="tabsAction">';
3801 $parameters = array();
3802 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3804 if (empty($reshook)) {
3806 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
3807 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))
3809 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=valid&token=' .
newToken() .
'&id=' .
$object->id,
'');
3811 print dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3817 if ($user->hasRight(
'expedition',
'creer')) {
3818 print dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=setdraft&token=' .
newToken() .
'&id=' .
$object->id,
'');
3822 if ($user->hasRight(
'expedition',
'creer')) {
3823 print dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=reopen&token=' .
newToken() .
'&id=' .
$object->id,
'');
3828 if (empty($user->socid)) {
3830 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
3831 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3833 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3841 print dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=create_delivery&token=' .
newToken() .
'&id=' .
$object->id,
'');
3846 if (
$object->signed_status != Expedition::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
3847 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=sign&token=' .
newToken() .
'">' . $langs->trans(
"SignShipping") .
'</a></div>';
3849 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=unsign&token=' .
newToken() .
'">' . $langs->trans(
"UnsignShipping") .
'</a></div>';
3855 if ($user->hasRight(
'facture',
'creer')) {
3857 print dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT .
'/compta/facture/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
'');
3864 if ($user->hasRight(
'expedition',
'creer') &&
$object->status > 0) {
3866 print dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3868 print dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifyclosed&token=' .
newToken() .
'&id=' .
$object->id,
'');
3874 if ($user->hasRight(
'expedition',
'creer')) {
3875 print dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=cancel&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'',
true, array(
'attr' => array(
'classOverride' =>
'butAction butActionDanger'))).
"\n";
3880 if ($user->hasRight(
'expedition',
'supprimer')) {
3881 print dolGetButtonAction($langs->trans(
'Delete'), $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"] .
'?action=delete&token=' .
newToken() .
'&id=' .
$object->id,
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
3893 if ($action !=
'presend' && $action !=
'editline') {
3894 print
'<div class="fichecenter"><div class="fichehalfleft">';
3897 $filedir =
$conf->expedition->dir_output .
"/sending/" . $objectref;
3899 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
3901 $genallowed = $user->hasRight(
'expedition',
'lire');
3902 $delallowed = $user->hasRight(
'expedition',
'creer');
3904 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3908 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'shipping'), 1);
3909 $linktoelem = $tmparray[
'linktoelem'];
3910 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3911 print $htmltoenteralink;
3913 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3919 print
'<br><!-- Link to sign -->';
3920 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
3921 print showOnlineSignatureUrl(
'expedition',
$object->ref, $object) .
'<br>';
3924 print
'</div><div class="fichehalfright">';
3928 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3933 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT .
'/expedition/messaging.php?id=' .
$object->id);
3935 $somethingshown = $formactions->showactions($object,
'shipping', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3936 print
'</div></div>';
3945 if (
GETPOST(
'modelselected')) {
3946 $action =
'presend';
3950 $modelmail =
'shipping_send';
3951 $defaulttopic =
'SendShippingRef';
3952 $diroutput =
$conf->expedition->dir_output .
'/sending';
3953 $trackid =
'shi' .
$object->id;
3955 include DOL_DOCUMENT_ROOT .
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
const STATUS_DRAFT
Draft status.
const STATUS_CANCELED
Canceled status.
const STATUS_CLOSED
Closed status -> parcel was received by customer / end of process prev status : validated or shipment...
const STATUS_VALIDATED
Validated status -> parcel is ready to be sent prev status : draft next status : closed or shipment_i...
Class to manage lines of shipment.
CRUD class for batch number management within shipment.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage order lines.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage products or services.
const DISABLED_STOCK
Stockable product.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Manage record for batch number management.
Class with list of lots and properties.
Class to manage projects.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
shipping_prepare_head($object)
Prepare array with list of tabs.