38 require
'../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
50 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
51 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
53 if (!empty($conf->propal->enabled)) {
54 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
56 if (!empty($conf->productbatch->enabled)) {
57 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
59 if (!empty($conf->project->enabled)) {
60 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
65 $langs->loadLangs(array(
"sendings",
"companies",
"bills",
'deliveries',
'orders',
'stocks',
'other',
'propal'));
67 if (!empty($conf->incoterm->enabled)) {
68 $langs->load(
'incoterm');
70 if (!empty($conf->productbatch->enabled)) {
71 $langs->load(
'productbatch');
74 $origin =
GETPOST(
'origin',
'alpha') ?
GETPOST(
'origin',
'alpha') :
'expedition';
77 if (empty($origin_id)) {
78 $origin_id =
GETPOST(
'origin_id',
'int');
80 if (empty($origin_id)) {
81 $origin_id =
GETPOST(
'object_id',
'int');
84 $line_id =
GETPOST(
'lineid',
'int') ?
GETPOST(
'lineid',
'int') :
'';
85 $facid =
GETPOST(
'facid',
'int');
87 $action =
GETPOST(
'action',
'alpha');
88 $confirm =
GETPOST(
'confirm',
'alpha');
89 $cancel =
GETPOST(
'cancel',
'alpha');
92 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
93 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
94 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
101 $extrafields->fetch_name_optionals_label($object->table_element);
102 $extrafields->fetch_name_optionals_label($object->table_element_line);
103 $extrafields->fetch_name_optionals_label($objectorder->table_element_line);
106 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
109 $hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
111 $date_delivery =
dol_mktime(
GETPOST(
'date_deliveryhour',
'int'),
GETPOST(
'date_deliverymin',
'int'), 0,
GETPOST(
'date_deliverymonth',
'int'),
GETPOST(
'date_deliveryday',
'int'),
GETPOST(
'date_deliveryyear',
'int'));
113 if ($id > 0 || !empty($ref)) {
114 $object->fetch($id, $ref);
115 $object->fetch_thirdparty();
121 $socid = $user->socid;
126 $permissiondellink = $user->rights->expedition->delivery->creer;
127 $permissiontoadd = $user->rights->expedition->creer;
135 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
140 if (empty($reshook)) {
142 if ($origin && $origin_id > 0) {
143 if ($origin ==
'commande') {
144 header(
"Location: ".DOL_URL_ROOT.
'/expedition/shipment.php?id='.((
int) $origin_id));
153 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
156 $upload_dir = $conf->expedition->dir_output.
'/sending';
157 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
160 if ($action ==
'reopen' && $user->rights->expedition->creer) {
162 $result = $object->reOpen();
166 if ($action ==
'set_incoterms' && !empty($conf->incoterm->enabled)) {
167 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
170 if ($action ==
'setref_customer') {
171 $result = $object->fetch($id);
176 $result = $object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPMENT_MODIFY');
179 $action =
'editref_customer';
181 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
186 if ($action ==
'update_extras') {
190 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
197 $result = $object->insertExtraFields(
'SHIPMENT_MODIFY');
205 $action =
'edit_extras';
210 if ($action ==
'add' && $user->rights->expedition->creer) {
215 $object->note =
GETPOST(
'note',
'alpha');
216 $object->origin = $origin;
217 $object->origin_id = $origin_id;
218 $object->fk_project =
GETPOST(
'projectid',
'int');
219 $object->weight =
GETPOST(
'weight',
'int') ==
'' ?
"NULL" :
GETPOST(
'weight',
'int');
220 $object->sizeH =
GETPOST(
'sizeH',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeH',
'int');
221 $object->sizeW =
GETPOST(
'sizeW',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeW',
'int');
222 $object->sizeS =
GETPOST(
'sizeS',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeS',
'int');
223 $object->size_units =
GETPOST(
'size_units',
'int');
224 $object->weight_units =
GETPOST(
'weight_units',
'int');
227 $classname = ucfirst($object->origin);
228 $objectsrc =
new $classname($db);
229 $objectsrc->fetch($object->origin_id);
231 $object->socid = $objectsrc->socid;
232 $object->ref_customer =
GETPOST(
'ref_customer',
'alpha');
233 $object->model_pdf =
GETPOST(
'model');
234 $object->date_delivery = $date_delivery;
235 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
236 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
237 $object->tracking_number =
GETPOST(
'tracking_number',
'alpha');
238 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
239 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
240 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
241 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
243 $batch_line = array();
244 $stockLine = array();
245 $array_options = array();
247 $num = count($objectsrc->lines);
250 for ($i = 0; $i < $num; $i++) {
257 $batch =
"batchl".$i.
"_0";
258 $stockLocation =
"ent1".$i.
"_0";
261 if (!empty($conf->productbatch->enabled) && $objectsrc->lines[$i]->product_tobatch) {
267 $sub_qty[$j][
'q'] =
GETPOST($qty,
'int');
268 $sub_qty[$j][
'id_batch'] =
GETPOST($batch,
'int');
269 $subtotalqty += $sub_qty[$j][
'q'];
277 $batch =
"batchl".$i.
"_".$j;
278 $qty =
"qtyl".$i.
'_'.$j;
281 $batch_line[$i][
'detail'] = $sub_qty;
282 $batch_line[$i][
'qty'] = $subtotalqty;
283 $batch_line[$i][
'ix_l'] =
GETPOST($idl,
'int');
285 $totalqty += $subtotalqty;
292 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse"),
null,
'errors');
301 $stockLine[$i][$j][
'warehouse_id'] =
GETPOST($stockLocation,
'int');
302 $stockLine[$i][$j][
'ix_l'] =
GETPOST($idl,
'int');
307 $stockLocation =
"ent1".$i.
"_".$j;
308 $qty =
"qtyl".$i.
'_'.$j;
312 if (
GETPOST($qty,
'int') > 0) {
318 $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i);
320 if (is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
322 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
323 unset($_POST[
"options_".$key]);
330 if ($totalqty > 0 || !empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
332 for ($i = 0; $i < $num; $i++) {
334 if (!isset($batch_line[$i])) {
336 if (isset($stockLine[$i])) {
338 $nbstockline = count($stockLine[$i]);
339 for ($j = 0; $j < $nbstockline; $j++) {
340 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 && !empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS))) {
341 $ret = $object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], $stockLine[$i][$j][
'qty'], $array_options[$i]);
349 if (
GETPOST($qty,
'int') > 0 || !empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
352 $entrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') :
GETPOST(
'entrepot_id',
'int');
353 if ($entrepot_id < 0) {
356 if (!($objectsrc->lines[$i]->fk_product > 0)) {
360 $ret = $object->addline($entrepot_id,
GETPOST($idl,
'int'),
price2num(
GETPOST($qty,
'alpha'),
'MS'), $array_options[$i]);
369 if ($batch_line[$i][
'qty'] > 0) {
370 $ret = $object->addline_batch($batch_line[$i], $array_options[$i]);
379 $ret = $extrafields->setOptionalsFromPost(
null, $object);
385 $ret = $object->create($user);
392 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
393 if (!empty($conf->stock->enabled)) {
394 $labelfieldmissing .=
'/'.$langs->transnoentitiesnoconv(
"Warehouse");
396 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
402 header(
"Location: card.php?id=".$object->id);
406 $_GET[
"commande_id"] =
GETPOST(
'commande_id',
'int');
409 } elseif ($action ==
'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer) {
413 $result = $object->create_delivery($user);
417 header(
"Location: ".DOL_URL_ROOT.
'/delivery/card.php?action=create_delivery&id='.$result);
424 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' &&
425 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
426 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))
428 $object->fetch_thirdparty();
430 $result = $object->valid($user);
436 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
437 $outputlangs = $langs;
439 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
440 $newlang =
GETPOST(
'lang_id',
'aZ09');
442 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
443 $newlang = $object->thirdparty->default_lang;
445 if (!empty($newlang)) {
447 $outputlangs->setDefaultLang($newlang);
449 $model = $object->model_pdf;
450 $ret = $object->fetch($id);
452 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
458 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->rights->expedition->supprimer) {
459 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
460 $result = $object->cancel(0, $also_update_stock);
462 $result = $object->setStatut(-1);
466 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->expedition->supprimer) {
467 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
468 $result = $object->delete(0, $also_update_stock);
470 header(
"Location: ".DOL_URL_ROOT.
'/expedition/index.php');
484 } elseif ($action ==
'setdate_livraison' && $user->rights->expedition->creer) {
485 $datedelivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
488 $result = $object->setDeliveryDate($user, $datedelivery);
492 } elseif (($action ==
'settracking_number'
493 || $action ==
'settracking_url'
494 || $action ==
'settrueWeight'
495 || $action ==
'settrueWidth'
496 || $action ==
'settrueHeight'
497 || $action ==
'settrueDepth'
498 || $action ==
'setshipping_method_id')
499 && $user->rights->expedition->creer
504 if ($action ==
'settracking_number') {
505 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
507 if ($action ==
'settracking_url') {
508 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'int'));
510 if ($action ==
'settrueWeight') {
511 $object->trueWeight = trim(
GETPOST(
'trueWeight',
'int'));
512 $object->weight_units =
GETPOST(
'weight_units',
'int');
514 if ($action ==
'settrueWidth') {
515 $object->trueWidth = trim(
GETPOST(
'trueWidth',
'int'));
517 if ($action ==
'settrueHeight') {
518 $object->trueHeight = trim(
GETPOST(
'trueHeight',
'int'));
519 $object->size_units =
GETPOST(
'size_units',
'int');
521 if ($action ==
'settrueDepth') {
522 $object->trueDepth = trim(
GETPOST(
'trueDepth',
'int'));
524 if ($action ==
'setshipping_method_id') {
525 $object->shipping_method_id = trim(
GETPOST(
'shipping_method_id',
'int'));
529 if ($object->update($user) >= 0) {
530 header(
"Location: card.php?id=".$object->id);
537 } elseif ($action ==
'classifybilled') {
539 $result = $object->setBilled();
541 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
545 } elseif ($action ==
'classifyclosed') {
547 $result = $object->setClosed();
549 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
553 } elseif ($action ==
'deleteline' && !empty($line_id)) {
556 $lines = $object->lines;
558 $line->fk_expedition = $object->id;
560 $num_prod = count($lines);
561 for ($i = 0; $i < $num_prod; $i++) {
562 if ($lines[$i]->
id == $line_id) {
563 if (count($lines[$i]->details_entrepot) > 1) {
565 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
566 $line->id = $details_entrepot->line_id;
567 if (!$error && $line->delete($user) < 0) {
573 $line->id = $line_id;
574 if (!$error && $line->delete($user) < 0) {
579 unset($_POST[
"lineid"]);
583 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
588 } elseif ($action ==
'updateline' && $user->rights->expedition->creer &&
GETPOST(
'save')) {
595 $lines = $object->lines;
596 $num_prod = count($lines);
597 for ($i = 0; $i < $num_prod; $i++) {
598 if ($lines[$i]->
id == $line_id) {
599 $update_done =
false;
601 $line->fk_expedition = $object->id;
604 $line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
606 if (is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
607 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
608 unset($_POST[
"options_".$key]);
611 $line->fk_product = $lines[$i]->fk_product;
612 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
614 foreach ($lines[$i]->detail_batch as $detail_batch) {
616 $batch =
"batchl".$detail_batch->fk_expeditiondet.
"_".$detail_batch->fk_origin_stock;
617 $qty =
"qtyl".$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id;
618 $batch_id =
GETPOST($batch,
'int');
619 $batch_qty =
GETPOST($qty,
'int');
620 if (!empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty)) {
621 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
622 if ($lines[$i]->entrepot_id != 0) {
624 $line->entrepot_id = $lotStock->warehouseid;
628 if (empty($line->detail_batch)) {
629 $line->detail_batch =
new stdClass();
632 $line->detail_batch->fk_origin_stock = $batch_id;
633 $line->detail_batch->batch = $lotStock->batch;
634 $line->detail_batch->id = $detail_batch->id;
635 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
636 $line->detail_batch->qty = $batch_qty;
637 if ($line->update($user) < 0) {
648 unset($_POST[$batch]);
653 $batch =
"batchl".$line_id.
"_0";
654 $qty =
"qtyl".$line_id.
"_0";
655 $batch_id =
GETPOST($batch,
'int');
656 $batch_qty =
GETPOST($qty,
'int');
658 if ($batch_qty > 0 && !empty($batch_id)) {
659 if ($lotStock->fetch($batch_id) > 0) {
661 if ($lines[$i]->entrepot_id > 0) {
663 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
664 $lineIdToAddLot = $line_id;
666 } elseif (count($lines[$i]->details_entrepot) > 1) {
668 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
669 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
670 $lineIdToAddLot = $detail_entrepot->line_id;
674 if ($lineIdToAddLot) {
676 if ($line->fetch($lineIdToAddLot) > 0) {
677 $line->detail_batch->fk_origin_stock = $batch_id;
678 $line->detail_batch->batch = $lotStock->batch;
679 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
680 $line->detail_batch->qty = $batch_qty;
681 if ($line->update($user) < 0) {
693 $line->origin_line_id = $lines[$i]->origin_line_id;
694 $line->entrepot_id = $lotStock->warehouseid;
696 $line->detail_batch[0]->fk_origin_stock = $batch_id;
697 $line->detail_batch[0]->batch = $lotStock->batch;
698 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
699 $line->detail_batch[0]->qty = $batch_qty;
700 if ($object->create_line_batch($line, $line->array_options) < 0) {
713 if ($lines[$i]->fk_product > 0) {
715 if ($lines[$i]->entrepot_id > 0) {
717 $stockLocation =
"entl".$line_id;
718 $qty =
"qtyl".$line_id;
719 $line->id = $line_id;
720 $line->entrepot_id =
GETPOST($stockLocation,
'int');
721 $line->qty =
GETPOST($qty,
'int');
722 if ($line->update($user) < 0) {
726 unset($_POST[$stockLocation]);
728 } elseif (count($lines[$i]->details_entrepot) > 1) {
730 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
732 $stockLocation =
"entl".$detail_entrepot->line_id;
733 $qty =
"qtyl".$detail_entrepot->line_id;
734 $warehouse =
GETPOST($stockLocation,
'int');
735 if (!empty($warehouse)) {
736 $line->id = $detail_entrepot->line_id;
737 $line->entrepot_id = $warehouse;
738 $line->qty =
GETPOST($qty,
'int');
739 if ($line->update($user) < 0) {
746 unset($_POST[$stockLocation]);
750 } elseif (empty($conf->stock->enabled) && empty($conf->productbatch->enabled)) {
751 $qty =
"qtyl".$line_id;
752 $line->id = $line_id;
753 $line->qty =
GETPOST($qty,
'int');
754 $line->entrepot_id = 0;
755 if ($line->update($user) < 0) {
765 $qty =
"qtyl".$line_id;
766 $line->id = $line_id;
767 $line->qty =
GETPOST($qty,
'int');
768 $line->entrepot_id = 0;
769 if ($line->update($user) < 0) {
779 if (empty($update_done)) {
780 $line->id = $lines[$i]->id;
781 $line->insertExtraFields();
786 unset($_POST[
"lineid"]);
789 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
791 $outputlangs = $langs;
793 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
794 $newlang =
GETPOST(
'lang_id',
'aZ09');
796 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
797 $newlang = $object->thirdparty->default_lang;
799 if (!empty($newlang)) {
801 $outputlangs->setDefaultLang($newlang);
804 $ret = $object->fetch($object->id);
805 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
808 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
811 } elseif ($action ==
'updateline' && $user->rights->expedition->creer &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
812 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
816 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
822 $triggersendname =
'SHIPPING_SENTBYMAIL';
824 $mode =
'emailfromshipment';
825 $trackid =
'shi'.$object->id;
826 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
834 $help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
838 if (empty($action)) {
845 if (!empty($conf->project->enabled)) {
849 $product_static =
new Product($db);
851 $warehousestatic =
new Entrepot($db);
853 if ($action ==
'create2') {
856 print
'<br>'.$langs->trans(
"ShipmentCreationIsDoneFromOrder");
857 $action =
''; $id =
''; $ref =
'';
861 if ($action ==
'create') {
871 $classname = ucfirst($origin);
873 $object =
new $classname($db);
874 if ($object->fetch($origin_id)) {
876 $soc->fetch($object->socid);
878 $author =
new User($db);
879 $author->fetch($object->user_author_id);
881 if (!empty($conf->stock->enabled)) {
885 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
886 print
'<input type="hidden" name="token" value="'.newToken().
'">';
887 print
'<input type="hidden" name="action" value="add">';
888 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
889 print
'<input type="hidden" name="origin_id" value="'.$object->id.
'">';
890 print
'<input type="hidden" name="ref_int" value="'.$object->ref_int.
'">';
891 if (
GETPOST(
'entrepot_id',
'int')) {
892 print
'<input type="hidden" name="entrepot_id" value="'.GETPOST(
'entrepot_id',
'int').
'">';
897 print
'<table class="border centpercent">';
900 print
'<tr><td class="titlefieldcreate fieldrequired">';
901 if ($origin ==
'commande' && !empty($conf->commande->enabled)) {
902 print $langs->trans(
"RefOrder");
904 if ($origin ==
'propal' && !empty($conf->propal->enabled)) {
905 print $langs->trans(
"RefProposal");
907 print
'</td><td colspan="3">';
908 print $object->getNomUrl(1);
914 if ($origin ==
'commande') {
915 print $langs->trans(
'RefCustomerOrder');
916 } elseif ($origin ==
'propal') {
917 print $langs->trans(
'RefCustomerOrder');
919 print $langs->trans(
'RefCustomer');
921 print
'</td><td colspan="3">';
922 print
'<input type="text" name="ref_customer" value="'.$object->ref_client.
'" />';
927 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Company').
'</td>';
928 print
'<td colspan="3">'.$soc->getNomUrl(1).
'</td>';
932 if (!empty($conf->project->enabled)) {
933 $projectid =
GETPOST(
'projectid',
'int') ?
GETPOST(
'projectid',
'int') : 0;
934 if (empty($projectid) && !empty($object->fk_project)) {
935 $projectid = $object->fk_project;
937 if ($origin ==
'project') {
938 $projectid = ($originid ? $originid : 0);
941 $langs->load(
"projects");
943 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
945 $numprojet = $formproject->select_projects($soc->id, $projectid,
'projectid', 0);
946 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>';
952 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
953 print
'<td colspan="3">';
954 $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date);
955 print
$form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
960 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
961 print
'<td colspan="3">';
962 $doleditor =
new DolEditor(
'note_public', $object->note_public,
'', 60,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3,
'90%');
963 print $doleditor->Create(1);
967 if ($object->note_private && !$user->socid) {
968 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
969 print
'<td colspan="3">';
970 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 60,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3,
'90%');
971 print $doleditor->Create(1);
977 print $langs->trans(
"Weight");
978 print
'</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST(
'weight',
'int').
'"> ';
979 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units',
'int'), 0, 2);
980 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
981 print
$form->textwithpicto($text, $htmltext);
985 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
986 print
' </td><td colspan="3"><input name="sizeW" size="4" value="'.GETPOST(
'sizeW',
'int').
'">';
987 print
' x <input name="sizeH" size="4" value="'.GETPOST(
'sizeH',
'int').
'">';
988 print
' x <input name="sizeS" size="4" value="'.GETPOST(
'sizeS',
'int').
'">';
990 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units',
'int'), 0, 2);
991 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
992 print
$form->textwithpicto($text, $htmltext);
996 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
997 print
'<td colspan="3">';
998 $expe->fetch_delivery_methods();
999 print
$form->selectarray(
"shipping_method_id", $expe->meths,
GETPOST(
'shipping_method_id',
'int'), 1, 0, 0,
"", 1);
1001 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1003 print
"</td></tr>\n";
1006 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1007 print
'<td colspan="3">';
1008 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1009 print
"</td></tr>\n";
1012 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1013 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $expe, $action);
1014 print $hookmanager->resPrint;
1016 if (empty($reshook)) {
1018 if ($object->fetch_optionals() > 0) {
1019 $expe->array_options = array_merge($expe->array_options, $object->array_options);
1021 print $expe->showOptionals($extrafields,
'edit',
$parameters);
1026 if (!empty($conf->incoterm->enabled)) {
1028 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $object->label_incoterms, 1).
'</label></td>';
1029 print
'<td colspan="3" class="maxwidthonsmartphone">';
1030 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1035 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1037 if (count($list) > 1) {
1038 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1039 print
'<td colspan="3">';
1040 print
$form->selectarray(
'model', $list, $conf->global->EXPEDITION_ADDON_PDF);
1041 print
"</td></tr>\n";
1051 $numAsked = count($object->lines);
1053 print
'<script type="text/javascript">'.
"\n";
1054 print
'jQuery(document).ready(function() {'.
"\n";
1055 print
'jQuery("#autofill").click(function() {';
1057 while ($i < $numAsked) {
1058 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1059 if (!empty($conf->productbatch->enabled)) {
1060 print
'jQuery("#qtyl'.$i.
'_'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1064 print
'return false; });'.
"\n";
1065 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);'.
"\n";
1066 print
'return false; });'.
"\n";
1068 print
'</script>'.
"\n";
1072 print
'<table class="noborder centpercent">';
1075 $object->loadExpeditions();
1078 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1081 print
'<tr class="liste_titre">';
1082 print
'<td>'.$langs->trans(
"Description").
'</td>';
1083 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1084 print
'<td class="center">'.$langs->trans(
"QtyShipped").
'</td>';
1085 print
'<td class="center">'.$langs->trans(
"QtyToShip");
1086 if (empty($conf->productbatch->enabled)) {
1087 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"').
'</a>';
1092 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Reset"),
'eraser').
'</span>';
1094 if (!empty($conf->stock->enabled)) {
1095 if (empty($conf->productbatch->enabled)) {
1096 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1098 print
'<td class="left">'.$langs->trans(
"Warehouse").
' / '.$langs->trans(
"Batch").
' ('.$langs->trans(
"Stock").
')</td>';
1104 $warehouse_id =
GETPOST(
'entrepot_id',
'int');
1105 $warehousePicking = array();
1107 if ($warehouse_id > 0) {
1108 $warehousePicking[] = $warehouse_id;
1110 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1114 while ($indiceAsked < $numAsked) {
1117 $line = $object->lines[$indiceAsked];
1119 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1120 $reshook = $hookmanager->executeHooks(
'printObjectLine',
$parameters, $object, $action);
1125 if (empty($reshook)) {
1127 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1130 if (!empty($line->date_start)) {
1133 if (!empty($line->date_end)) {
1137 print
'<!-- line '.$line->id.
' for product -->'.
"\n";
1138 print
'<tr class="oddeven">'.
"\n";
1141 if ($line->fk_product > 0) {
1142 $product->fetch($line->fk_product);
1143 $product->load_stock(
'warehouseopen');
1147 print
'<a name="'.$line->id.
'"></a>';
1150 $product_static->type = $line->fk_product_type;
1151 $product_static->id = $line->fk_product;
1152 $product_static->ref = $line->ref;
1153 $product_static->status = $line->product_tosell;
1154 $product_static->status_buy = $line->product_tobuy;
1155 $product_static->status_batch = $line->product_tobatch;
1159 $text = $product_static->getNomUrl(1);
1160 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1163 print
$form->textwithtooltip($text, $description, 3,
'',
'', $i);
1166 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1169 if ($showdescinproductdesc) {
1170 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1177 $text =
img_object($langs->trans(
'Service'),
'service');
1179 $text =
img_object($langs->trans(
'Product'),
'product');
1182 if (!empty($line->label)) {
1183 $text .=
' <strong>'.$line->label.
'</strong>';
1184 print
$form->textwithtooltip($text, $line->desc, 3,
'',
'', $i);
1186 print $text.
' '.nl2br($line->desc);
1190 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1196 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1201 print
'<td class="center">'.$line->qty;
1202 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1203 print
''.$unit_order.
'</td>';
1204 $qtyProdCom = $line->qty;
1207 print
'<td class="center">';
1208 $quantityDelivered = isset($object->expeditions[$line->id]) ? $object->expeditions[$line->id] :
'';
1209 print $quantityDelivered;
1210 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1211 print
''.$unit_order.
'</td>';
1214 $quantityAsked = $line->qty;
1215 if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1216 $quantityToBeDelivered = 0;
1218 if (is_numeric($quantityDelivered)) {
1219 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
1221 $quantityToBeDelivered = $quantityAsked;
1225 $warehouseObject =
null;
1226 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || empty($conf->stock->enabled)) {
1227 print
'<!-- Case warehouse already known or product not a predefined product -->';
1229 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
1230 $deliverableQty = min($quantityToBeDelivered, $stock);
1231 if ($deliverableQty < 0) {
1232 $deliverableQty = 0;
1234 if (empty($conf->productbatch->enabled) || !$product->hasbatch()) {
1236 print
'<td class="center">';
1237 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1238 if (
GETPOST(
'qtyl'.$indiceAsked,
'int')) {
1239 $deliverableQty =
GETPOST(
'qtyl'.$indiceAsked,
'int');
1241 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1242 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" class="qtyl center" type="text" size="4" value="'.$deliverableQty.
'">';
1244 if (! empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
1245 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1246 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1249 print $langs->trans(
"NA");
1254 if (!empty($conf->stock->enabled)) {
1255 print
'<td class="left">';
1256 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1258 $ent =
"entl".$indiceAsked;
1259 $idl =
"idl".$indiceAsked;
1260 $tmpentrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') : $warehouse_id;
1261 if ($line->fk_product > 0) {
1262 print
'<!-- Show warehouse selection -->';
1265 if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1268 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200',
'', 1, $stockMin,
'stock DESC, e.ref');
1270 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
1272 if ($stock < $quantityToBeDelivered) {
1273 print
' '.img_warning($langs->trans(
"StockTooLow"));
1278 print $langs->trans(
"Service");
1286 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) {
1287 $product->get_sousproduits_arbo();
1288 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1289 if (count($prods_arbo) > 0) {
1290 foreach ($prods_arbo as $key => $value) {
1293 if ($value[
'stock'] < $value[
'stock_alert']) {
1296 print
"<tr class=\"oddeven\"><td> ->
1297 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1298 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1299 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td></tr>";
1305 print
'<td></td><td></td></tr>';
1306 print
'<!-- Case product need lot -->';
1308 $staticwarehouse =
new Entrepot($db);
1309 if ($warehouse_id > 0) {
1310 $staticwarehouse->fetch($warehouse_id);
1316 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1317 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1321 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1322 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1323 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1325 $batchStock = + $dbatch->qty;
1326 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1327 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] :
'').
'>';
1328 print
'<td colspan="3" ></td><td class="center">';
1329 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1332 print
'<!-- Show details of lot -->';
1333 print
'<td class="left">';
1335 print $staticwarehouse->getNomUrl(0).
' / ';
1337 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1340 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
1341 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
1342 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1344 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
1345 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1347 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
1351 $quantityToBeDelivered -= $deliverableQty;
1352 if ($quantityToBeDelivered < 0) {
1353 $quantityToBeDelivered = 0;
1359 print
'<!-- Case there is no details of lot at all -->';
1360 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1361 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0" disabled="disabled"> ';
1364 print
'<td class="left">';
1365 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
1371 if (empty($conf->productbatch->enabled) || !$product->hasbatch()) {
1372 print
'<!-- Case warehouse not already known and product does not need lot -->';
1373 print
'<td></td><td></td></tr>'.
"\n";
1375 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1380 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1381 if ($stock_warehouse->real > 0) {
1385 $tmpwarehouseObject =
new Entrepot($db);
1386 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1387 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1392 $tmpwarehouseObject->fetch($warehouse_id);
1393 if ($stock_warehouse->real > 0) {
1394 $stock = + $stock_warehouse->real;
1395 $deliverableQty = min($quantityToBeDelivered, $stock);
1396 $deliverableQty = max(0, $deliverableQty);
1398 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] :
'').
'>';
1399 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked='.$indiceAsked.
') -->';
1400 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1401 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1402 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
1404 if (!isset($alreadyQtySetted[$line->fk_product])) {
1405 $alreadyQtySetted[$line->fk_product] = array();
1408 $deliverableQty = min($quantityToBeDelivered, $stock);
1411 if ($deliverableQty < 0) $deliverableQty = 0;
1414 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1415 $tooltip =
' class="classfortooltip" title="'.$langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)].
'" ';
1418 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1420 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1422 $deliverableQty =
GETPOST($inputName,
'int');
1425 print
'<input '.$tooltip.
' name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1426 print
'<input name="ent1'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$warehouse_id.
'">';
1428 if (! empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
1429 print
'<input name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1432 print $langs->trans(
"NA");
1437 if (!empty($conf->stock->enabled)) {
1438 print
'<td class="left">';
1439 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1440 print $tmpwarehouseObject->getNomUrl(0).
' ';
1442 print
'<!-- Show details of stock -->';
1443 print
'('.$stock.
')';
1445 print $langs->trans(
"Service");
1449 $quantityToBeDelivered -= $deliverableQty;
1450 if ($quantityToBeDelivered < 0) {
1451 $quantityToBeDelivered = 0;
1458 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) {
1459 $product->get_sousproduits_arbo();
1460 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1461 if (count($prods_arbo) > 0) {
1462 foreach ($prods_arbo as $key => $value) {
1465 if ($value[
'stock'] < $value[
'stock_alert']) {
1468 print
'<tr class"oddeven"><td>';
1469 print
" ->
1470 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1471 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1472 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1478 print
'<!-- Case warehouse not already known and product need lot -->';
1479 print
'<td></td><td></td></tr>';
1482 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1484 $tmpwarehouseObject =
new Entrepot($db);
1489 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1490 if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
1491 $nbofsuggested+=count($stock_warehouse->detail_batch);
1495 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1496 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1501 $tmpwarehouseObject->fetch($warehouse_id);
1502 if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
1503 foreach ($stock_warehouse->detail_batch as $dbatch) {
1504 $batchStock = + $dbatch->qty;
1505 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1506 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1508 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1509 $alreadyQtyBatchSetted[$line->fk_product] = array();
1512 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1513 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1516 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1519 if ($deliverableQty < 0) $deliverableQty = 0;
1521 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1523 $deliverableQty =
GETPOST($inputName,
'int');
1526 $tooltipClass = $tooltipTitle =
'';
1527 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1528 $tooltipClass =
' classfortooltip';
1529 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1531 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1533 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] :
'').
'><td colspan="3"></td><td class="center">';
1534 print
'<input class="qtyl '.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="'.$inputName.
'" id="'.$inputName.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1537 print
'<td class="left">';
1539 print $tmpwarehouseObject->getNomUrl(0).
' / ';
1541 print
'<!-- Show details of lot -->';
1542 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1545 print $langs->trans(
"Batch").
': ';
1546 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
1548 print $productlotObject->getNomUrl(1);
1550 print
'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
1552 print
' ('.$dbatch->qty.
')';
1553 $quantityToBeDelivered -= $deliverableQty;
1554 if ($quantityToBeDelivered < 0) {
1555 $quantityToBeDelivered = 0;
1565 $warehouse_selected_id =
GETPOST(
'entrepot_id',
'int');
1567 print
'<!-- line not shown yet, we show it -->';
1568 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1570 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1572 if (!empty($conf->productbatch->enabled) && $product->hasbatch()) {
1573 $disabled =
'disabled="disabled"';
1575 if ($warehouse_selected_id <= 0) {
1576 $disabled =
'disabled="disabled"';
1578 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').
'> ';
1580 print $langs->trans(
"NA");
1584 print
'<td class="left">';
1585 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1586 if ($warehouse_selected_id > 0) {
1587 $warehouseObject =
new Entrepot($db);
1588 $warehouseObject->fetch($warehouse_selected_id);
1589 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
1591 if ($line->fk_product) {
1592 print
img_warning().
' '.$langs->trans(
"StockTooLow");
1598 print $langs->trans(
"Service");
1607 if (!empty($extrafields)) {
1613 $srcLine->id = $line->id;
1614 $srcLine->fetch_optionals();
1616 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
1618 print $expLine->showOptionals($extrafields,
'edit', array(
'style'=>
'class="drag drop oddeven"',
'colspan'=>$colspan), $indiceAsked,
'', 1);
1629 print
$form->buttonsSaveCancel(
"Create");
1638 } elseif ($id || $ref) {
1644 $lines = $object->lines;
1646 $num_prod = count($lines);
1648 if ($object->id > 0) {
1649 if (!empty($object->origin) && $object->origin_id > 0) {
1650 $typeobject = $object->origin;
1651 $origin = $object->origin;
1652 $origin_id = $object->origin_id;
1653 $object->fetch_origin();
1657 $soc->fetch($object->socid);
1659 $res = $object->fetch_optionals();
1662 print
dol_get_fiche_head($head,
'shipping', $langs->trans(
"Shipment"), -1, $object->picto);
1667 if ($action ==
'delete') {
1668 $formquestion = array();
1670 $formquestion = array(
1672 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
1673 'name' =>
'alsoUpdateStock',
1674 'type' =>
'checkbox',
1680 $_SERVER[
'PHP_SELF'].
'?id='.$object->id,
1681 $langs->trans(
'DeleteSending'),
1682 $langs->trans(
"ConfirmDeleteSending", $object->ref),
1691 if ($action ==
'valid') {
1692 $objectref = substr($object->ref, 1, 4);
1693 if ($objectref ==
'PROV') {
1694 $numref = $object->getNextNumRef($soc);
1696 $numref = $object->ref;
1699 $text = $langs->trans(
"ConfirmValidateSending", $numref);
1701 if (!empty($conf->notification->enabled)) {
1702 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1703 $notify =
new Notify($db);
1705 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE', $object->socid, $object);
1708 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1);
1711 if ($action ==
'cancel') {
1712 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending", $object->ref),
'confirm_cancel',
'', 0, 1);
1717 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
1718 if (empty($reshook)) {
1720 } elseif ($reshook > 0) {
1729 $tmparray = $object->getTotalWeightVolume();
1730 $totalWeight = $tmparray[
'weight'];
1731 $totalVolume = $tmparray[
'volume'];
1734 if ($typeobject ==
'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
1736 $objectsrc->fetch($object->$typeobject->id);
1738 if ($typeobject ==
'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
1739 $objectsrc =
new Propal($db);
1740 $objectsrc->fetch($object->$typeobject->id);
1744 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1745 $morehtmlref =
'<div class="refidno">';
1747 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'', 0, 1);
1748 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'',
null,
null,
'', 1);
1750 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
1752 if (!empty($conf->project->enabled)) {
1753 $langs->load(
"projects");
1754 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
1756 if ($action !=
'classify') {
1757 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
1759 if ($action ==
'classify') {
1761 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
1762 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1763 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1764 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1765 $morehtmlref .=
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
1766 $morehtmlref .=
'</form>';
1768 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
1773 $morehtmlref .=
' : ';
1774 if (!empty($objectsrc->fk_project)) {
1776 $proj->fetch($objectsrc->fk_project);
1777 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1779 $morehtmlref .=
' - '.$proj->title;
1786 $morehtmlref .=
'</div>';
1789 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1792 print
'<div class="fichecenter">';
1793 print
'<div class="fichehalfleft">';
1794 print
'<div class="underbanner clearboth"></div>';
1796 print
'<table class="border tableforfield" width="100%">';
1799 if ($typeobject ==
'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
1801 print $langs->trans(
"RefOrder").
'</td>';
1802 print
'<td colspan="3">';
1803 print $objectsrc->getNomUrl(1,
'commande');
1807 if ($typeobject ==
'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
1809 print $langs->trans(
"RefProposal").
'</td>';
1810 print
'<td colspan="3">';
1811 print $objectsrc->getNomUrl(1,
'expedition');
1817 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
1818 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour").
"</td>\n";
1822 print
'<tr><td height="10">';
1823 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1824 print $langs->trans(
'DateDeliveryPlanned');
1827 if ($action !=
'editdate_livraison') {
1828 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>';
1830 print
'</tr></table>';
1831 print
'</td><td colspan="2">';
1832 if ($action ==
'editdate_livraison') {
1833 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1834 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1835 print
'<input type="hidden" name="action" value="setdate_livraison">';
1836 print
$form->selectDate($object->date_delivery ? $object->date_delivery : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
1837 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1840 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
1847 print
$form->editfieldkey(
"Weight",
'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer);
1848 print
'</td><td colspan="3">';
1850 if ($action ==
'edittrueWeight') {
1851 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1852 print
'<input name="action" value="settrueWeight" type="hidden">';
1853 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
1854 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1855 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text" class="width50">';
1856 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $object->weight_units, 0, 2);
1857 print
' <input class="button" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
1858 print
' <input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1861 print $object->trueWeight;
1862 print ($object->trueWeight && $object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight", $object->weight_units) :
'';
1866 if ($totalWeight > 0) {
1867 if (!empty($object->trueWeight)) {
1868 print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
1870 print
showDimensionInBestUnit($totalWeight, 0,
"weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT :
'no');
1871 if (!empty($object->trueWeight)) {
1878 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1879 print
$form->editfieldval(
"Width",
'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer);
1880 print ($object->trueWidth && $object->width_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->width_units) :
'';
1884 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1885 if ($action ==
'edittrueHeight') {
1886 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1887 print
'<input name="action" value="settrueHeight" type="hidden">';
1888 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
1889 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1890 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text" class="width50">';
1891 print $formproduct->selectMeasuringUnits(
"size_units",
"size", $object->size_units, 0, 2);
1892 print
' <input class="button" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
1893 print
' <input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1896 print $object->trueHeight;
1897 print ($object->trueHeight && $object->height_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->height_units) :
'';
1903 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1904 print
$form->editfieldval(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer);
1905 print ($object->trueDepth && $object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->depth_units) :
'';
1910 print $langs->trans(
"Volume");
1912 print
'<td colspan="3">';
1913 $calculatedVolume = 0;
1915 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
1916 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
1917 $volumeUnit = $object->size_units * 3;
1920 if ($calculatedVolume > 0) {
1921 if ($volumeUnit < 50) {
1922 print
showDimensionInBestUnit($calculatedVolume, $volumeUnit,
"volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT :
'no');
1927 if ($totalVolume > 0) {
1928 if ($calculatedVolume) {
1929 print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
1931 print
showDimensionInBestUnit($totalVolume, 0,
"volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT :
'no');
1933 if ($calculatedVolume) {
1942 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1947 print
'<div class="fichehalfright">';
1948 print
'<div class="underbanner clearboth"></div>';
1950 print
'<table class="border centpercent tableforfield">';
1953 print
'<tr><td height="10">';
1954 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1955 print $langs->trans(
'SendingMethod');
1958 if ($action !=
'editshipping_method_id') {
1959 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>';
1961 print
'</tr></table>';
1962 print
'</td><td colspan="2">';
1963 if ($action ==
'editshipping_method_id') {
1964 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1965 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1966 print
'<input type="hidden" name="action" value="setshipping_method_id">';
1967 $object->fetch_delivery_methods();
1968 print
$form->selectarray(
"shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0,
"", 1);
1970 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1972 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1975 if ($object->shipping_method_id > 0) {
1977 $code = $langs->getLabelFromKey($db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1978 print $langs->trans(
"SendingMethod".strtoupper($code));
1985 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1986 print
$form->editfieldval(
"TrackingNumber",
'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer,
'safehtmlstring', $object->tracking_number);
1990 if (!empty($conf->incoterm->enabled)) {
1992 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1993 print $langs->trans(
'IncotermLabel');
1994 print
'<td><td class="right">';
1995 if ($user->rights->expedition->creer) {
1996 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
2000 print
'</td></tr></table>';
2002 print
'<td colspan="3">';
2003 if ($action !=
'editincoterm') {
2004 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2006 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2012 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
2013 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2014 print $hookmanager->resPrint;
2021 print
'<div class="clearboth"></div>';
2026 if ($action ==
'editline') {
2027 print
' <form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$line_id.
'" method="POST">
2028 <input type="hidden" name="token" value="' .
newToken().
'">
2029 <input type="hidden" name="action" value="updateline">
2030 <input type="hidden" name="mode" value="">
2031 <input type="hidden" name="id" value="' . $object->id.
'">
2036 print
'<div class="div-table-responsive-no-min">';
2037 print
'<table class="noborder" width="100%" id="tablelines" >';
2039 print
'<tr class="liste_titre">';
2041 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
2042 print
'<td width="5" class="center linecolnum"> </td>';
2045 print
'<td class="linecoldescription" >'.$langs->trans(
"Products").
'</td>';
2047 print
'<td class="center linecolqty">'.$langs->trans(
"QtyOrdered").
'</td>';
2048 if ($origin && $origin_id > 0) {
2049 print
'<td class="center linecolqtyinothershipments">'.$langs->trans(
"QtyInOtherShipments").
'</td>';
2051 if ($action ==
'editline') {
2053 if (empty($conf->stock->enabled)) {
2056 if (empty($conf->productbatch->enabled)) {
2059 print
'<td class="center linecoleditlineotherinfo" colspan="'.$editColspan.
'">';
2060 if ($object->statut <= 1) {
2061 print $langs->trans(
"QtyToShip").
' - ';
2063 print $langs->trans(
"QtyShipped").
' - ';
2065 if (!empty($conf->stock->enabled)) {
2066 print $langs->trans(
"WarehouseSource").
' - ';
2068 if (!empty($conf->productbatch->enabled)) {
2069 print $langs->trans(
"Batch");
2073 if ($object->statut <= 1) {
2074 print
'<td class="center linecolqtytoship">'.$langs->trans(
"QtyToShip").
'</td>';
2076 print
'<td class="center linecolqtyshipped">'.$langs->trans(
"QtyShipped").
'</td>';
2078 if (!empty($conf->stock->enabled)) {
2079 print
'<td class="left linecolwarehousesource">'.$langs->trans(
"WarehouseSource").
'</td>';
2082 if (!empty($conf->productbatch->enabled)) {
2083 print
'<td class="left linecolbatch">'.$langs->trans(
"Batch").
'</td>';
2086 print
'<td class="center linecolweight">'.$langs->trans(
"CalculatedWeight").
'</td>';
2087 print
'<td class="center linecolvolume">'.$langs->trans(
"CalculatedVolume").
'</td>';
2089 if ($object->statut == 0) {
2090 print
'<td class="linecoledit"></td>';
2091 print
'<td class="linecoldelete" width="10"></td>';
2096 $outputlangs = $langs;
2098 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
2099 $object->fetch_thirdparty();
2101 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
2102 $newlang =
GETPOST(
'lang_id',
'aZ09');
2104 if (empty($newlang)) {
2105 $newlang = $object->thirdparty->default_lang;
2107 if (!empty($newlang)) {
2108 $outputlangs =
new Translate(
"", $conf);
2109 $outputlangs->setDefaultLang($newlang);
2114 $alreadysent = array();
2115 if ($origin && $origin_id > 0) {
2116 $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";
2117 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot";
2118 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
2120 $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';
2121 $sql .=
', p.description as product_desc';
2122 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2123 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
2124 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
2126 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2127 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
2128 $sql .=
" AND obj.fk_".$origin.
" = ".((int) $origin_id);
2129 $sql .=
" AND obj.rowid = ed.fk_origin_line";
2130 $sql .=
" AND ed.fk_expedition = e.rowid";
2132 $sql .=
" ORDER BY obj.fk_product";
2134 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
2135 $resql = $db->query($sql);
2137 $num = $db->num_rows(
$resql);
2141 $obj = $db->fetch_object(
$resql);
2144 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
2145 'shipment_ref'=>$obj->shipment_ref,
'shipment_id'=>$obj->shipment_id,
'warehouse'=>$obj->fk_entrepot,
'qty_shipped'=>$obj->qty_shipped,
2146 'product_tosell'=>$obj->product_tosell,
'product_tobuy'=>$obj->product_tobuy,
'product_tobatch'=>$obj->product_tobatch,
2147 'date_valid'=>$db->jdate($obj->date_valid),
'date_delivery'=>$db->jdate($obj->date_delivery));
2158 for ($i = 0; $i < $num_prod; $i++) {
2159 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
2160 $reshook = $hookmanager->executeHooks(
'printObjectLine',
$parameters, $object, $action);
2165 if (empty($reshook)) {
2166 print
'<!-- origin line id = '.$lines[$i]->origin_line_id.
' -->';
2167 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'" >';
2170 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
2171 print
'<td class="center linecolnum">'.($i + 1).
'</td>';
2175 if ($lines[$i]->fk_product > 0) {
2177 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
2179 $prod->fetch($lines[$i]->fk_product);
2180 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
2182 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
2185 print
'<td class="linecoldescription">';
2188 $product_static->type = $lines[$i]->fk_product_type;
2189 $product_static->id = $lines[$i]->fk_product;
2190 $product_static->ref = $lines[$i]->ref;
2191 $product_static->status = $lines[$i]->product_tosell;
2192 $product_static->status_buy = $lines[$i]->product_tobuy;
2193 $product_static->status_batch = $lines[$i]->product_tobatch;
2195 $product_static->weight = $lines[$i]->weight;
2196 $product_static->weight_units = $lines[$i]->weight_units;
2197 $product_static->length = $lines[$i]->length;
2198 $product_static->length_units = $lines[$i]->length_units;
2199 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
2200 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
2201 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
2202 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
2203 $product_static->surface = $lines[$i]->surface;
2204 $product_static->surface_units = $lines[$i]->surface_units;
2205 $product_static->volume = $lines[$i]->volume;
2206 $product_static->volume_units = $lines[$i]->volume_units;
2208 $text = $product_static->getNomUrl(1);
2209 $text .=
' - '.$label;
2211 print
$form->textwithtooltip($text, $description, 3,
'',
'', $i);
2212 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
2213 if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
2218 print
'<td class="linecoldescription" >';
2220 $text =
img_object($langs->trans(
'Service'),
'service');
2222 $text =
img_object($langs->trans(
'Product'),
'product');
2225 if (!empty($lines[$i]->label)) {
2226 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2227 print
$form->textwithtooltip($text, $lines[$i]->
description, 3,
'',
'', $i);
2237 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2242 print
'<td class="center linecolqty">'.$lines[$i]->qty_asked.
' '.$unit_order.
'</td>';
2245 if ($origin && $origin_id > 0) {
2246 print
'<td class="linecolqtyinothershipments center nowrap">';
2247 foreach ($alreadysent as $key => $val) {
2248 if ($lines[$i]->fk_origin_line == $key) {
2250 foreach ($val as $shipmentline_id => $shipmentline_var) {
2251 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
2259 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
2260 print $shipment_static->getNomUrl(1);
2261 print
' - '.$shipmentline_var[
'qty_shipped'];
2262 $htmltext = $langs->trans(
"DateValidation").
' : '.(empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
2263 if (!empty($conf->stock->enabled) && $shipmentline_var[
'warehouse'] > 0) {
2264 $warehousestatic->fetch($shipmentline_var[
'warehouse']);
2265 $htmltext .=
'<br>'.$langs->trans(
"FromLocation").
' : '.$warehousestatic->getNomUrl(1,
'', 0, 1);
2267 print
' '.$form->textwithpicto(
'', $htmltext, 1);
2274 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2276 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding centpercent">';
2277 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
2278 print
'<!-- case edit 1 -->';
2280 foreach ($lines[$i]->detail_batch as $detail_batch) {
2283 print
'<td><input class="qtyl" 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>';
2285 if ($lines[$i]->entrepot_id == 0) {
2287 $line->fetch($detail_batch->fk_expeditiondet);
2289 $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id;
2290 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>';
2296 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'_0" id="qtyl'.$line_id.
'_0" type="text" size="4" value="0"></td>';
2298 print
'<td>'.$formproduct->selectLotStock(
'',
'batchl'.$line_id.
'_0',
'', 1, 0, $lines[$i]->fk_product).
'</td>';
2300 } elseif (!empty($conf->stock->enabled)) {
2301 if ($lines[$i]->fk_product > 0) {
2302 if ($lines[$i]->entrepot_id > 0) {
2303 print
'<!-- case edit 2 -->';
2306 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'">'.$unit_order.
'</td>';
2308 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2310 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2312 } elseif (count($lines[$i]->details_entrepot) > 1) {
2313 print
'<!-- case edit 3 -->';
2314 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2317 print
'<td><input class="qtyl" name="qtyl'.$detail_entrepot->line_id.
'" id="qtyl'.$detail_entrepot->line_id.
'" type="text" size="4" value="'.$detail_entrepot->qty_shipped.
'">'.$unit_order.
'</td>';
2319 print
'<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl'.$detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2321 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2325 print
'<!-- case edit 4 -->';
2326 print
'<tr><td colspan="3">'.$langs->trans(
"NotEnoughStock").
'</td></tr>';
2329 print
'<!-- case edit 5 -->';
2332 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'">'.$unit_order.
'</td>';
2339 } elseif (empty($conf->stock->enabled) && empty($conf->productbatch->enabled)) {
2340 print
'<!-- case edit 6 -->';
2343 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2351 print
'</table></td>';
2354 print
'<td class="linecolqtytoship center">'.$lines[$i]->qty_shipped.
' '.$unit_order.
'</td>';
2357 if (!empty($conf->stock->enabled)) {
2358 print
'<td class="linecolwarehousesource left">';
2359 if ($lines[$i]->entrepot_id > 0) {
2361 $entrepot->fetch($lines[$i]->entrepot_id);
2362 print $entrepot->getNomUrl(1);
2363 } elseif (count($lines[$i]->details_entrepot) > 1) {
2365 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2366 if ($detail_entrepot->entrepot_id > 0) {
2368 $entrepot->fetch($detail_entrepot->entrepot_id);
2369 $detail .= $langs->trans(
"DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).
'<br>';
2372 print
$form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
"DetailWarehouseNumber"), $detail);
2378 if (!empty($conf->productbatch->enabled)) {
2379 if (isset($lines[$i]->detail_batch)) {
2380 print
'<!-- Detail of lot -->';
2381 print
'<td class="linecolbatch">';
2382 if ($lines[$i]->product_tobatch) {
2384 foreach ($lines[$i]->detail_batch as $dbatch) {
2385 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
2386 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
2387 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
2389 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
2390 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
2392 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
2395 print
$form->textwithtooltip(
img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $detail);
2397 print $langs->trans(
"NA");
2401 print
'<td class="linecolbatch" ></td>';
2407 print
'<td class="center linecolweight">';
2409 print $lines[$i]->weight * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
2416 print
'<td class="center linecolvolume">';
2418 print $lines[$i]->volume * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
2427 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2428 print
'<td class="center" colspan="2" valign="middle">';
2429 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2430 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2434 print
'<td class="linecoledit center">';
2435 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_edit().
'</a>';
2437 print
'<td class="linecoldelete" width="10">';
2438 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_delete().
'</a>';
2442 if (!empty($rowExtrafieldsStart)) {
2443 print $rowExtrafieldsStart;
2444 print $rowExtrafieldsView;
2452 if (!empty($extrafields)) {
2454 if ($origin && $origin_id > 0) {
2457 if (!empty($conf->productbatch->enabled)) {
2460 if (!empty($conf->stock->enabled)) {
2465 $line->fetch_optionals();
2468 if ($action ==
'editline' && $line->id == $line_id) {
2469 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'', 0,
'card');
2471 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'', 0,
'card');
2488 $object->fetchObjectLinked($object->id, $object->element);
2495 if (($user->socid == 0) && ($action !=
'presend')) {
2496 print
'<div class="tabsAction">';
2499 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2501 if (empty($reshook)) {
2503 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
2504 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate))) {
2505 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=valid&token='.
newToken().
'&id='.$object->id,
'');
2507 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2514 if (
isModEnabled(
'facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2515 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnbilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
2517 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
2522 if (empty($user->socid)) {
2523 if ($object->statut > 0) {
2524 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) {
2525 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2527 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2534 if ($user->rights->facture->creer) {
2537 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2544 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"].
'?action=create_delivery&token='.
newToken().
'&id='.$object->id,
'');
2548 if ($user->rights->expedition->creer && $object->statut > 0 && !$object->billed) {
2549 $label =
"Close"; $paramaction =
'classifyclosed';
2551 if (
isModEnabled(
'facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2552 $label =
"ClassifyBilled";
2553 $paramaction =
'classifybilled';
2555 print
dolGetButtonAction(
'', $langs->trans($label),
'default', $_SERVER[
"PHP_SELF"].
'?action='. $paramaction .
'&token='.
newToken().
'&id='.$object->id,
'');
2561 if ($user->rights->expedition->supprimer) {
2562 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"].
'?action=cancel&token='.
newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2567 if ($user->rights->expedition->supprimer) {
2568 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
2580 if ($action !=
'presend' && $action !=
'editline') {
2581 print
'<div class="fichecenter"><div class="fichehalfleft">';
2584 $filedir = $conf->expedition->dir_output.
"/sending/".$objectref;
2586 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2588 $genallowed = $user->rights->expedition->lire;
2589 $delallowed = $user->rights->expedition->creer;
2591 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2596 $somethingshown =
$form->showLinkedObjectBlock($object,
'');
2599 print
'</div><div class="fichehalfright">';
2602 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2604 $somethingshown =
$formactions->showactions($object,
'shipping', $socid, 1);
2606 print
'</div></div>';
2615 if (
GETPOST(
'modelselected')) {
2616 $action =
'presend';
2620 $modelmail =
'shipping_send';
2621 $defaulttopic = $langs->trans(
'SendShippingRef');
2622 $diroutput = $conf->expedition->dir_output.
'/sending';
2623 $trackid =
'shi'.$object->id;
2625 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';