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';
225 if ($action ==
'setdraft' && $permissiontoadd) {
227 $result =
$object->setDraft($user, 0);
231 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
236 if ($action ==
'reopen' && $permissiontoadd) {
242 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
248 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
252 if ($action ==
'classin' && $permissiontoadd) {
260 if ($action ==
'setref_customer' && $permissiontoadd) {
266 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPPING_MODIFY');
269 $action =
'editref_customer';
271 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
276 if ($action ==
'update_extras' && $permissiontoeditextra) {
279 $attribute_name =
GETPOST(
'attribute',
'aZ09');
282 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
289 $result =
$object->updateExtraField($attribute_name,
'SHIPPING_MODIFY');
297 $action =
'edit_extras';
302 if ($action ==
'add' && $permissiontoadd) {
305 if ($origin && $origin_id > 0) {
307 $classname = ucfirst($origin);
308 $objectsrc =
new $classname($db);
309 '@phan-var-force Facture|Commande $objectsrc';
310 $objectsrc->fetch($origin_id);
311 $object->socid = $objectsrc->socid;
316 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
325 $object->origin_type = $origin;
326 $object->origin_id = $origin_id;
336 $object->date_delivery = $date_delivery;
337 $object->date_shipping = $date_shipping;
344 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
349 $ret = $extrafields->setOptionalsFromPost(
null, $object);
363 if ($origin && $origin_id > 0) {
365 $object->origin_type = $origin;
366 $object->origin_id = $origin_id;
376 $object->date_delivery = $date_delivery;
377 $object->date_shipping = $date_shipping;
384 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
387 $classname = ucfirst(
$object->origin_type);
388 $objectsrc =
new $classname($db);
389 '@phan-var-force Facture|Commande $objectsrc';
390 $objectsrc->fetch(
$object->origin_id);
392 $object->socid = $objectsrc->socid;
393 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
397 $batch_line = array();
398 $stockLine = array();
399 $array_options = array();
401 $num = count($objectsrc->lines);
404 $product_batch_used = array();
406 for ($i = 0; $i < $num; $i++) {
414 $batch =
"batchl" . $i .
"_0";
415 $stockLocation =
"ent1" . $i .
"_0";
418 $is_batch_or_serial = 0;
419 if (!empty($objectsrc->lines[$i]->fk_product)) {
420 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
421 if ($resultFetch < 0) {
424 $is_batch_or_serial = $product->status_batch;
428 if (
isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
429 if (GETPOSTISSET($batch)) {
432 while (GETPOSTISSET($batch)) {
435 $sub_qty[$j][
'id_batch'] =
GETPOSTINT($batch);
436 $subtotalqty += $sub_qty[$j][
'q'];
438 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)))) {
439 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
444 if ($is_batch_or_serial == 2 && $sub_qty[$j][
'q'] > 0) {
446 $product_batch_used[$j] = $sub_qty[$j][
'id_batch'];
450 $batch =
"batchl" . $i .
"_" . $j;
451 $qty =
"qtyl" . $i .
'_' . $j;
454 $batch_line[$i][
'detail'] = $sub_qty;
455 $batch_line[$i][
'qty'] = $subtotalqty;
458 $totalqty += $subtotalqty;
465 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse") .
' (' . $langs->trans(
"Line") .
' ' .
GETPOSTINT($idl) .
')',
null,
'errors');
469 } elseif (GETPOSTISSET($stockLocation)) {
472 while (GETPOSTISSET($stockLocation)) {
475 $stockLine[$i][$j][
'warehouse_id'] =
GETPOSTINT($stockLocation);
476 $stockLine[$i][$j][
'ix_l'] =
GETPOSTINT($idl);
482 $stockLocation =
"ent1" . $i .
"_" . $j;
483 $qty =
"qtyl" . $i .
'_' . $j;
494 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
495 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i + 1),
null,
'errors');
501 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
503 if (isset($extrafields->attributes[
$object->table_element_line][
'label']) && is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
505 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
506 unset($_POST[
"options_" . $key]);
511 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
512 $selected_subtotal_lines =
GETPOST(
'subtotal_toselect',
'array:int');
513 for ($i = 0; $i < $num; $i++) {
516 if (!isset($batch_line[$i])) {
518 if (isset($stockLine[$i])) {
520 $nbstockline = count($stockLine[$i]);
521 for ($j = 0; $j < $nbstockline; $j++) {
522 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
523 $ret =
$object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], (
float) $stockLine[$i][$j][
'qty'], $array_options[$i]);
535 if ($entrepot_id < 0) {
538 if (!($objectsrc->lines[$i]->fk_product > 0)) {
549 if (
isModEnabled(
'subtotals') && $objectsrc->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && in_array($objectsrc->lines[$i]->id, $selected_subtotal_lines)) {
550 $object->addSubtotalLine($langs, $objectsrc->lines[$i]->desc, (
int) $objectsrc->lines[$i]->qty, $objectsrc->lines[$i]->extraparams, $objectsrc->lines[$i]->id);
555 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
556 $origin_line_id = (int) $batch_line[$i][
'ix_l'];
558 $res = $origin_line->fetch($origin_line_id);
563 $ret =
$object->addline_batch($batch_line[$i], $array_options[$i], $origin_line);
572 $ret = $extrafields->setOptionalsFromPost(
null, $object);
585 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
587 $labelfieldmissing .=
'/' . $langs->transnoentitiesnoconv(
"Warehouse");
589 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
596 foreach (
$object->lines as $line) {
597 $objectsrc_line =
new $objectsrc->class_element_line($db);
598 '@phan-var-force CommonObjectLine $objectsrc_line';
599 $objectsrc_line->fetch($line->origin_line_id);
600 $line->extraparams = $objectsrc_line->extraparams;
601 $line->setExtraParameters();
603 header(
"Location: card.php?id=" .
$object->id);
610 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
614 $result =
$object->create_delivery($user);
618 header(
"Location: " . DOL_URL_ROOT .
'/delivery/card.php?action=create_delivery&token=' .
newToken() .
'&id=' . $result);
626 $action ==
'confirm_valid' && $confirm ==
'yes' && ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
627 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
631 $result =
$object->valid($user);
638 $outputlangs = $langs;
641 $newlang =
GETPOST(
'lang_id',
'aZ09');
644 $newlang =
$object->thirdparty->default_lang;
646 if (!empty($newlang)) {
648 $outputlangs->setDefaultLang($newlang);
653 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
659 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
660 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
661 $result =
$object->cancel($user, 0, (
bool) $also_update_stock);
663 $result =
$object->setStatut(-1);
667 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
668 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
669 $result =
$object->delete($user, 0, (
bool) $also_update_stock);
671 header(
"Location: " . DOL_URL_ROOT .
'/expedition/index.php');
685 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $permissiontoadd) {
686 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
689 $object->line_order(
true,
'ASC',
false);
691 $outputlangs = $langs;
694 $newlang =
GETPOST(
'lang_id',
'aZ09');
697 $newlang =
$object->thirdparty->default_lang;
699 if (!empty($newlang)) {
701 $outputlangs->setDefaultLang($newlang);
705 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
708 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
713 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
715 $result =
$object->deleteLine($user, $lineid);
720 $outputlangs = $langs;
723 $newlang =
GETPOST(
'lang_id',
'aZ09');
726 $newlang =
$object->thirdparty->default_lang;
728 if (!empty($newlang)) {
730 $outputlangs->setDefaultLang($newlang);
734 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
737 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
742 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
743 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
745 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
750 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
751 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
753 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
758 } elseif ($action ==
'setdate_livraison' && $user->hasRight(
'expedition',
'creer')) {
762 $result =
$object->setDeliveryDate($user, $datedelivery);
766 } elseif ($action ==
'setdate_shipping' && $user->hasRight(
'expedition',
'creer')) {
770 $result =
$object->setShippingDate($user, $dateshipping);
774 } elseif (in_array($action, array(
'settracking_number',
'settracking_url',
'settrueWeight',
'settrueWidth',
'settrueHeight',
'settrueDepth',
'setshipping_method_id')) && $user->hasRight(
'expedition',
'creer')) {
778 if ($action ==
'settracking_number') {
779 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
781 if ($action ==
'settracking_url') {
782 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'restricthtml'));
785 if ($action ==
'settrueWeight') {
789 if ($action ==
'settrueWidth') {
792 if ($action ==
'settrueHeight') {
796 if ($action ==
'settrueDepth') {
799 if ($action ==
'setshipping_method_id') {
803 if (
$object->update($user) >= 0) {
804 header(
"Location: card.php?id=" .
$object->id);
809 } elseif ($action ==
'classifybilled' && $permissiontoadd) {
811 $result =
$object->setBilled();
813 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
817 } elseif ($action ==
'classifyclosed' && $permissiontoadd) {
819 $result =
$object->setClosed();
821 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
825 } elseif ($action ==
'deleteline' && !empty($line_id) && $permissiontoadd) {
831 $line->fk_expedition =
$object->id;
833 $num_prod = count($lines);
834 for ($i = 0; $i < $num_prod; $i++) {
835 if ($lines[$i]->
id == $line_id) {
838 if (is_array($lines[$i]->details_entrepot) && count($lines[$i]->details_entrepot) > 1) {
840 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
841 $line->id = $details_entrepot->line_id;
842 if (!$error && $line->delete($user) < 0) {
848 $line->id = $line_id;
849 if (!$error && $line->delete($user) < 0) {
854 unset($_POST[
"lineid"]);
858 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
863 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'save')) {
868 if (!
$object->fetch($id) > 0) {
873 $qty =
GETPOST(
'qty',
'alpha');
876 $element_type =
'shipping';
882 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
883 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
885 if (is_array($extralabelsline)) {
887 foreach ($extralabelsline as $key => $value) {
888 unset($_POST[
"options_" . $key]);
897 $result =
$object->updatelinefree(
GETPOSTINT(
'lineid'), (
float) $qty, $element_type, $fk_product,
GETPOSTINT(
'units'), $rang, $description, $fk_parent, 0, $array_options);
902 $outputlangs = $langs;
905 $newlang =
GETPOST(
'lang_id',
'aZ09');
908 $newlang =
$object->thirdparty->default_lang;
910 if (!empty($newlang)) {
912 $outputlangs->setDefaultLang($newlang);
913 $outputlangs->load(
'products');
917 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
919 unset($_POST[
'qty']);
920 unset($_POST[
'units']);
925 } elseif ($origin && $origin_id > 0) {
933 $num_prod = count($lines);
934 for ($i = 0; $i < $num_prod; $i++) {
935 if ($lines[$i]->
id == $line_id) {
936 $update_done =
false;
938 $line->fk_expedition =
$object->id;
941 $line->array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
943 if (is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
944 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
945 unset($_POST[
"options_" . $key]);
948 $line->fk_product = $lines[$i]->fk_product;
949 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
951 foreach ($lines[$i]->detail_batch as $detail_batch) {
953 $batch =
"batchl" . $detail_batch->fk_expeditiondet .
"_" . $detail_batch->fk_origin_stock;
954 $qty =
"qtyl" . $detail_batch->fk_expeditiondet .
'_' . $detail_batch->id;
957 if (!empty($batch_id)) {
958 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
959 if ($lines[$i]->entrepot_id != 0) {
961 $line->entrepot_id = $lotStock->warehouseid;
965 if (empty($line->detail_batch)) {
966 $line->detail_batch =
new stdClass();
969 $line->detail_batch->fk_origin_stock = $batch_id;
970 $line->detail_batch->batch = $lotStock->batch;
971 $line->detail_batch->id = $detail_batch->id;
972 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
973 $line->detail_batch->qty = $batch_qty;
974 if ($line->update($user) < 0) {
985 unset($_POST[$batch]);
990 $batch =
"batchl" . $line_id .
"_0";
991 $qty =
"qtyl" . $line_id .
"_0";
995 if ($batch_qty > 0 && !empty($batch_id)) {
996 if ($lotStock->fetch($batch_id) > 0) {
998 if ($lines[$i]->entrepot_id > 0) {
1000 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
1001 $lineIdToAddLot = $line_id;
1003 } elseif (count($lines[$i]->details_entrepot) > 1) {
1005 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1006 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
1007 $lineIdToAddLot = $detail_entrepot->line_id;
1011 if ($lineIdToAddLot) {
1013 if ($line->fetch($lineIdToAddLot) > 0) {
1014 $line->detail_batch->fk_origin_stock = $batch_id;
1015 $line->detail_batch->batch = $lotStock->batch;
1016 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
1017 $line->detail_batch->qty = $batch_qty;
1018 if ($line->update($user) < 0) {
1022 $update_done =
true;
1030 $line->origin_line_id = $lines[$i]->origin_line_id;
1031 $line->entrepot_id = $lotStock->warehouseid;
1033 $line->detail_batch[0]->fk_origin_stock = $batch_id;
1034 $line->detail_batch[0]->batch = $lotStock->batch;
1035 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
1036 $line->detail_batch[0]->qty = $batch_qty;
1037 if (
$object->create_line_batch($line, $line->array_options) < 0) {
1041 $update_done =
true;
1050 if ($lines[$i]->fk_product > 0) {
1052 if ($lines[$i]->entrepot_id == 0) {
1054 $stockLocation =
"entl" . $line_id;
1055 $qty =
"qtyl" . $line_id;
1056 $line->id = $line_id;
1057 $line->entrepot_id =
GETPOSTINT((
string) $stockLocation);
1059 if ($line->update($user) < 0) {
1063 unset($_POST[$stockLocation]);
1064 unset($_POST[$qty]);
1065 } elseif ($lines[$i]->entrepot_id > 0) {
1067 $stockLocation =
"entl" . $line_id;
1068 $qty =
"qtyl" . $line_id;
1069 $line->id = $line_id;
1070 $line->entrepot_id =
GETPOSTINT($stockLocation);
1072 if ($line->update($user) < 0) {
1076 unset($_POST[$stockLocation]);
1077 unset($_POST[$qty]);
1078 } elseif (count($lines[$i]->details_entrepot) > 1) {
1080 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1082 $stockLocation =
"entl" . $detail_entrepot->line_id;
1083 $qty =
"qtyl" . $detail_entrepot->line_id;
1085 if (!empty($warehouse)) {
1086 $line->id = $detail_entrepot->line_id;
1087 $line->entrepot_id = $warehouse;
1089 if ($line->update($user) < 0) {
1093 $update_done =
true;
1096 unset($_POST[$stockLocation]);
1097 unset($_POST[$qty]);
1101 $qty =
"qtyl" . $line_id;
1102 $line->id = $line_id;
1104 $line->entrepot_id = 0;
1105 if ($line->update($user) < 0) {
1109 $update_done =
true;
1111 unset($_POST[$qty]);
1115 $qty =
"qtyl" . $line_id;
1116 $line->id = $line_id;
1118 $line->entrepot_id = 0;
1119 if ($line->update($user) < 0) {
1123 $update_done =
true;
1125 unset($_POST[$qty]);
1129 if (empty($update_done)) {
1130 $line->id = $lines[$i]->id;
1131 $line->insertExtraFields();
1136 unset($_POST[
"lineid"]);
1141 $outputlangs = $langs;
1144 $newlang =
GETPOST(
'lang_id',
'aZ09');
1147 $newlang =
$object->thirdparty->default_lang;
1149 if (!empty($newlang)) {
1150 $outputlangs =
new Translate(
"", $conf);
1151 $outputlangs->setDefaultLang($newlang);
1155 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1158 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1162 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1163 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1165 } elseif ($action ==
'addline' && !$origin &&
getDolGlobalString(
'SHIPMENT_STANDALONE') && $usercancreate) {
1166 $langs->load(
'errors');
1168 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1172 $fk_elementdet =
'';
1173 $element_type =
'shipping';
1179 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
1180 if ($prod_entry_mode ==
'free') {
1185 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1193 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1194 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1196 if (is_array($extralabelsline)) {
1198 foreach ($extralabelsline as $key => $value) {
1199 unset($_POST[
"options_".$key]);
1203 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1204 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1209 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1213 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1216 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1217 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1221 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1222 if ($combinations =
GETPOST(
'combinations',
'array')) {
1226 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1227 $idprod = $res->fk_product_child;
1228 $fk_product = $idprod;
1230 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1236 if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1238 if (!empty($idprod) && $idprod > 0) {
1240 $prod->fetch($idprod);
1241 $desc = $prod->label;
1242 $description = $desc;
1245 $outputlangs = $langs;
1247 if (
GETPOST(
'lang_id',
'aZ09')) {
1248 $newlang =
GETPOST(
'lang_id',
'aZ09');
1250 if (empty($newlang)) {
1251 $newlang =
$object->thirdparty->default_lang;
1253 if (!empty($newlang)) {
1254 $outputlangs =
new Translate(
"", $conf);
1255 $outputlangs->setDefaultLang($newlang);
1258 $description = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1260 $description = $prod->description;
1265 $description = $line_desc;
1269 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1272 $outputlangs = $langs;
1274 if (
GETPOST(
'lang_id',
'alpha')) {
1275 $newlang =
GETPOST(
'lang_id',
'alpha');
1277 if (empty($newlang)) {
1278 $newlang =
$object->thirdparty->default_lang;
1280 if (!empty($newlang)) {
1281 $outputlangs =
new Translate(
"", $conf);
1282 $outputlangs->setDefaultLang($newlang);
1283 $outputlangs->load(
'products');
1285 if (!empty($prod->customcode)) {
1286 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1288 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1291 if (!empty($prod->country_code)) {
1292 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
1295 if (!empty($prod->customcode)) {
1296 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1298 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1301 if (!empty($prod->country_code)) {
1302 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $langs, 0);
1308 $type = $prod->type;
1309 $fk_unit = $prod->fk_unit;
1311 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1314 $fk_unit =
GETPOST(
'units',
'alpha');
1315 $description = $desc;
1316 $fk_elementdet =
'';
1321 $result =
$object->addlinefree((
float) $qty, $element_type, $idprod, $fk_unit, min($rank, count(
$object->lines) + 1), $description, $fk_parent, $array_options);
1328 $outputlangs = $langs;
1329 $newlang =
GETPOST(
'lang_id',
'alpha');
1331 $newlang =
$object->thirdparty->default_lang;
1333 if (!empty($newlang)) {
1334 $outputlangs =
new Translate(
"", $conf);
1335 $outputlangs->setDefaultLang($newlang);
1337 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1340 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1344 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $permissiontoadd) {
1345 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
1349 $outputlangs = $langs;
1352 $newlang =
GETPOST(
'lang_id',
'aZ09');
1355 $newlang =
$object->thirdparty->default_lang;
1357 if (!empty($newlang)) {
1358 $outputlangs =
new Translate(
"", $conf);
1359 $outputlangs->setDefaultLang($newlang);
1361 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1364 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1369 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $permissiontoadd) {
1370 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
1374 $outputlangs = $langs;
1377 $newlang =
GETPOST(
'lang_id',
'aZ09');
1380 $newlang =
$object->thirdparty->default_lang;
1382 if (!empty($newlang)) {
1383 $outputlangs =
new Translate(
"", $conf);
1384 $outputlangs->setDefaultLang($newlang);
1386 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1389 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1396 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
1402 $triggersendname =
'SHIPPING_SENTBYMAIL';
1404 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
1405 $mode =
'emailfromshipment';
1406 $trackid =
'shi' .
$object->id;
1407 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
1414$title =
$object->ref .
' - ' . $langs->trans(
"Card");
1415if ($action ==
'create') {
1416 $title = $langs->trans(
"NewSending");
1419$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
1421llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-expedition page-card');
1423if (empty($action)) {
1427$form =
new Form($db);
1433 $formproject =
null;
1436$product_static =
new Product($db);
1438$warehousestatic =
new Entrepot($db);
1443 print
'<br>' .$langs->trans(
"ShipmentCreationIsDoneFromOrder");
1450if ($action ==
'create' && $usercancreate) {
1458 $res = $soc->fetch($socid);
1461 $shipping_method_id = $soc->shipping_method_id;
1462 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1463 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1465 print
'<form name="crea_expedition" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
1466 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1467 print
'<input type="hidden" name="action" value="add">';
1468 print
'<input type="hidden" name="changecompany" value="0">';
1469 print
'<input type="hidden" name="originid" value="' .
$id .
'">';
1470 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
1474 print
'<table class="border centpercent">';
1478 print
'<td class="fieldrequired">' . $langs->trans(
'ThirdParty') .
'</td>';
1481 print $soc->getNomUrl(1);
1482 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1485 print
'<td class="valuefieldcreate">';
1486 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1490 $(document).ready(function() {
1491 $("#socid").change(function() {
1492 console.log("We have changed the company - Reload page");
1493 var socid = $(this).val();
1495 $("input[name=action]").val("create");
1496 $("input[name=changecompany]").val("1");
1497 $("form[name=crea_expedition]").submit();
1502 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>';
1508 if (
isModEnabled(
'project') && is_object($formproject)) {
1510 if (empty($projectid) && !empty(
$object->fk_project)) {
1511 $projectid = (int)
$object->fk_project;
1514 $langs->load(
"projects");
1516 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1517 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1518 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1519 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>';
1525 print
'<tr><td>'.$langs->trans(
"DateShipping").
'</td>';
1526 print
'<td colspan="3">';
1527 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1528 $date_shipping = ($date_shipping ? $date_shipping :
$object->date_shipping);
1529 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1534 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1535 print
'<td colspan="3">';
1536 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1537 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1538 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1544 print $langs->trans(
"Weight");
1545 print
'</td><td colspan="3">';
1546 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1547 print
'<input name="weight" size="4" value="' .
GETPOST(
'weight') .
'"> ';
1548 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units'), 0, 2);
1549 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1550 print $form->textwithpicto($text, $htmltext);
1555 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1556 print
' </td><td colspan="3">';
1557 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1558 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1559 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1560 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1562 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1563 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1564 print $form->textwithpicto($text, $htmltext);
1568 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1569 print
'<td colspan="3">';
1570 $expe->fetch_delivery_methods();
1571 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1572 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1574 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1576 print
"</td></tr>\n";
1579 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1580 print
'<td colspan="3">';
1581 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1582 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1583 print
"</td></tr>\n";
1586 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1587 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
1588 print $hookmanager->resPrint;
1590 if (empty($reshook)) {
1592 if (
$object->fetch_optionals() > 0) {
1593 $expe->array_options = array_merge($expe->array_options,
$object->array_options);
1595 print $expe->showOptionals($extrafields,
'edit', $parameters);
1601 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1602 print
'<td colspan="3" class="maxwidthonsmartphone">';
1603 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1604 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1609 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1611 if (is_array($list) && count($list) > 1) {
1612 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1613 print
'<td colspan="3">';
1614 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1615 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1616 print
"</td></tr>\n";
1622 print
'<td class="tdtop">';
1623 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext);
1625 print
'<td valign="top" colspan="2">';
1626 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1627 print $doleditor->Create(1);
1630 if (!$user->socid) {
1632 print
'<td class="tdtop">';
1633 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext);
1635 print
'<td valign="top" colspan="2">';
1636 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1637 print $doleditor->Create(1);
1645 print $form->buttonsSaveCancel(
"CreateDraft");
1648 } elseif ($origin) {
1649 $classname = ucfirst($origin);
1651 $object =
new $classname($db);
1653 '@phan-var-force Commande|Facture $object';
1656 if (
$object->fetch($origin_id)) {
1660 $author =
new User($db);
1661 $author->fetch(
$object->user_author_id);
1667 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
1668 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1669 print
'<input type="hidden" name="action" value="add">';
1670 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
1671 print
'<input type="hidden" name="origin_id" value="' .
$object->id .
'">';
1673 print
'<input type="hidden" name="entrepot_id" value="' .
GETPOSTINT(
'entrepot_id') .
'">';
1678 print
'<table class="border centpercent">';
1681 print
'<tr><td class="titlefieldcreate fieldrequired">';
1683 print $langs->trans(
"RefOrder");
1686 print $langs->trans(
"RefProposal");
1688 print
'</td><td colspan="3">';
1695 if ($origin ==
'commande') {
1696 print $langs->trans(
'RefCustomerOrder');
1697 } elseif ($origin ==
'propal') {
1698 print $langs->trans(
'RefCustomerOrder');
1700 print $langs->trans(
'RefCustomer');
1702 print
'</td><td colspan="3">';
1703 print
'<input type="text" name="ref_customer" value="' .
$object->ref_client .
'" />';
1708 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Company') .
'</td>';
1709 print
'<td colspan="3">' . $soc->getNomUrl(1) .
'</td>';
1710 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1714 if (
isModEnabled(
'project') && is_object($formproject)) {
1716 if (empty($projectid) && !empty(
$object->fk_project)) {
1717 $projectid = (int)
$object->fk_project;
1719 if ($origin ==
'project') {
1722 $langs->load(
"projects");
1724 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1725 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1726 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1727 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>';
1733 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
1734 print
'<td colspan="3">';
1735 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1736 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1737 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1742 print
'<tr><td>' . $langs->trans(
"DateShipping") .
'</td>';
1743 print
'<td colspan="3">';
1744 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1746 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1751 print
'<tr><td>' . $langs->trans(
"NotePublic") .
'</td>';
1752 print
'<td colspan="3">';
1753 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1754 print $doleditor->Create(1);
1758 if (
$object->note_private && !$user->socid) {
1759 print
'<tr><td>' . $langs->trans(
"NotePrivate") .
'</td>';
1760 print
'<td colspan="3">';
1761 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1762 print $doleditor->Create(1);
1768 print $langs->trans(
"Weight");
1769 print
'</td><td colspan="3">';
1770 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1773 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOST(
'weight_units'), 0, 2);
1774 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1775 print $form->textwithpicto($text, $htmltext);
1780 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1781 print
' </td><td colspan="3">';
1782 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1783 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1784 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1785 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1787 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1788 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1789 print $form->textwithpicto($text, $htmltext);
1793 print
"<tr><td>" . $langs->trans(
"DeliveryMethod") .
"</td>";
1794 print
'<td colspan="3">';
1795 $expe->fetch_delivery_methods();
1796 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1797 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1799 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1801 print
"</td></tr>\n";
1804 print
"<tr><td>" . $langs->trans(
"TrackingNumber") .
"</td>";
1805 print
'<td colspan="3">';
1806 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1807 print
'<input name="tracking_number" size="20" value="' .
GETPOST(
'tracking_number',
'alpha') .
'">';
1808 print
"</td></tr>\n";
1813 print
'<td><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1) .
'</label></td>';
1814 print
'<td colspan="3" class="maxwidthonsmartphone">';
1815 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1816 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1821 include_once DOL_DOCUMENT_ROOT .
'/core/modules/expedition/modules_expedition.php';
1823 if (is_array($list) && count($list) > 1) {
1824 print
"<tr><td>" . $langs->trans(
"DefaultModel") .
"</td>";
1825 print
'<td colspan="3">';
1826 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1827 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1828 print
"</td></tr>\n";
1836 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && !empty($extrafields->attributes[
$object->table_element][
'label'])) {
1837 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
1838 if (array_key_exists(
'options_'.$key, $objectsav->array_options)) {
1839 $object->array_options[
'options_'.$key] = $objectsav->array_options[
'options_'.$key];
1843 $parameters = array(
1844 'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
1848 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1858 $numAsked = count(
$object->lines);
1860 print
'<script type="text/javascript">' .
"\n";
1861 print
'jQuery(document).ready(function() {' .
"\n";
1862 print
'jQuery("#autofill").click(function() {';
1864 while ($i < $numAsked) {
1865 print
'jQuery("#qtyl' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1867 print
'jQuery("#qtyl' . $i .
'_' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1871 print
'return false; });' .
"\n";
1872 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);' .
"\n";
1873 print
'return false; });' .
"\n";
1875 print
'</script>' .
"\n";
1879 print
'<div class="div-table-responsive-no-min">';
1880 print
'<table class="noborder centpercent">';
1885 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1887 $title_lines_to_disable = array();
1892 $title_lines_to_disable =
$object->getDisabledShippmentSubtotalLines();
1894 $selectedLines =
GETPOST(
'subtotal_toselect',
'array:int');
1895 foreach (
$object->lines as $line) {
1896 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1897 $show_check_add_buttons =
true;
1902 print
'<tr class="liste_titre">';
1904 if (isset($show_check_add_buttons)) {
1905 print $form->showCheckAddButtons(
'checkforselect');
1907 print $langs->trans(
"Description");
1909 print
'<td class="center">' . $langs->trans(
"QtyOrdered") .
'</td>';
1910 print
'<td class="center">' . $langs->trans(
"QtyShipped") .
'</td>';
1911 print
'<td class="center">' . $langs->trans(
"QtyToShip");
1913 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">' .
img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"') .
'</a>';
1918 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">' .
img_picto($langs->trans(
"Reset"),
'eraser') .
'</span>';
1922 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' (' . $langs->trans(
"Stock") .
')</td>';
1924 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' / ' . $langs->trans(
"Batch") .
' (' . $langs->trans(
"Stock") .
')</td>';
1928 print
'<td class="left">' . $langs->trans(
'StockEntryDate') .
'</td>';
1934 $warehousePicking = array();
1936 if ($warehouse_id > 0) {
1937 $warehousePicking[] = $warehouse_id;
1939 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1943 while ($indiceAsked < $numAsked) {
1946 $line =
$object->lines[$indiceAsked];
1948 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1949 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1954 if (empty($reshook) && $line->special_code != SUBTOTALS_SPECIAL_CODE) {
1956 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1958 if (!empty($line->date_start)) {
1961 if (!empty($line->date_end)) {
1965 print
'<!-- line for order line ' . $line->id .
' -->' .
"\n";
1966 print
'<tr class="oddeven" id="row-' . $line->id .
'">' .
"\n";
1968 $qtyProdCom = $line->qty;
1969 $productChildrenNb = 0;
1971 if ($line->fk_product > 0) {
1972 $res = $product->fetch($line->fk_product);
1977 $productChildrenNb = $product->hasFatherOrChild(1);
1979 if ($productChildrenNb > 0) {
1980 $product->loadStockForVirtualProduct(
'warehouseopen', $qtyProdCom);
1982 $product->load_stock(
'warehouseopen');
1987 print
'<a name="' . $line->id .
'"></a>';
1990 $product_static->type = $line->fk_product_type;
1991 $product_static->id = $line->fk_product;
1992 $product_static->ref = $line->ref;
1993 $product_static->status = $line->product_tosell;
1994 $product_static->status_buy = $line->product_tobuy;
1995 $product_static->status_batch = $line->product_tobatch;
1997 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
1999 $text = $product_static->getNomUrl(1);
2000 $text .=
' - ' . (!empty($line->label) ? $line->label : $line->product_label);
2002 $description .= empty($product->stockable_product) ? $langs->trans(
'StockDisabled') : $langs->trans(
'StockEnabled');
2003 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2006 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
2009 if ($showdescinproductdesc) {
2010 print ($line->desc && $line->desc != $line->product_label) ?
'<br>' .
dol_htmlentitiesbr($line->desc) :
'';
2017 $text =
img_object($langs->trans(
'Service'),
'service');
2019 $text =
img_object($langs->trans(
'Product'),
'product');
2022 if (!empty($line->label)) {
2023 $text .=
' <strong>' . $line->label .
'</strong>';
2024 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
2026 print $text .
' ' . nl2br($line->desc);
2030 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
2041 print
'<td class="center">' . $line->qty;
2042 print
'<input name="qtyasked' . $indiceAsked .
'" id="qtyasked' . $indiceAsked .
'" type="hidden" value="' . $line->qty .
'">';
2044 print
' ' . $unit_order .
'</td>';
2048 print
'<td class="center">';
2049 $quantityDelivered = isset(
$object->expeditions[$line->id]) ?
$object->expeditions[$line->id] :
'';
2050 print $quantityDelivered;
2051 print
'<input name="qtydelivered' . $indiceAsked .
'" id="qtydelivered' . $indiceAsked .
'" type="hidden" value="' . $quantityDelivered .
'">';
2052 if ($quantityDelivered) {
2053 print
' ' . $unit_order .
'</td>';
2057 $quantityAsked = $line->qty;
2059 $quantityToBeDelivered = 0;
2061 if (is_numeric($quantityDelivered)) {
2062 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
2064 $quantityToBeDelivered = $quantityAsked;
2068 $warehouseObject =
null;
2069 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !
isModEnabled(
'stock')) {
2070 print
'<!-- Case warehouse already known or product not a predefined product -->';
2072 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
2074 $deliverableQty = $quantityToBeDelivered;
2076 $deliverableQty = min($quantityToBeDelivered, $stock);
2078 if ($deliverableQty < 0) {
2079 $deliverableQty = 0;
2081 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2083 print
'<td class="center">';
2085 if (GETPOSTISSET(
'qtyl'.$indiceAsked) &&
GETPOST(
'qtyl'.$indiceAsked) !==
'') {
2086 $deliverableQty =
GETPOSTFLOAT(
'qtyl'.$indiceAsked,
'MS');
2088 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2089 $qtylValue = $deliverableQty;
2092 } elseif (is_numeric($qtylValue)) {
2094 $qtylValue =
price($qtylValue);
2096 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" class="qtyl right" type="text" size="4" value="' . $qtylValue .
'">';
2099 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2100 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2103 print $langs->trans(
"NA");
2109 print
'<td class="left">';
2112 $ent =
"entl" . $indiceAsked;
2113 $idl =
"idl" . $indiceAsked;
2115 if ($line->fk_product > 0) {
2116 print
'<!-- Show warehouse selection -->';
2122 if ($productChildrenNb > 0) {
2123 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, 0,
'', 0, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2125 if ($product->stockable_product == Product::ENABLED_STOCK) {
2126 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2128 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2132 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
2134 if ($stock < $quantityToBeDelivered) {
2135 print
' ' .
img_warning($langs->trans(
"StockTooLow"));
2140 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span><input name="entl' . $indiceAsked .
'" id="entl' . $indiceAsked .
'" type="hidden" value="0">';
2151 $product->get_sousproduits_arbo();
2152 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2153 if (count($prods_arbo) > 0) {
2154 foreach ($prods_arbo as $key => $value) {
2157 if ($value[
'stock'] < $value[
'stock_alert']) {
2160 print
"<tr class=\"oddeven\"><td> ->
2161 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2162 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2163 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2173 print
'<td></td><td></td>';
2178 print
'<!-- Case product need lot -->';
2180 $staticwarehouse =
new Entrepot($db);
2181 if ($warehouse_id > 0) {
2182 $staticwarehouse->fetch($warehouse_id);
2188 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2189 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2193 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
2194 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2195 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2197 $batchStock = +$dbatch->qty;
2198 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2201 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2202 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2204 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2205 $alreadyQtyBatchSetted[$line->fk_product] = array();
2208 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2209 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2212 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2215 if ($deliverableQty < 0) {
2216 $deliverableQty = 0;
2219 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2220 if (GETPOSTISSET($inputName)) {
2221 $deliverableQty =
GETPOST($inputName,
'int');
2224 $tooltipClass = $tooltipTitle =
'';
2225 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2226 $tooltipClass =
' classfortooltip';
2227 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2229 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2231 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2233 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2234 print
'<td colspan="3" ></td><td class="center">';
2235 $qtylValue = $deliverableQty;
2238 } elseif (is_numeric($qtylValue)) {
2239 $qtylValue =
price($qtylValue);
2241 print
'<input class="qtyl ' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="' . $qtylValue .
'">';
2244 print
'<!-- Show details of lot -->';
2245 print
'<td class="left">';
2247 print $staticwarehouse->getNomUrl(0) .
' / ';
2249 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2252 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
2254 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2257 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2259 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
2263 $quantityToBeDelivered -= $deliverableQty;
2264 if ($quantityToBeDelivered < 0) {
2265 $quantityToBeDelivered = 0;
2270 print
'<td>' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2275 print
'<!-- Case there is no details of lot at all -->';
2276 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2277 print
'<input class="qtyl right" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="0" disabled="disabled"> ';
2280 print
'<td class="left">';
2281 print
img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
2291 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2292 print
'<!-- Case warehouse not already known and product does not need lot -->';
2293 print
'<td></td><td></td>';
2297 print
'</tr>' .
"\n";
2299 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2304 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2305 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2309 $tmpwarehouseObject =
new Entrepot($db);
2310 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2312 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2317 $tmpwarehouseObject->fetch($warehouse_id);
2318 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2319 $stock = +$stock_warehouse->real;
2320 $deliverableQty = min($quantityToBeDelivered, $stock);
2321 $deliverableQty = max(0, $deliverableQty);
2323 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2324 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked=' . $indiceAsked .
') -->';
2330 $tooltipClass = $tooltipTitle =
'';
2331 if ($productChildrenNb <= 0) {
2332 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2333 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
2335 if (!isset($alreadyQtySetted[$line->fk_product])) {
2336 $alreadyQtySetted[$line->fk_product] = array();
2339 $deliverableQty = min($quantityToBeDelivered, $stock);
2342 if ($deliverableQty < 0) {
2343 $deliverableQty = 0;
2346 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2347 $tooltipClass =
' classfortooltip';
2348 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2350 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
2353 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2356 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
2357 if (GETPOSTISSET($inputName)) {
2360 $qtylValue = $deliverableQty;
2363 } elseif (is_numeric($qtylValue)) {
2364 $qtylValue =
price($qtylValue);
2366 print
'<input class="qtyl' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="text" size="4" value="' . $qtylValue .
'">';
2367 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_id .
'">';
2370 print
'<input name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2373 print $langs->trans(
"NA");
2378 print
'<td class="left">';
2380 if ($product->stockable_product == Product::ENABLED_STOCK || $productChildrenNb > 0) {
2381 print $tmpwarehouseObject->getNomUrl(0) .
' ';
2382 if ($productChildrenNb <= 0) {
2383 print
'<!-- Show details of stock -->';
2384 print
'(' . $stock .
')';
2387 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2390 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2393 $quantityToBeDelivered -= $deliverableQty;
2394 if ($quantityToBeDelivered < 0) {
2395 $quantityToBeDelivered = 0;
2406 $product->get_sousproduits_arbo();
2407 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2408 if (count($prods_arbo) > 0) {
2409 foreach ($prods_arbo as $key => $value) {
2412 if ($value[
'stock'] < $value[
'stock_alert']) {
2415 print
'<tr class"oddeven"><td>';
2416 print
" ->
2417 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2418 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2419 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2428 print
'<!-- Case warehouse not already known and product need lot -->';
2429 print
'<td></td><td></td>';
2436 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2438 $tmpwarehouseObject =
new Entrepot($db);
2443 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2444 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2445 $nbofsuggested += count($stock_warehouse->detail_batch);
2449 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2451 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2456 $tmpwarehouseObject->fetch($warehouse_id);
2457 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2458 foreach ($stock_warehouse->detail_batch as $dbatch) {
2459 $batchStock = +$dbatch->qty;
2460 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2461 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2463 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2464 $alreadyQtyBatchSetted[$line->fk_product] = array();
2467 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2468 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2471 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2474 if ($deliverableQty < 0) {
2475 $deliverableQty = 0;
2478 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2479 if (GETPOSTISSET($inputName)) {
2483 $tooltipClass = $tooltipTitle =
'';
2484 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2485 $tooltipClass =
' classfortooltip';
2486 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2488 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2490 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2492 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'><td colspan="3"></td><td class="center">';
2493 $qtylValue = $deliverableQty;
2496 } elseif (is_numeric($qtylValue)) {
2497 $qtylValue =
price($qtylValue);
2499 print
'<input class="qtyl right ' . $tooltipClass .
'" title="' . $tooltipTitle .
'" name="' . $inputName .
'" id="' . $inputName .
'" type="text" size="4" value="' . $qtylValue .
'">';
2502 print
'<td class="left">';
2504 print $tmpwarehouseObject->getNomUrl(0) .
' / ';
2506 print
'<!-- Show details of lot -->';
2507 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2508 print
'<input name="entl' . $indiceAsked .
'_'.$subj.
'" type="hidden" value="' . $tmpwarehouseObject->id .
'">';
2511 print $langs->trans(
"Batch") .
': ';
2512 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
2514 print $productlotObject->getNomUrl(1);
2516 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
2519 print
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2522 print
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2524 print
' (' . $dbatch->qty .
')';
2525 $quantityToBeDelivered -= $deliverableQty;
2526 if ($quantityToBeDelivered < 0) {
2527 $quantityToBeDelivered = 0;
2533 print
'<td class="left">' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2541 $warehouse_selected_id =
GETPOSTINT(
'entrepot_id');
2543 print
'<!-- line not shown yet, we show it -->';
2544 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2549 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2550 $disabled =
'disabled="disabled"';
2551 $alt =
'Product need serial or batch number';
2553 if ($warehouse_selected_id <= 0) {
2554 $disabled =
'disabled="disabled"';
2557 if ($product->stockable_product == Product::ENABLED_STOCK) {
2560 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).
'"' :
'').
'> ';
2562 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
2568 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2569 $disabled =
'disabled="disabled"';
2571 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$quantityToBeDelivered.
'"'.($disabled ?
' '.$disabled :
'').
'> ';
2575 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="0">';
2577 print $langs->trans(
"NA");
2581 print
'<td class="left">';
2584 if (($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK)) {
2585 $warehouseObject =
new Entrepot($db);
2586 $warehouseObject->fetch($warehouse_selected_id);
2587 print
img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
2589 if ($line->fk_product) {
2590 if ($product->stockable_product != Product::ENABLED_STOCK) {
2591 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2593 print
img_warning() .
' ' . $langs->trans(
'StockTooLow');
2600 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2616 $srcLine->id = $line->id;
2617 $srcLine->fetch_optionals();
2619 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
2621 print $expLine->showOptionals($extrafields,
'edit', array(
'style' =>
'class="drag drop oddeven"',
'colspan' => $colspan), (
string) $indiceAsked,
'',
'1');
2622 } elseif (empty($reshook) && $line->special_code == SUBTOTALS_SPECIAL_CODE && !in_array($line->id, $title_lines_to_disable)) {
2623 require
dol_buildpath(
'/core/tpl/subtotalline_select.tpl.php');
2634 print $form->buttonsSaveCancel(
"Create");
2644 '@phan-var-force Expedition $object';
2650 $num_prod = count($lines);
2653 $typeobject =
$object->origin;
2655 $origin_id =
$object->origin_id;
2663 $res =
$object->fetch_optionals();
2671 if ($action ==
'delete') {
2672 $formquestion = array();
2674 $formquestion = array(
2676 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
2677 'name' =>
'alsoUpdateStock',
2678 'type' =>
'checkbox',
2683 $formconfirm = $form->formconfirm(
2684 $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
2685 $langs->trans(
'DeleteSending'),
2686 $langs->trans(
"ConfirmDeleteSending",
$object->ref),
2695 if ($action ==
'ask_subtotal_deleteline') {
2697 $langs->load(
"subtotals");
2698 $title =
"DeleteSubtotalLine";
2699 $question =
"ConfirmDeleteSubtotalLine";
2700 if (
GETPOST(
'type') ==
'title') {
2701 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2702 $title =
"DeleteTitleLine";
2703 $question =
"ConfirmDeleteTitleLine";
2705 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2709 if ($action ==
'valid') {
2710 $objectref = substr(
$object->ref, 1, 4);
2711 if ($objectref ==
'PROV') {
2712 $numref =
$object->getNextNumRef($soc);
2714 $numref = (string)
$object->ref;
2717 $text = $langs->trans(
"ConfirmValidateSending", $numref);
2719 $text .=
'<br>' .
img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementWillBeRecorded") .
'.';
2721 $text .=
'<br>' .
img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementNotYetRecorded") .
'.';
2725 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2726 $notify =
new Notify($db);
2728 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE',
$object->socid, $object);
2731 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 260);
2735 if ($action ==
'cancel') {
2736 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending",
$object->ref),
'confirm_cancel',
'', 0, 1);
2740 if ($action ==
'sign') {
2741 $text = $langs->trans(
'ConfirmSignShipping');
2743 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2744 $notify =
new Notify($db);
2746 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2751 'name' =>
'signed_status',
2752 'select_show_empty' => 0,
2753 'label' =>
'<span class="fieldrequired">' . $langs->trans(
'SignStatus') .
'</span>',
2754 'values' =>
$object->getSignedStatusLocalisedArray()
2756 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'SignShipping'), $text,
'confirm_sign', $formquestion, 0, 1);
2760 if ($action ==
'unsign') {
2761 $text = $langs->trans(
'ConfirmUnsignShipping');
2763 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2764 $notify =
new Notify($db);
2766 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2768 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnsignShipping'), $text,
'confirm_unsign',
'', 0, 1);
2772 $parameters = array(
'formConfirm' => $formconfirm);
2773 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2774 if (empty($reshook)) {
2775 $formconfirm .= $hookmanager->resPrint;
2776 } elseif ($reshook > 0) {
2777 $formconfirm = $hookmanager->resPrint;
2785 $tmparray =
$object->getTotalWeightVolume();
2786 $totalWeight = $tmparray[
'weight'];
2787 $totalVolume = $tmparray[
'volume'];
2789 if (!empty($typeobject) && $typeobject ===
'commande' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2791 $objectsrc->fetch(
$object->origin_object->id);
2793 if (!empty($typeobject) && $typeobject ===
'propal' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2794 $objectsrc =
new Propal($db);
2795 $objectsrc->fetch(
$object->origin_object->id);
2799 $linkback =
'<a href="' . DOL_URL_ROOT .
'/expedition/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2800 $morehtmlref =
'<div class="refidno">';
2802 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
2803 $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);
2806 $morehtmlref .=
'<br>' .
$object->thirdparty->getNomUrl(1);
2809 if ($origin && $origin_id > 0) {
2811 $langs->load(
"projects");
2812 $morehtmlref .=
'<br>';
2814 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2815 if ($action !=
'classify') {
2816 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2818 $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');
2820 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2822 $proj->fetch($objectsrc->fk_project);
2823 $morehtmlref .= $proj->getNomUrl(1);
2825 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2833 $langs->load(
"projects");
2834 $morehtmlref .=
'<br>';
2835 if ($permissiontoadd) {
2836 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2837 if ($action !=
'classify') {
2838 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2840 $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');
2842 if (!empty(
$object->fk_project)) {
2844 $proj->fetch(
$object->fk_project);
2845 $morehtmlref .= $proj->getNomUrl(1);
2847 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2854 $morehtmlref .=
'</div>';
2855 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2857 print
'<div class="fichecenter">';
2858 print
'<div class="fichehalfleft">';
2859 print
'<div class="underbanner clearboth"></div>';
2861 print
'<table class="border tableforfield centpercent">';
2864 if (!empty($typeobject) && $typeobject ==
'commande' &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2866 print $langs->trans(
"RefOrder") .
'</td>';
2868 print $objectsrc->getNomUrl(1,
'commande');
2872 if (!empty($typeobject) && $typeobject ==
'propal' &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2874 print $langs->trans(
"RefProposal") .
'</td>';
2876 print $objectsrc->getNomUrl(1,
'expedition');
2882 print
'<tr><td class="titlefieldmiddle">' . $langs->trans(
"DateCreation") .
'</td>';
2887 print
'<tr><td height="10">';
2888 print
'<table class="nobordernopadding centpercent"><tr><td>';
2889 print $langs->trans(
'DateDeliveryPlanned');
2891 if ($action !=
'editdate_livraison') {
2892 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>';
2894 print
'</tr></table>';
2896 if ($action ==
'editdate_livraison') {
2897 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2898 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2899 print
'<input type="hidden" name="action" value="setdate_livraison">';
2900 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2901 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2910 print
'<tr><td height="10">';
2911 print
'<table class="nobordernopadding centpercent"><tr><td>';
2912 print $langs->trans(
'DateShipping');
2914 if ($action !=
'editdate_shipping') {
2915 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>';
2917 print
'</tr></table>';
2919 if ($action ==
'editdate_shipping') {
2920 print
'<form name="setdate_shipping" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2921 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2922 print
'<input type="hidden" name="action" value="setdate_shipping">';
2923 print $form->selectDate(
$object->date_shipping ?
$object->date_shipping : -1,
'ship_', 1, 1, 0,
"setdate_shipping", 1, 0);
2924 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2934 print $form->editfieldkey(
"Weight",
'trueWeight',
$object->trueWeight, $object, $user->hasRight(
'expedition',
'creer'));
2937 if ($action ==
'edittrueWeight') {
2938 print
'<form name="settrueweight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2939 print
'<input name="action" value="settrueWeight" type="hidden">';
2940 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
2941 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2942 print
'<input id="trueWeight" name="trueWeight" value="' .
$object->trueWeight .
'" type="text" class="width50 valignmiddle">';
2943 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2944 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
2945 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
2953 if ($totalWeight > 0) {
2954 if (!empty(
$object->trueWeight)) {
2955 print
' (' . $langs->trans(
"SumOfProductWeights") .
': ';
2958 if (!empty(
$object->trueWeight)) {
2965 print
'<tr><td>' . $form->editfieldkey(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2966 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer'));
2971 print
'<tr><td>' . $form->editfieldkey(
"Height",
'trueHeight',
$object->trueHeight, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2972 if ($action ==
'edittrueHeight') {
2973 print
'<form name="settrueHeight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2974 print
'<input name="action" value="settrueHeight" type="hidden">';
2975 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
2976 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2977 print
'<input id="trueHeight" name="trueHeight" value="' .
$object->trueHeight .
'" type="text" class="width50">';
2978 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
2979 print
' <input class="button smallpaddingimp" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
2980 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
2990 print
'<tr><td>' . $form->editfieldkey(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2991 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer'));
2997 print $langs->trans(
"Volume");
3000 $calculatedVolume = 0;
3004 $volumeUnit =
$object->size_units * 3;
3007 if ($calculatedVolume > 0) {
3008 if ($volumeUnit < 50) {
3014 if ($totalVolume > 0) {
3015 if ($calculatedVolume) {
3016 print
' (' . $langs->trans(
"SumOfProductVolumes") .
': ';
3020 if ($calculatedVolume) {
3029 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3034 print
'<div class="fichehalfright">';
3035 print
'<div class="underbanner clearboth"></div>';
3037 print
'<table class="border centpercent tableforfield">';
3041 print
'<table class="nobordernopadding centpercent"><tr><td>';
3042 print $langs->trans(
'SendingMethod');
3045 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
3046 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>';
3048 print
'</tr></table>';
3050 if ($action ==
'editshipping_method_id') {
3051 print
'<form name="setshipping_method_id" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3052 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3053 print
'<input type="hidden" name="action" value="setshipping_method_id">';
3054 $object->fetch_delivery_methods();
3055 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
3057 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3059 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
3062 if (
$object->shipping_method_id > 0) {
3064 $code = $langs->getLabelFromKey($db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
3065 print $langs->trans(
"SendingMethod" . strtoupper($code));
3072 print
'<tr><td class="titlefieldmiddle">' . $form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3073 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url, $object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring',
$object->tracking_number);
3079 print
'<table class="nobordernopadding centpercent"><tr><td>';
3080 print $langs->trans(
'IncotermLabel');
3081 print
'<td><td class="right">';
3082 if ($permissiontoadd) {
3083 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/expedition/card.php?id=' .
$object->id .
'&action=editincoterm&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3087 print
'</td></tr></table>';
3090 if ($action !=
'editincoterm') {
3091 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3093 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3099 $parameters = array();
3100 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
3101 print $hookmanager->resPrint;
3108 print
'<div class="clearboth"></div>';
3117 if (!empty(
$object->table_element_line)) {
3119 $result =
$object->getLinesArray();
3121 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
3122 <input type="hidden" name="token" value="' .
newToken().
'">
3123 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3124 <input type="hidden" name="mode" value="">
3125 <input type="hidden" name="page_y" value="">
3126 <input type="hidden" name="id" value="' .
$object->id.
'">
3129 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
3130 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3133 print
'<div class="div-table-responsive-no-min">';
3134 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3135 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3143 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
3144 if ($action !=
'editline') {
3147 $parameters = array();
3148 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3152 if (empty($reshook)) {
3158 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3169 if ($action ==
'editline') {
3170 print
' <form name="updateline" id="updateline" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $line_id .
'" method="POST">
3171 <input type="hidden" name="token" value="' .
newToken() .
'">
3172 <input type="hidden" name="action" value="updateline">
3173 <input type="hidden" name="mode" value="">
3174 <input type="hidden" name="id" value="' .
$object->id .
'">
3179 print
'<div class="div-table-responsive-no-min">';
3180 print
'<table class="noborder centpercent" id="tablelines" >';
3182 print
'<tr class="liste_titre">';
3185 print
'<td width="5" class="center linecolnum"> </td>';
3188 print
'<td class="linecoldescription" >' . $langs->trans(
"Products") .
'</td>';
3190 print
'<td class="center linecolqty">' . $langs->trans(
"QtyOrdered") .
'</td>';
3191 if ($origin_id > 0) {
3192 print
'<td class="center linecolqtyinothershipments">' . $langs->trans(
"QtyInOtherShipments") .
'</td>';
3194 if ($action ==
'editline') {
3202 print
'<td class="center linecoleditlineotherinfo" colspan="' . $editColspan .
'">';
3204 print $langs->trans(
"QtyToShip");
3206 print $langs->trans(
"QtyShipped");
3209 print
' - ' . $langs->trans(
"WarehouseSource");
3212 print
' - ' . $langs->trans(
"Batch");
3217 print
'<td class="center linecolqtytoship">' . $langs->trans(
"QtyToShip") .
'</td>';
3219 print
'<td class="center linecolqtyshipped">' . $langs->trans(
"QtyShipped") .
'</td>';
3222 print
'<td class="left linecolwarehousesource">' . $langs->trans(
"WarehouseSource") .
'</td>';
3226 print
'<td class="left linecolbatch">' . $langs->trans(
"Batch") .
'</td>';
3229 print
'<td class="center linecolweight">' . $langs->trans(
"CalculatedWeight") .
'</td>';
3230 print
'<td class="center linecolvolume">' . $langs->trans(
"CalculatedVolume") .
'</td>';
3233 print
'<td class="linecoledit"></td>';
3234 print
'<td class="linecoldelete" width="10"></td>';
3239 $outputlangs = $langs;
3244 if (
GETPOST(
'lang_id',
'aZ09')) {
3245 $newlang =
GETPOST(
'lang_id',
'aZ09');
3247 if (empty($newlang)) {
3248 $newlang =
$object->thirdparty->default_lang;
3250 if (!empty($newlang)) {
3251 $outputlangs =
new Translate(
"", $conf);
3252 $outputlangs->setDefaultLang($newlang);
3257 $alreadysent = array();
3258 if ($origin_id > 0) {
3259 $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";
3260 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot";
3261 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
3263 $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';
3264 $sql .=
', p.description as product_desc';
3265 $sql .=
" FROM " . MAIN_DB_PREFIX .
"expeditiondet as ed";
3266 $sql .=
", " . MAIN_DB_PREFIX .
"expedition as e";
3267 $sql .=
", " . MAIN_DB_PREFIX . $origin .
"det as obj";
3269 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product as p ON obj.fk_product = p.rowid";
3270 $sql .=
" WHERE e.entity IN (" .
getEntity(
'expedition') .
")";
3271 $sql .=
" AND obj.fk_" . $origin .
" = " . ((int) $origin_id);
3272 $sql .=
" AND obj.rowid = ed.fk_elementdet";
3273 $sql .=
" AND ed.fk_expedition = e.rowid";
3275 $sql .=
" ORDER BY obj.fk_product";
3277 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
3278 $resql = $db->query($sql);
3280 $num = $db->num_rows($resql);
3284 $obj = $db->fetch_object($resql);
3287 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
3288 'shipment_ref' => $obj->shipment_ref,
3289 'shipment_id' => $obj->shipment_id,
3290 'warehouse' => $obj->fk_entrepot,
3291 'qty_shipped' => $obj->qty_shipped,
3292 'product_tosell' => $obj->product_tosell,
3293 'product_tobuy' => $obj->product_tobuy,
3294 'product_tobatch' => $obj->product_tobatch,
3295 'date_valid' => $db->jdate($obj->date_valid),
3296 'date_delivery' => $db->jdate($obj->date_delivery));
3307 $conf->cache[
'product'] = array();
3308 $conf->cache[
'warehouse'] = array();
3309 for ($i = 0; $i < $num_prod; $i++) {
3310 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
3311 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
3316 if (empty($reshook) && $lines[$i]->product_type !=
"9") {
3317 print
'<!-- origin line id = ' . $lines[$i]->origin_line_id .
' -->';
3318 print
'<tr class="oddeven" id="row-' . $lines[$i]->id .
'" data-id="' . $lines[$i]->id .
'" data-element="' . $lines[$i]->element .
'" >';
3322 print
'<td class="center linecolnum">' . ($i + 1) .
'</td>';
3326 if ($lines[$i]->fk_product > 0) {
3329 $product_id = $lines[$i]->fk_product;
3330 if (!isset($conf->cache[
'product'][$product_id])) {
3332 $prod->fetch($product_id);
3333 $conf->cache[
'product'][$product_id] = $prod;
3335 $prod = $conf->cache[
'product'][$product_id];
3337 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
3339 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
3342 print
'<td class="linecoldescription">';
3345 $product_static->type = $lines[$i]->fk_product_type;
3346 $product_static->id = $lines[$i]->fk_product;
3347 $product_static->ref = $lines[$i]->ref;
3348 $product_static->status = $lines[$i]->product_tosell;
3349 $product_static->status_buy = $lines[$i]->product_tobuy;
3350 $product_static->status_batch = $lines[$i]->product_tobatch;
3352 $product_static->weight = $lines[$i]->weight;
3353 $product_static->weight_units = $lines[$i]->weight_units;
3354 $product_static->length = $lines[$i]->length;
3355 $product_static->length_units = $lines[$i]->length_units;
3356 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
3357 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
3358 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
3359 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
3360 $product_static->surface = $lines[$i]->surface;
3361 $product_static->surface_units = $lines[$i]->surface_units;
3362 $product_static->volume = $lines[$i]->volume;
3363 $product_static->volume_units = $lines[$i]->volume_units;
3364 $product_static->stockable_product = $lines[$i]->stockable_product;
3366 $text = $product_static->getNomUrl(1);
3367 $text .=
' - ' . $label;
3369 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
3370 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
3376 print
'<td class="linecoldescription" >';
3378 $text =
img_object($langs->trans(
'Service'),
'service');
3380 $text =
img_object($langs->trans(
'Product'),
'product');
3383 if (!empty($lines[$i]->label)) {
3384 $text .=
' <strong>' . $lines[$i]->label .
'</strong>';
3385 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
3387 print $text .
' ' . nl2br($lines[$i]->
description);
3400 print
'<td class="center linecolqty">' . $lines[$i]->qty_asked .
' ' . $unit_order .
'</td>';
3403 if ($origin_id > 0) {
3404 print
'<td class="linecolqtyinothershipments center nowrap">';
3406 $qtyalreadysent = 0;
3407 foreach ($alreadysent as $key => $val) {
3408 if ($lines[$i]->fk_elementdet == $key) {
3410 foreach ($val as $shipmentline_id => $shipmentline_var) {
3411 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
3417 $htmltooltip .=
'<br>';
3419 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
3420 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
3421 $htmltooltip .=
' - ' . $shipmentline_var[
'qty_shipped'];
3422 $htmltooltip .=
' - ' . $langs->trans(
"DateValidation") .
' : ' . (empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
3429 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
3432 $htmltooltip = $langs->trans(
"QtyInOtherShipments") .
'...<br><br>' . $htmltooltip .
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
3436 print $form->textwithpicto((
string) $qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip' . $lines[$i]->id);
3440 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3442 print
'<td colspan="' . $editColspan .
'" class="center"><table class="nobordernopadding centpercent">';
3443 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
3444 print
'<!-- case edit 1 -->';
3446 foreach ($lines[$i]->detail_batch as $detail_batch) {
3449 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>';
3451 if ($lines[$i]->entrepot_id == 0) {
3453 $line->fetch($detail_batch->fk_expeditiondet);
3455 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
3456 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>';
3462 print
'<td><input class="qtyl" name="qtyl' . $line_id .
'_0" id="qtyl' . $line_id .
'_0" type="text" size="4" value="0"></td>';
3464 print
'<td>' . $formproduct->selectLotStock(
'',
'batchl' . $line_id .
'_0',
'', 1, 0, $lines[$i]->fk_product) .
'</td>';
3467 if ($lines[$i]->fk_product > 0) {
3468 if ($lines[$i]->entrepot_id > 0) {
3469 print
'<!-- case edit 2 -->';
3472 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>';
3474 print
'<td>' . $formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl' . $line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3478 print
' - ' . $langs->trans(
"NA");
3482 } elseif (count($lines[$i]->details_entrepot) > 1) {
3483 print
'<!-- case edit 3 -->';
3484 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3487 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>';
3489 print
'<td>' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl' . $detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3493 print
' - ' . $langs->trans(
"NA");
3499 print
'<!-- case edit 4 -->';
3502 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3503 print
'<td><span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span></td>';
3507 print
'<!-- case edit 5 -->';
3508 print
'<tr><td colspan="3">' . $langs->trans(
"ErrorStockIsNotEnough") .
'</td></tr>';
3511 print
'<!-- case edit 6 -->';
3514 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>';
3522 print
'<!-- case edit 7 -->';
3525 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3533 print
'</table></td>';
3536 print
'<td class="linecolqtytoship center">' . $lines[$i]->qty_shipped .
' ' . $unit_order .
'</td>';
3540 print
'<td class="linecolwarehousesource tdoverflowmax200">';
3542 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
3543 } elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) {
3544 $warehouse_id = $lines[$i]->entrepot_id;
3545 if (!isset($conf->cache[
'warehouse'][$warehouse_id])) {
3547 $warehouse->fetch($warehouse_id);
3548 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3550 $warehouse = $conf->cache[
'warehouse'][$warehouse_id];
3552 print $warehouse->getNomUrl(1);
3553 } elseif (count($lines[$i]->details_entrepot) > 1) {
3555 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3556 $warehouse_id = $detail_entrepot->entrepot_id;
3557 if ($warehouse_id > 0) {
3558 if (!isset($conf->cache[
'warehouse'][$warehouse_id])) {
3560 $warehouse->fetch($warehouse_id);
3561 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3563 $warehouse = $conf->cache[
'warehouse'][$warehouse_id];
3565 $detail .= $langs->trans(
"DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped) .
'<br>';
3568 print $form->textwithtooltip(
img_picto(
'',
'object_stock') .
' ' . $langs->trans(
"DetailWarehouseNumber"), $detail);
3569 } elseif (count($lines[$i]->detail_children ?? []) > 1) {
3571 foreach ($lines[$i]->detail_children as $child_product_id => $child_stock_list) {
3572 foreach ($child_stock_list as $warehouse_id => $total_qty) {
3574 $child_product_label =
'';
3575 if (!isset($conf->cache[
'product'][$child_product_id])) {
3576 $child_product =
new Product($db);
3577 $child_product->fetch($child_product_id);
3578 $conf->cache[
'product'][$child_product_id] = $child_product;
3580 $child_product = $conf->cache[
'product'][$child_product_id];
3582 $child_product_label = $child_product->ref .
' ' . $child_product->label;
3585 if (!isset($conf->cache[
'warehouse'][$warehouse_id])) {
3586 $child_warehouse =
new Entrepot($db);
3587 $child_warehouse->fetch($warehouse_id);
3588 $conf->cache[
'warehouse'][$warehouse_id] = $child_warehouse;
3590 $child_warehouse = $conf->cache[
'warehouse'][$warehouse_id];
3592 $detail .= $langs->trans(
'DetailChildrenFormat', $child_product_label, $child_warehouse->label,
price2num($total_qty,
'MS')) .
'<br>';
3595 print $form->textwithtooltip(
img_picto(
'',
'object_stock') .
' ' . $langs->trans(
'DetailWarehouseNumber'), $detail);
3602 if (isset($lines[$i]->detail_batch)) {
3603 print
'<!-- Detail of lot -->';
3604 print
'<td class="linecolbatch">';
3605 if ($lines[$i]->product_tobatch) {
3607 foreach ($lines[$i]->detail_batch as $dbatch) {
3608 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
3610 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
3613 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
3615 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
3618 print $form->textwithtooltip(
img_picto(
'',
'object_barcode') .
' ' . $langs->trans(
"DetailBatchNumber"), $detail);
3620 print $langs->trans(
"NA");
3624 print
'<td class="linecolbatch" ></td>';
3630 print
'<td class="center linecolweight">';
3632 print $lines[$i]->weight * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
3639 print
'<td class="center linecolvolume">';
3641 print $lines[$i]->volume * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
3650 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3651 print
'<td class="center" colspan="2" valign="middle">';
3652 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="' . $langs->trans(
"Save") .
'"><br>';
3653 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="' . $langs->trans(
"Cancel") .
'"><br>';
3656 $edit_url = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id;
3658 $product_id = $lines[$i]->fk_product;
3659 if (!isset($conf->cache[
'product'][$product_id])) {
3661 $product->fetch($product_id);
3662 $conf->cache[
'product'][$product_id] = $product;
3664 $product = $conf->cache[
'product'][$product_id];
3667 if ($product->hasFatherOrChild(1)) {
3673 print
'<td class="linecoledit center">';
3674 print
'<a class="editfielda reposition" href="' . $edit_url .
'">' .
img_edit() .
'</a>';
3676 print
'<td class="linecoldelete" width="10">';
3677 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id .
'">' .
img_delete() .
'</a>';
3681 if (!empty($rowExtrafieldsStart)) {
3682 print $rowExtrafieldsStart;
3683 print $rowExtrafieldsView;
3693 if ($origin_id > 0) {
3704 $line->fetch_optionals();
3707 if ($action ==
'editline' && $line->id == $line_id) {
3708 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
3710 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
3712 } elseif (empty($reshook) && $lines[$i]->product_type ==
"9") {
3714 $objectsrc->fetch($lines[$i]->origin_line_id);
3715 if ($objectsrc->special_code == SUBTOTALS_SPECIAL_CODE) {
3717 require
dol_buildpath(
'/core/tpl/subtotal_expedition_view.tpl.php');
3722 if (empty($num_prod)) {
3723 print
'<tr><td colspan="8"><span class="opacitymedium">' . $langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")) .
'</span></td></tr>';
3737 if (($user->socid == 0) && ($action !=
'presend')) {
3738 print
'<div class="tabsAction">';
3740 $parameters = array();
3741 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3743 if (empty($reshook)) {
3745 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
3746 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))
3750 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3756 if ($user->hasRight(
'expedition',
'creer')) {
3761 if ($user->hasRight(
'expedition',
'creer')) {
3767 if (empty($user->socid)) {
3769 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
3770 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3772 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3780 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=create_delivery&token=' .
newToken() .
'&id=' .
$object->id,
'');
3785 if (
$object->signed_status != Expedition::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
3786 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>';
3788 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>';
3794 if ($user->hasRight(
'facture',
'creer')) {
3796 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT .
'/compta/facture/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
'');
3803 if ($user->hasRight(
'expedition',
'creer') &&
$object->status > 0) {
3805 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3807 print
dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifyclosed&token=' .
newToken() .
'&id=' .
$object->id,
'');
3813 if ($user->hasRight(
'expedition',
'creer')) {
3814 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"] .
'?action=cancel&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3819 if ($user->hasRight(
'expedition',
'supprimer')) {
3832 if ($action !=
'presend' && $action !=
'editline') {
3833 print
'<div class="fichecenter"><div class="fichehalfleft">';
3836 $filedir = $conf->expedition->dir_output .
"/sending/" . $objectref;
3838 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
3840 $genallowed = $user->hasRight(
'expedition',
'lire');
3841 $delallowed = $user->hasRight(
'expedition',
'creer');
3843 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3847 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'shipping'), 1);
3848 $linktoelem = $tmparray[
'linktoelem'];
3849 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3850 print $htmltoenteralink;
3852 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3858 print
'<br><!-- Link to sign -->';
3859 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
3860 print showOnlineSignatureUrl(
'expedition',
$object->ref, $object) .
'<br>';
3863 print
'</div><div class="fichehalfright">';
3867 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3872 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT .
'/expedition/messaging.php?id=' .
$object->id);
3874 $somethingshown = $formactions->showactions($object,
'shipping', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3875 print
'</div></div>';
3884 if (
GETPOST(
'modelselected')) {
3885 $action =
'presend';
3889 $modelmail =
'shipping_send';
3890 $defaulttopic =
'SendShippingRef';
3891 $diroutput = $conf->expedition->dir_output .
'/sending';
3892 $trackid =
'shi' .
$object->id;
3894 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.