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 .
'/core/class/extrafields.class.php';
60require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
61require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/productlot.class.php';
62require_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
64 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
67 require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
70 require_once DOL_DOCUMENT_ROOT .
'/product/class/productbatch.class.php';
73 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
74 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
78$langs->loadLangs(array(
"sendings",
"companies",
"bills",
'orders',
'stocks',
'other',
'propal',
'productbatch'));
81 $langs->load(
'incoterm');
84 $langs->load(
'productbatch');
88$origin =
GETPOST(
'origin',
'alpha');
93if (empty($origin_id) && !empty($origin)) {
96if (empty($origin_id) && !empty($origin)) {
105$action =
GETPOST(
'action',
'alpha');
106$confirm =
GETPOST(
'confirm',
'alpha');
107$cancel =
GETPOST(
'cancel',
'alpha');
110$backtopage =
GETPOST(
'backtopage',
'alpha');
122$extrafields->fetch_name_optionals_label(
$object->table_element);
123$extrafields->fetch_name_optionals_label(
$object->table_element_line);
124$extrafields->fetch_name_optionals_label($objectorder->table_element_line);
127include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
130$usercanread = $user->hasRight(
"expedition",
"lire");
131$usercancreate = $user->hasRight(
"expedition",
"creer");
132$usercandelete = $user->hasRight(
"expedition",
"supprimer");
135$hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
146 $socid = $user->socid;
151$permissiondellink = $user->hasRight(
'expedition',
'delivery',
'creer');
152$permissiontoadd = $user->hasRight(
'expedition',
'creer');
153$permissiontoedit = $usercancreate;
154$permissiontoeditextra = $permissiontoadd;
155if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
157 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
160$upload_dir = $conf->expedition->dir_output .
'/sending';
166$shipping_method_id =
null;
176$parameters = array();
177$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
182if (empty($reshook)) {
183 $backurlforlist = DOL_URL_ROOT.
'/expedition/list.php';
185 if (empty($backtopage) || ($cancel && empty($id))) {
186 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
187 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
188 $backtopage = $backurlforlist;
190 $backtopage = DOL_URL_ROOT.
'/expedition/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
196 if (!empty($backtopageforcancel)) {
197 header(
"Location: ".$backtopageforcancel);
199 } elseif (!empty($backtopage)) {
200 header(
"Location: ".$backtopage);
208 if ($origin_id > 0) {
209 if ($origin ==
'commande') {
210 header(
"Location: " . DOL_URL_ROOT .
'/expedition/shipment.php?id=' . ((
int) $origin_id));
219 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
222 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
227 setEventMessages($langs->trans(
"StatusOfRefMustBe",
$object->ref, $langs->transnoentitiesnoconv(
"StatusSendingDraftShort")),
null,
'errors');
233 if ($action ==
'setdraft' && $permissiontoadd) {
235 $result =
$object->setDraft($user, 0);
239 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
244 if ($action ==
'reopen' && $permissiontoadd) {
250 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
256 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
260 if ($action ==
'classin' && $permissiontoadd) {
268 if ($action ==
'setref_customer' && $permissiontoadd) {
274 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPPING_MODIFY');
277 $action =
'editref_customer';
279 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
284 if ($action ==
'update_extras' && $permissiontoeditextra) {
287 $attribute_name =
GETPOST(
'attribute',
'aZ09');
290 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
297 $result =
$object->updateExtraField($attribute_name,
'SHIPPING_MODIFY');
305 $action =
'edit_extras';
310 if ($action ==
'add' && $permissiontoadd) {
313 if ($origin && $origin_id > 0) {
315 $classname = ucfirst($origin);
316 $objectsrc =
new $classname($db);
317 '@phan-var-force Facture|Commande $objectsrc';
318 $objectsrc->fetch($origin_id);
319 $object->socid = $objectsrc->socid;
324 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
333 $object->origin_type = $origin;
334 $object->origin_id = $origin_id;
344 $object->date_delivery = $date_delivery;
345 $object->date_shipping = $date_shipping;
352 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
357 $ret = $extrafields->setOptionalsFromPost(
null, $object);
371 if ($origin && $origin_id > 0) {
373 $object->origin_type = $origin;
374 $object->origin_id = $origin_id;
384 $object->date_delivery = $date_delivery;
385 $object->date_shipping = $date_shipping;
392 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
395 $classname = ucfirst(
$object->origin_type);
396 $objectsrc =
new $classname($db);
397 '@phan-var-force Facture|Commande $objectsrc';
398 $objectsrc->fetch(
$object->origin_id);
400 $object->socid = $objectsrc->socid;
401 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
405 $batch_line = array();
406 $stockLine = array();
407 $array_options = array();
409 $num = count($objectsrc->lines);
412 $product_batch_used = array();
414 for ($i = 0; $i < $num; $i++) {
422 $batch =
"batchl" . $i .
"_0";
423 $stockLocation =
"ent1" . $i .
"_0";
426 $is_batch_or_serial = 0;
427 if (!empty($objectsrc->lines[$i]->fk_product)) {
428 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
429 if ($resultFetch < 0) {
432 $is_batch_or_serial = $product->status_batch;
436 if (
isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
437 if (GETPOSTISSET($batch)) {
440 while (GETPOSTISSET($batch)) {
443 $sub_qty[$j][
'id_batch'] =
GETPOSTINT($batch);
444 $subtotalqty += $sub_qty[$j][
'q'];
446 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)))) {
447 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
452 if ($is_batch_or_serial == 2 && $sub_qty[$j][
'q'] > 0) {
454 $product_batch_used[] = $sub_qty[$j][
'id_batch'];
458 $batch =
"batchl" . $i .
"_" . $j;
459 $qty =
"qtyl" . $i .
'_' . $j;
462 $batch_line[$i][
'detail'] = $sub_qty;
463 $batch_line[$i][
'qty'] = $subtotalqty;
466 $totalqty += $subtotalqty;
473 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse") .
' (' . $langs->trans(
"Line") .
' ' .
GETPOSTINT($idl) .
')',
null,
'errors');
477 } elseif (GETPOSTISSET($stockLocation)) {
480 while (GETPOSTISSET($stockLocation)) {
483 $stockLine[$i][$j][
'warehouse_id'] =
GETPOSTINT($stockLocation);
484 $stockLine[$i][$j][
'ix_l'] =
GETPOSTINT($idl);
490 $stockLocation =
"ent1" . $i .
"_" . $j;
491 $qty =
"qtyl" . $i .
'_' . $j;
502 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
503 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i + 1),
null,
'errors');
509 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
511 if (isset($extrafields->attributes[
$object->table_element_line][
'label']) && is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
513 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
514 unset($_POST[
"options_" . $key]);
519 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
520 $selected_subtotal_lines =
GETPOST(
'subtotal_toselect',
'array:int');
521 for ($i = 0; $i < $num; $i++) {
524 if (!isset($batch_line[$i])) {
526 if (isset($stockLine[$i])) {
528 $nbstockline = count($stockLine[$i]);
529 for ($j = 0; $j < $nbstockline; $j++) {
530 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
531 $ret =
$object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], (
float) $stockLine[$i][$j][
'qty'], $array_options[$i]);
543 if ($entrepot_id < 0) {
546 if (!($objectsrc->lines[$i]->fk_product > 0)) {
557 if (
isModEnabled(
'subtotals') && $objectsrc->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && in_array($objectsrc->lines[$i]->id, $selected_subtotal_lines)) {
558 $object->addSubtotalLine($langs, $objectsrc->lines[$i]->desc, (
int) $objectsrc->lines[$i]->qty, $objectsrc->lines[$i]->extraparams, $objectsrc->lines[$i]->id);
563 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
564 $origin_line_id = (int) $batch_line[$i][
'ix_l'];
566 $res = $origin_line->fetch($origin_line_id);
571 $ret =
$object->addline_batch($batch_line[$i], $array_options[$i], $origin_line);
580 $ret = $extrafields->setOptionalsFromPost(
null, $object);
593 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
595 $labelfieldmissing .=
'/' . $langs->transnoentitiesnoconv(
"Warehouse");
597 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
604 foreach (
$object->lines as $line) {
605 $objectsrc_line =
new $objectsrc->class_element_line($db);
606 '@phan-var-force CommonObjectLine $objectsrc_line';
607 $objectsrc_line->fetch($line->origin_line_id);
608 $line->extraparams = $objectsrc_line->extraparams;
609 $line->setExtraParameters();
611 header(
"Location: card.php?id=" .
$object->id);
618 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
622 $result =
$object->create_delivery($user);
626 header(
"Location: " . DOL_URL_ROOT .
'/delivery/card.php?action=create_delivery&token=' .
newToken() .
'&id=' . $result);
634 $action ==
'confirm_valid' && $confirm ==
'yes' && ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
635 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
639 $result =
$object->valid($user);
646 $outputlangs = $langs;
649 $newlang =
GETPOST(
'lang_id',
'aZ09');
652 $newlang =
$object->thirdparty->default_lang;
654 if (!empty($newlang)) {
656 $outputlangs->setDefaultLang($newlang);
661 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
667 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
668 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
669 $result =
$object->cancel($user, 0, (
bool) $also_update_stock);
671 $result =
$object->setStatut(-1);
675 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
676 $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'));
789 if ($action ==
'settracking_url') {
790 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'restricthtml'));
793 if ($action ==
'settrueWeight') {
797 if ($action ==
'settrueWidth') {
800 if ($action ==
'settrueHeight') {
804 if ($action ==
'settrueDepth') {
807 if ($action ==
'setshipping_method_id') {
811 if (
$object->update($user) >= 0) {
812 header(
"Location: card.php?id=" .
$object->id);
817 } elseif ($action ==
'classifybilled' && $permissiontoadd) {
819 $result =
$object->setBilled();
821 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
825 } elseif ($action ==
'classifyclosed' && $permissiontoadd) {
827 $result =
$object->setClosed();
829 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
833 } elseif ($action ==
'deleteline' && !empty($line_id) && $permissiontoadd) {
839 $line->fk_expedition =
$object->id;
841 $num_prod = count($lines);
842 for ($i = 0; $i < $num_prod; $i++) {
843 if ($lines[$i]->
id == $line_id) {
846 if (is_array($lines[$i]->details_entrepot) && count($lines[$i]->details_entrepot) > 1) {
848 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
849 $line->id = $details_entrepot->line_id;
850 if (!$error && $line->delete($user) < 0) {
856 $line->id = $line_id;
857 if (!$error && $line->delete($user) < 0) {
862 unset($_POST[
"lineid"]);
866 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
871 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'save')) {
876 if (!
$object->fetch($id) > 0) {
881 $qty =
GETPOST(
'qty',
'alpha');
884 $element_type =
'shipping';
890 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
891 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
893 if (is_array($extralabelsline)) {
895 foreach ($extralabelsline as $key => $value) {
896 unset($_POST[
"options_" . $key]);
905 $result =
$object->updatelinefree(
GETPOSTINT(
'lineid'), (
float) $qty, $element_type, $fk_product,
GETPOSTINT(
'units'), $rang, $description, $fk_parent, 0, $array_options);
910 $outputlangs = $langs;
913 $newlang =
GETPOST(
'lang_id',
'aZ09');
916 $newlang =
$object->thirdparty->default_lang;
918 if (!empty($newlang)) {
920 $outputlangs->setDefaultLang($newlang);
921 $outputlangs->load(
'products');
925 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
927 unset($_POST[
'qty']);
928 unset($_POST[
'units']);
933 } elseif ($origin && $origin_id > 0) {
941 $num_prod = count($lines);
942 for ($i = 0; $i < $num_prod; $i++) {
943 if ($lines[$i]->
id == $line_id) {
944 $update_done =
false;
946 $line->fk_expedition =
$object->id;
949 $line->array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
951 if (is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
952 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
953 unset($_POST[
"options_" . $key]);
956 $line->fk_product = $lines[$i]->fk_product;
957 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
959 foreach ($lines[$i]->detail_batch as $detail_batch) {
961 $batch =
"batchl" . $detail_batch->fk_expeditiondet .
"_" . $detail_batch->fk_origin_stock;
962 $qty =
"qtyl" . $detail_batch->fk_expeditiondet .
'_' . $detail_batch->id;
965 if (!empty($batch_id)) {
966 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
967 if ($lines[$i]->entrepot_id != 0) {
969 $line->entrepot_id = $lotStock->warehouseid;
973 if (empty($line->detail_batch)) {
974 $line->detail_batch =
new stdClass();
977 $line->detail_batch->fk_origin_stock = $batch_id;
978 $line->detail_batch->batch = $lotStock->batch;
979 $line->detail_batch->id = $detail_batch->id;
980 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
981 $line->detail_batch->qty = $batch_qty;
982 if ($line->update($user) < 0) {
993 unset($_POST[$batch]);
998 $batch =
"batchl" . $line_id .
"_0";
999 $qty =
"qtyl" . $line_id .
"_0";
1002 $lineIdToAddLot = 0;
1003 if ($batch_qty > 0 && !empty($batch_id)) {
1004 if ($lotStock->fetch($batch_id) > 0) {
1006 if ($lines[$i]->entrepot_id > 0) {
1008 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
1009 $lineIdToAddLot = $line_id;
1011 } elseif (count($lines[$i]->details_entrepot) > 1) {
1013 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1014 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
1015 $lineIdToAddLot = $detail_entrepot->line_id;
1019 if ($lineIdToAddLot) {
1021 if ($line->fetch($lineIdToAddLot) > 0) {
1022 $line->detail_batch->fk_origin_stock = $batch_id;
1023 $line->detail_batch->batch = $lotStock->batch;
1024 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
1025 $line->detail_batch->qty = $batch_qty;
1026 if ($line->update($user) < 0) {
1030 $update_done =
true;
1038 $line->origin_line_id = $lines[$i]->origin_line_id;
1039 $line->entrepot_id = $lotStock->warehouseid;
1041 $line->detail_batch[0]->fk_origin_stock = $batch_id;
1042 $line->detail_batch[0]->batch = $lotStock->batch;
1043 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
1044 $line->detail_batch[0]->qty = $batch_qty;
1045 if (
$object->create_line_batch($line, $line->array_options) < 0) {
1049 $update_done =
true;
1058 if ($lines[$i]->fk_product > 0) {
1060 if ($lines[$i]->entrepot_id == 0) {
1062 $stockLocation =
"entl" . $line_id;
1063 $qty =
"qtyl" . $line_id;
1064 $line->id = $line_id;
1065 $line->entrepot_id =
GETPOSTINT((
string) $stockLocation);
1067 if ($line->update($user) < 0) {
1071 unset($_POST[$stockLocation]);
1072 unset($_POST[$qty]);
1073 } elseif ($lines[$i]->entrepot_id > 0) {
1075 $stockLocation =
"entl" . $line_id;
1076 $qty =
"qtyl" . $line_id;
1077 $line->id = $line_id;
1078 $line->entrepot_id =
GETPOSTINT($stockLocation);
1080 if ($line->update($user) < 0) {
1084 unset($_POST[$stockLocation]);
1085 unset($_POST[$qty]);
1086 } elseif (count($lines[$i]->details_entrepot) > 1) {
1088 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1090 $stockLocation =
"entl" . $detail_entrepot->line_id;
1091 $qty =
"qtyl" . $detail_entrepot->line_id;
1093 if (!empty($warehouse)) {
1094 $line->id = $detail_entrepot->line_id;
1095 $line->entrepot_id = $warehouse;
1097 if ($line->update($user) < 0) {
1101 $update_done =
true;
1104 unset($_POST[$stockLocation]);
1105 unset($_POST[$qty]);
1109 $qty =
"qtyl" . $line_id;
1110 $line->id = $line_id;
1112 $line->entrepot_id = 0;
1113 if ($line->update($user) < 0) {
1117 $update_done =
true;
1119 unset($_POST[$qty]);
1123 $qty =
"qtyl" . $line_id;
1124 $line->id = $line_id;
1126 $line->entrepot_id = 0;
1127 if ($line->update($user) < 0) {
1131 $update_done =
true;
1133 unset($_POST[$qty]);
1137 if (empty($update_done)) {
1138 $line->id = $lines[$i]->id;
1139 $line->insertExtraFields();
1144 unset($_POST[
"lineid"]);
1149 $outputlangs = $langs;
1152 $newlang =
GETPOST(
'lang_id',
'aZ09');
1155 $newlang =
$object->thirdparty->default_lang;
1157 if (!empty($newlang)) {
1158 $outputlangs =
new Translate(
"", $conf);
1159 $outputlangs->setDefaultLang($newlang);
1163 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1166 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1170 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1171 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1173 } elseif ($action ==
'addline' && !$origin &&
getDolGlobalString(
'SHIPMENT_STANDALONE') && $usercancreate) {
1174 $langs->load(
'errors');
1176 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1180 $fk_elementdet =
'';
1181 $element_type =
'shipping';
1187 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
1188 if ($prod_entry_mode ==
'free') {
1193 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1201 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1202 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1204 if (is_array($extralabelsline)) {
1206 foreach ($extralabelsline as $key => $value) {
1207 unset($_POST[
"options_".$key]);
1211 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1212 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1217 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1221 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1224 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1225 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1229 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1230 if ($combinations =
GETPOST(
'combinations',
'array')) {
1234 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1235 $idprod = $res->fk_product_child;
1236 $fk_product = $idprod;
1238 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1244 if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1246 if (!empty($idprod) && $idprod > 0) {
1248 $prod->fetch($idprod);
1249 $desc = $prod->label;
1250 $description = $desc;
1253 $outputlangs = $langs;
1255 if (
GETPOST(
'lang_id',
'aZ09')) {
1256 $newlang =
GETPOST(
'lang_id',
'aZ09');
1258 if (empty($newlang)) {
1259 $newlang =
$object->thirdparty->default_lang;
1261 if (!empty($newlang)) {
1262 $outputlangs =
new Translate(
"", $conf);
1263 $outputlangs->setDefaultLang($newlang);
1266 $description = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1268 $description = $prod->description;
1273 $description = $line_desc;
1277 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1280 $outputlangs = $langs;
1282 if (
GETPOST(
'lang_id',
'alpha')) {
1283 $newlang =
GETPOST(
'lang_id',
'alpha');
1285 if (empty($newlang)) {
1286 $newlang =
$object->thirdparty->default_lang;
1288 if (!empty($newlang)) {
1289 $outputlangs =
new Translate(
"", $conf);
1290 $outputlangs->setDefaultLang($newlang);
1291 $outputlangs->load(
'products');
1293 if (!empty($prod->customcode)) {
1294 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1296 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1299 if (!empty($prod->country_code)) {
1300 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
1303 if (!empty($prod->customcode)) {
1304 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1306 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1309 if (!empty($prod->country_code)) {
1310 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $langs, 0);
1316 $type = $prod->type;
1317 $fk_unit = $prod->fk_unit;
1319 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1322 $fk_unit =
GETPOST(
'units',
'alpha');
1323 $description = $desc;
1324 $fk_elementdet =
'';
1329 $result =
$object->addlinefree((
float) $qty, $element_type, $idprod, $fk_unit, min($rank, count(
$object->lines) + 1), $description, $fk_parent, $array_options);
1336 $outputlangs = $langs;
1337 $newlang =
GETPOST(
'lang_id',
'alpha');
1339 $newlang =
$object->thirdparty->default_lang;
1341 if (!empty($newlang)) {
1342 $outputlangs =
new Translate(
"", $conf);
1343 $outputlangs->setDefaultLang($newlang);
1345 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1348 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1352 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $permissiontoadd) {
1353 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
1357 $outputlangs = $langs;
1360 $newlang =
GETPOST(
'lang_id',
'aZ09');
1363 $newlang =
$object->thirdparty->default_lang;
1365 if (!empty($newlang)) {
1366 $outputlangs =
new Translate(
"", $conf);
1367 $outputlangs->setDefaultLang($newlang);
1369 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1372 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1377 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $permissiontoadd) {
1378 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
1382 $outputlangs = $langs;
1385 $newlang =
GETPOST(
'lang_id',
'aZ09');
1388 $newlang =
$object->thirdparty->default_lang;
1390 if (!empty($newlang)) {
1391 $outputlangs =
new Translate(
"", $conf);
1392 $outputlangs->setDefaultLang($newlang);
1394 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1397 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1404 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
1410 $triggersendname =
'SHIPPING_SENTBYMAIL';
1412 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
1413 $mode =
'emailfromshipment';
1414 $trackid =
'shi' .
$object->id;
1415 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
1422$title =
$object->ref .
' - ' . $langs->trans(
"Card");
1423if ($action ==
'create') {
1424 $title = $langs->trans(
"NewSending");
1427$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
1429llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-expedition page-card');
1431if (empty($action)) {
1435$form =
new Form($db);
1441 $formproject =
null;
1444$product_static =
new Product($db);
1446$warehousestatic =
new Entrepot($db);
1451 print
'<br>' .$langs->trans(
"ShipmentCreationIsDoneFromOrder");
1458if ($action ==
'create' && $usercancreate) {
1466 $res = $soc->fetch($socid);
1469 $shipping_method_id = $soc->shipping_method_id;
1470 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1471 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1473 print
'<form name="crea_expedition" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
1474 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1475 print
'<input type="hidden" name="action" value="add">';
1476 print
'<input type="hidden" name="changecompany" value="0">';
1477 print
'<input type="hidden" name="originid" value="' .
$id .
'">';
1478 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
1482 print
'<table class="border centpercent">';
1486 print
'<td class="fieldrequired">' . $langs->trans(
'ThirdParty') .
'</td>';
1489 print $soc->getNomUrl(1);
1490 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1493 print
'<td class="valuefieldcreate">';
1494 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1498 $(document).ready(function() {
1499 $("#socid").change(function() {
1500 console.log("We have changed the company - Reload page");
1501 var socid = $(this).val();
1503 $("input[name=action]").val("create");
1504 $("input[name=changecompany]").val("1");
1505 $("form[name=crea_expedition]").submit();
1510 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>';
1516 if (
isModEnabled(
'project') && is_object($formproject)) {
1518 if (empty($projectid) && !empty(
$object->fk_project)) {
1519 $projectid = (int)
$object->fk_project;
1522 $langs->load(
"projects");
1524 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1525 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1526 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1527 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>';
1533 print
'<tr><td>'.$langs->trans(
"DateShipping").
'</td>';
1534 print
'<td colspan="3">';
1535 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1536 $date_shipping = ($date_shipping ? $date_shipping :
$object->date_shipping);
1537 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1542 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1543 print
'<td colspan="3">';
1544 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1545 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1546 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1552 print $langs->trans(
"Weight");
1553 print
'</td><td colspan="3">';
1554 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1555 print
'<input name="weight" size="4" value="' .
GETPOST(
'weight') .
'"> ';
1556 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units'), 0, 2);
1557 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1558 print $form->textwithpicto($text, $htmltext);
1563 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1564 print
' </td><td colspan="3">';
1565 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1566 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1567 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1568 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1570 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1571 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1572 print $form->textwithpicto($text, $htmltext);
1576 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1577 print
'<td colspan="3">';
1578 $expe->fetch_delivery_methods();
1579 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1580 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1582 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1584 print
"</td></tr>\n";
1587 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1588 print
'<td colspan="3">';
1589 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1590 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1591 print
"</td></tr>\n";
1594 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1595 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
1596 print $hookmanager->resPrint;
1598 if (empty($reshook)) {
1600 if (
$object->fetch_optionals() > 0) {
1601 $expe->array_options = array_merge($expe->array_options,
$object->array_options);
1603 print $expe->showOptionals($extrafields,
'edit', $parameters);
1609 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1610 print
'<td colspan="3" class="maxwidthonsmartphone">';
1611 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1612 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1617 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1619 if (is_array($list) && count($list) > 1) {
1620 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1621 print
'<td colspan="3">';
1622 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1623 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1624 print
"</td></tr>\n";
1630 print
'<td class="tdtop">';
1631 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext);
1633 print
'<td valign="top" colspan="2">';
1634 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1635 print $doleditor->Create(1);
1638 if (!$user->socid) {
1640 print
'<td class="tdtop">';
1641 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext);
1643 print
'<td valign="top" colspan="2">';
1644 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1645 print $doleditor->Create(1);
1653 print $form->buttonsSaveCancel(
"CreateDraft");
1656 } elseif ($origin) {
1657 $classname = ucfirst($origin);
1659 $object =
new $classname($db);
1661 '@phan-var-force Commande|Facture $object';
1664 if (
$object->fetch($origin_id)) {
1668 $author =
new User($db);
1669 $author->fetch(
$object->user_author_id);
1675 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
1676 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1677 print
'<input type="hidden" name="action" value="add">';
1678 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
1679 print
'<input type="hidden" name="origin_id" value="' .
$object->id .
'">';
1681 print
'<input type="hidden" name="entrepot_id" value="' .
GETPOSTINT(
'entrepot_id') .
'">';
1686 print
'<table class="border centpercent">';
1689 print
'<tr><td class="titlefieldcreate fieldrequired">';
1691 print $langs->trans(
"RefOrder");
1694 print $langs->trans(
"RefProposal");
1696 print
'</td><td colspan="3">';
1703 if ($origin ==
'commande') {
1704 print $langs->trans(
'RefCustomerOrder');
1705 } elseif ($origin ==
'propal') {
1706 print $langs->trans(
'RefCustomerOrder');
1708 print $langs->trans(
'RefCustomer');
1710 print
'</td><td colspan="3">';
1711 print
'<input type="text" name="ref_customer" value="' .
$object->ref_client .
'" />';
1716 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Company') .
'</td>';
1717 print
'<td colspan="3">' . $soc->getNomUrl(1) .
'</td>';
1718 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1722 if (
isModEnabled(
'project') && is_object($formproject)) {
1724 if (empty($projectid) && !empty(
$object->fk_project)) {
1725 $projectid = (int)
$object->fk_project;
1727 if ($origin ==
'project') {
1730 $langs->load(
"projects");
1732 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1733 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1734 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1735 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>';
1741 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
1742 print
'<td colspan="3">';
1743 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1744 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1745 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1750 print
'<tr><td>' . $langs->trans(
"DateShipping") .
'</td>';
1751 print
'<td colspan="3">';
1752 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1754 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1759 print
'<tr><td>' . $langs->trans(
"NotePublic") .
'</td>';
1760 print
'<td colspan="3">';
1761 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1762 print $doleditor->Create(1);
1766 if (
$object->note_private && !$user->socid) {
1767 print
'<tr><td>' . $langs->trans(
"NotePrivate") .
'</td>';
1768 print
'<td colspan="3">';
1769 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1770 print $doleditor->Create(1);
1776 print $langs->trans(
"Weight");
1777 print
'</td><td colspan="3">';
1778 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1781 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOST(
'weight_units'), 0, 2);
1782 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1783 print $form->textwithpicto($text, $htmltext);
1788 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1789 print
' </td><td colspan="3">';
1790 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1791 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1792 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1793 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1795 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1796 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1797 print $form->textwithpicto($text, $htmltext);
1801 print
"<tr><td>" . $langs->trans(
"DeliveryMethod") .
"</td>";
1802 print
'<td colspan="3">';
1803 $expe->fetch_delivery_methods();
1804 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1805 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1807 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1809 print
"</td></tr>\n";
1812 print
"<tr><td>" . $langs->trans(
"TrackingNumber") .
"</td>";
1813 print
'<td colspan="3">';
1814 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1815 print
'<input name="tracking_number" size="20" value="' .
GETPOST(
'tracking_number',
'alpha') .
'">';
1816 print
"</td></tr>\n";
1821 print
'<td><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1) .
'</label></td>';
1822 print
'<td colspan="3" class="maxwidthonsmartphone">';
1823 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1824 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1829 include_once DOL_DOCUMENT_ROOT .
'/core/modules/expedition/modules_expedition.php';
1831 if (is_array($list) && count($list) > 1) {
1832 print
"<tr><td>" . $langs->trans(
"DefaultModel") .
"</td>";
1833 print
'<td colspan="3">';
1834 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1835 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1836 print
"</td></tr>\n";
1844 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && !empty($extrafields->attributes[
$object->table_element][
'label'])) {
1845 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
1846 if (array_key_exists(
'options_'.$key, $objectsav->array_options)) {
1847 $object->array_options[
'options_'.$key] = $objectsav->array_options[
'options_'.$key];
1851 $parameters = array(
1852 'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
1856 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1866 $numAsked = count(
$object->lines);
1868 print
'<script type="text/javascript">' .
"\n";
1869 print
'jQuery(document).ready(function() {' .
"\n";
1870 print
'jQuery("#autofill").click(function() {';
1872 while ($i < $numAsked) {
1873 print
'jQuery("#qtyl' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1875 print
'jQuery("#qtyl' . $i .
'_' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1879 print
'return false; });' .
"\n";
1880 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);' .
"\n";
1881 print
'return false; });' .
"\n";
1883 print
'</script>' .
"\n";
1887 print
'<div class="div-table-responsive-no-min">';
1888 print
'<table class="noborder centpercent">';
1893 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1895 $title_lines_to_disable = array();
1900 $title_lines_to_disable =
$object->getDisabledShippmentSubtotalLines();
1902 $selectedLines =
GETPOST(
'subtotal_toselect',
'array:int');
1903 foreach (
$object->lines as $line) {
1904 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1905 $show_check_add_buttons =
true;
1910 print
'<tr class="liste_titre">';
1912 if (isset($show_check_add_buttons)) {
1913 print $form->showCheckAddButtons(
'checkforselect');
1915 print $langs->trans(
"Description");
1917 print
'<td class="center">' . $langs->trans(
"QtyOrdered") .
'</td>';
1918 print
'<td class="center">' . $langs->trans(
"QtyShipped") .
'</td>';
1919 print
'<td class="center">' . $langs->trans(
"QtyToShip");
1921 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">' .
img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"') .
'</a>';
1926 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">' .
img_picto($langs->trans(
"Reset"),
'eraser') .
'</span>';
1930 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' (' . $langs->trans(
"Stock") .
')</td>';
1932 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' / ' . $langs->trans(
"Batch") .
' (' . $langs->trans(
"Stock") .
')</td>';
1936 print
'<td class="left">' . $langs->trans(
'StockEntryDate') .
'</td>';
1942 $warehousePicking = array();
1944 if ($warehouse_id > 0) {
1945 $warehousePicking[] = $warehouse_id;
1947 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1951 while ($indiceAsked < $numAsked) {
1954 $line =
$object->lines[$indiceAsked];
1956 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1957 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1962 if (empty($reshook) && $line->special_code != SUBTOTALS_SPECIAL_CODE) {
1964 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1966 if (!empty($line->date_start)) {
1969 if (!empty($line->date_end)) {
1973 print
'<!-- line for order line ' . $line->id .
' -->' .
"\n";
1974 print
'<tr class="oddeven" id="row-' . $line->id .
'">' .
"\n";
1976 $qtyProdCom = $line->qty;
1977 $productChildrenNb = 0;
1979 if ($line->fk_product > 0) {
1980 $res = $product->fetch($line->fk_product);
1985 $productChildrenNb = $product->hasFatherOrChild(1);
1987 if ($productChildrenNb > 0) {
1988 $product->loadStockForVirtualProduct(
'warehouseopen', $qtyProdCom);
1990 $product->load_stock(
'warehouseopen');
1995 print
'<a name="' . $line->id .
'"></a>';
1998 $product_static->type = $line->fk_product_type;
1999 $product_static->id = $line->fk_product;
2000 $product_static->ref = $line->ref;
2001 $product_static->status = $line->product_tosell;
2002 $product_static->status_buy = $line->product_tobuy;
2003 $product_static->status_batch = $line->product_tobatch;
2005 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
2007 $text = $product_static->getNomUrl(1);
2008 $text .=
' - ' . (!empty($line->label) ? $line->label : $line->product_label);
2010 $description .= empty($product->stockable_product) ? $langs->trans(
'StockDisabled') : $langs->trans(
'StockEnabled');
2011 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2014 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
2017 if ($showdescinproductdesc) {
2018 print ($line->desc && $line->desc != $line->product_label) ?
'<br>' .
dol_htmlentitiesbr($line->desc) :
'';
2025 $text =
img_object($langs->trans(
'Service'),
'service');
2027 $text =
img_object($langs->trans(
'Product'),
'product');
2030 if (!empty($line->label)) {
2031 $text .=
' <strong>' . $line->label .
'</strong>';
2032 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
2034 print $text .
' ' . nl2br($line->desc);
2038 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
2049 print
'<td class="center">' . $line->qty;
2050 print
'<input name="qtyasked' . $indiceAsked .
'" id="qtyasked' . $indiceAsked .
'" type="hidden" value="' . $line->qty .
'">';
2052 print
' ' . $unit_order .
'</td>';
2056 print
'<td class="center">';
2057 $quantityDelivered = isset(
$object->expeditions[$line->id]) ?
$object->expeditions[$line->id] :
'';
2058 print $quantityDelivered;
2059 print
'<input name="qtydelivered' . $indiceAsked .
'" id="qtydelivered' . $indiceAsked .
'" type="hidden" value="' . $quantityDelivered .
'">';
2060 if ($quantityDelivered) {
2061 print
' ' . $unit_order .
'</td>';
2065 $quantityAsked = $line->qty;
2067 $quantityToBeDelivered = 0;
2069 if (is_numeric($quantityDelivered)) {
2070 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
2072 $quantityToBeDelivered = $quantityAsked;
2076 $warehouseObject =
null;
2077 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !
isModEnabled(
'stock')) {
2078 print
'<!-- Case warehouse already known or product not a predefined product -->';
2080 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
2082 $deliverableQty = $quantityToBeDelivered;
2084 $deliverableQty = min($quantityToBeDelivered, $stock);
2086 if ($deliverableQty < 0) {
2087 $deliverableQty = 0;
2089 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2091 print
'<td class="center">';
2093 if (GETPOSTISSET(
'qtyl'.$indiceAsked) &&
GETPOST(
'qtyl'.$indiceAsked) !==
'') {
2094 $deliverableQty =
GETPOSTFLOAT(
'qtyl'.$indiceAsked,
'MS');
2096 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2097 $qtylValue = $deliverableQty;
2100 } elseif (is_numeric($qtylValue)) {
2102 $qtylValue =
price($qtylValue);
2104 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" class="qtyl right" type="text" size="4" value="' . $qtylValue .
'">';
2107 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2108 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2111 print $langs->trans(
"NA");
2117 print
'<td class="left">';
2120 $ent =
"entl" . $indiceAsked;
2121 $idl =
"idl" . $indiceAsked;
2123 if ($line->fk_product > 0) {
2124 print
'<!-- Show warehouse selection -->';
2130 if ($productChildrenNb > 0) {
2131 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, 0,
'', 0, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2133 if ($product->stockable_product == Product::ENABLED_STOCK) {
2134 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2136 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2140 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
2142 if ($stock < $quantityToBeDelivered) {
2143 print
' ' .
img_warning($langs->trans(
"StockTooLow"));
2148 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span><input name="entl' . $indiceAsked .
'" id="entl' . $indiceAsked .
'" type="hidden" value="0">';
2159 $product->get_sousproduits_arbo();
2160 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2161 if (count($prods_arbo) > 0) {
2162 foreach ($prods_arbo as $key => $value) {
2165 if ($value[
'stock'] < $value[
'stock_alert']) {
2168 print
"<tr class=\"oddeven\"><td> ->
2169 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2170 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2171 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2181 print
'<td></td><td></td>';
2186 print
'<!-- Case product need lot -->';
2188 $staticwarehouse =
new Entrepot($db);
2189 if ($warehouse_id > 0) {
2190 $staticwarehouse->fetch($warehouse_id);
2196 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2197 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2201 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
2202 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2203 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2205 $batchStock = +$dbatch->qty;
2206 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2209 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2210 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2212 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2213 $alreadyQtyBatchSetted[$line->fk_product] = array();
2216 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2217 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2220 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2223 if ($deliverableQty < 0) {
2224 $deliverableQty = 0;
2227 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2228 if (GETPOSTISSET($inputName)) {
2229 $deliverableQty =
GETPOST($inputName,
'int');
2232 $tooltipClass = $tooltipTitle =
'';
2233 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2234 $tooltipClass =
' classfortooltip';
2235 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2237 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2239 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2241 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2242 print
'<td colspan="3" ></td><td class="center">';
2243 $qtylValue = $deliverableQty;
2246 } elseif (is_numeric($qtylValue)) {
2247 $qtylValue =
price($qtylValue);
2249 print
'<input class="qtyl ' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="' . $qtylValue .
'">';
2252 print
'<!-- Show details of lot -->';
2253 print
'<td class="left">';
2255 print $staticwarehouse->getNomUrl(0) .
' / ';
2257 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2260 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
2262 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2265 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2267 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
2271 $quantityToBeDelivered -= $deliverableQty;
2272 if ($quantityToBeDelivered < 0) {
2273 $quantityToBeDelivered = 0;
2278 print
'<td>' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2283 print
'<!-- Case there is no details of lot at all -->';
2284 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2285 print
'<input class="qtyl right" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="0" disabled="disabled"> ';
2288 print
'<td class="left">';
2289 print
img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
2299 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2300 print
'<!-- Case warehouse not already known and product does not need lot -->';
2301 print
'<td></td><td></td>';
2305 print
'</tr>' .
"\n";
2307 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2312 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2313 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2317 $tmpwarehouseObject =
new Entrepot($db);
2318 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2320 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2325 $tmpwarehouseObject->fetch($warehouse_id);
2326 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2327 $stock = +$stock_warehouse->real;
2328 $deliverableQty = min($quantityToBeDelivered, $stock);
2329 $deliverableQty = max(0, $deliverableQty);
2331 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2332 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked=' . $indiceAsked .
') -->';
2338 $tooltipClass = $tooltipTitle =
'';
2339 if ($productChildrenNb <= 0) {
2340 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2341 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
2343 if (!isset($alreadyQtySetted[$line->fk_product])) {
2344 $alreadyQtySetted[$line->fk_product] = array();
2347 $deliverableQty = min($quantityToBeDelivered, $stock);
2350 if ($deliverableQty < 0) {
2351 $deliverableQty = 0;
2354 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2355 $tooltipClass =
' classfortooltip';
2356 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2358 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
2361 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2364 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
2365 if (GETPOSTISSET($inputName)) {
2368 $qtylValue = $deliverableQty;
2371 } elseif (is_numeric($qtylValue)) {
2372 $qtylValue =
price($qtylValue);
2374 print
'<input class="qtyl' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="text" size="4" value="' . $qtylValue .
'">';
2375 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_id .
'">';
2378 print
'<input name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2381 print $langs->trans(
"NA");
2386 print
'<td class="left">';
2388 if ($product->stockable_product == Product::ENABLED_STOCK || $productChildrenNb > 0) {
2389 print $tmpwarehouseObject->getNomUrl(0) .
' ';
2390 if ($productChildrenNb <= 0) {
2391 print
'<!-- Show details of stock -->';
2392 print
'(' . $stock .
')';
2395 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2398 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2401 $quantityToBeDelivered -= $deliverableQty;
2402 if ($quantityToBeDelivered < 0) {
2403 $quantityToBeDelivered = 0;
2414 $product->get_sousproduits_arbo();
2415 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2416 if (count($prods_arbo) > 0) {
2417 foreach ($prods_arbo as $key => $value) {
2420 if ($value[
'stock'] < $value[
'stock_alert']) {
2423 print
'<tr class"oddeven"><td>';
2424 print
" ->
2425 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2426 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2427 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2436 print
'<!-- Case warehouse not already known and product need lot -->';
2437 print
'<td></td><td></td>';
2444 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2446 $tmpwarehouseObject =
new Entrepot($db);
2451 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2452 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2453 $nbofsuggested += count($stock_warehouse->detail_batch);
2457 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2459 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2464 $tmpwarehouseObject->fetch($warehouse_id);
2465 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2466 foreach ($stock_warehouse->detail_batch as $dbatch) {
2467 $batchStock = +$dbatch->qty;
2468 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2469 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2471 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2472 $alreadyQtyBatchSetted[$line->fk_product] = array();
2475 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2476 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2479 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2482 if ($deliverableQty < 0) {
2483 $deliverableQty = 0;
2486 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2487 if (GETPOSTISSET($inputName)) {
2491 $tooltipClass = $tooltipTitle =
'';
2492 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2493 $tooltipClass =
' classfortooltip';
2494 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2496 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2498 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2500 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'><td colspan="3"></td><td class="center">';
2501 $qtylValue = $deliverableQty;
2504 } elseif (is_numeric($qtylValue)) {
2505 $qtylValue =
price($qtylValue);
2507 print
'<input class="qtyl right ' . $tooltipClass .
'" title="' . $tooltipTitle .
'" name="' . $inputName .
'" id="' . $inputName .
'" type="text" size="4" value="' . $qtylValue .
'">';
2510 print
'<td class="left">';
2512 print $tmpwarehouseObject->getNomUrl(0) .
' / ';
2514 print
'<!-- Show details of lot -->';
2515 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2516 print
'<input name="entl' . $indiceAsked .
'_'.$subj.
'" type="hidden" value="' . $tmpwarehouseObject->id .
'">';
2519 print $langs->trans(
"Batch") .
': ';
2520 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
2522 print $productlotObject->getNomUrl(1);
2524 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
2527 print
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2530 print
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2532 print
' (' . $dbatch->qty .
')';
2533 $quantityToBeDelivered -= $deliverableQty;
2534 if ($quantityToBeDelivered < 0) {
2535 $quantityToBeDelivered = 0;
2541 print
'<td class="left">' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2549 $warehouse_selected_id =
GETPOSTINT(
'entrepot_id');
2551 print
'<!-- line not shown yet, we show it -->';
2552 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2557 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2558 $disabled =
'disabled="disabled"';
2559 $alt =
'Product need serial or batch number';
2561 if ($warehouse_selected_id <= 0) {
2562 $disabled =
'disabled="disabled"';
2565 if ($product->stockable_product == Product::ENABLED_STOCK) {
2568 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).
'"' :
'').
'> ';
2570 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
2576 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2577 $disabled =
'disabled="disabled"';
2579 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$quantityToBeDelivered.
'"'.($disabled ?
' '.$disabled :
'').
'> ';
2583 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="0">';
2585 print $langs->trans(
"NA");
2589 print
'<td class="left">';
2592 if (($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK)) {
2593 $warehouseObject =
new Entrepot($db);
2594 $warehouseObject->fetch($warehouse_selected_id);
2595 print
img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
2597 if ($line->fk_product) {
2598 if ($product->stockable_product != Product::ENABLED_STOCK) {
2599 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2601 print
img_warning() .
' ' . $langs->trans(
'StockTooLow');
2608 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2624 $srcLine->id = $line->id;
2625 $srcLine->fetch_optionals();
2627 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
2629 print $expLine->showOptionals($extrafields,
'edit', array(
'style' =>
'class="drag drop oddeven"',
'colspan' => $colspan), (
string) $indiceAsked,
'',
'1');
2630 } elseif (empty($reshook) && $line->special_code == SUBTOTALS_SPECIAL_CODE && !in_array($line->id, $title_lines_to_disable)) {
2631 require
dol_buildpath(
'/core/tpl/subtotalline_select.tpl.php');
2642 print $form->buttonsSaveCancel(
"Create");
2652 '@phan-var-force Expedition $object';
2658 $num_prod = count($lines);
2661 $typeobject =
$object->origin;
2663 $origin_id =
$object->origin_id;
2671 $res =
$object->fetch_optionals();
2679 if ($action ==
'delete') {
2680 $formquestion = array();
2682 $formquestion = array(
2684 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
2685 'name' =>
'alsoUpdateStock',
2686 'type' =>
'checkbox',
2691 $formconfirm = $form->formconfirm(
2692 $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
2693 $langs->trans(
'DeleteSending'),
2694 $langs->trans(
"ConfirmDeleteSending",
$object->ref),
2703 if ($action ==
'ask_subtotal_deleteline') {
2705 $langs->load(
"subtotals");
2706 $title =
"DeleteSubtotalLine";
2707 $question =
"ConfirmDeleteSubtotalLine";
2708 if (
GETPOST(
'type') ==
'title') {
2709 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2710 $title =
"DeleteTitleLine";
2711 $question =
"ConfirmDeleteTitleLine";
2713 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2717 if ($action ==
'valid') {
2718 $objectref = substr(
$object->ref, 1, 4);
2719 if ($objectref ==
'PROV') {
2720 $numref =
$object->getNextNumRef($soc);
2722 $numref = (string)
$object->ref;
2725 $text = $langs->trans(
"ConfirmValidateSending", $numref);
2727 $text .=
'<br>' .
img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementWillBeRecorded") .
'.';
2729 $text .=
'<br>' .
img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementNotYetRecorded") .
'.';
2733 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2734 $notify =
new Notify($db);
2736 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE',
$object->socid, $object);
2739 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 260);
2743 if ($action ==
'cancel') {
2744 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending",
$object->ref),
'confirm_cancel',
'', 0, 1);
2748 if ($action ==
'sign') {
2749 $text = $langs->trans(
'ConfirmSignShipping');
2751 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2752 $notify =
new Notify($db);
2754 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2759 'name' =>
'signed_status',
2760 'select_show_empty' => 0,
2761 'label' =>
'<span class="fieldrequired">' . $langs->trans(
'SignStatus') .
'</span>',
2762 'values' =>
$object->getSignedStatusLocalisedArray()
2764 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'SignShipping'), $text,
'confirm_sign', $formquestion, 0, 1);
2768 if ($action ==
'unsign') {
2769 $text = $langs->trans(
'ConfirmUnsignShipping');
2771 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2772 $notify =
new Notify($db);
2774 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2776 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnsignShipping'), $text,
'confirm_unsign',
'', 0, 1);
2780 $parameters = array(
'formConfirm' => $formconfirm);
2781 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2782 if (empty($reshook)) {
2783 $formconfirm .= $hookmanager->resPrint;
2784 } elseif ($reshook > 0) {
2785 $formconfirm = $hookmanager->resPrint;
2793 $tmparray =
$object->getTotalWeightVolume();
2794 $totalWeight = $tmparray[
'weight'];
2795 $totalVolume = $tmparray[
'volume'];
2797 if (!empty($typeobject) && $typeobject ===
'commande' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2799 $objectsrc->fetch(
$object->origin_object->id);
2801 if (!empty($typeobject) && $typeobject ===
'propal' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2802 $objectsrc =
new Propal($db);
2803 $objectsrc->fetch(
$object->origin_object->id);
2807 $linkback =
'<a href="' . DOL_URL_ROOT .
'/expedition/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2808 $morehtmlref =
'<div class="refidno">';
2810 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
2811 $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);
2814 $morehtmlref .=
'<br>' .
$object->thirdparty->getNomUrl(1);
2817 if ($origin && $origin_id > 0) {
2819 $langs->load(
"projects");
2820 $morehtmlref .=
'<br>';
2822 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2823 if ($action !=
'classify') {
2824 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2826 $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');
2828 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2830 $proj->fetch($objectsrc->fk_project);
2831 $morehtmlref .= $proj->getNomUrl(1);
2833 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2841 $langs->load(
"projects");
2842 $morehtmlref .=
'<br>';
2843 if ($permissiontoadd) {
2844 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2845 if ($action !=
'classify') {
2846 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2848 $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');
2850 if (!empty(
$object->fk_project)) {
2852 $proj->fetch(
$object->fk_project);
2853 $morehtmlref .= $proj->getNomUrl(1);
2855 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2862 $morehtmlref .=
'</div>';
2863 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2865 print
'<div class="fichecenter">';
2866 print
'<div class="fichehalfleft">';
2867 print
'<div class="underbanner clearboth"></div>';
2869 print
'<table class="border tableforfield centpercent">';
2872 if (!empty($typeobject) && $typeobject ==
'commande' &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2874 print $langs->trans(
"RefOrder") .
'</td>';
2876 print $objectsrc->getNomUrl(1,
'commande');
2880 if (!empty($typeobject) && $typeobject ==
'propal' &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2882 print $langs->trans(
"RefProposal") .
'</td>';
2884 print $objectsrc->getNomUrl(1,
'expedition');
2890 print
'<tr><td class="titlefieldmiddle">' . $langs->trans(
"DateCreation") .
'</td>';
2895 print
'<tr><td height="10">';
2896 print
'<table class="nobordernopadding centpercent"><tr><td>';
2897 print $langs->trans(
'DateDeliveryPlanned');
2899 if ($action !=
'editdate_livraison') {
2900 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>';
2902 print
'</tr></table>';
2904 if ($action ==
'editdate_livraison') {
2905 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2906 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2907 print
'<input type="hidden" name="action" value="setdate_livraison">';
2908 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2909 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2918 print
'<tr><td height="10">';
2919 print
'<table class="nobordernopadding centpercent"><tr><td>';
2920 print $langs->trans(
'DateShipping');
2922 if ($action !=
'editdate_shipping') {
2923 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>';
2925 print
'</tr></table>';
2927 if ($action ==
'editdate_shipping') {
2928 print
'<form name="setdate_shipping" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2929 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2930 print
'<input type="hidden" name="action" value="setdate_shipping">';
2931 print $form->selectDate(
$object->date_shipping ?
$object->date_shipping : -1,
'ship_', 1, 1, 0,
"setdate_shipping", 1, 0);
2932 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2942 print $form->editfieldkey(
"Weight",
'trueWeight',
$object->trueWeight, $object, $user->hasRight(
'expedition',
'creer'));
2945 if ($action ==
'edittrueWeight') {
2946 print
'<form name="settrueweight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2947 print
'<input name="action" value="settrueWeight" type="hidden">';
2948 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
2949 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2950 print
'<input id="trueWeight" name="trueWeight" value="' .
$object->trueWeight .
'" type="text" class="width50 valignmiddle">';
2951 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2952 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
2953 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
2961 if ($totalWeight > 0) {
2962 if (!empty(
$object->trueWeight)) {
2963 print
' (' . $langs->trans(
"SumOfProductWeights") .
': ';
2966 if (!empty(
$object->trueWeight)) {
2973 print
'<tr><td>' . $form->editfieldkey(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2974 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer'));
2979 print
'<tr><td>' . $form->editfieldkey(
"Height",
'trueHeight',
$object->trueHeight, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2980 if ($action ==
'edittrueHeight') {
2981 print
'<form name="settrueHeight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2982 print
'<input name="action" value="settrueHeight" type="hidden">';
2983 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
2984 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2985 print
'<input id="trueHeight" name="trueHeight" value="' .
$object->trueHeight .
'" type="text" class="width50">';
2986 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
2987 print
' <input class="button smallpaddingimp" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
2988 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
2998 print
'<tr><td>' . $form->editfieldkey(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2999 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer'));
3005 print $langs->trans(
"Volume");
3008 $calculatedVolume = 0;
3012 $volumeUnit =
$object->size_units * 3;
3015 if ($calculatedVolume > 0) {
3016 if ($volumeUnit < 50) {
3022 if ($totalVolume > 0) {
3023 if ($calculatedVolume) {
3024 print
' (' . $langs->trans(
"SumOfProductVolumes") .
': ';
3028 if ($calculatedVolume) {
3037 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3042 print
'<div class="fichehalfright">';
3043 print
'<div class="underbanner clearboth"></div>';
3045 print
'<table class="border centpercent tableforfield">';
3049 print
'<table class="nobordernopadding centpercent"><tr><td>';
3050 print $langs->trans(
'SendingMethod');
3053 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
3054 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>';
3056 print
'</tr></table>';
3058 if ($action ==
'editshipping_method_id') {
3059 print
'<form name="setshipping_method_id" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3060 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3061 print
'<input type="hidden" name="action" value="setshipping_method_id">';
3062 $object->fetch_delivery_methods();
3063 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
3065 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3067 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
3070 if (
$object->shipping_method_id > 0) {
3072 $code = $langs->getLabelFromKey($db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
3073 print $langs->trans(
"SendingMethod" . strtoupper($code));
3080 print
'<tr><td class="titlefieldmiddle">' . $form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3081 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url, $object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring',
$object->tracking_number);
3087 print
'<table class="nobordernopadding centpercent"><tr><td>';
3088 print $langs->trans(
'IncotermLabel');
3089 print
'<td><td class="right">';
3090 if ($permissiontoadd) {
3091 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/expedition/card.php?id=' .
$object->id .
'&action=editincoterm&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3095 print
'</td></tr></table>';
3098 if ($action !=
'editincoterm') {
3099 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3101 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3107 $parameters = array();
3108 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
3109 print $hookmanager->resPrint;
3116 print
'<div class="clearboth"></div>';
3125 if (!empty(
$object->table_element_line)) {
3127 $result =
$object->getLinesArray();
3129 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
3130 <input type="hidden" name="token" value="' .
newToken().
'">
3131 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3132 <input type="hidden" name="mode" value="">
3133 <input type="hidden" name="page_y" value="">
3134 <input type="hidden" name="id" value="' .
$object->id.
'">
3137 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
3138 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3141 print
'<div class="div-table-responsive-no-min">';
3142 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3143 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3151 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
3152 if ($action !=
'editline') {
3155 $parameters = array();
3156 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3160 if (empty($reshook)) {
3166 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3177 if ($action ==
'editline') {
3178 print
' <form name="updateline" id="updateline" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $line_id .
'" method="POST">
3179 <input type="hidden" name="token" value="' .
newToken() .
'">
3180 <input type="hidden" name="action" value="updateline">
3181 <input type="hidden" name="mode" value="">
3182 <input type="hidden" name="id" value="' .
$object->id .
'">
3187 print
'<div class="div-table-responsive-no-min">';
3188 print
'<table class="noborder centpercent" id="tablelines" >';
3190 print
'<tr class="liste_titre">';
3193 print
'<td width="5" class="center linecolnum"> </td>';
3196 print
'<td class="linecoldescription" >' . $langs->trans(
"Products") .
'</td>';
3198 print
'<td class="center linecolqty">' . $langs->trans(
"QtyOrdered") .
'</td>';
3199 if ($origin_id > 0) {
3200 print
'<td class="center linecolqtyinothershipments">' . $langs->trans(
"QtyInOtherShipments") .
'</td>';
3202 if ($action ==
'editline') {
3210 print
'<td class="center linecoleditlineotherinfo" colspan="' . $editColspan .
'">';
3212 print $langs->trans(
"QtyToShip");
3214 print $langs->trans(
"QtyShipped");
3217 print
' - ' . $langs->trans(
"WarehouseSource");
3220 print
' - ' . $langs->trans(
"Batch");
3225 print
'<td class="center linecolqtytoship">' . $langs->trans(
"QtyToShip") .
'</td>';
3227 print
'<td class="center linecolqtyshipped">' . $langs->trans(
"QtyShipped") .
'</td>';
3230 print
'<td class="left linecolwarehousesource">' . $langs->trans(
"WarehouseSource") .
'</td>';
3234 print
'<td class="left linecolbatch">' . $langs->trans(
"Batch") .
'</td>';
3237 print
'<td class="center linecolweight">' . $langs->trans(
"CalculatedWeight") .
'</td>';
3238 print
'<td class="center linecolvolume">' . $langs->trans(
"CalculatedVolume") .
'</td>';
3241 print
'<td class="linecoledit"></td>';
3242 print
'<td class="linecoldelete" width="10"></td>';
3247 $outputlangs = $langs;
3252 if (
GETPOST(
'lang_id',
'aZ09')) {
3253 $newlang =
GETPOST(
'lang_id',
'aZ09');
3255 if (empty($newlang)) {
3256 $newlang =
$object->thirdparty->default_lang;
3258 if (!empty($newlang)) {
3259 $outputlangs =
new Translate(
"", $conf);
3260 $outputlangs->setDefaultLang($newlang);
3265 $alreadysent = array();
3266 if ($origin_id > 0) {
3267 $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";
3268 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot";
3269 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
3271 $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';
3272 $sql .=
', p.description as product_desc';
3273 $sql .=
" FROM " . MAIN_DB_PREFIX .
"expeditiondet as ed";
3274 $sql .=
", " . MAIN_DB_PREFIX .
"expedition as e";
3275 $sql .=
", " . MAIN_DB_PREFIX . $origin .
"det as obj";
3277 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product as p ON obj.fk_product = p.rowid";
3278 $sql .=
" WHERE e.entity IN (" .
getEntity(
'expedition') .
")";
3279 $sql .=
" AND obj.fk_" . $origin .
" = " . ((int) $origin_id);
3280 $sql .=
" AND obj.rowid = ed.fk_elementdet";
3281 $sql .=
" AND ed.fk_expedition = e.rowid";
3283 $sql .=
" ORDER BY obj.fk_product";
3285 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
3286 $resql = $db->query($sql);
3288 $num = $db->num_rows($resql);
3292 $obj = $db->fetch_object($resql);
3295 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
3296 'shipment_ref' => $obj->shipment_ref,
3297 'shipment_id' => $obj->shipment_id,
3298 'warehouse' => $obj->fk_entrepot,
3299 'qty_shipped' => $obj->qty_shipped,
3300 'product_tosell' => $obj->product_tosell,
3301 'product_tobuy' => $obj->product_tobuy,
3302 'product_tobatch' => $obj->product_tobatch,
3303 'date_valid' => $db->jdate($obj->date_valid),
3304 'date_delivery' => $db->jdate($obj->date_delivery));
3315 $conf->cache[
'product'] = array();
3316 $conf->cache[
'warehouse'] = array();
3317 for ($i = 0; $i < $num_prod; $i++) {
3318 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
3319 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
3324 if (empty($reshook) && $lines[$i]->product_type !=
"9") {
3325 print
'<!-- origin line id = ' . $lines[$i]->origin_line_id .
' -->';
3326 print
'<tr class="oddeven" id="row-' . $lines[$i]->id .
'" data-id="' . $lines[$i]->id .
'" data-element="' . $lines[$i]->element .
'" >';
3330 print
'<td class="center linecolnum">' . ($i + 1) .
'</td>';
3334 if ($lines[$i]->fk_product > 0) {
3337 $product_id = $lines[$i]->fk_product;
3338 if (!isset($conf->cache[
'product'][$product_id])) {
3340 $prod->fetch($product_id);
3341 $conf->cache[
'product'][$product_id] = $prod;
3343 $prod = $conf->cache[
'product'][$product_id];
3345 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
3347 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
3350 print
'<td class="linecoldescription">';
3353 $product_static->type = $lines[$i]->fk_product_type;
3354 $product_static->id = $lines[$i]->fk_product;
3355 $product_static->ref = $lines[$i]->ref;
3356 $product_static->status = $lines[$i]->product_tosell;
3357 $product_static->status_buy = $lines[$i]->product_tobuy;
3358 $product_static->status_batch = $lines[$i]->product_tobatch;
3360 $product_static->weight = $lines[$i]->weight;
3361 $product_static->weight_units = $lines[$i]->weight_units;
3362 $product_static->length = $lines[$i]->length;
3363 $product_static->length_units = $lines[$i]->length_units;
3364 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
3365 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
3366 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
3367 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
3368 $product_static->surface = $lines[$i]->surface;
3369 $product_static->surface_units = $lines[$i]->surface_units;
3370 $product_static->volume = $lines[$i]->volume;
3371 $product_static->volume_units = $lines[$i]->volume_units;
3372 $product_static->stockable_product = $lines[$i]->stockable_product;
3374 $text = $product_static->getNomUrl(1);
3375 $text .=
' - ' . $label;
3377 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
3378 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
3384 print
'<td class="linecoldescription" >';
3386 $text =
img_object($langs->trans(
'Service'),
'service');
3388 $text =
img_object($langs->trans(
'Product'),
'product');
3391 if (!empty($lines[$i]->label)) {
3392 $text .=
' <strong>' . $lines[$i]->label .
'</strong>';
3393 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
3395 print $text .
' ' . nl2br($lines[$i]->
description);
3408 print
'<td class="center linecolqty">' . $lines[$i]->qty_asked .
' ' . $unit_order .
'</td>';
3411 if ($origin_id > 0) {
3412 print
'<td class="linecolqtyinothershipments center nowrap">';
3414 $qtyalreadysent = 0;
3415 foreach ($alreadysent as $key => $val) {
3416 if ($lines[$i]->fk_elementdet == $key) {
3418 foreach ($val as $shipmentline_id => $shipmentline_var) {
3419 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
3425 $htmltooltip .=
'<br>';
3427 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
3428 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
3429 $htmltooltip .=
' - ' . $shipmentline_var[
'qty_shipped'];
3430 $htmltooltip .=
' - ' . $langs->trans(
"DateValidation") .
' : ' . (empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
3437 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
3440 $htmltooltip = $langs->trans(
"QtyInOtherShipments") .
'...<br><br>' . $htmltooltip .
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
3444 print $form->textwithpicto((
string) $qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip' . $lines[$i]->id);
3448 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3450 print
'<td colspan="' . $editColspan .
'" class="center"><table class="nobordernopadding centpercent">';
3451 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
3452 print
'<!-- case edit 1 -->';
3454 foreach ($lines[$i]->detail_batch as $detail_batch) {
3457 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>';
3459 if ($lines[$i]->entrepot_id == 0) {
3461 $line->fetch($detail_batch->fk_expeditiondet);
3463 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
3464 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>';
3470 print
'<td><input class="qtyl" name="qtyl' . $line_id .
'_0" id="qtyl' . $line_id .
'_0" type="text" size="4" value="0"></td>';
3472 print
'<td>' . $formproduct->selectLotStock(
'',
'batchl' . $line_id .
'_0',
'', 1, 0, $lines[$i]->fk_product) .
'</td>';
3475 if ($lines[$i]->fk_product > 0) {
3476 if ($lines[$i]->entrepot_id > 0) {
3477 print
'<!-- case edit 2 -->';
3480 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>';
3482 print
'<td>' . $formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl' . $line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3486 print
' - ' . $langs->trans(
"NA");
3490 } elseif (count($lines[$i]->details_entrepot) > 1) {
3491 print
'<!-- case edit 3 -->';
3492 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3495 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>';
3497 print
'<td>' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl' . $detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3501 print
' - ' . $langs->trans(
"NA");
3507 print
'<!-- case edit 4 -->';
3510 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3511 print
'<td><span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span></td>';
3515 print
'<!-- case edit 5 -->';
3516 print
'<tr><td colspan="3">' . $langs->trans(
"ErrorStockIsNotEnough") .
'</td></tr>';
3519 print
'<!-- case edit 6 -->';
3522 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>';
3530 print
'<!-- case edit 7 -->';
3533 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3541 print
'</table></td>';
3544 print
'<td class="linecolqtytoship center">' . $lines[$i]->qty_shipped .
' ' . $unit_order .
'</td>';
3548 print
'<td class="linecolwarehousesource tdoverflowmax200">';
3550 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
3551 } elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) {
3552 $warehouse_id = $lines[$i]->entrepot_id;
3553 if (!isset($conf->cache[
'warehouse'][$warehouse_id])) {
3555 $warehouse->fetch($warehouse_id);
3556 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3558 $warehouse = $conf->cache[
'warehouse'][$warehouse_id];
3560 print $warehouse->getNomUrl(1);
3561 } elseif (count($lines[$i]->details_entrepot) > 1) {
3563 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3564 $warehouse_id = $detail_entrepot->entrepot_id;
3565 if ($warehouse_id > 0) {
3566 if (!isset($conf->cache[
'warehouse'][$warehouse_id])) {
3568 $warehouse->fetch($warehouse_id);
3569 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3571 $warehouse = $conf->cache[
'warehouse'][$warehouse_id];
3573 $detail .= $langs->trans(
"DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped) .
'<br>';
3576 print $form->textwithtooltip(
img_picto(
'',
'object_stock') .
' ' . $langs->trans(
"DetailWarehouseNumber"), $detail);
3577 } elseif (count($lines[$i]->detail_children ?? []) > 1) {
3579 foreach ($lines[$i]->detail_children as $child_product_id => $child_stock_list) {
3580 foreach ($child_stock_list as $warehouse_id => $total_qty) {
3582 $child_product_label =
'';
3583 if (!isset($conf->cache[
'product'][$child_product_id])) {
3584 $child_product =
new Product($db);
3585 $child_product->fetch($child_product_id);
3586 $conf->cache[
'product'][$child_product_id] = $child_product;
3588 $child_product = $conf->cache[
'product'][$child_product_id];
3590 $child_product_label = $child_product->ref .
' ' . $child_product->label;
3593 if (!isset($conf->cache[
'warehouse'][$warehouse_id])) {
3594 $child_warehouse =
new Entrepot($db);
3595 $child_warehouse->fetch($warehouse_id);
3596 $conf->cache[
'warehouse'][$warehouse_id] = $child_warehouse;
3598 $child_warehouse = $conf->cache[
'warehouse'][$warehouse_id];
3600 $detail .= $langs->trans(
'DetailChildrenFormat', $child_product_label, $child_warehouse->label,
price2num($total_qty,
'MS')) .
'<br>';
3603 print $form->textwithtooltip(
img_picto(
'',
'object_stock') .
' ' . $langs->trans(
'DetailWarehouseNumber'), $detail);
3610 if (isset($lines[$i]->detail_batch)) {
3611 print
'<!-- Detail of lot -->';
3612 print
'<td class="linecolbatch">';
3613 if ($lines[$i]->product_tobatch) {
3615 foreach ($lines[$i]->detail_batch as $dbatch) {
3616 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
3618 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
3621 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
3623 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
3626 print $form->textwithtooltip(
img_picto(
'',
'object_barcode') .
' ' . $langs->trans(
"DetailBatchNumber"), $detail);
3628 print $langs->trans(
"NA");
3632 print
'<td class="linecolbatch" ></td>';
3638 print
'<td class="center linecolweight">';
3640 print $lines[$i]->weight * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
3647 print
'<td class="center linecolvolume">';
3649 print $lines[$i]->volume * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
3658 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3659 print
'<td class="center" colspan="2" valign="middle">';
3660 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="' . $langs->trans(
"Save") .
'"><br>';
3661 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="' . $langs->trans(
"Cancel") .
'"><br>';
3664 $edit_url = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id;
3666 $product_id = $lines[$i]->fk_product;
3667 if (!isset($conf->cache[
'product'][$product_id])) {
3669 $product->fetch($product_id);
3670 $conf->cache[
'product'][$product_id] = $product;
3672 $product = $conf->cache[
'product'][$product_id];
3675 if ($product->hasFatherOrChild(1)) {
3681 print
'<td class="linecoledit center">';
3682 print
'<a class="editfielda reposition" href="' . $edit_url .
'">' .
img_edit() .
'</a>';
3684 print
'<td class="linecoldelete" width="10">';
3685 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id .
'">' .
img_delete() .
'</a>';
3689 if (!empty($rowExtrafieldsStart)) {
3690 print $rowExtrafieldsStart;
3691 print $rowExtrafieldsView;
3701 if ($origin_id > 0) {
3712 $line->fetch_optionals();
3715 if ($action ==
'editline' && $line->id == $line_id) {
3716 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
3718 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
3720 } elseif (empty($reshook) && $lines[$i]->product_type ==
"9") {
3722 $objectsrc->fetch($lines[$i]->origin_line_id);
3723 if ($objectsrc->special_code == SUBTOTALS_SPECIAL_CODE) {
3725 require
dol_buildpath(
'/core/tpl/subtotal_expedition_view.tpl.php');
3730 if (empty($num_prod)) {
3731 print
'<tr><td colspan="8"><span class="opacitymedium">' . $langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")) .
'</span></td></tr>';
3745 if (($user->socid == 0) && ($action !=
'presend')) {
3746 print
'<div class="tabsAction">';
3748 $parameters = array();
3749 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3751 if (empty($reshook)) {
3753 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
3754 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))
3758 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3764 if ($user->hasRight(
'expedition',
'creer')) {
3769 if ($user->hasRight(
'expedition',
'creer')) {
3775 if (empty($user->socid)) {
3777 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
3778 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3780 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3788 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=create_delivery&token=' .
newToken() .
'&id=' .
$object->id,
'');
3793 if (
$object->signed_status != Expedition::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
3794 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>';
3796 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>';
3802 if ($user->hasRight(
'facture',
'creer')) {
3804 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT .
'/compta/facture/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
'');
3811 if ($user->hasRight(
'expedition',
'creer') &&
$object->status > 0) {
3813 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3815 print
dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifyclosed&token=' .
newToken() .
'&id=' .
$object->id,
'');
3821 if ($user->hasRight(
'expedition',
'creer')) {
3822 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"] .
'?action=cancel&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3827 if ($user->hasRight(
'expedition',
'supprimer')) {
3840 if ($action !=
'presend' && $action !=
'editline') {
3841 print
'<div class="fichecenter"><div class="fichehalfleft">';
3844 $filedir = $conf->expedition->dir_output .
"/sending/" . $objectref;
3846 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
3848 $genallowed = $user->hasRight(
'expedition',
'lire');
3849 $delallowed = $user->hasRight(
'expedition',
'creer');
3851 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3855 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'shipping'), 1);
3856 $linktoelem = $tmparray[
'linktoelem'];
3857 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3858 print $htmltoenteralink;
3860 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3866 print
'<br><!-- Link to sign -->';
3867 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
3868 print showOnlineSignatureUrl(
'expedition',
$object->ref, $object) .
'<br>';
3871 print
'</div><div class="fichehalfright">';
3875 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3880 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT .
'/expedition/messaging.php?id=' .
$object->id);
3882 $somethingshown = $formactions->showactions($object,
'shipping', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3883 print
'</div></div>';
3892 if (
GETPOST(
'modelselected')) {
3893 $action =
'presend';
3897 $modelmail =
'shipping_send';
3898 $defaulttopic =
'SendShippingRef';
3899 $diroutput = $conf->expedition->dir_output .
'/sending';
3900 $trackid =
'shi' .
$object->id;
3902 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_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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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...
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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, $mode=0)
Check permissions of a user to show a page and an object.
shipping_prepare_head($object)
Prepare array with list of tabs.