42require
'../main.inc.php';
52require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
53require_once DOL_DOCUMENT_ROOT .
'/expedition/class/expedition.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
56require_once DOL_DOCUMENT_ROOT .
'/core/lib/sendings.lib.php';
57require_once DOL_DOCUMENT_ROOT .
'/core/modules/expedition/modules_expedition.php';
58require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
59require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
60require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/productlot.class.php';
61require_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
63 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
66 require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
69 require_once DOL_DOCUMENT_ROOT .
'/product/class/productbatch.class.php';
72 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
73 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
77$langs->loadLangs(array(
"sendings",
"companies",
"bills",
'orders',
'stocks',
'other',
'propal',
'productbatch'));
80 $langs->load(
'incoterm');
83 $langs->load(
'productbatch');
87$origin =
GETPOST(
'origin',
'alpha');
92if (empty($origin_id) && !empty($origin)) {
95if (empty($origin_id) && !empty($origin)) {
104$action =
GETPOST(
'action',
'alpha');
105$confirm =
GETPOST(
'confirm',
'alpha');
106$cancel =
GETPOST(
'cancel',
'alpha');
109$backtopage =
GETPOST(
'backtopage',
'alpha');
120$extrafields->fetch_name_optionals_label(
$object->table_element);
121$extrafields->fetch_name_optionals_label(
$object->table_element_line);
122$extrafields->fetch_name_optionals_label($objectorder->table_element_line);
125include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
127if (empty($origin) && !empty(
$object->origin_type) &&
$object->origin_id > 0) {
128 $origin =
$object->origin_type;
129} elseif (empty($origin) && is_string(
$object->origin) &&
$object->origin !==
'' &&
$object->origin_id > 0) {
132if (empty($origin_id) &&
$object->origin_id > 0) {
133 $origin_id =
$object->origin_id;
135$origin_type = is_string($origin) ? $origin :
'';
138$usercanread = $user->hasRight(
"expedition",
"lire");
139$usercancreate = $user->hasRight(
"expedition",
"creer");
140$usercandelete = $user->hasRight(
"expedition",
"supprimer");
143$hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
153 $socid = $user->socid;
158$permissiondellink = $user->hasRight(
'expedition',
'delivery',
'creer');
159$permissiontoadd = $user->hasRight(
'expedition',
'creer');
160$permissiontoedit = $usercancreate;
161$permissiontoeditextra = $permissiontoadd;
162if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
164 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
167$upload_dir =
$conf->expedition->dir_output .
'/sending';
173$shipping_method_id =
null;
183$parameters = array();
184$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
189if (empty($reshook)) {
190 $backurlforlist = DOL_URL_ROOT.
'/expedition/list.php';
192 if (empty($backtopage) || ($cancel && empty($id))) {
193 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
194 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
195 $backtopage = $backurlforlist;
197 $backtopage = DOL_URL_ROOT.
'/expedition/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
203 if (!empty($backtopageforcancel)) {
204 header(
"Location: ".$backtopageforcancel);
206 } elseif (!empty($backtopage)) {
207 header(
"Location: ".$backtopage);
215 if ($origin_id > 0) {
216 if ($origin ==
'commande') {
217 header(
"Location: " . DOL_URL_ROOT .
'/expedition/shipment.php?id=' . ((
int) $origin_id));
226 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
229 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
232 if ($action ==
'setdraft' && $permissiontoadd) {
234 $result =
$object->setDraft($user, 0);
238 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
243 if ($action ==
'reopen' && $permissiontoadd) {
249 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
255 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
259 if ($action ==
'setref_customer' && $permissiontoadd) {
265 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPPING_MODIFY');
268 $action =
'editref_customer';
270 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
275 if ($action ==
'update_extras' && $permissiontoeditextra) {
278 $attribute_name =
GETPOST(
'attribute',
'aZ09');
281 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
288 $result =
$object->updateExtraField($attribute_name,
'SHIPPING_MODIFY');
296 $action =
'edit_extras';
301 if ($action ==
'add' && $permissiontoadd) {
304 if ($origin && $origin_id > 0) {
306 $classname = ucfirst($origin);
307 $objectsrc =
new $classname(
$db);
308 '@phan-var-force Facture|Commande $objectsrc';
309 $objectsrc->fetch($origin_id);
310 $object->socid = $objectsrc->socid;
315 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
324 $object->origin_type = $origin_type;
325 $object->origin_id = $origin_id;
335 $object->date_delivery = $date_delivery;
336 $object->date_shipping = $date_shipping;
343 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
348 $ret = $extrafields->setOptionalsFromPost(
null, $object);
362 if ($origin && $origin_id > 0) {
364 $object->origin_type = $origin_type;
365 $object->origin_id = $origin_id;
375 $object->date_delivery = $date_delivery;
376 $object->date_shipping = $date_shipping;
383 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
386 $classname = ucfirst(
$object->origin_type);
387 $objectsrc =
new $classname(
$db);
388 '@phan-var-force Facture|Commande $objectsrc';
389 $objectsrc->fetch(
$object->origin_id);
391 $object->socid = $objectsrc->socid;
392 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
396 $batch_line = array();
397 $stockLine = array();
398 $array_options = array();
400 $num = count($objectsrc->lines);
403 $product_batch_used = array();
405 for ($i = 0; $i < $num; $i++) {
413 $batch =
"batchl" . $i .
"_0";
414 $stockLocation =
"ent1" . $i .
"_0";
417 $is_batch_or_serial = 0;
418 if (!empty($objectsrc->lines[$i]->fk_product)) {
419 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
420 if ($resultFetch < 0) {
423 $is_batch_or_serial = $product->status_batch;
427 if (
isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
428 if (GETPOSTISSET($batch)) {
431 while (GETPOSTISSET($batch)) {
434 $sub_qty[$j][
'id_batch'] =
GETPOSTINT($batch);
435 $subtotalqty += $sub_qty[$j][
'q'];
437 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)))) {
438 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
443 if ($is_batch_or_serial == 2 && $sub_qty[$j][
'q'] > 0) {
445 $product_batch_used[$j] = $sub_qty[$j][
'id_batch'];
449 $batch =
"batchl" . $i .
"_" . $j;
450 $qty =
"qtyl" . $i .
'_' . $j;
453 $batch_line[$i][
'detail'] = $sub_qty;
454 $batch_line[$i][
'qty'] = $subtotalqty;
457 $totalqty += $subtotalqty;
464 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse") .
' (' . $langs->trans(
"Line") .
' ' .
GETPOSTINT($idl) .
')',
null,
'errors');
468 } elseif (GETPOSTISSET($stockLocation)) {
471 while (GETPOSTISSET($stockLocation)) {
474 $stockLine[$i][$j][
'warehouse_id'] =
GETPOSTINT($stockLocation);
475 $stockLine[$i][$j][
'ix_l'] =
GETPOSTINT($idl);
481 $stockLocation =
"ent1" . $i .
"_" . $j;
482 $qty =
"qtyl" . $i .
'_' . $j;
493 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
494 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i + 1),
null,
'errors');
500 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
502 if (isset($extrafields->attributes[
$object->table_element_line][
'label']) && is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
504 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
505 unset($_POST[
"options_" . $key]);
510 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
511 $selected_subtotal_lines =
GETPOST(
'subtotal_toselect',
'array:int');
512 for ($i = 0; $i < $num; $i++) {
515 if (!isset($batch_line[$i])) {
517 if (isset($stockLine[$i])) {
519 $nbstockline = count($stockLine[$i]);
520 for ($j = 0; $j < $nbstockline; $j++) {
521 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
522 $ret =
$object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], (
float) $stockLine[$i][$j][
'qty'], $array_options[$i]);
534 if ($entrepot_id < 0) {
537 if (!($objectsrc->lines[$i]->fk_product > 0)) {
548 if (
isModEnabled(
'subtotals') && $objectsrc->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && in_array($objectsrc->lines[$i]->id, $selected_subtotal_lines)) {
549 $object->addSubtotalLine($langs, $objectsrc->lines[$i]->desc, (
int) $objectsrc->lines[$i]->qty, $objectsrc->lines[$i]->extraparams, $objectsrc->lines[$i]->id);
554 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
555 $origin_line_id = (int) $batch_line[$i][
'ix_l'];
557 $res = $origin_line->fetch($origin_line_id);
562 $ret =
$object->addline_batch($batch_line[$i], $array_options[$i], $origin_line);
571 $ret = $extrafields->setOptionalsFromPost(
null, $object);
584 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
586 $labelfieldmissing .=
'/' . $langs->transnoentitiesnoconv(
"Warehouse");
588 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
595 foreach (
$object->lines as $line) {
596 $objectsrc_line =
new $objectsrc->class_element_line(
$db);
597 '@phan-var-force CommonObjectLine $objectsrc_line';
598 $objectsrc_line->fetch($line->origin_line_id);
599 $line->extraparams = $objectsrc_line->extraparams;
600 $line->setExtraParameters();
602 header(
"Location: card.php?id=" .
$object->id);
609 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
613 $result =
$object->create_delivery($user);
617 header(
"Location: " . DOL_URL_ROOT .
'/delivery/card.php?action=create_delivery&token=' .
newToken() .
'&id=' . $result);
625 $action ==
'confirm_valid' && $confirm ==
'yes' && ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
626 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
630 $result =
$object->valid($user);
637 $outputlangs = $langs;
640 $newlang =
GETPOST(
'lang_id',
'aZ09');
643 $newlang =
$object->thirdparty->default_lang;
645 if (!empty($newlang)) {
647 $outputlangs->setDefaultLang($newlang);
652 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
658 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
659 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
660 $result =
$object->cancel($user, 0, (
bool) $also_update_stock);
666 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
667 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
668 $result =
$object->delete($user, 0, (
bool) $also_update_stock);
670 header(
"Location: " . DOL_URL_ROOT .
'/expedition/index.php');
684 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $permissiontoadd) {
685 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
688 $object->line_order(
true,
'ASC',
false);
690 $outputlangs = $langs;
693 $newlang =
GETPOST(
'lang_id',
'aZ09');
696 $newlang =
$object->thirdparty->default_lang;
698 if (!empty($newlang)) {
700 $outputlangs->setDefaultLang($newlang);
704 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
707 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
712 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
714 $result =
$object->deleteLine($user, $lineid);
719 $outputlangs = $langs;
722 $newlang =
GETPOST(
'lang_id',
'aZ09');
725 $newlang =
$object->thirdparty->default_lang;
727 if (!empty($newlang)) {
729 $outputlangs->setDefaultLang($newlang);
733 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
736 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
741 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
742 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
744 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
749 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
750 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
752 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
757 } elseif ($action ==
'setdate_livraison' && $user->hasRight(
'expedition',
'creer')) {
761 $result =
$object->setDeliveryDate($user, $datedelivery);
765 } elseif ($action ==
'setdate_shipping' && $user->hasRight(
'expedition',
'creer')) {
769 $result =
$object->setShippingDate($user, $dateshipping);
773 } elseif (in_array($action, array(
'settracking_number',
'settracking_url',
'settrueWeight',
'settrueWidth',
'settrueHeight',
'settrueDepth',
'setshipping_method_id')) && $user->hasRight(
'expedition',
'creer')) {
777 if ($action ==
'settracking_number') {
778 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
779 $object->tracking_number = preg_replace(
'/\s+/',
'',
$object->tracking_number);
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(
'cancel',
'alpha') != $langs->trans(
"Cancel")) {
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 $update_done =
true;
1065 unset($_POST[$stockLocation]);
1066 unset($_POST[$qty]);
1067 } elseif ($lines[$i]->entrepot_id > 0) {
1069 $stockLocation =
"entl" . $line_id;
1070 $qty =
"qtyl" . $line_id;
1071 $line->id = $line_id;
1072 $line->entrepot_id =
GETPOSTINT($stockLocation);
1074 if ($line->update($user) < 0) {
1078 $update_done =
true;
1080 unset($_POST[$stockLocation]);
1081 unset($_POST[$qty]);
1082 } elseif (count($lines[$i]->details_entrepot) > 1) {
1084 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
1086 $stockLocation =
"entl" . $detail_entrepot->line_id;
1087 $qty =
"qtyl" . $detail_entrepot->line_id;
1089 if (!empty($warehouse)) {
1090 $line->id = $detail_entrepot->line_id;
1091 $line->entrepot_id = $warehouse;
1093 if ($line->update($user) < 0) {
1097 $update_done =
true;
1100 unset($_POST[$stockLocation]);
1101 unset($_POST[$qty]);
1105 $qty =
"qtyl" . $line_id;
1106 $line->id = $line_id;
1108 $line->entrepot_id = 0;
1109 if ($line->update($user) < 0) {
1113 $update_done =
true;
1115 unset($_POST[$qty]);
1119 $qty =
"qtyl" . $line_id;
1120 $line->id = $line_id;
1122 $line->entrepot_id = 0;
1123 if ($line->update($user) < 0) {
1127 $update_done =
true;
1129 unset($_POST[$qty]);
1133 if (empty($update_done)) {
1134 $line->id = $lines[$i]->id;
1135 $resultInsertExtraFields = $line->insertExtraFields();
1136 if ($resultInsertExtraFields < 0) {
1139 } elseif ($resultInsertExtraFields > 0) {
1140 $update_done =
true;
1144 if (empty($update_done) && !$error) {
1145 setEventMessages($langs->trans(
'NoShipmentLineChangeDetected'),
null,
'warnings');
1150 unset($_POST[
"lineid"]);
1155 $outputlangs = $langs;
1158 $newlang =
GETPOST(
'lang_id',
'aZ09');
1161 $newlang =
$object->thirdparty->default_lang;
1163 if (!empty($newlang)) {
1165 $outputlangs->setDefaultLang($newlang);
1169 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1172 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1176 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1177 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1179 } elseif ($action ==
'addline' && !$origin &&
getDolGlobalString(
'SHIPMENT_STANDALONE') && $usercancreate) {
1180 $langs->load(
'errors');
1182 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1186 $fk_elementdet =
'';
1187 $element_type =
'shipping';
1193 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
1194 if ($prod_entry_mode ==
'free') {
1199 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1207 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1208 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1210 if (is_array($extralabelsline)) {
1212 foreach ($extralabelsline as $key => $value) {
1213 unset($_POST[
"options_".$key]);
1217 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1218 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1223 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1227 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1230 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1231 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1235 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1236 if ($combinations =
GETPOST(
'combinations',
'array')) {
1240 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1241 $idprod = $res->fk_product_child;
1242 $fk_product = $idprod;
1244 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1250 if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1252 if (!empty($idprod) && $idprod > 0) {
1254 $prod->fetch($idprod);
1255 $desc =
$prod->label;
1256 $description = $desc;
1259 $outputlangs = $langs;
1261 if (
GETPOST(
'lang_id',
'aZ09')) {
1262 $newlang =
GETPOST(
'lang_id',
'aZ09');
1264 if (empty($newlang)) {
1265 $newlang =
$object->thirdparty->default_lang;
1267 if (!empty($newlang)) {
1269 $outputlangs->setDefaultLang($newlang);
1272 $description = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1274 $description =
$prod->description;
1279 $description = $line_desc;
1286 $outputlangs = $langs;
1288 if (
GETPOST(
'lang_id',
'alpha')) {
1289 $newlang =
GETPOST(
'lang_id',
'alpha');
1291 if (empty($newlang)) {
1292 $newlang =
$object->thirdparty->default_lang;
1294 if (!empty($newlang)) {
1296 $outputlangs->setDefaultLang($newlang);
1297 $outputlangs->load(
'products');
1299 if (!empty(
$prod->customcode)) {
1300 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.
$prod->customcode;
1302 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1305 if (!empty(
$prod->country_code)) {
1306 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry(
$prod->country_code,
'',
$db, $outputlangs, 0);
1309 if (!empty(
$prod->customcode)) {
1310 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.
$prod->customcode;
1312 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1315 if (!empty(
$prod->country_code)) {
1316 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry(
$prod->country_code,
'',
$db, $langs, 0);
1322 $type =
$prod->type;
1323 $fk_unit =
$prod->fk_unit;
1325 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1328 $fk_unit =
GETPOST(
'units',
'alpha');
1329 $description = $desc;
1330 $fk_elementdet =
'';
1335 $result =
$object->addlinefree((
float) $qty, $element_type, $idprod, $fk_unit, min($rank, count(
$object->lines) + 1), $description, $fk_parent, $array_options);
1342 $outputlangs = $langs;
1343 $newlang =
GETPOST(
'lang_id',
'alpha');
1345 $newlang =
$object->thirdparty->default_lang;
1347 if (!empty($newlang)) {
1349 $outputlangs->setDefaultLang($newlang);
1351 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1354 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1358 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $permissiontoadd) {
1359 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
1363 $outputlangs = $langs;
1366 $newlang =
GETPOST(
'lang_id',
'aZ09');
1369 $newlang =
$object->thirdparty->default_lang;
1371 if (!empty($newlang)) {
1373 $outputlangs->setDefaultLang($newlang);
1375 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1378 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1383 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $permissiontoadd) {
1384 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
1388 $outputlangs = $langs;
1391 $newlang =
GETPOST(
'lang_id',
'aZ09');
1394 $newlang =
$object->thirdparty->default_lang;
1396 if (!empty($newlang)) {
1398 $outputlangs->setDefaultLang($newlang);
1400 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1403 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
1410 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
1416 $triggersendname =
'SHIPPING_SENTBYMAIL';
1418 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
1419 $mode =
'emailfromshipment';
1420 $trackid =
'shi' .
$object->id;
1421 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
1428$title =
$object->ref .
' - ' . $langs->trans(
"Card");
1429if ($action ==
'create') {
1430 $title = $langs->trans(
"NewSending");
1433$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
1435llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-expedition page-card');
1437if (empty($action)) {
1447 $formproject =
null;
1457 print
'<br>' .$langs->trans(
"ShipmentCreationIsDoneFromOrder");
1464if ($action ==
'create' && $usercancreate) {
1472 $res = $soc->fetch($socid);
1475 $shipping_method_id = $soc->shipping_method_id;
1476 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1477 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1479 print
'<form name="crea_expedition" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
1480 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1481 print
'<input type="hidden" name="action" value="add">';
1482 print
'<input type="hidden" name="changecompany" value="0">';
1483 print
'<input type="hidden" name="originid" value="' .
$id .
'">';
1484 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
1488 print
'<table class="border centpercent">';
1492 print
'<td class="fieldrequired">' . $langs->trans(
'ThirdParty') .
'</td>';
1495 print $soc->getNomUrl(1);
1496 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1499 print
'<td class="valuefieldcreate">';
1500 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1504 $(document).ready(function() {
1505 $("#socid").change(function() {
1506 console.log("We have changed the company - Reload page");
1507 var socid = $(this).val();
1509 $("input[name=action]").val("create");
1510 $("input[name=changecompany]").val("1");
1511 $("form[name=crea_expedition]").submit();
1516 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>';
1522 if (
isModEnabled(
'project') && is_object($formproject)) {
1524 if (empty($projectid) && !empty(
$object->fk_project)) {
1525 $projectid = (int)
$object->fk_project;
1528 $langs->load(
"projects");
1530 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1531 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1532 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1533 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>';
1539 print
'<tr><td>'.$langs->trans(
"DateShipping").
'</td>';
1540 print
'<td colspan="3">';
1541 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1542 $date_shipping = ($date_shipping ? $date_shipping :
$object->date_shipping);
1543 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1548 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1549 print
'<td colspan="3">';
1550 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1551 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1552 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1558 print $langs->trans(
"Weight");
1559 print
'</td><td colspan="3">';
1560 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1561 print
'<input name="weight" size="4" value="' .
GETPOST(
'weight') .
'"> ';
1562 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units'), 0, 2);
1563 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1564 print $form->textwithpicto($text, $htmltext);
1569 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1570 print
' </td><td colspan="3">';
1571 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1572 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1573 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1574 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1576 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1577 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1578 print $form->textwithpicto($text, $htmltext);
1582 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1583 print
'<td colspan="3">';
1584 $expe->fetch_delivery_methods();
1585 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1586 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1588 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1590 print
"</td></tr>\n";
1593 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1594 print
'<td colspan="3">';
1595 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1596 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1597 print
"</td></tr>\n";
1600 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1601 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
1602 print $hookmanager->resPrint;
1604 if (empty($reshook)) {
1606 if (
$object->fetch_optionals() > 0) {
1607 $expe->array_options = array_merge($expe->array_options,
$object->array_options);
1609 print $expe->showOptionals($extrafields,
'edit', $parameters);
1615 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1616 print
'<td colspan="3" class="maxwidthonsmartphone">';
1617 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1618 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1623 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1625 if (is_array($list) && count($list) > 1) {
1626 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1627 print
'<td colspan="3">';
1628 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1629 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1630 print
"</td></tr>\n";
1636 print
'<td class="tdtop">';
1637 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext);
1639 print
'<td valign="top" colspan="2">';
1640 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1641 print $doleditor->Create(1);
1644 if (!$user->socid) {
1646 print
'<td class="tdtop">';
1647 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext);
1649 print
'<td valign="top" colspan="2">';
1650 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1651 print $doleditor->Create(1);
1659 print $form->buttonsSaveCancel(
"CreateDraft");
1662 } elseif ($origin) {
1663 $classname = ucfirst($origin);
1667 '@phan-var-force Commande|Facture $object';
1670 if (
$object->fetch($origin_id)) {
1675 $author->fetch(
$object->user_author_id);
1681 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
1682 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1683 print
'<input type="hidden" name="action" value="add">';
1684 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
1685 print
'<input type="hidden" name="origin_id" value="' .
$object->id .
'">';
1687 print
'<input type="hidden" name="entrepot_id" value="' .
GETPOSTINT(
'entrepot_id') .
'">';
1692 print
'<table class="border centpercent">';
1695 print
'<tr><td class="titlefieldcreate fieldrequired">';
1697 print $langs->trans(
"RefOrder");
1700 print $langs->trans(
"RefProposal");
1702 print
'</td><td colspan="3">';
1709 if ($origin ==
'commande') {
1710 print $langs->trans(
'RefCustomerOrder');
1711 } elseif ($origin ==
'propal') {
1712 print $langs->trans(
'RefCustomerOrder');
1714 print $langs->trans(
'RefCustomer');
1716 print
'</td><td colspan="3">';
1717 print
'<input type="text" name="ref_customer" value="' .
$object->ref_client .
'" />';
1722 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Company') .
'</td>';
1723 print
'<td colspan="3">' . $soc->getNomUrl(1) .
'</td>';
1724 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1728 if (
isModEnabled(
'project') && is_object($formproject)) {
1730 if (empty($projectid) && !empty(
$object->fk_project)) {
1731 $projectid = (int)
$object->fk_project;
1733 if ($origin ==
'project') {
1736 $langs->load(
"projects");
1738 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1739 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1740 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1741 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>';
1747 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
1748 print
'<td colspan="3">';
1749 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1750 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1751 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1756 print
'<tr><td>' . $langs->trans(
"DateShipping") .
'</td>';
1757 print
'<td colspan="3">';
1758 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1760 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1765 print
'<tr><td>' . $langs->trans(
"NotePublic") .
'</td>';
1766 print
'<td colspan="3">';
1767 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1768 print $doleditor->Create(1);
1772 if (
$object->note_private && !$user->socid) {
1773 print
'<tr><td>' . $langs->trans(
"NotePrivate") .
'</td>';
1774 print
'<td colspan="3">';
1775 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1776 print $doleditor->Create(1);
1782 print $langs->trans(
"Weight");
1783 print
'</td><td colspan="3">';
1784 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1787 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOST(
'weight_units'), 0, 2);
1788 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1789 print $form->textwithpicto($text, $htmltext);
1794 print $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
' x ' . $langs->trans(
"Depth");
1795 print
' </td><td colspan="3">';
1796 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1797 print
'<input name="sizeW" size="4" value="' .
GETPOST(
'sizeW') .
'">';
1798 print
' x <input name="sizeH" size="4" value="' .
GETPOST(
'sizeH') .
'">';
1799 print
' x <input name="sizeS" size="4" value="' .
GETPOST(
'sizeS') .
'">';
1801 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units'), 0, 2);
1802 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1803 print $form->textwithpicto($text, $htmltext);
1807 print
"<tr><td>" . $langs->trans(
"DeliveryMethod") .
"</td>";
1808 print
'<td colspan="3">';
1809 $expe->fetch_delivery_methods();
1810 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1811 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1813 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1815 print
"</td></tr>\n";
1818 print
"<tr><td>" . $langs->trans(
"TrackingNumber") .
"</td>";
1819 print
'<td colspan="3">';
1820 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1821 print
'<input name="tracking_number" size="20" value="' .
GETPOST(
'tracking_number',
'alpha') .
'">';
1822 print
"</td></tr>\n";
1827 print
'<td><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1) .
'</label></td>';
1828 print
'<td colspan="3" class="maxwidthonsmartphone">';
1829 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1830 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1835 include_once DOL_DOCUMENT_ROOT .
'/core/modules/expedition/modules_expedition.php';
1837 if (is_array($list) && count($list) > 1) {
1838 print
"<tr><td>" . $langs->trans(
"DefaultModel") .
"</td>";
1839 print
'<td colspan="3">';
1840 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1841 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1842 print
"</td></tr>\n";
1850 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && !empty($extrafields->attributes[
$object->table_element][
'label'])) {
1851 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
1852 if (array_key_exists(
'options_'.$key, $objectsav->array_options)) {
1853 $object->array_options[
'options_'.$key] = $objectsav->array_options[
'options_'.$key];
1857 $parameters = array(
1858 'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
1862 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1872 $numAsked = count(
$object->lines);
1874 print
'<script type="text/javascript">' .
"\n";
1875 print
'jQuery(document).ready(function() {' .
"\n";
1876 print
'jQuery("#autofill").click(function() {';
1878 while ($i < $numAsked) {
1879 print
'jQuery("#qtyl' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1881 print
'jQuery("#qtyl' . $i .
'_' . $i .
'").val(jQuery("#qtyasked' . $i .
'").val() - jQuery("#qtydelivered' . $i .
'").val());' .
"\n";
1885 print
'return false; });' .
"\n";
1886 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);' .
"\n";
1887 print
'return false; });' .
"\n";
1889 print
'</script>' .
"\n";
1893 print
'<div class="div-table-responsive-no-min">';
1894 print
'<table class="noborder centpercent">';
1899 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1901 $title_lines_to_disable = array();
1906 $title_lines_to_disable =
$object->getDisabledShippmentSubtotalLines();
1908 $selectedLines =
GETPOST(
'subtotal_toselect',
'array:int');
1909 foreach (
$object->lines as $line) {
1910 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1911 $show_check_add_buttons =
true;
1916 print
'<tr class="liste_titre">';
1918 if (isset($show_check_add_buttons)) {
1919 print $form->showCheckAddButtons(
'checkforselect');
1921 print $langs->trans(
"Description");
1923 print
'<td class="center">' . $langs->trans(
"QtyOrdered") .
'</td>';
1924 print
'<td class="center">' . $langs->trans(
"QtyShipped") .
'</td>';
1925 print
'<td class="center">' . $langs->trans(
"QtyToShip");
1927 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">' .
img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"') .
'</a>';
1932 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">' .
img_picto($langs->trans(
"Reset"),
'eraser') .
'</span>';
1936 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' (' . $langs->trans(
"Stock") .
')</td>';
1938 print
'<td class="left">' . $langs->trans(
"Warehouse") .
' / ' . $langs->trans(
"Batch") .
' (' . $langs->trans(
"Stock") .
')</td>';
1942 print
'<td class="left">' . $langs->trans(
'StockEntryDate') .
'</td>';
1948 $warehousePicking = array();
1950 if ($warehouse_id > 0) {
1951 $warehousePicking[] = $warehouse_id;
1953 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1957 while ($indiceAsked < $numAsked) {
1960 $line =
$object->lines[$indiceAsked];
1962 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1963 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1968 if (empty($reshook) && $line->special_code != SUBTOTALS_SPECIAL_CODE) {
1970 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1972 if (!empty($line->date_start)) {
1975 if (!empty($line->date_end)) {
1979 print
'<!-- line for order line ' . $line->id .
' -->' .
"\n";
1980 print
'<tr class="oddeven" id="row-' . $line->id .
'">' .
"\n";
1982 $qtyProdCom = $line->qty;
1983 $productChildrenNb = 0;
1985 if ($line->fk_product > 0) {
1986 $res = $product->fetch($line->fk_product);
1991 $productChildrenNb = $product->hasFatherOrChild(1);
1993 if ($productChildrenNb > 0) {
1994 $product->loadStockForVirtualProduct(
'warehouseopen', $qtyProdCom);
1996 $product->load_stock(
'warehouseopen');
2001 print
'<a name="' . $line->id .
'"></a>';
2004 $product_static->type = $line->fk_product_type;
2005 $product_static->id = $line->fk_product;
2006 $product_static->ref = $line->ref;
2007 $product_static->status = $line->product_tosell;
2008 $product_static->status_buy = $line->product_tobuy;
2009 $product_static->status_batch = $line->product_tobatch;
2011 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
2013 $text = $product_static->getNomUrl(1);
2014 $text .=
' - ' . (!empty($line->label) ? $line->label : $line->product_label);
2016 $description .= empty($product->stockable_product) ? $langs->trans(
'StockDisabled') : $langs->trans(
'StockEnabled');
2017 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2023 if ($showdescinproductdesc) {
2024 print ($line->desc && $line->desc != $line->product_label) ?
'<br>' .
dol_htmlentitiesbr($line->desc) :
'';
2029 $srcLine->id = $line->id;
2030 $srcLine->fetch_optionals();
2031 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
2032 $lineExtrafieldsHtml = $expLine->showOptionals($extrafields,
'edit', array(), (
string) $indiceAsked,
'',
'1',
'line');
2033 if (!empty($lineExtrafieldsHtml)) {
2034 print
'<div style="padding-top: 10px" id="extrafield_lines_area_create_' . $indiceAsked .
'" name="extrafield_lines_area_create_' . $indiceAsked .
'">';
2035 print $lineExtrafieldsHtml;
2043 $text =
img_object($langs->trans(
'Service'),
'service');
2045 $text =
img_object($langs->trans(
'Product'),
'product');
2048 if (!empty($line->label)) {
2049 $text .=
' <strong>' . $line->label .
'</strong>';
2050 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
2052 print $text .
' ' . nl2br($line->desc);
2060 $srcLine->id = $line->id;
2061 $srcLine->fetch_optionals();
2062 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
2063 $lineExtrafieldsHtml = $expLine->showOptionals($extrafields,
'edit', array(), (
string) $indiceAsked,
'',
'1',
'line');
2064 if (!empty($lineExtrafieldsHtml)) {
2065 print
'<div style="padding-top: 10px" id="extrafield_lines_area_create_' . $indiceAsked .
'" name="extrafield_lines_area_create_' . $indiceAsked .
'">';
2066 print $lineExtrafieldsHtml;
2079 print
'<td class="center">' . $line->qty;
2080 print
'<input name="qtyasked' . $indiceAsked .
'" id="qtyasked' . $indiceAsked .
'" type="hidden" value="' . $line->qty .
'">';
2082 print
' ' . $unit_order .
'</td>';
2086 print
'<td class="center">';
2087 $quantityDelivered = isset(
$object->expeditions[$line->id]) ?
$object->expeditions[$line->id] :
'';
2088 print $quantityDelivered;
2089 print
'<input name="qtydelivered' . $indiceAsked .
'" id="qtydelivered' . $indiceAsked .
'" type="hidden" value="' . $quantityDelivered .
'">';
2090 if ($quantityDelivered) {
2091 print
' ' . $unit_order .
'</td>';
2095 $quantityAsked = $line->qty;
2097 $quantityToBeDelivered = 0;
2099 if (is_numeric($quantityDelivered)) {
2100 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
2102 $quantityToBeDelivered = $quantityAsked;
2106 $warehouseObject =
null;
2107 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !
isModEnabled(
'stock')) {
2108 print
'<!-- Case warehouse already known or product not a predefined product -->';
2110 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
2112 $deliverableQty = $quantityToBeDelivered;
2114 $deliverableQty = min($quantityToBeDelivered, $stock);
2116 if ($deliverableQty < 0) {
2117 $deliverableQty = 0;
2119 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2121 print
'<td class="center">';
2123 if (GETPOSTISSET(
'qtyl'.$indiceAsked) &&
GETPOST(
'qtyl'.$indiceAsked) !==
'') {
2124 $deliverableQty =
GETPOSTFLOAT(
'qtyl'.$indiceAsked,
'MS');
2126 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2127 $qtylValue = $deliverableQty;
2130 } elseif (is_numeric($qtylValue)) {
2132 $qtylValue =
price($qtylValue);
2134 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" class="qtyl right" type="text" size="4" value="' . $qtylValue .
'">';
2137 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2138 print
'<input name="qtyl' . $indiceAsked .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2141 print $langs->trans(
"NA");
2147 print
'<td class="left">';
2150 $ent =
"entl" . $indiceAsked;
2151 $idl =
"idl" . $indiceAsked;
2153 if ($line->fk_product > 0) {
2154 print
'<!-- Show warehouse selection -->';
2160 if ($productChildrenNb > 0) {
2161 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, 0,
'', 0, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2163 if ($product->stockable_product == Product::ENABLED_STOCK) {
2164 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl' . $indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
2166 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2170 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
2172 if ($stock < $quantityToBeDelivered) {
2173 print
' ' .
img_warning($langs->trans(
"StockTooLow"));
2178 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span><input name="entl' . $indiceAsked .
'" id="entl' . $indiceAsked .
'" type="hidden" value="0">';
2189 $product->get_sousproduits_arbo();
2190 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2191 if (count($prods_arbo) > 0) {
2192 foreach ($prods_arbo as $key => $value) {
2195 if ($value[
'stock'] < $value[
'stock_alert']) {
2198 print
"<tr class=\"oddeven\"><td> ->
2199 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2200 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2201 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2211 print
'<td></td><td></td>';
2216 print
'<!-- Case product need lot -->';
2219 if ($warehouse_id > 0) {
2220 $staticwarehouse->fetch($warehouse_id);
2226 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2227 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2231 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
2232 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
2233 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
2235 $batchStock = +$dbatch->qty;
2236 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2239 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2240 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2242 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2243 $alreadyQtyBatchSetted[$line->fk_product] = array();
2246 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2247 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2250 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2253 if ($deliverableQty < 0) {
2254 $deliverableQty = 0;
2257 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2258 if (GETPOSTISSET($inputName)) {
2259 $deliverableQty =
GETPOST($inputName,
'int');
2262 $tooltipClass = $tooltipTitle =
'';
2263 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2264 $tooltipClass =
' classfortooltip';
2265 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2267 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2269 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2271 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2272 print
'<td colspan="3" ></td><td class="center">';
2273 $qtylValue = $deliverableQty;
2276 } elseif (is_numeric($qtylValue)) {
2277 $qtylValue =
price($qtylValue);
2279 print
'<input class="qtyl ' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="' . $qtylValue .
'">';
2282 print
'<!-- Show details of lot -->';
2283 print
'<td class="left">';
2285 print $staticwarehouse->getNomUrl(0) .
' / ';
2287 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2290 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
2292 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2295 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2297 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
2301 $quantityToBeDelivered -= $deliverableQty;
2302 if ($quantityToBeDelivered < 0) {
2303 $quantityToBeDelivered = 0;
2308 print
'<td>' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2313 print
'<!-- Case there is no details of lot at all -->';
2314 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2315 print
'<input class="qtyl right" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'_' . $subj .
'" type="text" size="4" value="0" disabled="disabled"> ';
2318 print
'<td class="left">';
2319 print
img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
2329 if (!
isModEnabled(
'productbatch') || !$product->hasbatch()) {
2330 print
'<!-- Case warehouse not already known and product does not need lot -->';
2331 print
'<td></td><td></td>';
2335 print
'</tr>' .
"\n";
2337 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2342 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2343 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2348 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2350 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2355 $tmpwarehouseObject->fetch($warehouse_id);
2356 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2357 $stock = +$stock_warehouse->real;
2358 $deliverableQty = min($quantityToBeDelivered, $stock);
2359 $deliverableQty = max(0, $deliverableQty);
2361 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'>';
2362 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked=' . $indiceAsked .
') -->';
2368 $tooltipClass = $tooltipTitle =
'';
2369 if ($productChildrenNb <= 0) {
2370 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2371 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
2373 if (!isset($alreadyQtySetted[$line->fk_product])) {
2374 $alreadyQtySetted[$line->fk_product] = array();
2377 $deliverableQty = min($quantityToBeDelivered, $stock);
2380 if ($deliverableQty < 0) {
2381 $deliverableQty = 0;
2384 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
2385 $tooltipClass =
' classfortooltip';
2386 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2388 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
2391 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
2394 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
2395 if (GETPOSTISSET($inputName)) {
2398 $qtylValue = $deliverableQty;
2401 } elseif (is_numeric($qtylValue)) {
2402 $qtylValue =
price($qtylValue);
2404 print
'<input class="qtyl' . $tooltipClass .
' right" title="' . $tooltipTitle .
'" name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="text" size="4" value="' . $qtylValue .
'">';
2405 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_id .
'">';
2408 print
'<input name="qtyl' . $indiceAsked .
'_' . $subj .
'" id="qtyl' . $indiceAsked .
'" type="hidden" value="0">';
2411 print $langs->trans(
"NA");
2416 print
'<td class="left">';
2418 if ($product->stockable_product == Product::ENABLED_STOCK || $productChildrenNb > 0) {
2419 print $tmpwarehouseObject->getNomUrl(0) .
' ';
2420 if ($productChildrenNb <= 0) {
2421 print
'<!-- Show details of stock -->';
2422 print
'(' . $stock .
')';
2425 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2428 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2431 $quantityToBeDelivered -= $deliverableQty;
2432 if ($quantityToBeDelivered < 0) {
2433 $quantityToBeDelivered = 0;
2444 $product->get_sousproduits_arbo();
2445 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
2446 if (count($prods_arbo) > 0) {
2447 foreach ($prods_arbo as $key => $value) {
2450 if ($value[
'stock'] < $value[
'stock_alert']) {
2453 print
'<tr class"oddeven"><td>';
2454 print
" ->
2455 <a href=\"" . DOL_URL_ROOT .
"/product/card.php?id=" . $value[
'id'] .
"\">" . $value[
'fullpath'] .
"
2456 </a> (" . $value[
'nb'] .
")</td><td class=\"center\"> " . $value[
'nb_total'] .
"</td><td> </td><td> </td>
2457 <td class=\"center\">" . $value[
'stock'] .
" " . $img .
"</td>";
2466 print
'<!-- Case warehouse not already known and product need lot -->';
2467 print
'<td></td><td></td>';
2474 print
'<input name="idl' . $indiceAsked .
'" type="hidden" value="' . $line->id .
'">';
2481 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2482 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2483 $nbofsuggested += count($stock_warehouse->detail_batch);
2487 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
2489 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
2494 $tmpwarehouseObject->fetch($warehouse_id);
2495 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
2496 foreach ($stock_warehouse->detail_batch as $dbatch) {
2497 $batchStock = +$dbatch->qty;
2498 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2499 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
2501 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
2502 $alreadyQtyBatchSetted[$line->fk_product] = array();
2505 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
2506 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
2509 $deliverableQty = min($quantityToBeDelivered, $batchStock);
2512 if ($deliverableQty < 0) {
2513 $deliverableQty = 0;
2516 $inputName =
'qtyl' . $indiceAsked .
'_' . $subj;
2517 if (GETPOSTISSET($inputName)) {
2521 $tooltipClass = $tooltipTitle =
'';
2522 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
2523 $tooltipClass =
' classfortooltip';
2524 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines') .
' : ' . $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2526 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0;
2528 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
2530 print
'<!-- subj=' . $subj .
'/' . $nbofsuggested .
' --><tr ' . ((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'') .
'><td colspan="3"></td><td class="center">';
2531 $qtylValue = $deliverableQty;
2534 } elseif (is_numeric($qtylValue)) {
2535 $qtylValue =
price($qtylValue);
2537 print
'<input class="qtyl right ' . $tooltipClass .
'" title="' . $tooltipTitle .
'" name="' . $inputName .
'" id="' . $inputName .
'" type="text" size="4" value="' . $qtylValue .
'">';
2540 print
'<td class="left">';
2542 print $tmpwarehouseObject->getNomUrl(0) .
' / ';
2544 print
'<!-- Show details of lot -->';
2545 print
'<input name="batchl' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $dbatch->id .
'">';
2546 print
'<input name="entl' . $indiceAsked .
'_'.$subj.
'" type="hidden" value="' . $tmpwarehouseObject->id .
'">';
2549 print $langs->trans(
"Batch") .
': ';
2550 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
2552 print $productlotObject->getNomUrl(1);
2554 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
2557 print
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
2560 print
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
2562 print
' (' . $dbatch->qty .
')';
2563 $quantityToBeDelivered -= $deliverableQty;
2564 if ($quantityToBeDelivered < 0) {
2565 $quantityToBeDelivered = 0;
2571 print
'<td class="left">' .
dol_print_date($dbatch->context[
'stock_entry_date'],
'day') .
'</td>';
2579 $warehouse_selected_id =
GETPOSTINT(
'entrepot_id');
2581 print
'<!-- line not shown yet, we show it -->';
2582 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
2587 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2588 $disabled =
'disabled="disabled"';
2589 $alt =
'Product need serial or batch number';
2591 if ($warehouse_selected_id <= 0) {
2592 $disabled =
'disabled="disabled"';
2595 if ($product->stockable_product == Product::ENABLED_STOCK) {
2598 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).
'"' :
'').
'> ';
2600 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
2604 if (
isModEnabled(
'productbatch') && $product->hasbatch()) {
2605 $disabled =
'disabled="disabled"';
2607 if ($warehouse_selected_id <= 0) {
2608 $disabled =
'disabled="disabled"';
2610 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$quantityToBeDelivered.
'"'.($disabled ?
' '.$disabled :
'').
'> ';
2611 if (empty($disabled) && !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
2612 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
2615 print $langs->trans(
"NA");
2619 print
'<td class="left">';
2622 if (($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK)) {
2624 $warehouseObject->fetch($warehouse_selected_id);
2625 print
img_warning() .
' ' . $langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
2627 if ($line->fk_product) {
2628 if ($product->stockable_product != Product::ENABLED_STOCK) {
2629 print
img_warning() .
' ' . $langs->trans(
'StockDisabled');
2631 print
img_warning() .
' ' . $langs->trans(
'StockTooLow');
2638 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
2647 } elseif (empty($reshook) && $line->special_code == SUBTOTALS_SPECIAL_CODE && !in_array($line->id, $title_lines_to_disable)) {
2648 require
dol_buildpath(
'/core/tpl/subtotalline_select.tpl.php');
2659 print $form->buttonsSaveCancel(
"Create");
2669 '@phan-var-force Expedition $object';
2675 $num_prod = count($lines);
2678 $typeobject =
$object->origin;
2680 $origin_id =
$object->origin_id;
2688 $res =
$object->fetch_optionals();
2691 print
dol_get_fiche_head($head,
'shipping', $langs->trans(
"Shipment"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2696 if ($action ==
'delete') {
2697 $formquestion = array();
2699 $formquestion = array(
2701 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
2702 'name' =>
'alsoUpdateStock',
2703 'type' =>
'checkbox',
2708 $formconfirm = $form->formconfirm(
2709 $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
2710 $langs->trans(
'DeleteSending'),
2711 $langs->trans(
"ConfirmDeleteSending",
$object->ref),
2720 if ($action ==
'ask_subtotal_deleteline') {
2722 $langs->load(
"subtotals");
2723 $title =
"DeleteSubtotalLine";
2724 $question =
"ConfirmDeleteSubtotalLine";
2725 if (
GETPOST(
'type') ==
'title') {
2726 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2727 $title =
"DeleteTitleLine";
2728 $question =
"ConfirmDeleteTitleLine";
2730 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2734 if ($action ==
'valid') {
2735 $objectref = substr(
$object->ref, 1, 4);
2736 if ($objectref ==
'PROV') {
2737 $numref =
$object->getNextNumRef($soc);
2742 $text = $langs->trans(
"ConfirmValidateSending", $numref);
2744 $text .=
'<br>' .
img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementWillBeRecorded") .
'.';
2746 $text .=
'<br>' .
img_picto(
'',
'movement',
'class="pictofixedwidth"') . $langs->trans(
"StockMovementNotYetRecorded") .
'.';
2750 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2753 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE',
$object->socid, $object);
2756 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 260);
2760 if ($action ==
'cancel') {
2761 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending",
$object->ref),
'confirm_cancel',
'', 0, 1);
2765 if ($action ==
'sign') {
2766 $text = $langs->trans(
'ConfirmSignShipping');
2768 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2771 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2776 'name' =>
'signed_status',
2777 'select_show_empty' => 0,
2778 'label' =>
'<span class="fieldrequired">' . $langs->trans(
'SignStatus') .
'</span>',
2779 'values' =>
$object->getSignedStatusLocalisedArray()
2781 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'SignShipping'), $text,
'confirm_sign', $formquestion, 0, 1);
2785 if ($action ==
'unsign') {
2786 $text = $langs->trans(
'ConfirmUnsignShipping');
2788 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2791 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid, $object);
2793 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnsignShipping'), $text,
'confirm_unsign',
'', 0, 1);
2797 $parameters = array(
'formConfirm' => $formconfirm);
2798 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2799 if (empty($reshook)) {
2800 $formconfirm .= $hookmanager->resPrint;
2801 } elseif ($reshook > 0) {
2802 $formconfirm = $hookmanager->resPrint;
2810 $tmparray =
$object->getTotalWeightVolume();
2811 $totalWeight = $tmparray[
'weight'];
2812 $totalVolume = $tmparray[
'volume'];
2814 if (!empty($typeobject) && $typeobject ===
'commande' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2816 $objectsrc->fetch(
$object->origin_object->id);
2818 if (!empty($typeobject) && $typeobject ===
'propal' && is_object(
$object->origin_object) &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2820 $objectsrc->fetch(
$object->origin_object->id);
2824 $linkback =
'<a href="' . DOL_URL_ROOT .
'/expedition/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2825 $morehtmlref =
'<div class="refidno">';
2827 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
2828 $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);
2831 $morehtmlref .=
'<br>' .
$object->thirdparty->getNomUrl(1);
2834 if ($origin && $origin_id > 0) {
2836 $langs->load(
"projects");
2837 $morehtmlref .=
'<br>';
2839 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2840 if ($action !=
'classify') {
2841 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2843 $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');
2845 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2847 $proj->fetch($objectsrc->fk_project);
2848 $morehtmlref .= $proj->getNomUrl(1);
2850 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2858 $langs->load(
"projects");
2859 $morehtmlref .=
'<br>';
2860 if ($permissiontoadd) {
2861 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2862 if ($action !=
'classify') {
2863 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2865 $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');
2867 if (!empty(
$object->fk_project)) {
2869 $proj->fetch(
$object->fk_project);
2870 $morehtmlref .= $proj->getNomUrl(1);
2872 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2879 $morehtmlref .=
'</div>';
2880 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2882 print
'<div class="fichecenter">';
2883 print
'<div class="fichehalfleft">';
2884 print
'<div class="underbanner clearboth"></div>';
2886 print
'<table class="border tableforfield centpercent">';
2889 if (!empty($typeobject) && $typeobject ==
'commande' &&
$object->origin_object->id &&
isModEnabled(
'order')) {
2891 print $langs->trans(
"RefOrder") .
'</td>';
2893 print $objectsrc->getNomUrl(1,
'commande');
2897 if (!empty($typeobject) && $typeobject ==
'propal' &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2899 print $langs->trans(
"RefProposal") .
'</td>';
2901 print $objectsrc->getNomUrl(1,
'expedition');
2907 print
'<tr><td class="titlefieldmiddle">' . $langs->trans(
"DateCreation") .
'</td>';
2912 print
'<tr><td height="10">';
2913 print
'<table class="nobordernopadding centpercent"><tr><td>';
2914 print $langs->trans(
'DateDeliveryPlanned');
2916 if ($action !=
'editdate_livraison') {
2917 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>';
2919 print
'</tr></table>';
2921 if ($action ==
'editdate_livraison') {
2922 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2923 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2924 print
'<input type="hidden" name="action" value="setdate_livraison">';
2925 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2926 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2935 print
'<tr><td height="10">';
2936 print
'<table class="nobordernopadding centpercent"><tr><td>';
2937 print $langs->trans(
'DateShipping');
2939 if ($action !=
'editdate_shipping') {
2940 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>';
2942 print
'</tr></table>';
2944 if ($action ==
'editdate_shipping') {
2945 print
'<form name="setdate_shipping" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2946 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2947 print
'<input type="hidden" name="action" value="setdate_shipping">';
2948 print $form->selectDate(
$object->date_shipping ?
$object->date_shipping : -1,
'ship_', 1, 1, 0,
"setdate_shipping", 1, 0);
2949 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2959 print $form->editfieldkey(
"Weight",
'trueWeight',
$object->trueWeight, $object, $user->hasRight(
'expedition',
'creer'));
2962 if ($action ==
'edittrueWeight') {
2963 print
'<form name="settrueweight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2964 print
'<input name="action" value="settrueWeight" type="hidden">';
2965 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
2966 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2967 print
'<input id="trueWeight" name="trueWeight" value="' .
$object->trueWeight .
'" type="text" class="width50 valignmiddle">';
2968 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2969 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
2970 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
2978 if ($totalWeight > 0) {
2979 if (!empty(
$object->trueWeight)) {
2980 print
' (' . $langs->trans(
"SumOfProductWeights") .
': ';
2983 if (!empty(
$object->trueWeight)) {
2990 print
'<tr><td>' . $form->editfieldkey(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2991 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'expedition',
'creer'));
2996 print
'<tr><td>' . $form->editfieldkey(
"Height",
'trueHeight',
$object->trueHeight, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
2997 if ($action ==
'edittrueHeight') {
2998 print
'<form name="settrueHeight" action="' . $_SERVER[
"PHP_SELF"] .
'" method="post">';
2999 print
'<input name="action" value="settrueHeight" type="hidden">';
3000 print
'<input name="id" value="' .
$object->id .
'" type="hidden">';
3001 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3002 print
'<input id="trueHeight" name="trueHeight" value="' .
$object->trueHeight .
'" type="text" class="width50">';
3003 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
3004 print
' <input class="button smallpaddingimp" name="modify" value="' . $langs->trans(
"Modify") .
'" type="submit">';
3005 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'" type="submit">';
3015 print
'<tr><td>' . $form->editfieldkey(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3016 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'expedition',
'creer'));
3022 print $langs->trans(
"Volume");
3025 $calculatedVolume = 0;
3029 $volumeUnit =
$object->size_units * 3;
3032 if ($calculatedVolume > 0) {
3033 if ($volumeUnit < 50) {
3039 if ($totalVolume > 0) {
3040 if ($calculatedVolume) {
3041 print
' (' . $langs->trans(
"SumOfProductVolumes") .
': ';
3045 if ($calculatedVolume) {
3054 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3059 print
'<div class="fichehalfright">';
3060 print
'<div class="underbanner clearboth"></div>';
3062 print
'<table class="border centpercent tableforfield">';
3066 print
'<table class="nobordernopadding centpercent"><tr><td>';
3067 print $langs->trans(
'SendingMethod');
3070 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
3071 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>';
3073 print
'</tr></table>';
3075 if ($action ==
'editshipping_method_id') {
3076 print
'<form name="setshipping_method_id" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3077 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3078 print
'<input type="hidden" name="action" value="setshipping_method_id">';
3079 $object->fetch_delivery_methods();
3080 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
3082 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3084 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
3087 if (
$object->shipping_method_id > 0) {
3089 $code = $langs->getLabelFromKey(
$db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
3090 print $langs->trans(
"SendingMethod" . strtoupper($code));
3097 print
'<tr><td class="titlefieldmiddle">' . $form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number, $object, $user->hasRight(
'expedition',
'creer')) .
'</td><td>';
3098 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url, $object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring',
$object->tracking_number);
3104 print
'<table class="nobordernopadding centpercent"><tr><td>';
3105 print $langs->trans(
'IncotermLabel');
3106 print
'<td><td class="right">';
3107 if ($permissiontoadd) {
3108 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/expedition/card.php?id=' .
$object->id .
'&action=editincoterm&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3112 print
'</td></tr></table>';
3115 if ($action !=
'editincoterm') {
3116 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3118 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3124 $parameters = array();
3125 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
3126 print $hookmanager->resPrint;
3133 print
'<div class="clearboth"></div>';
3142 if (!empty(
$object->table_element_line)) {
3144 $result =
$object->getLinesArray();
3146 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
3147 <input type="hidden" name="token" value="' .
newToken().
'">
3148 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3149 <input type="hidden" name="mode" value="">
3150 <input type="hidden" name="page_y" value="">
3151 <input type="hidden" name="id" value="' .
$object->id.
'">
3154 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
3155 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3158 print
'<div class="div-table-responsive-no-min">';
3159 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3160 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3168 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
3169 if ($action !=
'editline') {
3172 $parameters = array();
3173 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3177 if (empty($reshook)) {
3183 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
3194 if ($action ==
'editline') {
3195 print
' <form name="updateline" id="updateline" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $line_id .
'" method="POST">
3196 <input type="hidden" name="token" value="' .
newToken() .
'">
3197 <input type="hidden" name="action" value="updateline">
3198 <input type="hidden" name="mode" value="">
3199 <input type="hidden" name="id" value="' .
$object->id .
'">
3204 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3207 print
'<div class="div-table-responsive-no-min">';
3208 print
'<table class="noborder centpercent" id="tablelines" >';
3210 print
'<tr class="liste_titre">';
3213 print
'<td width="5" class="center linecolnum"> </td>';
3216 print
'<td class="linecoldescription" >' . $langs->trans(
"Products") .
'</td>';
3218 print
'<td class="center linecolqty">' . $langs->trans(
"QtyOrdered") .
'</td>';
3219 if ($origin_id > 0) {
3220 print
'<td class="center linecolqtyinothershipments">' . $langs->trans(
"QtyInOtherShipments") .
'</td>';
3222 if ($action ==
'editline') {
3230 print
'<td class="center linecoleditlineotherinfo" colspan="' . $editColspan .
'">';
3232 print $langs->trans(
"QtyToShip");
3234 print $langs->trans(
"QtyShipped");
3237 print
' - ' . $langs->trans(
"WarehouseSource");
3240 print
' - ' . $langs->trans(
"Batch");
3245 print
'<td class="center linecolqtytoship">' . $langs->trans(
"QtyToShip") .
'</td>';
3247 print
'<td class="center linecolqtyshipped">' . $langs->trans(
"QtyShipped") .
'</td>';
3250 print
'<td class="left linecolwarehousesource">' . $langs->trans(
"WarehouseSource") .
'</td>';
3254 print
'<td class="left linecolbatch">' . $langs->trans(
"Batch") .
'</td>';
3257 print
'<td class="center linecolweight">' . $langs->trans(
"CalculatedWeight") .
'</td>';
3258 print
'<td class="center linecolvolume">' . $langs->trans(
"CalculatedVolume") .
'</td>';
3261 print
'<td class="linecoledit"></td>';
3262 print
'<td class="linecoldelete" width="10"></td>';
3263 print
'<td class="linecolmove"></td>';
3268 $outputlangs = $langs;
3273 if (
GETPOST(
'lang_id',
'aZ09')) {
3274 $newlang =
GETPOST(
'lang_id',
'aZ09');
3276 if (empty($newlang)) {
3277 $newlang =
$object->thirdparty->default_lang;
3279 if (!empty($newlang)) {
3281 $outputlangs->setDefaultLang($newlang);
3286 $alreadysent = array();
3287 if ($origin_id > 0) {
3288 $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";
3289 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot";
3290 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
3291 $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';
3292 $sql .=
', p.description as product_desc';
3293 $sql .=
" FROM " . MAIN_DB_PREFIX .
"expeditiondet as ed";
3294 $sql .=
", " . MAIN_DB_PREFIX .
"expedition as e";
3295 $sql .=
", " . MAIN_DB_PREFIX .
$db->sanitize((
string) $origin) .
"det as obj";
3296 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product as p ON obj.fk_product = p.rowid";
3297 $sql .=
" WHERE e.entity IN (" .
getEntity(
'expedition') .
")";
3298 $sql .=
" AND obj.fk_" .
$db->sanitize((
string) $origin) .
" = " . ((int) $origin_id);
3299 $sql .=
" AND obj.rowid = ed.fk_elementdet";
3300 $sql .=
" AND ed.fk_expedition = e.rowid";
3302 $sql .=
" ORDER BY obj.fk_product";
3304 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
3305 $resql =
$db->query($sql);
3307 $num =
$db->num_rows($resql);
3311 $obj =
$db->fetch_object($resql);
3314 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
3315 'shipment_ref' => $obj->shipment_ref,
3316 'shipment_id' => $obj->shipment_id,
3317 'warehouse' => $obj->fk_entrepot,
3318 'qty_shipped' => $obj->qty_shipped,
3319 'product_tosell' => $obj->product_tosell,
3320 'product_tobuy' => $obj->product_tobuy,
3321 'product_tobatch' => $obj->product_tobatch,
3322 'date_valid' =>
$db->jdate($obj->date_valid),
3323 'date_delivery' =>
$db->jdate($obj->date_delivery));
3334 $conf->cache[
'product'] = array();
3335 $conf->cache[
'warehouse'] = array();
3336 for ($i = 0; $i < $num_prod; $i++) {
3337 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
3338 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
3343 if (empty($reshook) && $lines[$i]->product_type !=
"9") {
3344 print
'<!-- origin line id = ' . $lines[$i]->origin_line_id .
' -->';
3345 print
'<tr class="oddeven" id="row-' . $lines[$i]->id .
'" data-id="' . $lines[$i]->id .
'" data-element="' . $lines[$i]->element .
'" >';
3347 $line->fetch_optionals();
3351 print
'<td class="center linecolnum">' . ($i + 1) .
'</td>';
3355 if ($lines[$i]->fk_product > 0) {
3358 $product_id = $lines[$i]->fk_product;
3359 if (!isset(
$conf->cache[
'product'][$product_id])) {
3361 $prod->fetch($product_id);
3362 $conf->cache[
'product'][$product_id] =
$prod;
3364 $prod =
$conf->cache[
'product'][$product_id];
3366 $label = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"label"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
3368 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
3371 print
'<td class="linecoldescription">';
3374 $product_static->type = $lines[$i]->fk_product_type;
3375 $product_static->id = $lines[$i]->fk_product;
3376 $product_static->ref = $lines[$i]->ref;
3377 $product_static->status = $lines[$i]->product_tosell;
3378 $product_static->status_buy = $lines[$i]->product_tobuy;
3379 $product_static->status_batch = $lines[$i]->product_tobatch;
3381 $product_static->weight = $lines[$i]->weight;
3382 $product_static->weight_units = $lines[$i]->weight_units;
3383 $product_static->length = $lines[$i]->length;
3384 $product_static->length_units = $lines[$i]->length_units;
3385 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
3386 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
3387 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
3388 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
3389 $product_static->surface = $lines[$i]->surface;
3390 $product_static->surface_units = $lines[$i]->surface_units;
3391 $product_static->volume = $lines[$i]->volume;
3392 $product_static->volume_units = $lines[$i]->volume_units;
3393 $product_static->stockable_product = $lines[$i]->stockable_product;
3395 $text = $product_static->getNomUrl(1);
3396 $text .=
' - ' . $label;
3398 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
3399 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
3403 $lineExtrafieldsHtml = $line->showOptionals($extrafields, ($action ==
'editline' && $line->id == $line_id) ?
'edit' :
'view', array(),
'',
'',
'1',
'line');
3404 if (!empty($lineExtrafieldsHtml)) {
3405 print
'<div style="padding-top: 10px" id="extrafield_lines_area_' . $line->id .
'" name="extrafield_lines_area_' . $line->id .
'">';
3406 print $lineExtrafieldsHtml;
3411 print
'<td class="linecoldescription" >';
3413 $text =
img_object($langs->trans(
'Service'),
'service');
3415 $text =
img_object($langs->trans(
'Product'),
'product');
3418 if (!empty($lines[$i]->label)) {
3419 $text .=
' <strong>' . $lines[$i]->label .
'</strong>';
3420 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
3422 print $text .
' ' . nl2br($lines[$i]->
description);
3426 $lineExtrafieldsHtml = $line->showOptionals($extrafields, ($action ==
'editline' && $line->id == $line_id) ?
'edit' :
'view', array(),
'',
'',
'1',
'line');
3427 if (!empty($lineExtrafieldsHtml)) {
3428 print
'<div style="padding-top: 10px" id="extrafield_lines_area_' . $line->id .
'" name="extrafield_lines_area_' . $line->id .
'">';
3429 print $lineExtrafieldsHtml;
3441 print
'<td class="center linecolqty">' . $lines[$i]->qty_asked .
' ' . $unit_order .
'</td>';
3444 if ($origin_id > 0) {
3445 print
'<td class="linecolqtyinothershipments center nowrap">';
3447 $qtyalreadysent = 0;
3448 foreach ($alreadysent as $key => $val) {
3449 if ($lines[$i]->fk_elementdet == $key) {
3451 foreach ($val as $shipmentline_id => $shipmentline_var) {
3452 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
3458 $htmltooltip .=
'<br>';
3460 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
3461 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
3462 $htmltooltip .=
' - ' . $shipmentline_var[
'qty_shipped'];
3463 $htmltooltip .=
' - ' . $langs->trans(
"DateValidation") .
' : ' . (empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
3470 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
3473 $htmltooltip = $langs->trans(
"QtyInOtherShipments") .
'...<br><br>' . $htmltooltip .
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
3477 print $form->textwithpicto((
string) $qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip' . $lines[$i]->id);
3481 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3483 print
'<td colspan="' . $editColspan .
'" class="center"><table class="nobordernopadding centpercent">';
3484 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
3485 print
'<!-- case edit 1 -->';
3487 foreach ($lines[$i]->detail_batch as $detail_batch) {
3490 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>';
3492 if ($lines[$i]->entrepot_id == 0) {
3494 $line->fetch($detail_batch->fk_expeditiondet);
3496 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
3497 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>';
3503 print
'<td><input class="qtyl" name="qtyl' . $line_id .
'_0" id="qtyl' . $line_id .
'_0" type="text" size="4" value="0"></td>';
3505 print
'<td>' . $formproduct->selectLotStock(
'',
'batchl' . $line_id .
'_0',
'', 1, 0, $lines[$i]->fk_product) .
'</td>';
3508 if ($lines[$i]->fk_product > 0) {
3509 if ($lines[$i]->entrepot_id > 0) {
3510 print
'<!-- case edit 2 -->';
3513 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>';
3515 print
'<td>' . $formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl' . $line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3519 print
' - ' . $langs->trans(
"NA");
3523 } elseif (count($lines[$i]->details_entrepot) > 1) {
3524 print
'<!-- case edit 3 -->';
3525 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3528 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>';
3530 print
'<td>' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl' . $detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200') .
'</td>';
3534 print
' - ' . $langs->trans(
"NA");
3540 print
'<!-- case edit 4 -->';
3543 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3544 print
'<td><span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span></td>';
3548 print
'<!-- case edit 5 -->';
3549 print
'<tr><td colspan="3">' . $langs->trans(
"ErrorStockIsNotEnough") .
'</td></tr>';
3552 print
'<!-- case edit 6 -->';
3555 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>';
3563 print
'<!-- case edit 7 -->';
3566 print
'<td><input class="qtyl right" name="qtyl' . $line_id .
'" id="qtyl' . $line_id .
'" type="text" size="4" value="' . $lines[$i]->qty_shipped .
'"></td>';
3574 print
'</table></td>';
3577 print
'<td class="linecolqtytoship center">' . $lines[$i]->qty_shipped .
' ' . $unit_order .
'</td>';
3581 print
'<td class="linecolwarehousesource tdoverflowmax200">';
3583 print
'<span class="opacitymedium">(' . $langs->trans(
"Service") .
')</span>';
3584 } elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) {
3585 $warehouse_id = $lines[$i]->entrepot_id;
3586 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
3588 $warehouse->fetch($warehouse_id);
3589 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3591 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
3593 print $warehouse->getNomUrl(1);
3594 } elseif (count($lines[$i]->details_entrepot) > 1) {
3596 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
3597 $warehouse_id = $detail_entrepot->entrepot_id;
3598 if ($warehouse_id > 0) {
3599 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
3601 $warehouse->fetch($warehouse_id);
3602 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
3604 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
3606 $detail .= $langs->trans(
"DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped) .
'<br>';
3609 print $form->textwithtooltip(
img_picto(
'',
'object_stock') .
' ' . $langs->trans(
"DetailWarehouseNumber"), $detail);
3610 } elseif (count($lines[$i]->detail_children ?? []) > 1) {
3612 foreach ($lines[$i]->detail_children as $child_product_id => $child_stock_list) {
3613 foreach ($child_stock_list as $warehouse_id => $total_qty) {
3615 $child_product_label =
'';
3616 if (!isset(
$conf->cache[
'product'][$child_product_id])) {
3618 $child_product->fetch($child_product_id);
3619 $conf->cache[
'product'][$child_product_id] = $child_product;
3621 $child_product =
$conf->cache[
'product'][$child_product_id];
3623 $child_product_label = $child_product->ref .
' ' . $child_product->label;
3626 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
3628 $child_warehouse->fetch($warehouse_id);
3629 $conf->cache[
'warehouse'][$warehouse_id] = $child_warehouse;
3631 $child_warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
3633 $detail .= $langs->trans(
'DetailChildrenFormat', $child_product_label, $child_warehouse->label,
price2num($total_qty,
'MS')) .
'<br>';
3636 print $form->textwithtooltip(
img_picto(
'',
'object_stock') .
' ' . $langs->trans(
'DetailWarehouseNumber'), $detail);
3643 if (isset($lines[$i]->detail_batch)) {
3644 print
'<!-- Detail of lot -->';
3645 print
'<td class="linecolbatch">';
3646 if ($lines[$i]->product_tobatch) {
3648 foreach ($lines[$i]->detail_batch as $dbatch) {
3649 $detail .= $langs->trans(
"Batch") .
': ' . $dbatch->batch;
3651 $detail .=
' - ' . $langs->trans(
"SellByDate") .
': ' .
dol_print_date($dbatch->sellby,
"day");
3654 $detail .=
' - ' . $langs->trans(
"EatByDate") .
': ' .
dol_print_date($dbatch->eatby,
"day");
3656 $detail .=
' - ' . $langs->trans(
"Qty") .
': ' . $dbatch->qty;
3659 print $form->textwithtooltip(
img_picto(
'',
'object_barcode') .
' ' . $langs->trans(
"DetailBatchNumber"), $detail);
3661 print $langs->trans(
"NA");
3665 print
'<td class="linecolbatch" ></td>';
3671 print
'<td class="center linecolweight">';
3673 print $lines[$i]->weight * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
3680 print
'<td class="center linecolvolume">';
3682 print $lines[$i]->volume * $lines[$i]->qty_shipped .
' ' .
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
3693 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3694 print
'<td class="center" colspan="2" valign="middle">';
3695 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="' . $langs->trans(
"Save") .
'"><br>';
3696 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="' . $langs->trans(
"Cancel") .
'"><br>';
3699 print
'<td class="linecolmove tdlineupdown center"></td>';
3701 } elseif ($showmovecol) {
3702 $edit_url = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id;
3704 $product_id = $lines[$i]->fk_product;
3705 if (!isset(
$conf->cache[
'product'][$product_id])) {
3707 $product->fetch($product_id);
3708 $conf->cache[
'product'][$product_id] = $product;
3710 $product =
$conf->cache[
'product'][$product_id];
3713 if ($product->hasFatherOrChild(1)) {
3719 print
'<td class="linecoledit center">';
3720 print
'<a class="editfielda reposition" href="' . $edit_url .
'">' .
img_edit() .
'</a>';
3722 print
'<td class="linecoldelete" width="10">';
3723 print
'<a class="reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=deleteline&token=' .
newToken() .
'&lineid=' . $lines[$i]->id .
'">' .
img_delete() .
'</a>';
3725 print
'<td class="linecolmove tdlineupdown center">';
3726 if ($usercancreate && $num_prod > 1) {
3728 print
'<a class="lineupdown" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=up&token=' .
newToken() .
'&rowid=' . $lines[$i]->id .
'">' .
img_up(
'default', 0,
'imgupforline') .
'</a>';
3730 if ($i < $num_prod - 1) {
3731 print
'<a class="lineupdown" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=down&token=' .
newToken() .
'&rowid=' . $lines[$i]->id .
'">' .
img_down(
'default', 0,
'imgdownforline') .
'</a>';
3736 if (isset($rowExtrafieldsStart, $rowExtrafieldsView, $rowEnd)) {
3737 print $rowExtrafieldsStart;
3738 print $rowExtrafieldsView;
3743 } elseif (empty($reshook) && $lines[$i]->product_type ==
"9") {
3745 $objectsrc->fetch($lines[$i]->origin_line_id);
3746 if ($objectsrc->special_code == SUBTOTALS_SPECIAL_CODE) {
3748 require
dol_buildpath(
'/core/tpl/subtotal_expedition_view.tpl.php');
3753 if (empty($num_prod)) {
3754 print
'<tr><td colspan="8"><span class="opacitymedium">' . $langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")) .
'</span></td></tr>';
3760 if ($action ==
'editline') {
3771 if (($user->socid == 0) && ($action !=
'presend')) {
3772 print
'<div class="tabsAction">';
3774 $parameters = array();
3775 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3777 if (empty($reshook)) {
3779 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
3780 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))
3784 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3790 if ($user->hasRight(
'expedition',
'creer')) {
3795 if ($user->hasRight(
'expedition',
'creer')) {
3801 if (empty($user->socid)) {
3803 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
3804 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3806 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3814 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=create_delivery&token=' .
newToken() .
'&id=' .
$object->id,
'');
3819 if (
$object->signed_status != Expedition::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
3820 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>';
3822 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>';
3828 if ($user->hasRight(
'facture',
'creer')) {
3830 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT .
'/compta/facture/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
'');
3837 if ($user->hasRight(
'expedition',
'creer') &&
$object->status > 0) {
3839 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3841 print
dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifyclosed&token=' .
newToken() .
'&id=' .
$object->id,
'');
3847 if ($user->hasRight(
'expedition',
'creer')) {
3848 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"] .
'?action=cancel&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3853 if ($user->hasRight(
'expedition',
'supprimer')) {
3866 if ($action !=
'presend' && $action !=
'editline') {
3867 print
'<div class="fichecenter"><div class="fichehalfleft">';
3870 $filedir =
$conf->expedition->dir_output .
"/sending/" . $objectref;
3872 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
3874 $genallowed = $user->hasRight(
'expedition',
'lire');
3875 $delallowed = $user->hasRight(
'expedition',
'creer');
3877 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3881 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'shipping'), 1);
3882 $linktoelem = $tmparray[
'linktoelem'];
3883 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3884 print $htmltoenteralink;
3886 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3892 print
'<br><!-- Link to sign -->';
3893 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
3894 print showOnlineSignatureUrl(
'expedition',
$object->ref, $object) .
'<br>';
3897 print
'</div><div class="fichehalfright">';
3901 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3906 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT .
'/expedition/messaging.php?id=' .
$object->id);
3908 $somethingshown = $formactions->showactions($object,
'shipping', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3909 print
'</div></div>';
3918 if (
GETPOST(
'modelselected')) {
3919 $action =
'presend';
3923 $modelmail =
'shipping_send';
3924 $defaulttopic =
'SendShippingRef';
3925 $diroutput =
$conf->expedition->dir_output .
'/sending';
3926 $trackid =
'shi' .
$object->id;
3928 include DOL_DOCUMENT_ROOT .
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
const STATUS_DRAFT
Draft status.
const STATUS_CANCELED
Canceled status.
const STATUS_CLOSED
Closed status -> parcel was received by customer / end of process prev status : validated or shipment...
const STATUS_VALIDATED
Validated status -> parcel is ready to be sent prev status : draft next status : closed or shipment_i...
Class to manage lines of shipment.
CRUD class for batch number management within shipment.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage order lines.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage products or services.
const DISABLED_STOCK
Stockable product.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Manage record for batch number management.
Class with list of lots and properties.
Class to manage projects.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
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.