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;
272 $classname = ucfirst(
$object->origin_type);
273 $objectsrc =
new $classname($db);
274 '@phan-var-force Facture|Commande $objectsrc';
275 $objectsrc->fetch(
$object->origin_id);
277 $object->socid = $objectsrc->socid;
280 $object->date_delivery = $date_delivery;
281 $object->date_shipping = $date_shipping;
282 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
289 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
291 $batch_line = array();
292 $stockLine = array();
293 $array_options = array();
295 $num = count($objectsrc->lines);
298 $product_batch_used = array();
300 for ($i = 0; $i < $num; $i++) {
308 $batch =
"batchl".$i.
"_0";
309 $stockLocation =
"ent1".$i.
"_0";
312 $is_batch_or_serial = 0;
313 if (!empty($objectsrc->lines[$i]->fk_product)) {
314 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
315 if ($resultFetch < 0) {
318 $is_batch_or_serial = $product->status_batch;
322 if (isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
323 if (GETPOSTISSET($batch)) {
326 while (GETPOSTISSET($batch)) {
329 $sub_qty[$j][
'id_batch'] =
GETPOSTINT($batch);
330 $subtotalqty += $sub_qty[$j][
'q'];
332 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)))) {
333 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
338 if ($is_batch_or_serial == 2 && $sub_qty[$j][
'q'] > 0) {
340 $product_batch_used[$j] = $sub_qty[$j][
'id_batch'];
344 $batch =
"batchl".$i.
"_".$j;
345 $qty =
"qtyl".$i.
'_'.$j;
348 $batch_line[$i][
'detail'] = $sub_qty;
349 $batch_line[$i][
'qty'] = $subtotalqty;
352 $totalqty += $subtotalqty;
359 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse").
' ('.$langs->trans(
"Line").
' '.
GETPOSTINT($idl).
')',
null,
'errors');
363 } elseif (GETPOSTISSET($stockLocation)) {
366 while (GETPOSTISSET($stockLocation)) {
369 $stockLine[$i][$j][
'warehouse_id'] =
GETPOSTINT($stockLocation);
370 $stockLine[$i][$j][
'ix_l'] =
GETPOSTINT($idl);
376 $stockLocation =
"ent1".$i.
"_".$j;
377 $qty =
"qtyl".$i.
'_'.$j;
388 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
389 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i + 1),
null,
'errors');
395 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
397 if (isset($extrafields->attributes[
$object->table_element_line][
'label']) && is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
399 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
400 unset($_POST[
"options_".$key]);
405 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
406 $selected_subtotal_lines =
GETPOST(
'subtotal_toselect',
'array');
407 for ($i = 0; $i < $num; $i++) {
410 if (!isset($batch_line[$i])) {
412 if (isset($stockLine[$i])) {
414 $nbstockline = count($stockLine[$i]);
415 for ($j = 0; $j < $nbstockline; $j++) {
416 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
417 $ret =
$object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], (
float) $stockLine[$i][$j][
'qty'], $array_options[$i]);
429 if ($entrepot_id < 0) {
432 if (!($objectsrc->lines[$i]->fk_product > 0)) {
442 if (isModEnabled(
'subtotals') && $objectsrc->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE && in_array($objectsrc->lines[$i]->id, $selected_subtotal_lines)) {
443 $object->addSubtotalLine($langs, $objectsrc->lines[$i]->desc, (
int) $objectsrc->lines[$i]->qty, $objectsrc->lines[$i]->extraparams, $objectsrc->lines[$i]->id);
448 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
449 $origin_line_id = (int) $batch_line[$i][
'ix_l'];
451 $res = $origin_line->fetch($origin_line_id);
456 $ret =
$object->addline_batch($batch_line[$i], $array_options[$i], $origin_line);
465 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
478 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
479 if (isModEnabled(
'stock')) {
480 $labelfieldmissing .=
'/'.$langs->transnoentitiesnoconv(
"Warehouse");
482 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
489 foreach (
$object->lines as $line) {
490 $objectsrc_line =
new $objectsrc->class_element_line($db);
491 '@phan-var-force CommonObjectLine $objectsrc_line';
492 $objectsrc_line->fetch($line->origin_line_id);
493 $line->extraparams = $objectsrc_line->extraparams;
494 $line->setExtraParameters();
496 header(
"Location: card.php?id=".
$object->id);
503 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
507 $result =
$object->create_delivery($user);
511 header(
"Location: ".DOL_URL_ROOT.
'/delivery/card.php?action=create_delivery&token='.
newToken().
'&id='.$result);
518 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
519 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
523 $result =
$object->valid($user);
530 $outputlangs = $langs;
533 $newlang =
GETPOST(
'lang_id',
'aZ09');
536 $newlang =
$object->thirdparty->default_lang;
538 if (!empty($newlang)) {
540 $outputlangs->setDefaultLang($newlang);
545 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
551 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
552 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
553 $result =
$object->cancel(0, (
bool) $also_update_stock);
555 $result =
$object->setStatut(-1);
559 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
560 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
561 $result =
$object->delete($user, 0, (
bool) $also_update_stock);
563 header(
"Location: ".DOL_URL_ROOT.
'/expedition/index.php');
577 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $permissiontoadd) {
578 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
581 $object->line_order(
true,
'ASC',
false);
583 $outputlangs = $langs;
586 $newlang =
GETPOST(
'lang_id',
'aZ09');
589 $newlang =
$object->thirdparty->default_lang;
591 if (!empty($newlang)) {
593 $outputlangs->setDefaultLang($newlang);
597 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
600 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
605 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
606 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'SHIPPING_MODIFY');
608 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
613 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'creer')) {
614 $result =
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'SHIPPING_MODIFY');
616 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
621 } elseif ($action ==
'setdate_livraison' && $user->hasRight(
'expedition',
'creer')) {
625 $result =
$object->setDeliveryDate($user, $datedelivery);
629 } elseif ($action ==
'setdate_shipping' && $user->hasRight(
'expedition',
'creer')) {
633 $result =
$object->setShippingDate($user, $dateshipping);
637 } elseif (in_array($action, array(
'settracking_number',
'settracking_url',
'settrueWeight',
'settrueWidth',
'settrueHeight',
'settrueDepth',
'setshipping_method_id')) && $user->hasRight(
'expedition',
'creer')) {
641 if ($action ==
'settracking_number') {
642 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
644 if ($action ==
'settracking_url') {
645 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'restricthtml'));
648 if ($action ==
'settrueWeight') {
652 if ($action ==
'settrueWidth') {
655 if ($action ==
'settrueHeight') {
659 if ($action ==
'settrueDepth') {
662 if ($action ==
'setshipping_method_id') {
667 if (
$object->update($user) >= 0) {
668 header(
"Location: card.php?id=".
$object->id);
675 } elseif ($action ==
'classifybilled' && $permissiontoadd) {
677 $result =
$object->setBilled();
679 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
683 } elseif ($action ==
'classifyclosed' && $permissiontoadd) {
685 $result =
$object->setClosed();
687 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
691 } elseif ($action ==
'deleteline' && !empty($line_id) && $permissiontoadd) {
696 $line->fk_expedition =
$object->id;
698 $num_prod = count($lines);
699 for ($i = 0; $i < $num_prod; $i++) {
700 if ($lines[$i]->
id == $line_id) {
701 if (count($lines[$i]->details_entrepot) > 1) {
703 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
704 $line->id = $details_entrepot->line_id;
705 if (!$error && $line->delete($user) < 0) {
711 $line->id = $line_id;
712 if (!$error && $line->delete($user) < 0) {
717 unset($_POST[
"lineid"]);
721 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
726 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'save')) {
733 $num_prod = count($lines);
734 for ($i = 0; $i < $num_prod; $i++) {
735 if ($lines[$i]->
id == $line_id) {
736 $update_done =
false;
738 $line->fk_expedition =
$object->id;
741 $line->array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
743 if (is_array($extrafields->attributes[
$object->table_element_line][
'label'])) {
744 foreach ($extrafields->attributes[
$object->table_element_line][
'label'] as $key => $value) {
745 unset($_POST[
"options_".$key]);
748 $line->fk_product = $lines[$i]->fk_product;
749 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
751 foreach ($lines[$i]->detail_batch as $detail_batch) {
753 $batch =
"batchl".$detail_batch->fk_expeditiondet.
"_".$detail_batch->fk_origin_stock;
754 $qty =
"qtyl".$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id;
757 if (!empty($batch_id)) {
758 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
759 if ($lines[$i]->entrepot_id != 0) {
761 $line->entrepot_id = $lotStock->warehouseid;
765 if (empty($line->detail_batch)) {
766 $line->detail_batch =
new stdClass();
769 $line->detail_batch->fk_origin_stock = $batch_id;
770 $line->detail_batch->batch = $lotStock->batch;
771 $line->detail_batch->id = $detail_batch->id;
772 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
773 $line->detail_batch->qty = $batch_qty;
774 if ($line->update($user) < 0) {
785 unset($_POST[$batch]);
790 $batch =
"batchl".$line_id.
"_0";
791 $qty =
"qtyl".$line_id.
"_0";
795 if ($batch_qty > 0 && !empty($batch_id)) {
796 if ($lotStock->fetch($batch_id) > 0) {
798 if ($lines[$i]->entrepot_id > 0) {
800 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
801 $lineIdToAddLot = $line_id;
803 } elseif (count($lines[$i]->details_entrepot) > 1) {
805 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
806 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
807 $lineIdToAddLot = $detail_entrepot->line_id;
811 if ($lineIdToAddLot) {
813 if ($line->fetch($lineIdToAddLot) > 0) {
814 $line->detail_batch->fk_origin_stock = $batch_id;
815 $line->detail_batch->batch = $lotStock->batch;
816 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
817 $line->detail_batch->qty = $batch_qty;
818 if ($line->update($user) < 0) {
830 $line->origin_line_id = $lines[$i]->origin_line_id;
831 $line->entrepot_id = $lotStock->warehouseid;
833 $line->detail_batch[0]->fk_origin_stock = $batch_id;
834 $line->detail_batch[0]->batch = $lotStock->batch;
835 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
836 $line->detail_batch[0]->qty = $batch_qty;
837 if (
$object->create_line_batch($line, $line->array_options) < 0) {
850 if ($lines[$i]->fk_product > 0) {
852 if ($lines[$i]->entrepot_id == 0) {
854 $stockLocation =
"entl".$line_id;
855 $qty =
"qtyl".$line_id;
856 $line->id = $line_id;
857 $line->entrepot_id =
GETPOSTINT((
string) $stockLocation);
859 if ($line->update($user) < 0) {
863 unset($_POST[$stockLocation]);
865 } elseif ($lines[$i]->entrepot_id > 0) {
867 $stockLocation =
"entl".$line_id;
868 $qty =
"qtyl".$line_id;
869 $line->id = $line_id;
870 $line->entrepot_id =
GETPOSTINT($stockLocation);
872 if ($line->update($user) < 0) {
876 unset($_POST[$stockLocation]);
878 } elseif (count($lines[$i]->details_entrepot) > 1) {
880 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
882 $stockLocation =
"entl".$detail_entrepot->line_id;
883 $qty =
"qtyl".$detail_entrepot->line_id;
885 if (!empty($warehouse)) {
886 $line->id = $detail_entrepot->line_id;
887 $line->entrepot_id = $warehouse;
889 if ($line->update($user) < 0) {
896 unset($_POST[$stockLocation]);
900 } elseif (!isModEnabled(
'stock') && empty(
$conf->productbatch->enabled)) {
901 $qty =
"qtyl".$line_id;
902 $line->id = $line_id;
904 $line->entrepot_id = 0;
905 if ($line->update($user) < 0) {
915 $qty =
"qtyl".$line_id;
916 $line->id = $line_id;
918 $line->entrepot_id = 0;
919 if ($line->update($user) < 0) {
929 if (empty($update_done)) {
930 $line->id = $lines[$i]->id;
931 $line->insertExtraFields();
936 unset($_POST[
"lineid"]);
941 $outputlangs = $langs;
944 $newlang =
GETPOST(
'lang_id',
'aZ09');
947 $newlang =
$object->thirdparty->default_lang;
949 if (!empty($newlang)) {
951 $outputlangs->setDefaultLang($newlang);
955 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
958 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
961 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
962 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
966 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
972 $triggersendname =
'SHIPPING_SENTBYMAIL';
974 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
975 $mode =
'emailfromshipment';
976 $trackid =
'shi'.$object->id;
977 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
985$title =
$object->ref.
' - '.$langs->trans(
"Shipment");
986if ($action ==
'create2') {
987 $title = $langs->trans(
"CreateShipment");
989$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
991llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-expedition page-card');
997$form =
new Form($db);
1000if (isModEnabled(
'project')) {
1003 $formproject =
null;
1006$product_static =
new Product($db);
1008$warehousestatic =
new Entrepot($db);
1010if ($action ==
'create2') {
1013 print
'<br>'.$langs->trans(
"ShipmentCreationIsDoneFromOrder");
1020if ($action ==
'create') {
1030 $classname = ucfirst($origin);
1032 $object =
new $classname($db);
1034 '@phan-var-force Commande|Facture $object';
1036 if (
$object->fetch($origin_id)) {
1040 $author =
new User($db);
1041 $author->fetch(
$object->user_author_id);
1043 if (isModEnabled(
'stock')) {
1047 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1048 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1049 print
'<input type="hidden" name="action" value="add">';
1050 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1051 print
'<input type="hidden" name="origin_id" value="'.$object->id.
'">';
1053 print
'<input type="hidden" name="entrepot_id" value="'.GETPOSTINT(
'entrepot_id').
'">';
1058 print
'<table class="border centpercent">';
1061 print
'<tr><td class="titlefieldcreate fieldrequired">';
1062 if ($origin ==
'commande' && isModEnabled(
'order')) {
1063 print $langs->trans(
"RefOrder");
1065 if ($origin ==
'propal' && isModEnabled(
"propal")) {
1066 print $langs->trans(
"RefProposal");
1068 print
'</td><td colspan="3">';
1075 if ($origin ==
'commande') {
1076 print $langs->trans(
'RefCustomerOrder');
1077 } elseif ($origin ==
'propal') {
1078 print $langs->trans(
'RefCustomerOrder');
1080 print $langs->trans(
'RefCustomer');
1082 print
'</td><td colspan="3">';
1083 print
'<input type="text" name="ref_customer" value="'.$object->ref_client.
'" />';
1088 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Company').
'</td>';
1089 print
'<td colspan="3">'.$soc->getNomUrl(1).
'</td>';
1093 if (isModEnabled(
'project') && is_object($formproject)) {
1095 if (empty($projectid) && !empty(
$object->fk_project)) {
1096 $projectid =
$object->fk_project;
1098 if ($origin ==
'project') {
1102 $langs->load(
"projects");
1104 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1105 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1106 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1107 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>';
1113 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1114 print
'<td colspan="3">';
1115 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1116 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1117 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1122 print
'<tr><td>' . $langs->trans(
"DateShipping") .
'</td>';
1123 print
'<td colspan="3">';
1124 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1126 print $form->selectDate($date_shipping ? $date_shipping : -1,
'date_shipping', 1, 1, 1);
1131 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
1132 print
'<td colspan="3">';
1133 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1134 print $doleditor->Create(1);
1138 if (
$object->note_private && !$user->socid) {
1139 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
1140 print
'<td colspan="3">';
1141 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1142 print $doleditor->Create(1);
1148 print $langs->trans(
"Weight");
1149 print
'</td><td colspan="3">';
1150 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1151 print
'<input name="weight" size="4" value="'.dol_escape_htmltag(
GETPOST(
'weight',
'alpha')).
'"> ';
1152 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOSTINT(
'weight_units'), 0, 2);
1153 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1154 print $form->textwithpicto($text, $htmltext);
1158 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
1159 print
' </td><td colspan="3">';
1160 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1161 print
'<input name="sizeW" size="4" value="'.GETPOSTINT(
'sizeW').
'">';
1162 print
' x <input name="sizeH" size="4" value="'.GETPOSTINT(
'sizeH').
'">';
1163 print
' x <input name="sizeS" size="4" value="'.GETPOSTINT(
'sizeS').
'">';
1165 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size", (
string)
GETPOSTINT(
'size_units'), 0, 2);
1166 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1167 print $form->textwithpicto($text, $htmltext);
1171 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1172 print
'<td colspan="3">';
1173 $expe->fetch_delivery_methods();
1174 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1175 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1, 0, 0,
'',
'widthcentpercentminusxx');
1177 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1179 print
"</td></tr>\n";
1182 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1183 print
'<td colspan="3">';
1184 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1185 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1186 print
"</td></tr>\n";
1189 if (isModEnabled(
'incoterm')) {
1191 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1192 print
'<td colspan="3" class="maxwidthonsmartphone">';
1193 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1194 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1199 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1201 if (is_array($list) && count($list) > 1) {
1202 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1203 print
'<td colspan="3">';
1204 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1205 print $form->selectarray(
'model', $list,
getDolGlobalString(
'EXPEDITION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx');
1206 print
"</td></tr>\n";
1214 if (isset($extrafields->attributes[
$object->table_element][
'label'])) {
1215 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
1216 if (array_key_exists(
'options_' . $key, $objectsav->array_options)) {
1217 $object->array_options[
'options_' . $key] = $objectsav->array_options[
'options_' . $key];
1221 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'cols' =>
'3',
'socid' => $socid);
1222 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1232 $numAsked = count(
$object->lines);
1234 print
'<script type="text/javascript">'.
"\n";
1235 print
'jQuery(document).ready(function() {'.
"\n";
1236 print
'jQuery("#autofill").click(function() {';
1238 while ($i < $numAsked) {
1239 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1240 if (isModEnabled(
'productbatch')) {
1241 print
'jQuery("#qtyl'.$i.
'_'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1245 print
'return false; });'.
"\n";
1246 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);'.
"\n";
1247 print
'return false; });'.
"\n";
1249 print
'</script>'.
"\n";
1253 print
'<div class="div-table-responsive-no-min">';
1254 print
'<table class="noborder centpercent">';
1260 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1262 $title_lines_to_disable = array();
1265 if (isModEnabled(
'subtotals')) {
1267 $title_lines_to_disable =
$object->getDisabledShippmentSubtotalLines();
1269 foreach (
$object->lines as $line) {
1270 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1271 $show_check_add_buttons =
true;
1276 print
'<tr class="liste_titre">';
1278 if (isset($show_check_add_buttons)) {
1279 print $form->showCheckAddButtons(
'checkforselect');
1281 print $langs->trans(
"Description");
1283 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1284 print
'<td class="center">'.$langs->trans(
"QtyShipped").
'</td>';
1285 print
'<td class="center">'.$langs->trans(
"QtyToShip");
1286 if (empty(
$conf->productbatch->enabled)) {
1287 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"').
'</a>';
1292 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Reset"),
'eraser').
'</span>';
1294 if (isModEnabled(
'stock')) {
1295 if (empty(
$conf->productbatch->enabled)) {
1296 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1298 print
'<td class="left">'.$langs->trans(
"Warehouse").
' / '.$langs->trans(
"Batch").
' ('.$langs->trans(
"Stock").
')</td>';
1302 print
'<td class="left">'.$langs->trans(
'StockEntryDate').
'</td>';
1308 $warehousePicking = array();
1310 if ($warehouse_id > 0) {
1311 $warehousePicking[] = $warehouse_id;
1313 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1317 while ($indiceAsked < $numAsked) {
1320 $line =
$object->lines[$indiceAsked];
1322 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1323 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
1328 if (empty($reshook) && $line->special_code != SUBTOTALS_SPECIAL_CODE) {
1330 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1333 if (!empty($line->date_start)) {
1336 if (!empty($line->date_end)) {
1340 print
'<!-- line for order line '.$line->id.
' -->'.
"\n";
1341 print
'<tr class="oddeven" id="row-'.$line->id.
'">'.
"\n";
1343 $qtyProdCom = $line->qty;
1344 $productChildrenNb = 0;
1346 if ($line->fk_product > 0) {
1347 $res = $product->fetch($line->fk_product);
1352 $productChildrenNb = $product->hasFatherOrChild(1);
1354 if ($productChildrenNb > 0) {
1355 $product->loadStockForVirtualProduct(
'warehouseopen', $qtyProdCom);
1357 $product->load_stock(
'warehouseopen');
1362 print
'<a name="'.$line->id.
'"></a>';
1365 $product_static->type = $line->fk_product_type;
1366 $product_static->id = $line->fk_product;
1367 $product_static->ref = $line->ref;
1368 $product_static->status = $line->product_tosell;
1369 $product_static->status_buy = $line->product_tobuy;
1370 $product_static->status_batch = $line->product_tobatch;
1372 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
1374 $text = $product_static->getNomUrl(1);
1375 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1377 $description .= empty($product->stockable_product) ? $langs->trans(
'StockDisabled') : $langs->trans(
'StockEnabled');
1378 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
1381 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1384 if ($showdescinproductdesc) {
1385 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1392 $text =
img_object($langs->trans(
'Service'),
'service');
1394 $text =
img_object($langs->trans(
'Product'),
'product');
1397 if (!empty($line->label)) {
1398 $text .=
' <strong>'.$line->label.
'</strong>';
1399 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
1401 print $text.
' '.nl2br($line->desc);
1405 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1416 print
'<td class="center">'.$line->qty;
1417 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1418 print
''.$unit_order.
'</td>';
1421 print
'<td class="center">';
1422 $quantityDelivered = isset(
$object->expeditions[$line->id]) ?
$object->expeditions[$line->id] :
'';
1423 print $quantityDelivered;
1424 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1425 print
''.$unit_order.
'</td>';
1428 $quantityAsked = $line->qty;
1430 $quantityToBeDelivered = 0;
1432 if (is_numeric($quantityDelivered)) {
1433 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
1435 $quantityToBeDelivered = $quantityAsked;
1439 $warehouseObject =
null;
1440 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !isModEnabled(
'stock')) {
1441 print
'<!-- Case warehouse already known or product not a predefined product -->';
1443 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
1445 $deliverableQty = $quantityToBeDelivered;
1447 $deliverableQty = min($quantityToBeDelivered, $stock);
1449 if ($deliverableQty < 0) {
1450 $deliverableQty = 0;
1452 if (empty(
$conf->productbatch->enabled) || !$product->hasbatch()) {
1454 print
'<td class="center">';
1456 if (GETPOSTISSET(
'qtyl'.$indiceAsked) &&
GETPOST(
'qtyl'.$indiceAsked) !==
'') {
1457 $deliverableQty =
GETPOSTFLOAT(
'qtyl'.$indiceAsked,
'MS');
1459 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1460 $qtylValue = $deliverableQty;
1464 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" class="qtyl right" type="text" size="4" value="'.$qtylValue.
'">';
1467 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1468 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1471 print $langs->trans(
"NA");
1476 if (isModEnabled(
'stock')) {
1477 print
'<td class="left">';
1480 $ent =
"entl".$indiceAsked;
1481 $idl =
"idl".$indiceAsked;
1483 if ($line->fk_product > 0) {
1484 print
'<!-- Show warehouse selection -->';
1490 if ($productChildrenNb > 0) {
1491 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, 0,
'', 0, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
1493 if ($product->stockable_product == Product::ENABLED_STOCK) {
1494 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200', array(), 1, $stockMin,
'stock DESC, e.ref');
1496 print
img_warning().
' '.$langs->trans(
'StockDisabled');
1500 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
1502 if ($stock < $quantityToBeDelivered) {
1503 print
' '.img_warning($langs->trans(
"StockTooLow"));
1508 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span><input name="entl'.$indiceAsked.
'" id="entl'.$indiceAsked.
'" type="hidden" value="0">';
1519 $product->get_sousproduits_arbo();
1520 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1521 if (count($prods_arbo) > 0) {
1522 foreach ($prods_arbo as $key => $value) {
1525 if ($value[
'stock'] < $value[
'stock_alert']) {
1528 print
"<tr class=\"oddeven\"><td> ->
1529 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1530 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1531 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1541 print
'<td></td><td></td>';
1546 print
'<!-- Case product need lot -->';
1548 $staticwarehouse =
new Entrepot($db);
1549 if ($warehouse_id > 0) {
1550 $staticwarehouse->fetch($warehouse_id);
1556 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1557 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1561 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1562 if (is_object($product->stock_warehouse[$warehouse_id]) && !empty($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1563 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1565 $batchStock = + $dbatch->qty;
1566 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1569 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1570 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1572 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1573 $alreadyQtyBatchSetted[$line->fk_product] = array();
1576 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1577 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1580 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1583 if ($deliverableQty < 0) {
1584 $deliverableQty = 0;
1587 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1588 if (GETPOSTISSET($inputName)) {
1589 $deliverableQty =
GETPOST($inputName,
'int');
1592 $tooltipClass = $tooltipTitle =
'';
1593 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1594 $tooltipClass =
' classfortooltip';
1595 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1597 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1599 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1601 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1602 print
'<td colspan="3" ></td><td class="center">';
1603 $qtylValue = $deliverableQty;
1607 print
'<input class="qtyl '.$tooltipClass.
' right" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$qtylValue.
'">';
1610 print
'<!-- Show details of lot -->';
1611 print
'<td class="left">';
1613 print $staticwarehouse->getNomUrl(0).
' / ';
1615 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1618 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
1620 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1623 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1625 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
1629 $quantityToBeDelivered -= $deliverableQty;
1630 if ($quantityToBeDelivered < 0) {
1631 $quantityToBeDelivered = 0;
1636 print
'<td>'.dol_print_date($dbatch->context[
'stock_entry_date'],
'day').
'</td>';
1641 print
'<!-- Case there is no details of lot at all -->';
1642 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1643 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0" disabled="disabled"> ';
1646 print
'<td class="left">';
1647 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
1657 if (empty(
$conf->productbatch->enabled) || !$product->hasbatch()) {
1658 print
'<!-- Case warehouse not already known and product does not need lot -->';
1659 print
'<td></td><td></td>';
1665 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1670 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1671 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
1675 $tmpwarehouseObject =
new Entrepot($db);
1676 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1678 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1683 $tmpwarehouseObject->fetch($warehouse_id);
1684 if ($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
1685 $stock = + $stock_warehouse->real;
1686 $deliverableQty = min($quantityToBeDelivered, $stock);
1687 $deliverableQty = max(0, $deliverableQty);
1689 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1690 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked='.$indiceAsked.
') -->';
1692 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1693 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
1695 if (!isset($alreadyQtySetted[$line->fk_product])) {
1696 $alreadyQtySetted[$line->fk_product] = array();
1699 $deliverableQty = min($quantityToBeDelivered, $stock);
1702 if ($deliverableQty < 0) {
1703 $deliverableQty = 0;
1706 $tooltipClass = $tooltipTitle =
'';
1707 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1708 $tooltipClass =
' classfortooltip';
1709 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1711 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
1714 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1716 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1717 if (GETPOSTISSET($inputName)) {
1720 $qtylValue = $deliverableQty;
1724 print
'<input class="qtyl'.$tooltipClass.
' right" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$qtylValue.
'">';
1725 print
'<input name="ent1'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$warehouse_id.
'">';
1728 print
'<input name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1731 print $langs->trans(
"NA");
1736 if (isModEnabled(
'stock')) {
1737 print
'<td class="left">';
1739 if ($product->stockable_product == Product::ENABLED_STOCK || $productChildrenNb > 0) {
1740 print $tmpwarehouseObject->getNomUrl(0).
' ';
1741 if ($productChildrenNb <= 0) {
1742 print
'<!-- Show details of stock -->';
1743 print
'('.$stock.
')';
1746 print
img_warning().
' '.$langs->trans(
'StockDisabled');
1749 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
1753 $quantityToBeDelivered -= $deliverableQty;
1754 if ($quantityToBeDelivered < 0) {
1755 $quantityToBeDelivered = 0;
1766 $product->get_sousproduits_arbo();
1767 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1768 if (count($prods_arbo) > 0) {
1769 foreach ($prods_arbo as $key => $value) {
1772 if ($value[
'stock'] < $value[
'stock_alert']) {
1775 print
'<tr class"oddeven"><td>';
1776 print
" ->
1777 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1778 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1779 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1788 print
'<!-- Case warehouse not already known and product need lot -->';
1789 print
'<td></td><td></td>';
1796 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1798 $tmpwarehouseObject =
new Entrepot($db);
1803 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1804 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
1805 $nbofsuggested += count($stock_warehouse->detail_batch);
1809 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1811 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1816 $tmpwarehouseObject->fetch($warehouse_id);
1817 if (($stock_warehouse->real > 0 || !
getDolGlobalInt(
'STOCK_DISALLOW_NEGATIVE_TRANSFER')) && (!empty($stock_warehouse->detail_batch))) {
1818 foreach ($stock_warehouse->detail_batch as $dbatch) {
1819 $batchStock = + $dbatch->qty;
1820 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1821 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1823 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1824 $alreadyQtyBatchSetted[$line->fk_product] = array();
1827 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1828 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1831 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1834 if ($deliverableQty < 0) {
1835 $deliverableQty = 0;
1838 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1839 if (GETPOSTISSET($inputName)) {
1843 $tooltipClass = $tooltipTitle =
'';
1844 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1845 $tooltipClass =
' classfortooltip';
1846 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1848 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1850 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1852 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'><td colspan="3"></td><td class="center">';
1853 $qtylValue = $deliverableQty;
1857 print
'<input class="qtyl right '.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="'.$inputName.
'" id="'.$inputName.
'" type="text" size="4" value="'.$qtylValue.
'">';
1860 print
'<td class="left">';
1862 print $tmpwarehouseObject->getNomUrl(0).
' / ';
1864 print
'<!-- Show details of lot -->';
1865 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1868 print $langs->trans(
"Batch").
': ';
1869 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
1871 print $productlotObject->getNomUrl(1);
1873 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
1876 print
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1879 print
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1881 print
' ('.$dbatch->qty.
')';
1882 $quantityToBeDelivered -= $deliverableQty;
1883 if ($quantityToBeDelivered < 0) {
1884 $quantityToBeDelivered = 0;
1890 print
'<td class="left">'.dol_print_date($dbatch->context[
'stock_entry_date'],
'day').
'</td>';
1898 $warehouse_selected_id =
GETPOSTINT(
'entrepot_id');
1900 print
'<!-- line not shown yet, we show it -->';
1901 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1905 if (isModEnabled(
'productbatch') && $product->hasbatch()) {
1906 $disabled =
'disabled="disabled"';
1908 if ($warehouse_selected_id <= 0) {
1909 $disabled =
'disabled="disabled"';
1915 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').
'> ';
1917 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
1921 if (isModEnabled(
'productbatch') && $product->hasbatch()) {
1922 $disabled =
'disabled="disabled"';
1924 if ($warehouse_selected_id <= 0) {
1925 $disabled =
'disabled="disabled"';
1927 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$quantityToBeDelivered.
'"'.($disabled ?
' '.$disabled :
'').
'> ';
1928 if (empty($disabled)) {
1929 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
1932 print $langs->trans(
"NA");
1936 print
'<td class="left">';
1938 if ($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK) {
1939 $warehouseObject =
new Entrepot($db);
1940 $warehouseObject->fetch($warehouse_selected_id);
1941 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
1943 if ($line->fk_product) {
1944 if ($product->stockable_product == Product::ENABLED_STOCK) {
1945 print
img_warning().
' '.$langs->trans(
'StockTooLow');
1947 print
img_warning().
' '.$langs->trans(
'StockDisabled');
1954 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
1966 if (!empty($extrafields)) {
1972 $srcLine->id = $line->id;
1973 $srcLine->fetch_optionals();
1975 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
1977 print $expLine->showOptionals($extrafields,
'edit', array(
'style' =>
'class="drag drop oddeven"',
'colspan' => $colspan), (
string) $indiceAsked,
'',
'1');
1979 } elseif (empty($reshook) && $line->special_code == SUBTOTALS_SPECIAL_CODE && !in_array($line->id, $title_lines_to_disable)) {
1980 require
dol_buildpath(
'/core/tpl/subtotalline_select.tpl.php');
1991 print $form->buttonsSaveCancel(
"Create");
2001 '@phan-var-force Expedition $object';
2007 $num_prod = count($lines);
2010 $typeobject =
$object->origin;
2012 $origin_id =
$object->origin_id;
2020 $res =
$object->fetch_optionals();
2028 if ($action ==
'delete') {
2029 $formquestion = array();
2031 $formquestion = array(
2033 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
2034 'name' =>
'alsoUpdateStock',
2035 'type' =>
'checkbox',
2040 $formconfirm = $form->formconfirm(
2041 $_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
2042 $langs->trans(
'DeleteSending'),
2043 $langs->trans(
"ConfirmDeleteSending",
$object->ref),
2052 if ($action ==
'ask_subtotal_deleteline') {
2054 $langs->load(
"subtotals");
2055 $title =
"DeleteSubtotalLine";
2056 $question =
"ConfirmDeleteSubtotalLine";
2057 if (
GETPOST(
'type') ==
'title') {
2058 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2059 $title =
"DeleteTitleLine";
2060 $question =
"ConfirmDeleteTitleLine";
2062 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2066 if ($action ==
'valid') {
2067 $objectref = substr(
$object->ref, 1, 4);
2068 if ($objectref ==
'PROV') {
2069 $numref =
$object->getNextNumRef($soc);
2074 $text = $langs->trans(
"ConfirmValidateSending", $numref);
2076 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementWillBeRecorded").
'.';
2078 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementNotYetRecorded").
'.';
2081 if (isModEnabled(
'notification')) {
2082 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2083 $notify =
new Notify($db);
2085 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE',
$object->socid,
$object);
2088 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 260);
2092 if ($action ==
'cancel') {
2093 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending",
$object->ref),
'confirm_cancel',
'', 0, 1);
2097 if ($action ==
'sign') {
2098 $text = $langs->trans(
'ConfirmSignShipping');
2099 if (isModEnabled(
'notification')) {
2100 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2101 $notify =
new Notify($db);
2103 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid,
$object);
2108 'name' =>
'signed_status',
2109 'select_show_empty' => 0,
2110 'label' =>
'<span class="fieldrequired">' . $langs->trans(
'SignStatus') .
'</span>',
2111 'values' =>
$object->getSignedStatusLocalisedArray()
2113 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'SignShipping'), $text,
'confirm_sign', $formquestion, 0, 1);
2117 if ($action ==
'unsign') {
2118 $text = $langs->trans(
'ConfirmUnsignShipping');
2119 if (isModEnabled(
'notification')) {
2120 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2121 $notify =
new Notify($db);
2123 $text .= $notify->confirmMessage(
'SHIPPING_MODIFY',
$object->socid,
$object);
2125 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'UnsignShipping'), $text,
'confirm_unsign',
'', 0, 1);
2129 $parameters = array(
'formConfirm' => $formconfirm);
2130 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2131 if (empty($reshook)) {
2132 $formconfirm .= $hookmanager->resPrint;
2133 } elseif ($reshook > 0) {
2134 $formconfirm = $hookmanager->resPrint;
2142 $tmparray =
$object->getTotalWeightVolume();
2143 $totalWeight = $tmparray[
'weight'];
2144 $totalVolume = $tmparray[
'volume'];
2146 if (!empty($typeobject) && $typeobject ===
'commande' && is_object(
$object->origin_object) &&
$object->origin_object->id && isModEnabled(
'order')) {
2148 $objectsrc->fetch(
$object->origin_object->id);
2150 if (!empty($typeobject) && $typeobject ===
'propal' && is_object(
$object->origin_object) &&
$object->origin_object->id && isModEnabled(
"propal")) {
2151 $objectsrc =
new Propal($db);
2152 $objectsrc->fetch(
$object->origin_object->id);
2156 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2157 $morehtmlref =
'<div class="refidno">';
2159 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer,
$object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
2160 $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);
2162 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
2164 if (isModEnabled(
'project')) {
2165 $langs->load(
"projects");
2166 $morehtmlref .=
'<br>';
2168 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2169 if ($action !=
'classify') {
2170 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2172 $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');
2174 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2176 $proj->fetch($objectsrc->fk_project);
2177 $morehtmlref .= $proj->getNomUrl(1);
2179 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2184 $morehtmlref .=
'</div>';
2187 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2190 print
'<div class="fichecenter">';
2191 print
'<div class="fichehalfleft">';
2192 print
'<div class="underbanner clearboth"></div>';
2194 print
'<table class="border tableforfield centpercent">';
2197 if (!empty($typeobject) && $typeobject ==
'commande' &&
$object->origin_object->id && isModEnabled(
'order')) {
2199 print $langs->trans(
"RefOrder").
'</td>';
2201 print $objectsrc->getNomUrl(1,
'commande');
2205 if (!empty($typeobject) && $typeobject ==
'propal' &&
$object->origin_object->id && isModEnabled(
"propal")) {
2207 print $langs->trans(
"RefProposal").
'</td>';
2209 print $objectsrc->getNomUrl(1,
'expedition');
2215 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateCreation").
'</td>';
2216 print
'<td>'.dol_print_date(
$object->date_creation,
"dayhour").
"</td>\n";
2220 print
'<tr><td height="10">';
2221 print
'<table class="nobordernopadding centpercent"><tr><td>';
2222 print $langs->trans(
'DateDeliveryPlanned');
2224 if ($action !=
'editdate_livraison') {
2225 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>';
2227 print
'</tr></table>';
2229 if ($action ==
'editdate_livraison') {
2230 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2231 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2232 print
'<input type="hidden" name="action" value="setdate_livraison">';
2233 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2234 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2243 print
'<tr><td height="10">';
2244 print
'<table class="nobordernopadding centpercent"><tr><td>';
2245 print $langs->trans(
'DateShipping');
2247 if ($action !=
'editdate_shipping') {
2248 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>';
2250 print
'</tr></table>';
2252 if ($action ==
'editdate_shipping') {
2253 print
'<form name="setdate_shipping" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2254 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2255 print
'<input type="hidden" name="action" value="setdate_shipping">';
2256 print $form->selectDate(
$object->date_shipping ?
$object->date_shipping : -1,
'ship_', 1, 1, 0,
"setdate_shipping", 1, 0);
2257 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2267 print $form->editfieldkey(
"Weight",
'trueWeight',
$object->trueWeight,
$object, $user->hasRight(
'expedition',
'creer'));
2270 if ($action ==
'edittrueWeight') {
2271 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2272 print
'<input name="action" value="settrueWeight" type="hidden">';
2273 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2274 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2275 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text" class="width50 valignmiddle">';
2276 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2277 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2278 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2282 print (
$object->trueWeight &&
$object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight",
$object->weight_units) :
'';
2286 if ($totalWeight > 0) {
2287 if (!empty(
$object->trueWeight)) {
2288 print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
2291 if (!empty(
$object->trueWeight)) {
2298 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth',
$object->trueWidth,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2299 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth,
$object, $user->hasRight(
'expedition',
'creer'));
2300 print (
$object->trueWidth &&
$object->width_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->width_units) :
'';
2304 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight',
$object->trueHeight,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2305 if ($action ==
'edittrueHeight') {
2306 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2307 print
'<input name="action" value="settrueHeight" type="hidden">';
2308 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2309 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2310 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text" class="width50">';
2311 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
2312 print
' <input class="button smallpaddingimp" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2313 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2317 print (
$object->trueHeight &&
$object->height_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->height_units) :
'';
2323 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth',
$object->trueDepth,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2324 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth,
$object, $user->hasRight(
'expedition',
'creer'));
2325 print (
$object->trueDepth &&
$object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->depth_units) :
'';
2330 print $langs->trans(
"Volume");
2333 $calculatedVolume = 0;
2337 $volumeUnit =
$object->size_units * 3;
2340 if ($calculatedVolume > 0) {
2341 if ($volumeUnit < 50) {
2347 if ($totalVolume > 0) {
2348 if ($calculatedVolume) {
2349 print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
2353 if ($calculatedVolume) {
2362 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2367 print
'<div class="fichehalfright">';
2368 print
'<div class="underbanner clearboth"></div>';
2370 print
'<table class="border centpercent tableforfield">';
2374 print
'<table class="nobordernopadding centpercent"><tr><td>';
2375 print $langs->trans(
'SendingMethod');
2378 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
2379 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>';
2381 print
'</tr></table>';
2383 if ($action ==
'editshipping_method_id') {
2384 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2385 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2386 print
'<input type="hidden" name="action" value="setshipping_method_id">';
2387 $object->fetch_delivery_methods();
2388 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
2390 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2392 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2395 if (
$object->shipping_method_id > 0) {
2397 $code = $langs->getLabelFromKey($db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
2398 print $langs->trans(
"SendingMethod".strtoupper($code));
2405 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number,
$object, $user->hasRight(
'expedition',
'creer')).
'</td><td>';
2406 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url,
$object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring',
$object->tracking_number);
2410 if (isModEnabled(
'incoterm')) {
2412 print
'<table class="nobordernopadding centpercent"><tr><td>';
2413 print $langs->trans(
'IncotermLabel');
2414 print
'<td><td class="right">';
2415 if ($permissiontoadd) {
2416 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
2420 print
'</td></tr></table>';
2423 if ($action !=
'editincoterm') {
2424 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
2426 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
2432 $parameters = array();
2433 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2434 print $hookmanager->resPrint;
2441 print
'<div class="clearboth"></div>';
2446 if ($action ==
'editline') {
2447 print
' <form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$line_id.
'" method="POST">
2448 <input type="hidden" name="token" value="' .
newToken().
'">
2449 <input type="hidden" name="action" value="updateline">
2450 <input type="hidden" name="mode" value="">
2451 <input type="hidden" name="id" value="' .
$object->id.
'">
2456 print
'<div class="div-table-responsive-no-min">';
2457 print
'<table class="noborder centpercent" id="tablelines" >';
2459 print
'<tr class="liste_titre">';
2462 print
'<td width="5" class="center linecolnum"> </td>';
2465 print
'<td class="linecoldescription" >'.$langs->trans(
"Products").
'</td>';
2467 print
'<td class="center linecolqty">'.$langs->trans(
"QtyOrdered").
'</td>';
2468 if ($origin && $origin_id > 0) {
2469 print
'<td class="center linecolqtyinothershipments">'.$langs->trans(
"QtyInOtherShipments").
'</td>';
2471 if ($action ==
'editline') {
2473 if (!isModEnabled(
'stock')) {
2476 if (empty(
$conf->productbatch->enabled)) {
2479 print
'<td class="center linecoleditlineotherinfo" colspan="'.$editColspan.
'">';
2481 print $langs->trans(
"QtyToShip");
2483 print $langs->trans(
"QtyShipped");
2485 if (isModEnabled(
'stock')) {
2486 print
' - '.$langs->trans(
"WarehouseSource");
2488 if (isModEnabled(
'productbatch')) {
2489 print
' - '.$langs->trans(
"Batch");
2494 print
'<td class="center linecolqtytoship">'.$langs->trans(
"QtyToShip").
'</td>';
2496 print
'<td class="center linecolqtyshipped">'.$langs->trans(
"QtyShipped").
'</td>';
2498 if (isModEnabled(
'stock')) {
2499 print
'<td class="left linecolwarehousesource">'.$langs->trans(
"WarehouseSource").
'</td>';
2502 if (isModEnabled(
'productbatch')) {
2503 print
'<td class="left linecolbatch">'.$langs->trans(
"Batch").
'</td>';
2506 print
'<td class="center linecolweight">'.$langs->trans(
"CalculatedWeight").
'</td>';
2507 print
'<td class="center linecolvolume">'.$langs->trans(
"CalculatedVolume").
'</td>';
2510 print
'<td class="linecoledit"></td>';
2511 print
'<td class="linecoldelete" width="10"></td>';
2516 $outputlangs = $langs;
2521 if (
GETPOST(
'lang_id',
'aZ09')) {
2522 $newlang =
GETPOST(
'lang_id',
'aZ09');
2524 if (empty($newlang)) {
2525 $newlang =
$object->thirdparty->default_lang;
2527 if (!empty($newlang)) {
2529 $outputlangs->setDefaultLang($newlang);
2534 $alreadysent = array();
2535 if ($origin && $origin_id > 0) {
2536 $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";
2537 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot";
2538 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
2540 $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';
2541 $sql .=
', p.description as product_desc';
2542 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2543 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
2544 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
2546 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2547 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
2548 $sql .=
" AND obj.fk_".$origin.
" = ".((int) $origin_id);
2549 $sql .=
" AND obj.rowid = ed.fk_elementdet";
2550 $sql .=
" AND ed.fk_expedition = e.rowid";
2552 $sql .=
" ORDER BY obj.fk_product";
2554 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
2555 $resql = $db->query($sql);
2557 $num = $db->num_rows($resql);
2561 $obj = $db->fetch_object($resql);
2564 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
2565 'shipment_ref' => $obj->shipment_ref,
'shipment_id' => $obj->shipment_id,
'warehouse' => $obj->fk_entrepot,
'qty_shipped' => $obj->qty_shipped,
2566 'product_tosell' => $obj->product_tosell,
'product_tobuy' => $obj->product_tobuy,
'product_tobatch' => $obj->product_tobatch,
2567 'date_valid' => $db->jdate($obj->date_valid),
'date_delivery' => $db->jdate($obj->date_delivery));
2578 $conf->cache[
'product'] = array();
2579 $conf->cache[
'warehouse'] = array();
2580 for ($i = 0; $i < $num_prod; $i++) {
2581 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
2582 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
2587 if (empty($reshook) && $lines[$i]->product_type !=
"9") {
2588 print
'<!-- origin line id = '.$lines[$i]->origin_line_id.
' -->';
2589 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'" >';
2593 print
'<td class="center linecolnum">'.($i + 1).
'</td>';
2597 if ($lines[$i]->fk_product > 0) {
2600 $product_id = $lines[$i]->fk_product;
2601 if (!isset(
$conf->cache[
'product'][$product_id])) {
2603 $prod->fetch($product_id);
2604 $conf->cache[
'product'][$product_id] = $prod;
2606 $prod =
$conf->cache[
'product'][$product_id];
2608 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
2610 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
2613 print
'<td class="linecoldescription">';
2616 $product_static->type = $lines[$i]->fk_product_type;
2617 $product_static->id = $lines[$i]->fk_product;
2618 $product_static->ref = $lines[$i]->ref;
2619 $product_static->status = $lines[$i]->product_tosell;
2620 $product_static->status_buy = $lines[$i]->product_tobuy;
2621 $product_static->status_batch = $lines[$i]->product_tobatch;
2623 $product_static->weight = $lines[$i]->weight;
2624 $product_static->weight_units = $lines[$i]->weight_units;
2625 $product_static->length = $lines[$i]->length;
2626 $product_static->length_units = $lines[$i]->length_units;
2627 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
2628 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
2629 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
2630 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
2631 $product_static->surface = $lines[$i]->surface;
2632 $product_static->surface_units = $lines[$i]->surface_units;
2633 $product_static->volume = $lines[$i]->volume;
2634 $product_static->volume_units = $lines[$i]->volume_units;
2635 $product_static->stockable_product = $lines[$i]->stockable_product;
2637 $text = $product_static->getNomUrl(1);
2638 $text .=
' - '.$label;
2640 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2641 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
2647 print
'<td class="linecoldescription" >';
2649 $text =
img_object($langs->trans(
'Service'),
'service');
2651 $text =
img_object($langs->trans(
'Product'),
'product');
2654 if (!empty($lines[$i]->label)) {
2655 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2656 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
2671 print
'<td class="center linecolqty">'.$lines[$i]->qty_asked.
' '.$unit_order.
'</td>';
2674 if ($origin && $origin_id > 0) {
2675 print
'<td class="linecolqtyinothershipments center nowrap">';
2677 $qtyalreadysent = 0;
2678 foreach ($alreadysent as $key => $val) {
2679 if ($lines[$i]->fk_elementdet == $key) {
2681 foreach ($val as $shipmentline_id => $shipmentline_var) {
2682 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
2688 $htmltooltip .=
'<br>';
2690 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
2691 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
2692 $htmltooltip .=
' - '.$shipmentline_var[
'qty_shipped'];
2693 $htmltooltip .=
' - '.$langs->trans(
"DateValidation").
' : '.(empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
2700 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
2703 $htmltooltip = $langs->trans(
"QtyInOtherShipments").
'...<br><br>'.$htmltooltip.
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
2707 print $form->textwithpicto((
string) $qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip'.$lines[$i]->
id);
2711 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2713 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding centpercent">';
2714 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
2715 print
'<!-- case edit 1 -->';
2717 foreach ($lines[$i]->detail_batch as $detail_batch) {
2720 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>';
2722 if ($lines[$i]->entrepot_id == 0) {
2724 $line->fetch($detail_batch->fk_expeditiondet);
2726 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
2727 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>';
2733 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'_0" id="qtyl'.$line_id.
'_0" type="text" size="4" value="0"></td>';
2735 print
'<td>'.$formproduct->selectLotStock(
'',
'batchl'.$line_id.
'_0',
'', 1, 0, $lines[$i]->fk_product).
'</td>';
2737 } elseif (isModEnabled(
'stock')) {
2738 if ($lines[$i]->fk_product > 0) {
2739 if ($lines[$i]->entrepot_id > 0) {
2740 print
'<!-- case edit 2 -->';
2743 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>';
2745 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200').
'</td>';
2748 if (isModEnabled(
'productbatch')) {
2749 print
' - '.$langs->trans(
"NA");
2753 } elseif (count($lines[$i]->details_entrepot) > 1) {
2754 print
'<!-- case edit 3 -->';
2755 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2758 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>';
2760 print
'<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl'.$detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1, 0, array(),
'minwidth200').
'</td>';
2763 if (isModEnabled(
'productbatch')) {
2764 print
' - '.$langs->trans(
"NA");
2770 print
'<!-- case edit 4 -->';
2773 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2774 print
'<td><span class="opacitymedium">('.$langs->trans(
"Service").
')</span></td>';
2778 print
'<!-- case edit 5 -->';
2779 print
'<tr><td colspan="3">'.$langs->trans(
"ErrorStockIsNotEnough").
'</td></tr>';
2782 print
'<!-- case edit 6 -->';
2785 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>';
2792 } elseif (!isModEnabled(
'stock') && empty(
$conf->productbatch->enabled)) {
2793 print
'<!-- case edit 7 -->';
2796 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2804 print
'</table></td>';
2807 print
'<td class="linecolqtytoship center">'.$lines[$i]->qty_shipped.
' '.$unit_order.
'</td>';
2810 if (isModEnabled(
'stock')) {
2811 print
'<td class="linecolwarehousesource tdoverflowmax200">';
2813 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
2814 } elseif ($lines[$i]->entrepot_id > 0 && $lines[$i]->stockable_product == Product::ENABLED_STOCK) {
2815 $warehouse_id = $lines[$i]->entrepot_id;
2816 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
2818 $warehouse->fetch($warehouse_id);
2819 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
2821 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
2823 print $warehouse->getNomUrl(1);
2824 } elseif (count($lines[$i]->details_entrepot) > 1) {
2826 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2827 $warehouse_id = $detail_entrepot->entrepot_id;
2828 if ($warehouse_id > 0) {
2829 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
2831 $warehouse->fetch($warehouse_id);
2832 $conf->cache[
'warehouse'][$warehouse_id] = $warehouse;
2834 $warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
2836 $detail .= $langs->trans(
"DetailWarehouseFormat", $warehouse->label, $detail_entrepot->qty_shipped).
'<br>';
2839 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
"DetailWarehouseNumber"), $detail);
2840 } elseif (count($lines[$i]->detail_children ?? []) > 1) {
2842 foreach ($lines[$i]->detail_children as $child_product_id => $child_stock_list) {
2843 foreach ($child_stock_list as $warehouse_id => $total_qty) {
2845 $child_product_label =
'';
2846 if (!isset(
$conf->cache[
'product'][$child_product_id])) {
2847 $child_product =
new Product($db);
2848 $child_product->fetch($child_product_id);
2849 $conf->cache[
'product'][$child_product_id] = $child_product;
2851 $child_product =
$conf->cache[
'product'][$child_product_id];
2853 $child_product_label = $child_product->ref .
' ' . $child_product->label;
2856 if (!isset(
$conf->cache[
'warehouse'][$warehouse_id])) {
2857 $child_warehouse =
new Entrepot($db);
2858 $child_warehouse->fetch($warehouse_id);
2859 $conf->cache[
'warehouse'][$warehouse_id] = $child_warehouse;
2861 $child_warehouse =
$conf->cache[
'warehouse'][$warehouse_id];
2864 $detail .= $langs->trans(
'DetailChildrenFormat', $child_product_label, $child_warehouse->label,
price2num($total_qty,
'MS')).
'<br>';
2867 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
'DetailWarehouseNumber'), $detail);
2873 if (isModEnabled(
'productbatch')) {
2874 if (isset($lines[$i]->detail_batch)) {
2875 print
'<!-- Detail of lot -->';
2876 print
'<td class="linecolbatch">';
2877 if ($lines[$i]->product_tobatch) {
2879 foreach ($lines[$i]->detail_batch as $dbatch) {
2880 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
2882 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
2885 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
2887 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
2890 print $form->textwithtooltip(
img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $detail);
2892 print $langs->trans(
"NA");
2896 print
'<td class="linecolbatch" ></td>';
2902 print
'<td class="center linecolweight">';
2904 print $lines[$i]->weight * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
2911 print
'<td class="center linecolvolume">';
2913 print $lines[$i]->volume * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
2922 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2923 print
'<td class="center" colspan="2" valign="middle">';
2924 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2925 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2928 $edit_url = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&lineid='.$lines[$i]->id;
2930 $product_id = $lines[$i]->fk_product;
2931 if (!isset(
$conf->cache[
'product'][$product_id])) {
2933 $product->fetch($product_id);
2934 $conf->cache[
'product'][$product_id] = $product;
2936 $product =
$conf->cache[
'product'][$product_id];
2939 if ($product->hasFatherOrChild(1)) {
2945 print
'<td class="linecoledit center">';
2946 print
'<a class="editfielda reposition" href="'.$edit_url.
'">'.
img_edit().
'</a>';
2948 print
'<td class="linecoldelete" width="10">';
2949 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_delete().
'</a>';
2953 if (!empty($rowExtrafieldsStart)) {
2954 print $rowExtrafieldsStart;
2955 print $rowExtrafieldsView;
2963 if (!empty($extrafields)) {
2965 if ($origin && $origin_id > 0) {
2968 if (isModEnabled(
'productbatch')) {
2971 if (isModEnabled(
'stock')) {
2976 $line->fetch_optionals();
2979 if ($action ==
'editline' && $line->id == $line_id) {
2980 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
2982 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan' => $colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'',
'',
'card');
2985 } elseif (empty($reshook) && $lines[$i]->product_type ==
"9") {
2987 $objectsrc->fetch($lines[$i]->origin_line_id);
2988 if ($objectsrc->special_code == SUBTOTALS_SPECIAL_CODE) {
2990 require
dol_buildpath(
'/core/tpl/subtotal_expedition_view.tpl.php');
2997 if (empty($num_prod)) {
2998 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")).
'</span></td></tr>';
3016 if (($user->socid == 0) && ($action !=
'presend')) {
3017 print
'<div class="tabsAction">';
3019 $parameters = array();
3020 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3022 if (empty($reshook)) {
3024 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
3025 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))) {
3028 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3034 if ($user->hasRight(
'expedition',
'creer')) {
3039 if ($user->hasRight(
'expedition',
'creer')) {
3045 if (empty($user->socid)) {
3047 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
3048 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3050 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3058 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=create_delivery&token=' .
newToken() .
'&id=' .
$object->id,
'');
3063 if (
$object->signed_status != Expedition::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
3064 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>';
3066 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>';
3072 if ($user->hasRight(
'facture',
'creer')) {
3074 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->socid,
'');
3081 if ($user->hasRight(
'expedition',
'creer') &&
$object->status > 0) {
3083 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3085 print
dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifyclosed&token=' .
newToken() .
'&id=' .
$object->id,
'');
3091 if ($user->hasRight(
'expedition',
'creer')) {
3092 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"].
'?action=cancel&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3097 if ($user->hasRight(
'expedition',
'supprimer')) {
3110 if ($action !=
'presend' && $action !=
'editline') {
3111 print
'<div class="fichecenter"><div class="fichehalfleft">';
3114 $filedir =
$conf->expedition->dir_output.
"/sending/".$objectref;
3116 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3118 $genallowed = $user->hasRight(
'expedition',
'lire');
3119 $delallowed = $user->hasRight(
'expedition',
'creer');
3121 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3125 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'shipping'), 1);
3126 $linktoelem = $tmparray[
'linktoelem'];
3127 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3128 print $htmltoenteralink;
3130 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
3136 print
'<br><!-- Link to sign -->';
3137 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
3138 print showOnlineSignatureUrl(
'expedition',
$object->ref,
$object).
'<br>';
3141 print
'</div><div class="fichehalfright">';
3144 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3146 $somethingshown = $formactions->showactions(
$object,
'shipping', $socid, 1);
3148 print
'</div></div>';
3157 if (
GETPOST(
'modelselected')) {
3158 $action =
'presend';
3162 $modelmail =
'shipping_send';
3163 $defaulttopic =
'SendShippingRef';
3164 $diroutput =
$conf->expedition->dir_output.
'/sending';
3165 $trackid =
'shi'.$object->id;
3167 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.