40require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
52if (isModEnabled(
"product") || isModEnabled(
"service")) {
53 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
55if (isModEnabled(
"propal")) {
56 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
58if (isModEnabled(
'productbatch')) {
59 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
61if (isModEnabled(
'project')) {
62 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
75$langs->loadLangs(array(
"sendings",
"companies",
"bills",
'deliveries',
'orders',
'stocks',
'other',
'propal',
'productbatch'));
77if (isModEnabled(
'incoterm')) {
78 $langs->load(
'incoterm');
80if (isModEnabled(
'productbatch')) {
81 $langs->load(
'productbatch');
84$origin =
GETPOST(
'origin',
'alpha') ?
GETPOST(
'origin',
'alpha') :
'expedition';
87if (empty($origin_id)) {
90if (empty($origin_id)) {
97$action =
GETPOST(
'action',
'alpha');
98$confirm =
GETPOST(
'confirm',
'alpha');
99$cancel =
GETPOST(
'cancel',
'alpha');
111$extrafields->fetch_name_optionals_label(
$object->table_element);
112$extrafields->fetch_name_optionals_label(
$object->table_element_line);
113$extrafields->fetch_name_optionals_label($objectorder->table_element_line);
116include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
119$hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
125if ($id > 0 || !empty($ref)) {
133 $socid = $user->socid;
138$permissiondellink = $user->hasRight(
'expedition',
'delivery',
'creer');
139$permissiontoadd = $user->hasRight(
'expedition',
'creer');
140$permissiontoeditextra = $permissiontoadd;
141if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
143 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
146$upload_dir =
$conf->expedition->dir_output.
'/sending';
158$parameters = array();
159$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
164if (empty($reshook)) {
166 if ($origin && $origin_id > 0) {
167 if ($origin ==
'commande') {
168 header(
"Location: ".DOL_URL_ROOT.
'/expedition/shipment.php?id='.((
int) $origin_id));
177 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
180 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
183 if ($action ==
'setdraft' && $permissiontoadd) {
185 $result =
$object->setDraft($user, 0);
189 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
194 if ($action ==
'reopen' && $permissiontoadd) {
200 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
206 if ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $permissiontoadd) {
210 if ($action ==
'setref_customer' && $permissiontoadd) {
216 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPPING_MODIFY');
219 $action =
'editref_customer';
221 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
226 if ($action ==
'update_extras' && $permissiontoeditextra) {
229 $attribute_name =
GETPOST(
'attribute',
'aZ09');
232 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
239 $result =
$object->updateExtraField($attribute_name,
'SHIPPING_MODIFY');
247 $action =
'edit_extras';
252 if ($action ==
'add' && $permissiontoadd) {
256 $object->origin_type = $origin;
257 $object->origin_id = $origin_id;
269 $classname = ucfirst(
$object->origin_type);
270 $objectsrc =
new $classname($db);
271 '@phan-var-force Facture|Commande $objectsrc';
272 $objectsrc->fetch(
$object->origin_id);
274 $object->socid = $objectsrc->socid;
277 $object->date_delivery = $date_delivery;
278 $object->date_shipping = $date_shipping;
279 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
286 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
288 $batch_line = array();
289 $stockLine = array();
290 $array_options = array();
292 $num = count($objectsrc->lines);
295 $product_batch_used = array();
297 for ($i = 0; $i < $num; $i++) {
305 $batch =
"batchl".$i.
"_0";
306 $stockLocation =
"ent1".$i.
"_0";
309 $is_batch_or_serial = 0;
310 if (!empty($objectsrc->lines[$i]->fk_product)) {
311 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
312 if ($resultFetch < 0) {
315 $is_batch_or_serial = $product->status_batch;
319 if (isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
320 if (GETPOSTISSET($batch)) {
323 while (GETPOSTISSET($batch)) {
326 $sub_qty[$j][
'id_batch'] =
GETPOSTINT($batch);
327 $subtotalqty += $sub_qty[$j][
'q'];
329 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)))) {
330 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
335 if ($is_batch_or_serial == 2 && $sub_qty[$j][
'q'] > 0) {
337 $product_batch_used[$j] = $sub_qty[$j][
'id_batch'];
341 $batch =
"batchl".$i.
"_".$j;
342 $qty =
"qtyl".$i.
'_'.$j;
345 $batch_line[$i][
'detail'] = $sub_qty;
346 $batch_line[$i][
'qty'] = $subtotalqty;
349 $totalqty += $subtotalqty;
356 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse").
' ('.$langs->trans(
"Line").
' '.
GETPOSTINT($idl).
')',
null,
'errors');
360 } elseif (GETPOSTISSET($stockLocation)) {
363 while (GETPOSTISSET($stockLocation)) {
366 $stockLine[$i][$j][
'warehouse_id'] =
GETPOSTINT($stockLocation);
367 $stockLine[$i][$j][
'ix_l'] =
GETPOSTINT($idl);
373 $stockLocation =
"ent1".$i.
"_".$j;
374 $qty =
"qtyl".$i.
'_'.$j;
385 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
386 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i + 1),
null,
'errors');
392 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
394 if (isset($extrafields->attributes[
$object->table_element_line][
'label']) && is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
396 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
397 unset($_POST[
"options_".$key]);
402 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
403 $selected_subtotal_lines =
GETPOST(
'subtotal_toselect',
'array');
404 for ($i = 0; $i < $num; $i++) {
407 if (!isset($batch_line[$i])) {
409 if (isset($stockLine[$i])) {
411 $nbstockline = count($stockLine[$i]);
412 for ($j = 0; $j < $nbstockline; $j++) {
413 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
414 $ret =
$object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], (
float) $stockLine[$i][$j][
'qty'], $array_options[$i]);
426 if ($entrepot_id < 0) {
429 if (!($objectsrc->lines[$i]->fk_product > 0)) {
439 if (isModEnabled(
'subtotals') && $objectsrc->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && in_array($objectsrc->lines[$i]->id, $selected_subtotal_lines)) {
440 $object->addSubtotalLine($langs, $objectsrc->lines[$i]->desc, (
int) $objectsrc->lines[$i]->qty, $objectsrc->lines[$i]->extraparams, $objectsrc->lines[$i]->id);
445 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
446 $origin_line_id = (int) $batch_line[$i][
'ix_l'];
448 $res = $origin_line->fetch($origin_line_id);
453 $ret =
$object->addline_batch($batch_line[$i], $array_options[$i], $origin_line);
462 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
475 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
476 if (isModEnabled(
'stock')) {
477 $labelfieldmissing .=
'/'.$langs->transnoentitiesnoconv(
"Warehouse");
479 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
486 foreach (
$object->lines as $line) {
487 $objectsrc_line =
new $objectsrc->class_element_line($db);
488 '@phan-var-force CommonObjectLine $objectsrc_line';
489 $objectsrc_line->fetch($line->origin_line_id);
490 $line->extraparams = $objectsrc_line->extraparams;
491 $line->setExtraParameters();
493 header(
"Location: card.php?id=".
$object->id);
500 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
504 $result =
$object->create_delivery($user);
508 header(
"Location: ".DOL_URL_ROOT.
'/delivery/card.php?action=create_delivery&token='.
newToken().
'&id='.$result);
515 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
516 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
520 $result =
$object->valid($user);
527 $outputlangs = $langs;
530 $newlang =
GETPOST(
'lang_id',
'aZ09');
533 $newlang =
$object->thirdparty->default_lang;
535 if (!empty($newlang)) {
537 $outputlangs->setDefaultLang($newlang);
542 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
548 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
549 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
550 $result =
$object->cancel(0, (
bool) $also_update_stock);
552 $result =
$object->setStatut(-1);
556 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
557 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
558 $result =
$object->delete($user, 0, (
bool) $also_update_stock);
560 header(
"Location: ".DOL_URL_ROOT.
'/expedition/index.php');
574 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $permissiontoadd) {
575 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
578 $object->line_order(
true,
'ASC',
false);
580 $outputlangs = $langs;
583 $newlang =
GETPOST(
'lang_id',
'aZ09');
586 $newlang =
$object->thirdparty->default_lang;
588 if (!empty($newlang)) {
590 $outputlangs->setDefaultLang($newlang);
594 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
597 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
602 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
603 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
605 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
610 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
611 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
613 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
618 } elseif ($action ==
'setdate_livraison' && $user->hasRight(
'expedition',
'creer')) {
622 $result =
$object->setDeliveryDate($user, $datedelivery);
626 } elseif ($action ==
'setdate_shipping' && $user->hasRight(
'expedition',
'creer')) {
630 $result =
$object->setShippingDate($user, $dateshipping);
634 } elseif (in_array($action, array(
'settracking_number',
'settracking_url',
'settrueWeight',
'settrueWidth',
'settrueHeight',
'settrueDepth',
'setshipping_method_id')) && $user->hasRight(
'expedition',
'creer')) {
638 if ($action ==
'settracking_number') {
639 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
641 if ($action ==
'settracking_url') {
642 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'restricthtml'));
644 if ($action ==
'settrueWeight') {
648 if ($action ==
'settrueWidth') {
651 if ($action ==
'settrueHeight') {
655 if ($action ==
'settrueDepth') {
658 if ($action ==
'setshipping_method_id') {
663 if (
$object->update($user) >= 0) {
664 header(
"Location: card.php?id=".
$object->id);
671 } elseif ($action ==
'classifybilled' && $permissiontoadd) {
673 $result =
$object->setBilled();
675 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
679 } elseif ($action ==
'classifyclosed' && $permissiontoadd) {
681 $result =
$object->setClosed();
683 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
687 } elseif ($action ==
'deleteline' && !empty($line_id) && $permissiontoadd) {
692 $line->fk_expedition =
$object->id;
694 $num_prod = count($lines);
695 for ($i = 0; $i < $num_prod; $i++) {
696 if ($lines[$i]->
id == $line_id) {
697 if (count($lines[$i]->details_entrepot) > 1) {
699 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
700 $line->id = $details_entrepot->line_id;
701 if (!$error && $line->delete($user) < 0) {
707 $line->id = $line_id;
708 if (!$error && $line->delete($user) < 0) {
713 unset($_POST[
"lineid"]);
717 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
722 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'save')) {
729 $num_prod = count($lines);
730 for ($i = 0; $i < $num_prod; $i++) {
731 if ($lines[$i]->
id == $line_id) {
732 $update_done =
false;
734 $line->fk_expedition =
$object->id;
737 $line->array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
739 if (is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
740 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
741 unset($_POST[
"options_".$key]);
744 $line->fk_product = $lines[$i]->fk_product;
745 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
747 foreach ($lines[$i]->detail_batch as $detail_batch) {
749 $batch =
"batchl".$detail_batch->fk_expeditiondet.
"_".$detail_batch->fk_origin_stock;
750 $qty =
"qtyl".$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id;
753 if (!empty($batch_id)) {
754 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
755 if ($lines[$i]->entrepot_id != 0) {
757 $line->entrepot_id = $lotStock->warehouseid;
761 if (empty($line->detail_batch)) {
762 $line->detail_batch =
new stdClass();
765 $line->detail_batch->fk_origin_stock = $batch_id;
766 $line->detail_batch->batch = $lotStock->batch;
767 $line->detail_batch->id = $detail_batch->id;
768 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
769 $line->detail_batch->qty = $batch_qty;
770 if ($line->update($user) < 0) {
781 unset($_POST[$batch]);
786 $batch =
"batchl".$line_id.
"_0";
787 $qty =
"qtyl".$line_id.
"_0";
791 if ($batch_qty > 0 && !empty($batch_id)) {
792 if ($lotStock->fetch($batch_id) > 0) {
794 if ($lines[$i]->entrepot_id > 0) {
796 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
797 $lineIdToAddLot = $line_id;
799 } elseif (count($lines[$i]->details_entrepot) > 1) {
801 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
802 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
803 $lineIdToAddLot = $detail_entrepot->line_id;
807 if ($lineIdToAddLot) {
809 if ($line->fetch($lineIdToAddLot) > 0) {
810 $line->detail_batch->fk_origin_stock = $batch_id;
811 $line->detail_batch->batch = $lotStock->batch;
812 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
813 $line->detail_batch->qty = $batch_qty;
814 if ($line->update($user) < 0) {
826 $line->origin_line_id = $lines[$i]->origin_line_id;
827 $line->entrepot_id = $lotStock->warehouseid;
829 $line->detail_batch[0]->fk_origin_stock = $batch_id;
830 $line->detail_batch[0]->batch = $lotStock->batch;
831 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
832 $line->detail_batch[0]->qty = $batch_qty;
833 if (
$object->create_line_batch($line, $line->array_options) < 0) {
846 if ($lines[$i]->fk_product > 0) {
848 if ($lines[$i]->entrepot_id == 0) {
850 $stockLocation =
"entl".$line_id;
851 $qty =
"qtyl".$line_id;
852 $line->id = $line_id;
853 $line->entrepot_id =
GETPOSTINT((
string) $stockLocation);
855 if ($line->update($user) < 0) {
859 unset($_POST[$stockLocation]);
861 } elseif ($lines[$i]->entrepot_id > 0) {
863 $stockLocation =
"entl".$line_id;
864 $qty =
"qtyl".$line_id;
865 $line->id = $line_id;
866 $line->entrepot_id =
GETPOSTINT($stockLocation);
868 if ($line->update($user) < 0) {
872 unset($_POST[$stockLocation]);
874 } elseif (count($lines[$i]->details_entrepot) > 1) {
876 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
878 $stockLocation =
"entl".$detail_entrepot->line_id;
879 $qty =
"qtyl".$detail_entrepot->line_id;
881 if (!empty($warehouse)) {
882 $line->id = $detail_entrepot->line_id;
883 $line->entrepot_id = $warehouse;
885 if ($line->update($user) < 0) {
892 unset($_POST[$stockLocation]);
896 } elseif (!isModEnabled(
'stock') && empty(
$conf->productbatch->enabled)) {
897 $qty =
"qtyl".$line_id;
898 $line->id = $line_id;
900 $line->entrepot_id = 0;
901 if ($line->update($user) < 0) {
911 $qty =
"qtyl".$line_id;
912 $line->id = $line_id;
914 $line->entrepot_id = 0;
915 if ($line->update($user) < 0) {
925 if (empty($update_done)) {
926 $line->id = $lines[$i]->id;
927 $line->insertExtraFields();
932 unset($_POST[
"lineid"]);
937 $outputlangs = $langs;
940 $newlang =
GETPOST(
'lang_id',
'aZ09');
943 $newlang =
$object->thirdparty->default_lang;
945 if (!empty($newlang)) {
947 $outputlangs->setDefaultLang($newlang);
951 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
954 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
957 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
958 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
962 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
968 $triggersendname =
'SHIPPING_SENTBYMAIL';
970 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
971 $mode =
'emailfromshipment';
972 $trackid =
'shi'.$object->id;
973 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
981$title =
$object->ref.
' - '.$langs->trans(
"Shipment");
982if ($action ==
'create2') {
983 $title = $langs->trans(
"CreateShipment");
985$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
987llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-expedition page-card');
993$form =
new Form($db);
996if (isModEnabled(
'project')) {
1002$product_static =
new Product($db);
1004$warehousestatic =
new Entrepot($db);
1006if ($action ==
'create2') {
1009 print
'<br>'.$langs->trans(
"ShipmentCreationIsDoneFromOrder");
1016if ($action ==
'create') {
1026 $classname = ucfirst($origin);
1028 $object =
new $classname($db);
1030 '@phan-var-force Commande|Facture $object';
1032 if (
$object->fetch($origin_id)) {
1036 $author =
new User($db);
1037 $author->fetch(
$object->user_author_id);
1039 if (isModEnabled(
'stock')) {
1043 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1044 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1045 print
'<input type="hidden" name="action" value="add">';
1046 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1047 print
'<input type="hidden" name="origin_id" value="'.$object->id.
'">';
1049 print
'<input type="hidden" name="entrepot_id" value="'.GETPOSTINT(
'entrepot_id').
'">';
1054 print
'<table class="border centpercent">';
1057 print
'<tr><td class="titlefieldcreate fieldrequired">';
1058 if ($origin ==
'commande' && isModEnabled(
'order')) {
1059 print $langs->trans(
"RefOrder");
1061 if ($origin ==
'propal' && isModEnabled(
"propal")) {
1062 print $langs->trans(
"RefProposal");
1064 print
'</td><td colspan="3">';
1071 if ($origin ==
'commande') {
1072 print $langs->trans(
'RefCustomerOrder');
1073 } elseif ($origin ==
'propal') {
1074 print $langs->trans(
'RefCustomerOrder');
1076 print $langs->trans(
'RefCustomer');
1078 print
'</td><td colspan="3">';
1079 print
'<input type="text" name="ref_customer" value="'.$object->ref_client.
'" />';
1084 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Company').
'</td>';
1085 print
'<td colspan="3">'.$soc->getNomUrl(1).
'</td>';
1089 if (isModEnabled(
'project') && is_object($formproject)) {
1091 if (empty($projectid) && !empty(
$object->fk_project)) {
1092 $projectid =
$object->fk_project;
1094 if ($origin ==
'project') {
1098 $langs->load(
"projects");
1100 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1101 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1102 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1103 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>';
1109 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1110 print
'<td colspan="3">';
1111 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1112 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1113 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1118 print
'<tr><td>' . $langs->trans(
"DateShipping") .
'</td>';
1119 print
'<td colspan="3">';
1120 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1122 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1127 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
1128 print
'<td colspan="3">';
1129 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1130 print $doleditor->Create(1);
1134 if (
$object->note_private && !$user->socid) {
1135 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
1136 print
'<td colspan="3">';
1137 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1138 print $doleditor->Create(1);
1144 print $langs->trans(
"Weight");
1145 print
'</td><td colspan="3">';
1146 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1147 print
'<input name="weight" size="4" value="'.GETPOSTINT(
'weight').
'"> ';
1148 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOSTINT(
'weight_units'), 0, 2);
1149 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1150 print $form->textwithpicto($text, $htmltext);
1154 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
1155 print
' </td><td colspan="3">';
1156 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1157 print
'<input name="sizeW" size="4" value="'.GETPOSTINT(
'sizeW').
'">';
1158 print
' x <input name="sizeH" size="4" value="'.GETPOSTINT(
'sizeH').
'">';
1159 print
' x <input name="sizeS" size="4" value="'.GETPOSTINT(
'sizeS').
'">';
1161 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size", (
string)
GETPOSTINT(
'size_units'), 0, 2);
1162 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1163 print $form->textwithpicto($text, $htmltext);
1167 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1168 print
'<td colspan="3">';
1169 $expe->fetch_delivery_methods();
1170 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1171 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1173 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1175 print
"</td></tr>\n";
1178 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1179 print
'<td colspan="3">';
1180 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1181 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1182 print
"</td></tr>\n";
1185 if (isModEnabled(
'incoterm')) {
1187 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1188 print
'<td colspan="3" class="maxwidthonsmartphone">';
1189 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1190 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1195 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1197 if (is_array($list) && count($list) > 1) {
1198 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1199 print
'<td colspan="3">';
1200 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1201 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1202 print
"</td></tr>\n";
1210 if (isset($extrafields->attributes[
$object->table_element][
'label'])) {
1211 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
1212 if (array_key_exists(
'options_' . $key, $objectsav->array_options)) {
1213 $object->array_options[
'options_' . $key] = $objectsav->array_options[
'options_' . $key];
1217 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'cols' =>
'3',
'socid' => $socid);
1218 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1228 $numAsked = count(
$object->lines);
1230 print
'<script type="text/javascript">'.
"\n";
1231 print
'jQuery(document).ready(function() {'.
"\n";
1232 print
'jQuery("#autofill").click(function() {';
1234 while ($i < $numAsked) {
1235 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1236 if (isModEnabled(
'productbatch')) {
1237 print
'jQuery("#qtyl'.$i.
'_'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1241 print
'return false; });'.
"\n";
1242 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);'.
"\n";
1243 print
'return false; });'.
"\n";
1245 print
'</script>'.
"\n";
1249 print
'<div class="div-table-responsive-no-min">';
1250 print
'<table class="noborder centpercent">';
1256 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1258 $title_lines_to_disable = array();
1261 if (isModEnabled(
'subtotals')) {
1263 $title_lines_to_disable =
$object->getDisabledShippmentSubtotalLines();
1265 foreach (
$object->lines as $line) {
1266 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1267 $show_check_add_buttons =
true;
1272 print
'<tr class="liste_titre">';
1274 if (isset($show_check_add_buttons)) {
1275 print $form->showCheckAddButtons(
'checkforselect');
1277 print $langs->trans(
"Description");
1279 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1280 print
'<td class="center">'.$langs->trans(
"QtyShipped").
'</td>';
1281 print
'<td class="center">'.$langs->trans(
"QtyToShip");
1282 if (empty(
$conf->productbatch->enabled)) {
1283 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"').
'</a>';
1288 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Reset"),
'eraser').
'</span>';
1290 if (isModEnabled(
'stock')) {
1291 if (empty(
$conf->productbatch->enabled)) {
1292 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1294 print
'<td class="left">'.$langs->trans(
"Warehouse").
' / '.$langs->trans(
"Batch").
' ('.$langs->trans(
"Stock").
')</td>';
1298 print
'<td class="left">'.$langs->trans(
'StockEntryDate').
'</td>';
1304 $warehousePicking = array();
1306 if ($warehouse_id > 0) {
1307 $warehousePicking[] = $warehouse_id;
1309 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1313 while ($indiceAsked < $numAsked) {
1316 $line =
$object->lines[$indiceAsked];
1318 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1319 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
1324 if (empty($reshook) && $line->special_code != SUBTOTALS_SPECIAL_CODE) {
1326 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1329 if (!empty($line->date_start)) {
1332 if (!empty($line->date_end)) {
1336 print
'<!-- line for order line '.$line->id.
' -->'.
"\n";
1337 print
'<tr class="oddeven" id="row-'.$line->id.
'">'.
"\n";
1339 $qtyProdCom = $line->qty;
1340 $productChildrenNb = 0;
1342 if ($line->fk_product > 0) {
1343 $res = $product->fetch($line->fk_product);
1348 $productChildrenNb = $product->hasFatherOrChild(1);
1350 if ($productChildrenNb > 0) {
1351 $product->loadStockForVirtualProduct(
'warehouseopen', $qtyProdCom);
1353 $product->load_stock(
'warehouseopen');
1358 print
'<a name="'.$line->id.
'"></a>';
1361 $product_static->type = $line->fk_product_type;
1362 $product_static->id = $line->fk_product;
1363 $product_static->ref = $line->ref;
1364 $product_static->status = $line->product_tosell;
1365 $product_static->status_buy = $line->product_tobuy;
1366 $product_static->status_batch = $line->product_tobatch;
1368 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
1370 $text = $product_static->getNomUrl(1);
1371 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1373 $description .= empty($product->stockable_product) ? $langs->trans(
'StockDisabled') : $langs->trans(
'StockEnabled');
1374 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
1377 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1380 if ($showdescinproductdesc) {
1381 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1388 $text =
img_object($langs->trans(
'Service'),
'service');
1390 $text =
img_object($langs->trans(
'Product'),
'product');
1393 if (!empty($line->label)) {
1394 $text .=
' <strong>'.$line->label.
'</strong>';
1395 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
1397 print $text.
' '.nl2br($line->desc);
1401 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1412 print
'<td class="center">'.$line->qty;
1413 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1414 print
''.$unit_order.
'</td>';
1417 print
'<td class="center">';
1418 $quantityDelivered = isset(
$object->expeditions[$line->id]) ?
$object->expeditions[$line->id] :
'';
1419 print $quantityDelivered;
1420 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1421 print
''.$unit_order.
'</td>';
1424 $quantityAsked = $line->qty;
1426 $quantityToBeDelivered = 0;
1428 if (is_numeric($quantityDelivered)) {
1429 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
1431 $quantityToBeDelivered = $quantityAsked;
1435 $warehouseObject =
null;
1436 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !isModEnabled(
'stock')) {
1437 print
'<!-- Case warehouse already known or product not a predefined product -->';
1439 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
1441 $deliverableQty = $quantityToBeDelivered;
1443 $deliverableQty = min($quantityToBeDelivered, $stock);
1445 if ($deliverableQty < 0) {
1446 $deliverableQty = 0;
1448 if (empty(
$conf->productbatch->enabled) || !$product->hasbatch()) {
1450 print
'<td class="center">';
1453 $deliverableQty =
GETPOSTINT(
'qtyl'.$indiceAsked);
1455 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1456 $qtylValue = $deliverableQty;
1460 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" class="qtyl right" type="text" size="4" value="'.$qtylValue.
'">';
1463 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1464 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1467 print $langs->trans(
"NA");
1472 if (isModEnabled(
'stock')) {
1473 print
'<td class="left">';
1476 $ent =
"entl".$indiceAsked;
1477 $idl =
"idl".$indiceAsked;
1479 if ($line->fk_product > 0) {
1480 print
'<!-- Show warehouse selection -->';
1486 if ($productChildrenNb > 0) {
1487 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, 0,
'', 0, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
1489 if ($product->stockable_product == Product::ENABLED_STOCK) {
1490 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
1492 print
img_warning().
' '.$langs->trans(
'StockDisabled');
1496 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
1498 if ($stock < $quantityToBeDelivered) {
1499 print
' '.img_warning($langs->trans(
"StockTooLow"));
1504 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span><input name="entl'.$indiceAsked.
'" id="entl'.$indiceAsked.
'" type="hidden" value="0">';
1515 $product->get_sousproduits_arbo();
1516 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1517 if (count($prods_arbo) > 0) {
1518 foreach ($prods_arbo as $key => $value) {
1521 if ($value[
'stock'] < $value[
'stock_alert']) {
1524 print
"<tr class=\"oddeven\"><td> ->
1525 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1526 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1527 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1537 print
'<td></td><td></td>';
1542 print
'<!-- Case product need lot -->';
1544 $staticwarehouse =
new Entrepot($db);
1545 if ($warehouse_id > 0) {
1546 $staticwarehouse->fetch($warehouse_id);
1552 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1553 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1557 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1558 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1559 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1561 $batchStock = + $dbatch->qty;
1562 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1565 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1566 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1568 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1569 $alreadyQtyBatchSetted[$line->fk_product] = array();
1572 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1573 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1576 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1579 if ($deliverableQty < 0) {
1580 $deliverableQty = 0;
1583 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1584 if (GETPOSTISSET($inputName)) {
1585 $deliverableQty =
GETPOST($inputName,
'int');
1588 $tooltipClass = $tooltipTitle =
'';
1589 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1590 $tooltipClass =
' classfortooltip';
1591 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1593 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1595 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1597 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1598 print
'<td colspan="3" ></td><td class="center">';
1599 $qtylValue = $deliverableQty;
1603 print
'<input class="qtyl '.$tooltipClass.
' right" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$qtylValue.
'">';
1606 print
'<!-- Show details of lot -->';
1607 print
'<td class="left">';
1609 print $staticwarehouse->getNomUrl(0).
' / ';
1611 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1614 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
1616 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1619 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1621 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
1625 $quantityToBeDelivered -= $deliverableQty;
1626 if ($quantityToBeDelivered < 0) {
1627 $quantityToBeDelivered = 0;
1632 print
'<td>'.dol_print_date($dbatch->context[
'stock_entry_date'],
'day').
'</td>';
1637 print
'<!-- Case there is no details of lot at all -->';
1638 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1639 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0" disabled="disabled"> ';
1642 print
'<td class="left">';
1643 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
1653 if (empty(
$conf->productbatch->enabled) || !$product->hasbatch()) {
1654 print
'<!-- Case warehouse not already known and product does not need lot -->';
1655 print
'<td></td><td></td>';
1661 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1666 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1667 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
1671 $tmpwarehouseObject =
new Entrepot($db);
1672 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1674 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1679 $tmpwarehouseObject->fetch($warehouse_id);
1680 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
1681 $stock = + $stock_warehouse->real;
1682 $deliverableQty = min($quantityToBeDelivered, $stock);
1683 $deliverableQty = max(0, $deliverableQty);
1685 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1686 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked='.$indiceAsked.
') -->';
1688 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1689 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
1691 if (!isset($alreadyQtySetted[$line->fk_product])) {
1692 $alreadyQtySetted[$line->fk_product] = array();
1695 $deliverableQty = min($quantityToBeDelivered, $stock);
1698 if ($deliverableQty < 0) {
1699 $deliverableQty = 0;
1702 $tooltipClass = $tooltipTitle =
'';
1703 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1704 $tooltipClass =
' classfortooltip';
1705 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1707 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
1710 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1712 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1713 if (GETPOSTISSET($inputName)) {
1716 $qtylValue = $deliverableQty;
1720 print
'<input class="qtyl'.$tooltipClass.
' right" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$qtylValue.
'">';
1721 print
'<input name="ent1'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$warehouse_id.
'">';
1724 print
'<input name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1727 print $langs->trans(
"NA");
1732 if (isModEnabled(
'stock')) {
1733 print
'<td class="left">';
1735 if ($product->stockable_product == Product::ENABLED_STOCK || $productChildrenNb > 0) {
1736 print $tmpwarehouseObject->getNomUrl(0).
' ';
1737 if ($productChildrenNb <= 0) {
1738 print
'<!-- Show details of stock -->';
1739 print
'('.$stock.
')';
1742 print
img_warning().
' '.$langs->trans(
'StockDisabled');
1745 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
1749 $quantityToBeDelivered -= $deliverableQty;
1750 if ($quantityToBeDelivered < 0) {
1751 $quantityToBeDelivered = 0;
1762 $product->get_sousproduits_arbo();
1763 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1764 if (count($prods_arbo) > 0) {
1765 foreach ($prods_arbo as $key => $value) {
1768 if ($value[
'stock'] < $value[
'stock_alert']) {
1771 print
'<tr class"oddeven"><td>';
1772 print
" ->
1773 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1774 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1775 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1784 print
'<!-- Case warehouse not already known and product need lot -->';
1785 print
'<td></td><td></td>';
1792 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1794 $tmpwarehouseObject =
new Entrepot($db);
1799 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1800 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
1801 $nbofsuggested += count($stock_warehouse->detail_batch);
1805 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1807 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1812 $tmpwarehouseObject->fetch($warehouse_id);
1813 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
1814 foreach ($stock_warehouse->detail_batch as $dbatch) {
1815 $batchStock = + $dbatch->qty;
1816 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1817 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1819 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1820 $alreadyQtyBatchSetted[$line->fk_product] = array();
1823 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1824 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1827 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1830 if ($deliverableQty < 0) {
1831 $deliverableQty = 0;
1834 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1835 if (GETPOSTISSET($inputName)) {
1839 $tooltipClass = $tooltipTitle =
'';
1840 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1841 $tooltipClass =
' classfortooltip';
1842 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1844 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1846 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1848 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'><td colspan="3"></td><td class="center">';
1849 $qtylValue = $deliverableQty;
1853 print
'<input class="qtyl right '.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="'.$inputName.
'" id="'.$inputName.
'" type="text" size="4" value="'.$qtylValue.
'">';
1856 print
'<td class="left">';
1858 print $tmpwarehouseObject->getNomUrl(0).
' / ';
1860 print
'<!-- Show details of lot -->';
1861 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1864 print $langs->trans(
"Batch").
': ';
1865 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
1867 print $productlotObject->getNomUrl(1);
1869 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
1872 print
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1875 print
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1877 print
' ('.$dbatch->qty.
')';
1878 $quantityToBeDelivered -= $deliverableQty;
1879 if ($quantityToBeDelivered < 0) {
1880 $quantityToBeDelivered = 0;
1886 print
'<td class="left">'.dol_print_date($dbatch->context[
'stock_entry_date'],
'day').
'</td>';
1894 $warehouse_selected_id =
GETPOSTINT(
'entrepot_id');
1896 print
'<!-- line not shown yet, we show it -->';
1897 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1901 if (isModEnabled(
'productbatch') && $product->hasbatch()) {
1902 $disabled =
'disabled="disabled"';
1904 if ($warehouse_selected_id <= 0) {
1905 $disabled =
'disabled="disabled"';
1911 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').
'> ';
1913 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
1917 if (isModEnabled(
'productbatch') && $product->hasbatch()) {
1918 $disabled =
'disabled="disabled"';
1920 if ($warehouse_selected_id <= 0) {
1921 $disabled =
'disabled="disabled"';
1923 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$quantityToBeDelivered.
'"'.($disabled ?
' '.$disabled :
'').
'> ';
1924 if (empty($disabled)) {
1925 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
1928 print $langs->trans(
"NA");
1932 print
'<td class="left">';
1934 if ($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK) {
1935 $warehouseObject =
new Entrepot($db);
1936 $warehouseObject->fetch($warehouse_selected_id);
1937 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
1939 if ($line->fk_product) {
1940 if ($product->stockable_product == Product::ENABLED_STOCK) {
1941 print
img_warning().
' '.$langs->trans(
'StockTooLow');
1943 print
img_warning().
' '.$langs->trans(
'StockDisabled');
1950 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
1962 if (!empty($extrafields)) {
1968 $srcLine->id = $line->id;
1969 $srcLine->fetch_optionals();
1971 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
1973 print $expLine->showOptionals($extrafields,
'edit', array(
'style' =>
'class="drag drop oddeven"',
'colspan' => $colspan), (
string) $indiceAsked,
'',
'1');
1975 } elseif (empty($reshook) && $line->special_code == SUBTOTALS_SPECIAL_CODE && !in_array($line->id, $title_lines_to_disable)) {
1976 require
dol_buildpath(
'/core/tpl/subtotalline_select.tpl.php');
1987 print $form->buttonsSaveCancel(
"Create");
1997 '@phan-var-force Expedition $object';
2003 $num_prod = count($lines);
2006 $typeobject =
$object->origin;
2008 $origin_id =
$object->origin_id;
2016 $res =
$object->fetch_optionals();
2024 if ($action ==
'delete') {
2025 $formquestion = array();
2027 $formquestion = array(
2029 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
2030 'name' =>
'alsoUpdateStock',
2031 'type' =>
'checkbox',
2036 $formconfirm = $form->formconfirm(
2037 $_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
2038 $langs->trans(
'DeleteSending'),
2039 $langs->trans(
"ConfirmDeleteSending",
$object->ref),
2048 if ($action ==
'ask_subtotal_deleteline') {
2050 $langs->load(
"subtotals");
2051 $title =
"DeleteSubtotalLine";
2052 $question =
"ConfirmDeleteSubtotalLine";
2053 if (
GETPOST(
'type') ==
'title') {
2054 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2055 $title =
"DeleteTitleLine";
2056 $question =
"ConfirmDeleteTitleLine";
2058 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2062 if ($action ==
'valid') {
2063 $objectref = substr(
$object->ref, 1, 4);
2064 if ($objectref ==
'PROV') {
2065 $numref =
$object->getNextNumRef($soc);
2070 $text = $langs->trans(
"ConfirmValidateSending", $numref);
2072 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementWillBeRecorded").
'.';
2074 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementNotYetRecorded").
'.';
2077 if (isModEnabled(
'notification')) {
2078 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2079 $notify =
new Notify($db);
2081 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE',
$object->socid,
$object);
2084 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 260);
2088 if ($action ==
'cancel') {
2089 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending",
$object->ref),
'confirm_cancel',
'', 0, 1);
2093 if ($action ==
'sign') {
2094 $text = $langs->trans(
'ConfirmSignShipping');
2095 if (isModEnabled(
'notification')) {
2096 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2097 $notify =
new Notify($db);
2099 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid,
$object);
2104 'name' =>
'signed_status',
2105 'select_show_empty' => 0,
2106 'label' =>
'<span class="fieldrequired">' . $langs->trans(
'SignStatus') .
'</span>',
2107 'values' =>
$object->getSignedStatusLocalisedArray()
2109 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'SignShipping'), $text,
'confirm_sign', $formquestion, 0, 1);
2113 if ($action ==
'unsign') {
2114 $text = $langs->trans(
'ConfirmUnsignShipping');
2115 if (isModEnabled(
'notification')) {
2116 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2117 $notify =
new Notify($db);
2119 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid,
$object);
2121 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'UnsignShipping'), $text,
'confirm_unsign',
'', 0, 1);
2125 $parameters = array(
'formConfirm' => $formconfirm);
2126 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2127 if (empty($reshook)) {
2128 $formconfirm .= $hookmanager->resPrint;
2129 } elseif ($reshook > 0) {
2130 $formconfirm = $hookmanager->resPrint;
2138 $tmparray =
$object->getTotalWeightVolume();
2139 $totalWeight = $tmparray[
'weight'];
2140 $totalVolume = $tmparray[
'volume'];
2142 if (!empty($typeobject) && $typeobject ===
'commande' && is_object(
$object->origin_object) &&
$object->origin_object->id && isModEnabled(
'order')) {
2144 $objectsrc->fetch(
$object->origin_object->id);
2146 if (!empty($typeobject) && $typeobject ===
'propal' && is_object(
$object->origin_object) &&
$object->origin_object->id && isModEnabled(
"propal")) {
2147 $objectsrc =
new Propal($db);
2148 $objectsrc->fetch(
$object->origin_object->id);
2152 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2153 $morehtmlref =
'<div class="refidno">';
2155 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer,
$object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
2156 $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);
2158 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
2160 if (isModEnabled(
'project')) {
2161 $langs->load(
"projects");
2162 $morehtmlref .=
'<br>';
2164 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2165 if ($action !=
'classify') {
2166 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2168 $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');
2170 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2172 $proj->fetch($objectsrc->fk_project);
2173 $morehtmlref .= $proj->getNomUrl(1);
2175 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2180 $morehtmlref .=
'</div>';
2183 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2186 print
'<div class="fichecenter">';
2187 print
'<div class="fichehalfleft">';
2188 print
'<div class="underbanner clearboth"></div>';
2190 print
'<table class="border tableforfield centpercent">';
2193 if (!empty($typeobject) && $typeobject ==
'commande' &&
$object->origin_object->id && isModEnabled(
'order')) {
2195 print $langs->trans(
"RefOrder").
'</td>';
2197 print $objectsrc->getNomUrl(1,
'commande');
2201 if (!empty($typeobject) && $typeobject ==
'propal' &&
$object->origin_object->id && isModEnabled(
"propal")) {
2203 print $langs->trans(
"RefProposal").
'</td>';
2205 print $objectsrc->getNomUrl(1,
'expedition');
2211 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateCreation").
'</td>';
2212 print
'<td>'.dol_print_date(
$object->date_creation,
"dayhour").
"</td>\n";
2216 print
'<tr><td height="10">';
2217 print
'<table class="nobordernopadding centpercent"><tr><td>';
2218 print $langs->trans(
'DateDeliveryPlanned');
2220 if ($action !=
'editdate_livraison') {
2221 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>';
2223 print
'</tr></table>';
2225 if ($action ==
'editdate_livraison') {
2226 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2227 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2228 print
'<input type="hidden" name="action" value="setdate_livraison">';
2229 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2230 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2239 print
'<tr><td height="10">';
2240 print
'<table class="nobordernopadding centpercent"><tr><td>';
2241 print $langs->trans(
'DateShipping');
2243 if ($action !=
'editdate_shipping') {
2244 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>';
2246 print
'</tr></table>';
2248 if ($action ==
'editdate_shipping') {
2249 print
'<form name="setdate_shipping" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2250 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2251 print
'<input type="hidden" name="action" value="setdate_shipping">';
2252 print $form->selectDate(
$object->date_shipping ?
$object->date_shipping : -1,
'ship_', 1, 1, 0,
"setdate_shipping", 1, 0);
2253 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2263 print $form->editfieldkey(
"Weight",
'trueWeight',
$object->trueWeight,
$object, $user->hasRight(
'expedition',
'creer'));
2266 if ($action ==
'edittrueWeight') {
2267 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2268 print
'<input name="action" value="settrueWeight" type="hidden">';
2269 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2270 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2271 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text" class="width50 valignmiddle">';
2272 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2273 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2274 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2278 print (
$object->trueWeight &&
$object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight",
$object->weight_units) :
'';
2282 if ($totalWeight > 0) {
2283 if (!empty(
$object->trueWeight)) {
2284 print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
2287 if (!empty(
$object->trueWeight)) {
2294 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth',
$object->trueWidth,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2295 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth,
$object, $user->hasRight(
'expedition',
'creer'));
2296 print (
$object->trueWidth &&
$object->width_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->width_units) :
'';
2300 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight',
$object->trueHeight,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2301 if ($action ==
'edittrueHeight') {
2302 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2303 print
'<input name="action" value="settrueHeight" type="hidden">';
2304 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2305 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2306 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text" class="width50">';
2307 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
2308 print
' <input class="button smallpaddingimp" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2309 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2313 print (
$object->trueHeight &&
$object->height_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->height_units) :
'';
2319 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth',
$object->trueDepth,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2320 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth,
$object, $user->hasRight(
'expedition',
'creer'));
2321 print (
$object->trueDepth &&
$object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->depth_units) :
'';
2326 print $langs->trans(
"Volume");
2329 $calculatedVolume = 0;
2333 $volumeUnit =
$object->size_units * 3;
2336 if ($calculatedVolume > 0) {
2337 if ($volumeUnit < 50) {
2343 if ($totalVolume > 0) {
2344 if ($calculatedVolume) {
2345 print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
2349 if ($calculatedVolume) {
2358 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2363 print
'<div class="fichehalfright">';
2364 print
'<div class="underbanner clearboth"></div>';
2366 print
'<table class="border centpercent tableforfield">';
2370 print
'<table class="nobordernopadding centpercent"><tr><td>';
2371 print $langs->trans(
'SendingMethod');
2374 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
2375 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>';
2377 print
'</tr></table>';
2379 if ($action ==
'editshipping_method_id') {
2380 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2381 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2382 print
'<input type="hidden" name="action" value="setshipping_method_id">';
2383 $object->fetch_delivery_methods();
2384 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
2386 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2388 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2391 if (
$object->shipping_method_id > 0) {
2393 $code = $langs->getLabelFromKey($db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
2394 print $langs->trans(
"SendingMethod".strtoupper($code));
2401 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2402 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url,
$object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring',
$object->tracking_number);
2406 if (isModEnabled(
'incoterm')) {
2408 print
'<table class="nobordernopadding centpercent"><tr><td>';
2409 print $langs->trans(
'IncotermLabel');
2410 print
'<td><td class="right">';
2411 if ($permissiontoadd) {
2412 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
2416 print
'</td></tr></table>';
2419 if ($action !=
'editincoterm') {
2420 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
2422 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
2428 $parameters = array();
2429 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2430 print $hookmanager->resPrint;
2437 print
'<div class="clearboth"></div>';
2442 if ($action ==
'editline') {
2443 print
' <form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$line_id.
'" method="POST">
2444 <input type="hidden" name="token" value="' .
newToken().
'">
2445 <input type="hidden" name="action" value="updateline">
2446 <input type="hidden" name="mode" value="">
2447 <input type="hidden" name="id" value="' .
$object->id.
'">
2452 print
'<div class="div-table-responsive-no-min">';
2453 print
'<table class="noborder centpercent" id="tablelines" >';
2455 print
'<tr class="liste_titre">';
2458 print
'<td width="5" class="center linecolnum"> </td>';
2461 print
'<td class="linecoldescription" >'.$langs->trans(
"Products").
'</td>';
2463 print
'<td class="center linecolqty">'.$langs->trans(
"QtyOrdered").
'</td>';
2464 if ($origin && $origin_id > 0) {
2465 print
'<td class="center linecolqtyinothershipments">'.$langs->trans(
"QtyInOtherShipments").
'</td>';
2467 if ($action ==
'editline') {
2469 if (!isModEnabled(
'stock')) {
2472 if (empty(
$conf->productbatch->enabled)) {
2475 print
'<td class="center linecoleditlineotherinfo" colspan="'.$editColspan.
'">';
2477 print $langs->trans(
"QtyToShip");
2479 print $langs->trans(
"QtyShipped");
2481 if (isModEnabled(
'stock')) {
2482 print
' - '.$langs->trans(
"WarehouseSource");
2484 if (isModEnabled(
'productbatch')) {
2485 print
' - '.$langs->trans(
"Batch");
2490 print
'<td class="center linecolqtytoship">'.$langs->trans(
"QtyToShip").
'</td>';
2492 print
'<td class="center linecolqtyshipped">'.$langs->trans(
"QtyShipped").
'</td>';
2494 if (isModEnabled(
'stock')) {
2495 print
'<td class="left linecolwarehousesource">'.$langs->trans(
"WarehouseSource").
'</td>';
2498 if (isModEnabled(
'productbatch')) {
2499 print
'<td class="left linecolbatch">'.$langs->trans(
"Batch").
'</td>';
2502 print
'<td class="center linecolweight">'.$langs->trans(
"CalculatedWeight").
'</td>';
2503 print
'<td class="center linecolvolume">'.$langs->trans(
"CalculatedVolume").
'</td>';
2506 print
'<td class="linecoledit"></td>';
2507 print
'<td class="linecoldelete" width="10"></td>';
2512 $outputlangs = $langs;
2517 if (
GETPOST(
'lang_id',
'aZ09')) {
2518 $newlang =
GETPOST(
'lang_id',
'aZ09');
2520 if (empty($newlang)) {
2521 $newlang =
$object->thirdparty->default_lang;
2523 if (!empty($newlang)) {
2525 $outputlangs->setDefaultLang($newlang);
2530 $alreadysent = array();
2531 if ($origin && $origin_id > 0) {
2532 $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";
2533 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot";
2534 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
2536 $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';
2537 $sql .=
', p.description as product_desc';
2538 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2539 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
2540 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
2542 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2543 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
2544 $sql .=
" AND obj.fk_".$origin.
" = ".((int) $origin_id);
2545 $sql .=
" AND obj.rowid = ed.fk_elementdet";
2546 $sql .=
" AND ed.fk_expedition = e.rowid";
2548 $sql .=
" ORDER BY obj.fk_product";
2550 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
2551 $resql = $db->query($sql);
2553 $num = $db->num_rows($resql);
2557 $obj = $db->fetch_object($resql);
2560 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
2561 'shipment_ref' => $obj->shipment_ref,
'shipment_id' => $obj->shipment_id,
'warehouse' => $obj->fk_entrepot,
'qty_shipped' => $obj->qty_shipped,
2562 'product_tosell' => $obj->product_tosell,
'product_tobuy' => $obj->product_tobuy,
'product_tobatch' => $obj->product_tobatch,
2563 'date_valid' => $db->jdate($obj->date_valid),
'date_delivery' => $db->jdate($obj->date_delivery));
2574 $conf->cache[
'product'] = array();
2575 $conf->cache[
'warehouse'] = array();
2576 for ($i = 0; $i < $num_prod; $i++) {
2577 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
2578 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
2583 if (empty($reshook) && $lines[$i]->product_type !=
"9") {
2584 print
'<!-- origin line id = '.$lines[$i]->origin_line_id.
' -->';
2585 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'" >';
2589 print
'<td class="center linecolnum">'.($i + 1).
'</td>';
2593 if ($lines[$i]->fk_product > 0) {
2596 $product_id = $lines[$i]->fk_product;
2597 if (!isset(
$conf->cache[
'product'][$product_id])) {
2599 $prod->fetch($product_id);
2600 $conf->cache[
'product'][$product_id] = $prod;
2602 $prod =
$conf->cache[
'product'][$product_id];
2604 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
2606 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
2609 print
'<td class="linecoldescription">';
2612 $product_static->type = $lines[$i]->fk_product_type;
2613 $product_static->id = $lines[$i]->fk_product;
2614 $product_static->ref = $lines[$i]->ref;
2615 $product_static->status = $lines[$i]->product_tosell;
2616 $product_static->status_buy = $lines[$i]->product_tobuy;
2617 $product_static->status_batch = $lines[$i]->product_tobatch;
2619 $product_static->weight = $lines[$i]->weight;
2620 $product_static->weight_units = $lines[$i]->weight_units;
2621 $product_static->length = $lines[$i]->length;
2622 $product_static->length_units = $lines[$i]->length_units;
2623 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
2624 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
2625 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
2626 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
2627 $product_static->surface = $lines[$i]->surface;
2628 $product_static->surface_units = $lines[$i]->surface_units;
2629 $product_static->volume = $lines[$i]->volume;
2630 $product_static->volume_units = $lines[$i]->volume_units;
2631 $product_static->stockable_product = $lines[$i]->stockable_product;
2633 $text = $product_static->getNomUrl(1);
2634 $text .=
' - '.$label;
2636 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2637 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
2643 print
'<td class="linecoldescription" >';
2645 $text =
img_object($langs->trans(
'Service'),
'service');
2647 $text =
img_object($langs->trans(
'Product'),
'product');
2650 if (!empty($lines[$i]->label)) {
2651 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2652 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
2667 print
'<td class="center linecolqty">'.$lines[$i]->qty_asked.
' '.$unit_order.
'</td>';
2670 if ($origin && $origin_id > 0) {
2671 print
'<td class="linecolqtyinothershipments center nowrap">';
2673 $qtyalreadysent = 0;
2674 foreach ($alreadysent as $key => $val) {
2675 if ($lines[$i]->fk_elementdet == $key) {
2677 foreach ($val as $shipmentline_id => $shipmentline_var) {
2678 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
2684 $htmltooltip .=
'<br>';
2686 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
2687 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
2688 $htmltooltip .=
' - '.$shipmentline_var[
'qty_shipped'];
2689 $htmltooltip .=
' - '.$langs->trans(
"DateValidation").
' : '.(empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
2696 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
2699 $htmltooltip = $langs->trans(
"QtyInOtherShipments").
'...<br><br>'.$htmltooltip.
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
2703 print $form->textwithpicto((
string) $qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip'.$lines[$i]->
id);
2707 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2709 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding centpercent">';
2710 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
2711 print
'<!-- case edit 1 -->';
2713 foreach ($lines[$i]->detail_batch as $detail_batch) {
2716 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>';
2718 if ($lines[$i]->entrepot_id == 0) {
2720 $line->fetch($detail_batch->fk_expeditiondet);
2722 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
2723 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>';
2729 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'_0" id="qtyl'.$line_id.
'_0" type="text" size="4" value="0"></td>';
2731 print
'<td>'.$formproduct->selectLotStock(
'',
'batchl'.$line_id.
'_0',
'', 1, 0, $lines[$i]->fk_product).
'</td>';
2733 } elseif (isModEnabled(
'stock')) {
2734 if ($lines[$i]->fk_product > 0) {
2735 if ($lines[$i]->entrepot_id > 0) {
2736 print
'<!-- case edit 2 -->';
2739 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>';
2741 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200').
'</td>';
2744 if (isModEnabled(
'productbatch')) {
2745 print
' - '.$langs->trans(
"NA");
2749 } elseif (count($lines[$i]->details_entrepot) > 1) {
2750 print
'<!-- case edit 3 -->';
2751 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2754 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>';
2756 print
'<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl'.$detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200').
'</td>';
2759 if (isModEnabled(
'productbatch')) {
2760 print
' - '.$langs->trans(
"NA");
2766 print
'<!-- case edit 4 -->';
2769 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2770 print
'<td><span class="opacitymedium">('.$langs->trans(
"Service").
')</span></td>';
2774 print
'<!-- case edit 5 -->';
2775 print
'<tr><td colspan="3">'.$langs->trans(
"ErrorStockIsNotEnough").
'</td></tr>';
2778 print
'<!-- case edit 6 -->';
2781 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>';
2788 } elseif (!isModEnabled(
'stock') && empty(
$conf->productbatch->enabled)) {
2789 print
'<!-- case edit 7 -->';
2792 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2800 print
'</table></td>';
2803 print
'<td class="linecolqtytoship center">'.$lines[$i]->qty_shipped.
' '.$unit_order.
'</td>';
2806 if (isModEnabled(
'stock')) {
2807 print
'<td class="linecolwarehousesource tdoverflowmax200">';
2809 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
2810 } elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) {
2811 $warehouse_id = $lines[$i]->entrepot_id;
2812 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
2814 $warehouse->fetch($warehouse_id);
2815 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
2817 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
2819 print $warehouse->getNomUrl(1);
2820 } elseif (count($lines[$i]->details_entrepot) > 1) {
2822 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2823 $warehouse_id = $detail_entrepot->entrepot_id;
2824 if ($warehouse_id > 0) {
2825 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
2827 $warehouse->fetch($warehouse_id);
2828 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
2830 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
2832 $detail .= $langs->trans(
"DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped).
'<br>';
2835 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
"DetailWarehouseNumber"), $detail);
2836 } elseif (count($lines[$i]->detail_children ?? []) > 1) {
2838 foreach ($lines[$i]->detail_children as $child_product_id => $child_stock_list) {
2839 foreach ($child_stock_list as $warehouse_id => $total_qty) {
2841 $child_product_label =
'';
2842 if (!isset(
$conf->cache[
'product'][$child_product_id])) {
2843 $child_product =
new Product($db);
2844 $child_product->fetch($child_product_id);
2845 $conf->cache[
'product'][$child_product_id] = $child_product;
2847 $child_product =
$conf->cache[
'product'][$child_product_id];
2849 $child_product_label = $child_product->ref .
' ' . $child_product->label;
2852 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
2853 $child_warehouse =
new Entrepot($db);
2854 $child_warehouse->fetch($warehouse_id);
2855 $conf->cache[
'warehouse'][$warehouse_id] = $child_warehouse;
2857 $child_warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
2860 $detail .= $langs->trans(
'DetailChildrenFormat', $child_product_label, $child_warehouse->label,
price2num($total_qty,
'MS')).
'<br>';
2863 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
'DetailWarehouseNumber'), $detail);
2869 if (isModEnabled(
'productbatch')) {
2870 if (isset($lines[$i]->detail_batch)) {
2871 print
'<!-- Detail of lot -->';
2872 print
'<td class="linecolbatch">';
2873 if ($lines[$i]->product_tobatch) {
2875 foreach ($lines[$i]->detail_batch as $dbatch) {
2876 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
2878 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
2881 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
2883 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
2886 print $form->textwithtooltip(
img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $detail);
2888 print $langs->trans(
"NA");
2892 print
'<td class="linecolbatch" ></td>';
2898 print
'<td class="center linecolweight">';
2900 print $lines[$i]->weight * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
2907 print
'<td class="center linecolvolume">';
2909 print $lines[$i]->volume * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
2918 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2919 print
'<td class="center" colspan="2" valign="middle">';
2920 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2921 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2924 $edit_url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&lineid='.$lines[$i]->id;
2926 $product_id = $lines[$i]->fk_product;
2927 if (!isset(
$conf->cache[
'product'][$product_id])) {
2929 $product->fetch($product_id);
2930 $conf->cache[
'product'][$product_id] = $product;
2932 $product =
$conf->cache[
'product'][$product_id];
2935 if ($product->hasFatherOrChild(1)) {
2941 print
'<td class="linecoledit center">';
2942 print
'<a class="editfielda reposition" href="'.$edit_url.
'">'.
img_edit().
'</a>';
2944 print
'<td class="linecoldelete" width="10">';
2945 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_delete().
'</a>';
2949 if (!empty($rowExtrafieldsStart)) {
2950 print $rowExtrafieldsStart;
2951 print $rowExtrafieldsView;
2959 if (!empty($extrafields)) {
2961 if ($origin && $origin_id > 0) {
2964 if (isModEnabled(
'productbatch')) {
2967 if (isModEnabled(
'stock')) {
2972 $line->fetch_optionals();
2975 if ($action ==
'editline' && $line->id == $line_id) {
2976 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
2978 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
2981 } elseif (empty($reshook) && $lines[$i]->product_type ==
"9") {
2983 $objectsrc->fetch($lines[$i]->origin_line_id);
2984 if ($objectsrc->special_code == SUBTOTALS_SPECIAL_CODE) {
2986 require
dol_buildpath(
'/core/tpl/subtotal_expedition_view.tpl.php');
2993 if (empty($num_prod)) {
2994 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")).
'</span></td></tr>';
3012 if (($user->socid == 0) && ($action !=
'presend')) {
3013 print
'<div class="tabsAction">';
3015 $parameters = array();
3016 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3018 if (empty($reshook)) {
3020 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
3021 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))) {
3024 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3030 if ($user->hasRight(
'expedition',
'creer')) {
3035 if ($user->hasRight(
'expedition',
'creer')) {
3041 if (empty($user->socid)) {
3043 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
3044 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3046 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3054 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=create_delivery&token=' .
newToken() .
'&id=' .
$object->id,
'');
3059 if (
$object->signed_status != Expedition::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
3060 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>';
3062 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>';
3068 if ($user->hasRight(
'facture',
'creer')) {
3070 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->socid,
'');
3077 if ($user->hasRight(
'expedition',
'creer') &&
$object->status > 0) {
3079 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3081 print
dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifyclosed&token=' .
newToken() .
'&id=' .
$object->id,
'');
3087 if ($user->hasRight(
'expedition',
'creer')) {
3088 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"].
'?action=cancel&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3093 if ($user->hasRight(
'expedition',
'supprimer')) {
3106 if ($action !=
'presend' && $action !=
'editline') {
3107 print
'<div class="fichecenter"><div class="fichehalfleft">';
3110 $filedir =
$conf->expedition->dir_output.
"/sending/".$objectref;
3112 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3114 $genallowed = $user->hasRight(
'expedition',
'lire');
3115 $delallowed = $user->hasRight(
'expedition',
'creer');
3117 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3121 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'shipping'), 1);
3122 $linktoelem = $tmparray[
'linktoelem'];
3123 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3124 print $htmltoenteralink;
3126 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
3132 print
'<br><!-- Link to sign -->';
3133 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
3134 print showOnlineSignatureUrl(
'expedition',
$object->ref,
$object).
'<br>';
3137 print
'</div><div class="fichehalfright">';
3140 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3142 $somethingshown = $formactions->showactions(
$object,
'shipping', $socid, 1);
3144 print
'</div></div>';
3153 if (
GETPOST(
'modelselected')) {
3154 $action =
'presend';
3158 $modelmail =
'shipping_send';
3159 $defaulttopic =
'SendShippingRef';
3160 $diroutput =
$conf->expedition->dir_output.
'/sending';
3161 $trackid =
'shi'.$object->id;
3163 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
const STATUS_DRAFT
Draft status.
const STATUS_CLOSED
Closed status -> parcel was received by customer / end of process prev status : validated or shipment...
const STATUS_VALIDATED
Validated status -> parcel is ready to be sent prev status : draft next status : closed or shipment_i...
Class to manage lines of shipment.
CRUD class for batch number management within shipment.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage order lines.
Class 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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.