39require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
51if (isModEnabled(
"product") || isModEnabled(
"service")) {
52 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
54if (isModEnabled(
"propal")) {
55 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
57if (isModEnabled(
'productbatch')) {
58 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
60if (isModEnabled(
'project')) {
61 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
66$langs->loadLangs(array(
"sendings",
"companies",
"bills",
'deliveries',
'orders',
'stocks',
'other',
'propal'));
68if (isModEnabled(
'incoterm')) {
69 $langs->load(
'incoterm');
71if (isModEnabled(
'productbatch')) {
72 $langs->load(
'productbatch');
75$origin =
GETPOST(
'origin',
'alpha') ?
GETPOST(
'origin',
'alpha') :
'expedition';
78if (empty($origin_id)) {
79 $origin_id =
GETPOST(
'origin_id',
'int');
81if (empty($origin_id)) {
82 $origin_id =
GETPOST(
'object_id',
'int');
86$facid =
GETPOST(
'facid',
'int');
88$action =
GETPOST(
'action',
'alpha');
89$confirm =
GETPOST(
'confirm',
'alpha');
90$cancel =
GETPOST(
'cancel',
'alpha');
93$hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
94$hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
95$hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
102$extrafields->fetch_name_optionals_label($object->table_element);
103$extrafields->fetch_name_optionals_label($object->table_element_line);
104$extrafields->fetch_name_optionals_label($objectorder->table_element_line);
107include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
110$hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
112$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'));
114if ($id > 0 || !empty($ref)) {
115 $object->fetch($id, $ref);
116 $object->fetch_thirdparty();
122 $socid = $user->socid;
127$permissiondellink = $user->rights->expedition->delivery->creer;
128$permissiontoadd = $user->rights->expedition->creer;
135$parameters = array();
136$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
141if (empty($reshook)) {
143 if ($origin && $origin_id > 0) {
144 if ($origin ==
'commande') {
145 header(
"Location: ".DOL_URL_ROOT.
'/expedition/shipment.php?id='.((
int) $origin_id));
154 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
157 $upload_dir = $conf->expedition->dir_output.
'/sending';
158 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
161 if ($action ==
'setdraft' && $user->rights->expedition->creer) {
163 $result = $object->setDraft($user, 0);
169 if ($action ==
'reopen' && $user->rights->expedition->creer) {
171 $result = $object->reOpen();
178 if ($action ==
'set_incoterms' && isModEnabled(
'incoterm')) {
179 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
182 if ($action ==
'setref_customer') {
183 $result = $object->fetch($id);
188 $result = $object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPMENT_MODIFY');
191 $action =
'editref_customer';
193 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
198 if ($action ==
'update_extras') {
202 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
209 $result = $object->insertExtraFields(
'SHIPMENT_MODIFY');
217 $action =
'edit_extras';
222 if ($action ==
'add' && $user->rights->expedition->creer) {
227 $object->note =
GETPOST(
'note',
'restricthtml');
228 $object->note_private =
GETPOST(
'note',
'restricthtml');
229 $object->origin = $origin;
230 $object->origin_id = $origin_id;
231 $object->fk_project =
GETPOST(
'projectid',
'int');
232 $object->weight =
GETPOST(
'weight',
'int') ==
'' ?
"NULL" :
GETPOST(
'weight',
'int');
233 $object->sizeH =
GETPOST(
'sizeH',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeH',
'int');
234 $object->sizeW =
GETPOST(
'sizeW',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeW',
'int');
235 $object->sizeS =
GETPOST(
'sizeS',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeS',
'int');
236 $object->size_units =
GETPOST(
'size_units',
'int');
237 $object->weight_units =
GETPOST(
'weight_units',
'int');
242 $classname = ucfirst($object->origin);
243 $objectsrc =
new $classname($db);
244 $objectsrc->fetch($object->origin_id);
246 $object->socid = $objectsrc->socid;
247 $object->ref_customer =
GETPOST(
'ref_customer',
'alpha');
248 $object->model_pdf =
GETPOST(
'model');
249 $object->date_delivery = $date_delivery;
250 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
251 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
252 $object->tracking_number =
GETPOST(
'tracking_number',
'alpha');
253 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
254 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
255 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
256 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
258 $batch_line = array();
259 $stockLine = array();
260 $array_options = array();
262 $num = count($objectsrc->lines);
265 for ($i = 0; $i < $num; $i++) {
272 $batch =
"batchl".$i.
"_0";
273 $stockLocation =
"ent1".$i.
"_0";
276 $is_batch_or_serial=0;
277 if (!empty($objectsrc->lines[$i]->fk_product)) {
278 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
279 if ($resultFetch < 0) {
282 $is_batch_or_serial = $product->status_batch;
286 if (isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
287 if (GETPOSTISSET($batch)) {
290 while (GETPOSTISSET($batch)) {
293 $sub_qty[$j][
'id_batch'] =
GETPOST($batch,
'int');
294 $subtotalqty += $sub_qty[$j][
'q'];
302 if ($is_batch_or_serial==2 && $sub_qty[$j][
'q']>1) {
303 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
308 $batch =
"batchl".$i.
"_".$j;
309 $qty =
"qtyl".$i.
'_'.$j;
312 $batch_line[$i][
'detail'] = $sub_qty;
313 $batch_line[$i][
'qty'] = $subtotalqty;
314 $batch_line[$i][
'ix_l'] =
GETPOST($idl,
'int');
316 $totalqty += $subtotalqty;
323 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse").
' ('.$langs->trans(
"Line").
' '.
GETPOST($idl,
'int').
')',
null,
'errors');
327 } elseif (GETPOSTISSET($stockLocation)) {
330 while (GETPOSTISSET($stockLocation)) {
333 $stockLine[$i][$j][
'warehouse_id'] =
GETPOST($stockLocation,
'int');
334 $stockLine[$i][$j][
'ix_l'] =
GETPOST($idl,
'int');
339 $stockLocation =
"ent1".$i.
"_".$j;
340 $qty =
"qtyl".$i.
'_'.$j;
344 if (
GETPOST($qty,
'int') > 0) {
350 $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i);
352 if (isset($extrafields->attributes[$object->table_element_line][
'label']) && is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
354 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
355 unset($_POST[
"options_".$key]);
361 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
362 for ($i = 0; $i < $num; $i++) {
365 if (!isset($batch_line[$i])) {
367 if (isset($stockLine[$i])) {
369 $nbstockline = count($stockLine[$i]);
370 for ($j = 0; $j < $nbstockline; $j++) {
371 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
372 $ret = $object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], $stockLine[$i][$j][
'qty'], $array_options[$i]);
383 $entrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') :
GETPOST(
'entrepot_id',
'int');
384 if ($entrepot_id < 0) {
387 if (!($objectsrc->lines[$i]->fk_product > 0)) {
391 $ret = $object->addline($entrepot_id,
GETPOST($idl,
'int'),
price2num(
GETPOST($qty,
'alpha'),
'MS'), $array_options[$i]);
400 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
401 $ret = $object->addline_batch($batch_line[$i], $array_options[$i]);
410 $ret = $extrafields->setOptionalsFromPost(
null, $object);
416 $ret = $object->create($user);
423 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
424 if (isModEnabled(
'stock')) {
425 $labelfieldmissing .=
'/'.$langs->transnoentitiesnoconv(
"Warehouse");
427 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
433 header(
"Location: card.php?id=".$object->id);
437 $_GET[
"commande_id"] =
GETPOST(
'commande_id',
'int');
440 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->creer) {
444 $result = $object->create_delivery($user);
448 header(
"Location: ".DOL_URL_ROOT.
'/delivery/card.php?action=create_delivery&id='.$result);
455 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' &&
456 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
457 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))
459 $object->fetch_thirdparty();
461 $result = $object->valid($user);
467 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
468 $outputlangs = $langs;
471 $newlang =
GETPOST(
'lang_id',
'aZ09');
474 $newlang = $object->thirdparty->default_lang;
476 if (!empty($newlang)) {
478 $outputlangs->setDefaultLang($newlang);
480 $model = $object->model_pdf;
481 $ret = $object->fetch($id);
483 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
489 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->rights->expedition->supprimer) {
490 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
491 $result = $object->cancel(0, $also_update_stock);
493 $result = $object->setStatut(-1);
497 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->expedition->supprimer) {
498 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
499 $result = $object->delete(0, $also_update_stock);
501 header(
"Location: ".DOL_URL_ROOT.
'/expedition/index.php');
515 } elseif ($action ==
'setdate_livraison' && !empty($user->rights->expedition->creer)) {
516 $datedelivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
519 $result = $object->setDeliveryDate($user, $datedelivery);
523 } elseif (($action ==
'settracking_number'
524 || $action ==
'settracking_url'
525 || $action ==
'settrueWeight'
526 || $action ==
'settrueWidth'
527 || $action ==
'settrueHeight'
528 || $action ==
'settrueDepth'
529 || $action ==
'setshipping_method_id')
530 && $user->rights->expedition->creer
535 if ($action ==
'settracking_number') {
536 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
538 if ($action ==
'settracking_url') {
539 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'int'));
541 if ($action ==
'settrueWeight') {
542 $object->trueWeight = trim(
GETPOST(
'trueWeight',
'int'));
543 $object->weight_units =
GETPOST(
'weight_units',
'int');
545 if ($action ==
'settrueWidth') {
546 $object->trueWidth = trim(
GETPOST(
'trueWidth',
'int'));
548 if ($action ==
'settrueHeight') {
549 $object->trueHeight = trim(
GETPOST(
'trueHeight',
'int'));
550 $object->size_units =
GETPOST(
'size_units',
'int');
552 if ($action ==
'settrueDepth') {
553 $object->trueDepth = trim(
GETPOST(
'trueDepth',
'int'));
555 if ($action ==
'setshipping_method_id') {
556 $object->shipping_method_id = trim(
GETPOST(
'shipping_method_id',
'int'));
560 if ($object->update($user) >= 0) {
561 header(
"Location: card.php?id=".$object->id);
568 } elseif ($action ==
'classifybilled') {
570 $result = $object->setBilled();
572 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
576 } elseif ($action ==
'classifyclosed') {
578 $result = $object->setClosed();
580 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
584 } elseif ($action ==
'deleteline' && !empty($line_id)) {
587 $lines = $object->lines;
589 $line->fk_expedition = $object->id;
591 $num_prod = count($lines);
592 for ($i = 0; $i < $num_prod; $i++) {
593 if ($lines[$i]->
id == $line_id) {
594 if (count($lines[$i]->details_entrepot) > 1) {
596 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
597 $line->id = $details_entrepot->line_id;
598 if (!$error && $line->delete($user) < 0) {
604 $line->id = $line_id;
605 if (!$error && $line->delete($user) < 0) {
610 unset($_POST[
"lineid"]);
614 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
619 } elseif ($action ==
'updateline' && $user->rights->expedition->creer &&
GETPOST(
'save')) {
626 $lines = $object->lines;
627 $num_prod = count($lines);
628 for ($i = 0; $i < $num_prod; $i++) {
629 if ($lines[$i]->
id == $line_id) {
630 $update_done =
false;
632 $line->fk_expedition = $object->id;
635 $line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
637 if (is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
638 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
639 unset($_POST[
"options_".$key]);
642 $line->fk_product = $lines[$i]->fk_product;
643 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
645 foreach ($lines[$i]->detail_batch as $detail_batch) {
647 $batch =
"batchl".$detail_batch->fk_expeditiondet.
"_".$detail_batch->fk_origin_stock;
648 $qty =
"qtyl".$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id;
649 $batch_id =
GETPOST($batch,
'int');
650 $batch_qty =
GETPOST($qty,
'int');
651 if (!empty($batch_id)) {
652 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
653 if ($lines[$i]->entrepot_id != 0) {
655 $line->entrepot_id = $lotStock->warehouseid;
659 if (empty($line->detail_batch)) {
660 $line->detail_batch =
new stdClass();
663 $line->detail_batch->fk_origin_stock = $batch_id;
664 $line->detail_batch->batch = $lotStock->batch;
665 $line->detail_batch->id = $detail_batch->id;
666 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
667 $line->detail_batch->qty = $batch_qty;
668 if ($line->update($user) < 0) {
679 unset($_POST[$batch]);
684 $batch =
"batchl".$line_id.
"_0";
685 $qty =
"qtyl".$line_id.
"_0";
686 $batch_id =
GETPOST($batch,
'int');
687 $batch_qty =
GETPOST($qty,
'int');
689 if ($batch_qty > 0 && !empty($batch_id)) {
690 if ($lotStock->fetch($batch_id) > 0) {
692 if ($lines[$i]->entrepot_id > 0) {
694 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
695 $lineIdToAddLot = $line_id;
697 } elseif (count($lines[$i]->details_entrepot) > 1) {
699 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
700 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
701 $lineIdToAddLot = $detail_entrepot->line_id;
705 if ($lineIdToAddLot) {
707 if ($line->fetch($lineIdToAddLot) > 0) {
708 $line->detail_batch->fk_origin_stock = $batch_id;
709 $line->detail_batch->batch = $lotStock->batch;
710 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
711 $line->detail_batch->qty = $batch_qty;
712 if ($line->update($user) < 0) {
724 $line->origin_line_id = $lines[$i]->origin_line_id;
725 $line->entrepot_id = $lotStock->warehouseid;
727 $line->detail_batch[0]->fk_origin_stock = $batch_id;
728 $line->detail_batch[0]->batch = $lotStock->batch;
729 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
730 $line->detail_batch[0]->qty = $batch_qty;
731 if ($object->create_line_batch($line, $line->array_options) < 0) {
744 if ($lines[$i]->fk_product > 0) {
746 if ($lines[$i]->entrepot_id > 0) {
748 $stockLocation =
"entl".$line_id;
749 $qty =
"qtyl".$line_id;
750 $line->id = $line_id;
751 $line->entrepot_id =
GETPOST($stockLocation,
'int');
752 $line->qty =
GETPOST($qty,
'int');
753 if ($line->update($user) < 0) {
757 unset($_POST[$stockLocation]);
759 } elseif (count($lines[$i]->details_entrepot) > 1) {
761 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
763 $stockLocation =
"entl".$detail_entrepot->line_id;
764 $qty =
"qtyl".$detail_entrepot->line_id;
765 $warehouse =
GETPOST($stockLocation,
'int');
766 if (!empty($warehouse)) {
767 $line->id = $detail_entrepot->line_id;
768 $line->entrepot_id = $warehouse;
769 $line->qty =
GETPOST($qty,
'int');
770 if ($line->update($user) < 0) {
777 unset($_POST[$stockLocation]);
781 } elseif (!isModEnabled(
'stock') && empty($conf->productbatch->enabled)) {
782 $qty =
"qtyl".$line_id;
783 $line->id = $line_id;
784 $line->qty =
GETPOST($qty,
'int');
785 $line->entrepot_id = 0;
786 if ($line->update($user) < 0) {
796 $qty =
"qtyl".$line_id;
797 $line->id = $line_id;
798 $line->qty =
GETPOST($qty,
'int');
799 $line->entrepot_id = 0;
800 if ($line->update($user) < 0) {
810 if (empty($update_done)) {
811 $line->id = $lines[$i]->id;
812 $line->insertExtraFields();
817 unset($_POST[
"lineid"]);
820 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
822 $outputlangs = $langs;
825 $newlang =
GETPOST(
'lang_id',
'aZ09');
828 $newlang = $object->thirdparty->default_lang;
830 if (!empty($newlang)) {
832 $outputlangs->setDefaultLang($newlang);
835 $ret = $object->fetch($object->id);
836 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
839 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
842 } elseif ($action ==
'updateline' && $user->rights->expedition->creer &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
843 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
847 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
853 $triggersendname =
'SHIPPING_SENTBYMAIL';
855 $mode =
'emailfromshipment';
856 $trackid =
'shi'.$object->id;
857 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
865$title = $object->ref.
' - '.$langs->trans(
"Shipment");
866if ($action ==
'create2') {
867 $title = $langs->trans(
"CreateShipment");
869$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
877$form =
new Form($db);
880if (isModEnabled(
'project')) {
884$product_static =
new Product($db);
886$warehousestatic =
new Entrepot($db);
888if ($action ==
'create2') {
891 print
'<br>'.$langs->trans(
"ShipmentCreationIsDoneFromOrder");
892 $action =
''; $id =
''; $ref =
'';
896if ($action ==
'create') {
906 $classname = ucfirst($origin);
908 $object =
new $classname($db);
909 if ($object->fetch($origin_id)) {
911 $soc->fetch($object->socid);
913 $author =
new User($db);
914 $author->fetch($object->user_author_id);
916 if (isModEnabled(
'stock')) {
920 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
921 print
'<input type="hidden" name="token" value="'.newToken().
'">';
922 print
'<input type="hidden" name="action" value="add">';
923 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
924 print
'<input type="hidden" name="origin_id" value="'.$object->id.
'">';
925 if (
GETPOST(
'entrepot_id',
'int')) {
926 print
'<input type="hidden" name="entrepot_id" value="'.GETPOST(
'entrepot_id',
'int').
'">';
931 print
'<table class="border centpercent">';
934 print
'<tr><td class="titlefieldcreate fieldrequired">';
935 if ($origin ==
'commande' && isModEnabled(
'commande')) {
936 print $langs->trans(
"RefOrder");
938 if ($origin ==
'propal' && isModEnabled(
"propal")) {
939 print $langs->trans(
"RefProposal");
941 print
'</td><td colspan="3">';
942 print $object->getNomUrl(1);
948 if ($origin ==
'commande') {
949 print $langs->trans(
'RefCustomerOrder');
950 } elseif ($origin ==
'propal') {
951 print $langs->trans(
'RefCustomerOrder');
953 print $langs->trans(
'RefCustomer');
955 print
'</td><td colspan="3">';
956 print
'<input type="text" name="ref_customer" value="'.$object->ref_client.
'" />';
961 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Company').
'</td>';
962 print
'<td colspan="3">'.$soc->getNomUrl(1).
'</td>';
966 if (isModEnabled(
'project')) {
967 $projectid =
GETPOST(
'projectid',
'int') ?
GETPOST(
'projectid',
'int') : 0;
968 if (empty($projectid) && !empty($object->fk_project)) {
969 $projectid = $object->fk_project;
971 if ($origin ==
'project') {
972 $projectid = ($originid ? $originid : 0);
975 $langs->load(
"projects");
977 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
978 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
979 $numprojet = $formproject->select_projects($soc->id, $projectid,
'projectid', 0);
980 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>';
986 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
987 print
'<td colspan="3">';
988 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
989 $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date);
990 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
995 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
996 print
'<td colspan="3">';
997 $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%');
998 print $doleditor->Create(1);
1002 if ($object->note_private && !$user->socid) {
1003 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
1004 print
'<td colspan="3">';
1005 $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%');
1006 print $doleditor->Create(1);
1012 print $langs->trans(
"Weight");
1013 print
'</td><td colspan="3">';
1014 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1015 print
'<input name="weight" size="4" value="'.GETPOST(
'weight',
'int').
'"> ';
1016 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units',
'int'), 0, 2);
1017 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1018 print $form->textwithpicto($text, $htmltext);
1022 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
1023 print
' </td><td colspan="3">';
1024 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1025 print
'<input name="sizeW" size="4" value="'.GETPOST(
'sizeW',
'int').
'">';
1026 print
' x <input name="sizeH" size="4" value="'.GETPOST(
'sizeH',
'int').
'">';
1027 print
' x <input name="sizeS" size="4" value="'.GETPOST(
'sizeS',
'int').
'">';
1029 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units',
'int'), 0, 2);
1030 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1031 print $form->textwithpicto($text, $htmltext);
1035 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1036 print
'<td colspan="3">';
1037 $expe->fetch_delivery_methods();
1038 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1039 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOST(
'shipping_method_id',
'int'), 1, 0, 0,
"", 1);
1041 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1043 print
"</td></tr>\n";
1046 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1047 print
'<td colspan="3">';
1048 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1049 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1050 print
"</td></tr>\n";
1053 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1054 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
1055 print $hookmanager->resPrint;
1057 if (empty($reshook)) {
1059 if ($object->fetch_optionals() > 0) {
1060 $expe->array_options = array_merge($expe->array_options, $object->array_options);
1062 print $expe->showOptionals($extrafields,
'edit', $parameters);
1067 if (isModEnabled(
'incoterm')) {
1069 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $object->label_incoterms, 1).
'</label></td>';
1070 print
'<td colspan="3" class="maxwidthonsmartphone">';
1071 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1072 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1077 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1079 if (count($list) > 1) {
1080 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1081 print
'<td colspan="3">';
1082 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1083 print $form->selectarray(
'model', $list, $conf->global->EXPEDITION_ADDON_PDF);
1084 print
"</td></tr>\n";
1094 $numAsked = count($object->lines);
1096 print
'<script type="text/javascript">'.
"\n";
1097 print
'jQuery(document).ready(function() {'.
"\n";
1098 print
'jQuery("#autofill").click(function() {';
1100 while ($i < $numAsked) {
1101 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1102 if (isModEnabled(
'productbatch')) {
1103 print
'jQuery("#qtyl'.$i.
'_'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1107 print
'return false; });'.
"\n";
1108 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);'.
"\n";
1109 print
'return false; });'.
"\n";
1111 print
'</script>'.
"\n";
1115 print
'<table class="noborder centpercent">';
1118 $object->loadExpeditions();
1121 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1124 print
'<tr class="liste_titre">';
1125 print
'<td>'.$langs->trans(
"Description").
'</td>';
1126 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1127 print
'<td class="center">'.$langs->trans(
"QtyShipped").
'</td>';
1128 print
'<td class="center">'.$langs->trans(
"QtyToShip");
1129 if (empty($conf->productbatch->enabled)) {
1130 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"').
'</a>';
1135 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Reset"),
'eraser').
'</span>';
1137 if (isModEnabled(
'stock')) {
1138 if (empty($conf->productbatch->enabled)) {
1139 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1141 print
'<td class="left">'.$langs->trans(
"Warehouse").
' / '.$langs->trans(
"Batch").
' ('.$langs->trans(
"Stock").
')</td>';
1147 $warehouse_id =
GETPOST(
'entrepot_id',
'int');
1148 $warehousePicking = array();
1150 if ($warehouse_id > 0) {
1151 $warehousePicking[] = $warehouse_id;
1153 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1157 while ($indiceAsked < $numAsked) {
1160 $line = $object->lines[$indiceAsked];
1162 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1163 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1168 if (empty($reshook)) {
1170 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1173 if (!empty($line->date_start)) {
1176 if (!empty($line->date_end)) {
1180 print
'<!-- line for order line '.$line->id.
' -->'.
"\n";
1181 print
'<tr class="oddeven" id="row-'.$line->id.
'">'.
"\n";
1184 if ($line->fk_product > 0) {
1185 $res = $product->fetch($line->fk_product);
1189 $product->load_stock(
'warehouseopen');
1193 print
'<a name="'.$line->id.
'"></a>';
1196 $product_static->type = $line->fk_product_type;
1197 $product_static->id = $line->fk_product;
1198 $product_static->ref = $line->ref;
1199 $product_static->status = $line->product_tosell;
1200 $product_static->status_buy = $line->product_tobuy;
1201 $product_static->status_batch = $line->product_tobatch;
1203 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
1205 $text = $product_static->getNomUrl(1);
1206 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1209 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
1212 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1215 if ($showdescinproductdesc) {
1216 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1223 $text =
img_object($langs->trans(
'Service'),
'service');
1225 $text =
img_object($langs->trans(
'Product'),
'product');
1228 if (!empty($line->label)) {
1229 $text .=
' <strong>'.$line->label.
'</strong>';
1230 print $form->textwithtooltip($text, $line->desc, 3,
'',
'', $i);
1232 print $text.
' '.nl2br($line->desc);
1236 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1242 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1247 print
'<td class="center">'.$line->qty;
1248 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1249 print
''.$unit_order.
'</td>';
1250 $qtyProdCom = $line->qty;
1253 print
'<td class="center">';
1254 $quantityDelivered = isset($object->expeditions[$line->id]) ? $object->expeditions[$line->id] :
'';
1255 print $quantityDelivered;
1256 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1257 print
''.$unit_order.
'</td>';
1260 $quantityAsked = $line->qty;
1261 if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1262 $quantityToBeDelivered = 0;
1264 if (is_numeric($quantityDelivered)) {
1265 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
1267 $quantityToBeDelivered = $quantityAsked;
1271 $warehouseObject =
null;
1272 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !isModEnabled(
'stock')) {
1273 print
'<!-- Case warehouse already known or product not a predefined product -->';
1275 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
1276 $deliverableQty = min($quantityToBeDelivered, $stock);
1277 if ($deliverableQty < 0) {
1278 $deliverableQty = 0;
1280 if (empty($conf->productbatch->enabled) || !$product->hasbatch()) {
1282 print
'<td class="center">';
1283 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1284 if (
GETPOST(
'qtyl'.$indiceAsked,
'int')) {
1285 $deliverableQty =
GETPOST(
'qtyl'.$indiceAsked,
'int');
1287 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1288 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" class="qtyl center" type="text" size="4" value="'.$deliverableQty.
'">';
1291 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1292 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1295 print $langs->trans(
"NA");
1300 if (isModEnabled(
'stock')) {
1301 print
'<td class="left">';
1302 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1304 $ent =
"entl".$indiceAsked;
1305 $idl =
"idl".$indiceAsked;
1306 $tmpentrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') : $warehouse_id;
1307 if ($line->fk_product > 0) {
1308 print
'<!-- Show warehouse selection -->';
1314 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200',
'', 1, $stockMin,
'stock DESC, e.ref');
1316 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
1318 if ($stock < $quantityToBeDelivered) {
1319 print
' '.img_warning($langs->trans(
"StockTooLow"));
1324 print $langs->trans(
"Service");
1332 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) {
1333 $product->get_sousproduits_arbo();
1334 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1335 if (count($prods_arbo) > 0) {
1336 foreach ($prods_arbo as $key => $value) {
1339 if ($value[
'stock'] < $value[
'stock_alert']) {
1342 print
"<tr class=\"oddeven\"><td> ->
1343 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1344 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1345 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td></tr>";
1351 print
'<td></td><td></td></tr>';
1352 print
'<!-- Case product need lot -->';
1354 $staticwarehouse =
new Entrepot($db);
1355 if ($warehouse_id > 0) {
1356 $staticwarehouse->fetch($warehouse_id);
1362 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1363 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1367 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1368 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1369 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1371 $batchStock = + $dbatch->qty;
1372 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1375 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1376 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1378 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1379 $alreadyQtyBatchSetted[$line->fk_product] = array();
1382 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1383 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1386 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1389 if ($deliverableQty < 0) $deliverableQty = 0;
1391 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1392 if (GETPOSTISSET($inputName)) {
1393 $deliverableQty =
GETPOST($inputName,
'int');
1396 $tooltipClass = $tooltipTitle =
'';
1397 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1398 $tooltipClass =
' classfortooltip';
1399 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1401 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1403 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1405 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1406 print
'<td colspan="3" ></td><td class="center">';
1408 print
'<input class="qtyl '.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1411 print
'<!-- Show details of lot -->';
1412 print
'<td class="left">';
1414 print $staticwarehouse->getNomUrl(0).
' / ';
1416 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1419 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
1420 if (empty($conf->global->PRODUCT_DISABLE_SELLBY) && !empty($dbatch->sellby)) {
1421 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1423 if (empty($conf->global->PRODUCT_DISABLE_EATBY) && !empty($dbatch->eatby)) {
1424 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1426 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
1430 $quantityToBeDelivered -= $deliverableQty;
1431 if ($quantityToBeDelivered < 0) {
1432 $quantityToBeDelivered = 0;
1438 print
'<!-- Case there is no details of lot at all -->';
1439 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1440 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0" disabled="disabled"> ';
1443 print
'<td class="left">';
1444 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
1450 if (empty($conf->productbatch->enabled) || !$product->hasbatch()) {
1451 print
'<!-- Case warehouse not already known and product does not need lot -->';
1452 print
'<td></td><td></td></tr>'.
"\n";
1454 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1459 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1460 if ($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1464 $tmpwarehouseObject =
new Entrepot($db);
1465 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1467 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1472 $tmpwarehouseObject->fetch($warehouse_id);
1473 if ($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1474 $stock = + $stock_warehouse->real;
1475 $deliverableQty = min($quantityToBeDelivered, $stock);
1476 $deliverableQty = max(0, $deliverableQty);
1478 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1479 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked='.$indiceAsked.
') -->';
1480 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1481 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1482 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
1484 if (!isset($alreadyQtySetted[$line->fk_product])) {
1485 $alreadyQtySetted[$line->fk_product] = array();
1488 $deliverableQty = min($quantityToBeDelivered, $stock);
1491 if ($deliverableQty < 0) $deliverableQty = 0;
1493 $tooltipClass = $tooltipTitle =
'';
1494 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1495 $tooltipClass =
' classfortooltip';
1496 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1498 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
1501 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1503 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1504 if (GETPOSTISSET($inputName)) {
1505 $deliverableQty =
GETPOST($inputName,
'int');
1508 print
'<input class="qtyl'.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1509 print
'<input name="ent1'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$warehouse_id.
'">';
1512 print
'<input name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1515 print $langs->trans(
"NA");
1520 if (isModEnabled(
'stock')) {
1521 print
'<td class="left">';
1522 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1523 print $tmpwarehouseObject->getNomUrl(0).
' ';
1525 print
'<!-- Show details of stock -->';
1526 print
'('.$stock.
')';
1528 print $langs->trans(
"Service");
1532 $quantityToBeDelivered -= $deliverableQty;
1533 if ($quantityToBeDelivered < 0) {
1534 $quantityToBeDelivered = 0;
1541 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) {
1542 $product->get_sousproduits_arbo();
1543 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1544 if (count($prods_arbo) > 0) {
1545 foreach ($prods_arbo as $key => $value) {
1548 if ($value[
'stock'] < $value[
'stock_alert']) {
1551 print
'<tr class"oddeven"><td>';
1552 print
" ->
1553 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1554 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1555 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1561 print
'<!-- Case warehouse not already known and product need lot -->';
1562 print
'<td></td><td></td></tr>';
1565 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1567 $tmpwarehouseObject =
new Entrepot($db);
1572 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1573 if (($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) && (count($stock_warehouse->detail_batch))) {
1574 $nbofsuggested+=count($stock_warehouse->detail_batch);
1578 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1580 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1585 $tmpwarehouseObject->fetch($warehouse_id);
1586 if (($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) && (count($stock_warehouse->detail_batch))) {
1587 foreach ($stock_warehouse->detail_batch as $dbatch) {
1588 $batchStock = + $dbatch->qty;
1589 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1590 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1592 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1593 $alreadyQtyBatchSetted[$line->fk_product] = array();
1596 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1597 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1600 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1603 if ($deliverableQty < 0) $deliverableQty = 0;
1605 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1606 if (GETPOSTISSET($inputName)) {
1607 $deliverableQty =
GETPOST($inputName,
'int');
1610 $tooltipClass = $tooltipTitle =
'';
1611 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1612 $tooltipClass =
' classfortooltip';
1613 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1615 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1617 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1619 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'><td colspan="3"></td><td class="center">';
1620 print
'<input class="qtyl '.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="'.$inputName.
'" id="'.$inputName.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1623 print
'<td class="left">';
1625 print $tmpwarehouseObject->getNomUrl(0).
' / ';
1627 print
'<!-- Show details of lot -->';
1628 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1631 print $langs->trans(
"Batch").
': ';
1632 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
1634 print $productlotObject->getNomUrl(1);
1636 print
'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
1638 if (empty($conf->global->PRODUCT_DISABLE_SELLBY) && !empty($dbatch->sellby)) {
1639 print
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1641 if (empty($conf->global->PRODUCT_DISABLE_EATBY) && !empty($dbatch->eatby)) {
1642 print
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1644 print
' ('.$dbatch->qty.
')';
1645 $quantityToBeDelivered -= $deliverableQty;
1646 if ($quantityToBeDelivered < 0) {
1647 $quantityToBeDelivered = 0;
1657 $warehouse_selected_id =
GETPOST(
'entrepot_id',
'int');
1659 print
'<!-- line not shown yet, we show it -->';
1660 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1662 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1664 if (isModEnabled(
'productbatch') && $product->hasbatch()) {
1665 $disabled =
'disabled="disabled"';
1667 if ($warehouse_selected_id <= 0) {
1668 $disabled =
'disabled="disabled"';
1670 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').
'> ';
1671 if (empty($disabled) && !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1672 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
1675 print $langs->trans(
"NA");
1679 print
'<td class="left">';
1680 if ($line->product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1681 if ($warehouse_selected_id > 0) {
1682 $warehouseObject =
new Entrepot($db);
1683 $warehouseObject->fetch($warehouse_selected_id);
1684 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
1686 if ($line->fk_product) {
1687 print
img_warning().
' '.$langs->trans(
"StockTooLow");
1693 print $langs->trans(
"Service");
1702 if (!empty($extrafields)) {
1708 $srcLine->id = $line->id;
1709 $srcLine->fetch_optionals();
1711 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
1713 print $expLine->showOptionals($extrafields,
'edit', array(
'style'=>
'class="drag drop oddeven"',
'colspan'=>$colspan), $indiceAsked,
'', 1);
1724 print $form->buttonsSaveCancel(
"Create");
1733} elseif ($object->id > 0) {
1739 $lines = $object->lines;
1741 $num_prod = count($lines);
1743 if (!empty($object->origin) && $object->origin_id > 0) {
1744 $typeobject = $object->origin;
1745 $origin = $object->origin;
1746 $origin_id = $object->origin_id;
1747 $object->fetch_origin();
1751 $soc->fetch($object->socid);
1753 $res = $object->fetch_optionals();
1756 print
dol_get_fiche_head($head,
'shipping', $langs->trans(
"Shipment"), -1, $object->picto);
1761 if ($action ==
'delete') {
1762 $formquestion = array();
1764 $formquestion = array(
1766 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
1767 'name' =>
'alsoUpdateStock',
1768 'type' =>
'checkbox',
1773 $formconfirm = $form->formconfirm(
1774 $_SERVER[
'PHP_SELF'].
'?id='.$object->id,
1775 $langs->trans(
'DeleteSending'),
1776 $langs->trans(
"ConfirmDeleteSending", $object->ref),
1785 if ($action ==
'valid') {
1786 $objectref = substr($object->ref, 1, 4);
1787 if ($objectref ==
'PROV') {
1788 $numref = $object->getNextNumRef($soc);
1790 $numref = $object->ref;
1793 $text = $langs->trans(
"ConfirmValidateSending", $numref);
1795 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementWillBeRecorded").
'.';
1797 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementNotYetRecorded").
'.';
1800 if (isModEnabled(
'notification')) {
1801 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1802 $notify =
new Notify($db);
1804 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE', $object->socid, $object);
1807 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 250);
1810 if ($action ==
'cancel') {
1811 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending", $object->ref),
'confirm_cancel',
'', 0, 1);
1815 $parameters = array(
'formConfirm' => $formconfirm);
1816 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1817 if (empty($reshook)) {
1818 $formconfirm .= $hookmanager->resPrint;
1819 } elseif ($reshook > 0) {
1820 $formconfirm = $hookmanager->resPrint;
1828 $tmparray = $object->getTotalWeightVolume();
1829 $totalWeight = $tmparray[
'weight'];
1830 $totalVolume = $tmparray[
'volume'];
1833 if ($typeobject ==
'commande' && $object->$typeobject->id && isModEnabled(
'commande')) {
1835 $objectsrc->fetch($object->$typeobject->id);
1837 if ($typeobject ==
'propal' && $object->$typeobject->id && isModEnabled(
"propal")) {
1838 $objectsrc =
new Propal($db);
1839 $objectsrc->fetch($object->$typeobject->id);
1843 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1844 $morehtmlref =
'<div class="refidno">';
1846 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'', 0, 1);
1847 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer,
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE :
''),
'', null, null,
'', 1);
1849 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
1851 if (isModEnabled(
'project')) {
1852 $langs->load(
"projects");
1853 $morehtmlref .=
'<br>';
1855 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1856 if ($action !=
'classify') {
1857 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1859 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1861 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
1863 $proj->fetch($objectsrc->fk_project);
1864 $morehtmlref .= $proj->getNomUrl(1);
1866 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1871 $morehtmlref .=
'</div>';
1874 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1877 print
'<div class="fichecenter">';
1878 print
'<div class="fichehalfleft">';
1879 print
'<div class="underbanner clearboth"></div>';
1881 print
'<table class="border tableforfield" width="100%">';
1884 if ($typeobject ==
'commande' && $object->$typeobject->id && isModEnabled(
'commande')) {
1886 print $langs->trans(
"RefOrder").
'</td>';
1887 print
'<td colspan="3">';
1888 print $objectsrc->getNomUrl(1,
'commande');
1892 if ($typeobject ==
'propal' && $object->$typeobject->id && isModEnabled(
"propal")) {
1894 print $langs->trans(
"RefProposal").
'</td>';
1895 print
'<td colspan="3">';
1896 print $objectsrc->getNomUrl(1,
'expedition');
1902 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
1903 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour").
"</td>\n";
1907 print
'<tr><td height="10">';
1908 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1909 print $langs->trans(
'DateDeliveryPlanned');
1912 if ($action !=
'editdate_livraison') {
1913 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>';
1915 print
'</tr></table>';
1916 print
'</td><td colspan="2">';
1917 if ($action ==
'editdate_livraison') {
1918 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1919 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1920 print
'<input type="hidden" name="action" value="setdate_livraison">';
1921 print $form->selectDate($object->date_delivery ? $object->date_delivery : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
1922 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
1925 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
1932 print $form->editfieldkey(
"Weight",
'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer);
1933 print
'</td><td colspan="3">';
1935 if ($action ==
'edittrueWeight') {
1936 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1937 print
'<input name="action" value="settrueWeight" type="hidden">';
1938 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
1939 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1940 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text" class="width50 valignmiddle">';
1941 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
1942 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
1943 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1946 print $object->trueWeight;
1947 print ($object->trueWeight && $object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight", $object->weight_units) :
'';
1951 if ($totalWeight > 0) {
1952 if (!empty($object->trueWeight)) {
1953 print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
1955 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');
1956 if (!empty($object->trueWeight)) {
1963 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1964 print $form->editfieldval(
"Width",
'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer);
1965 print ($object->trueWidth && $object->width_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->width_units) :
'';
1969 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1970 if ($action ==
'edittrueHeight') {
1971 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1972 print
'<input name="action" value="settrueHeight" type="hidden">';
1973 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
1974 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1975 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text" class="width50">';
1976 print $formproduct->selectMeasuringUnits(
"size_units",
"size", $object->size_units, 0, 2);
1977 print
' <input class="button smallpaddingimp" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
1978 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1981 print $object->trueHeight;
1982 print ($object->trueHeight && $object->height_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->height_units) :
'';
1988 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1989 print $form->editfieldval(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer);
1990 print ($object->trueDepth && $object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->depth_units) :
'';
1995 print $langs->trans(
"Volume");
1997 print
'<td colspan="3">';
1998 $calculatedVolume = 0;
2000 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
2001 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
2002 $volumeUnit = $object->size_units * 3;
2005 if ($calculatedVolume > 0) {
2006 if ($volumeUnit < 50) {
2007 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');
2012 if ($totalVolume > 0) {
2013 if ($calculatedVolume) {
2014 print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
2016 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');
2018 if ($calculatedVolume) {
2027 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2032 print
'<div class="fichehalfright">';
2033 print
'<div class="underbanner clearboth"></div>';
2035 print
'<table class="border centpercent tableforfield">';
2038 print
'<tr><td height="10">';
2039 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2040 print $langs->trans(
'SendingMethod');
2043 if ($action !=
'editshipping_method_id') {
2044 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>';
2046 print
'</tr></table>';
2047 print
'</td><td colspan="2">';
2048 if ($action ==
'editshipping_method_id') {
2049 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2050 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2051 print
'<input type="hidden" name="action" value="setshipping_method_id">';
2052 $object->fetch_delivery_methods();
2053 print $form->selectarray(
"shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0,
"", 1);
2055 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2057 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2060 if ($object->shipping_method_id > 0) {
2062 $code = $langs->getLabelFromKey($db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
2063 print $langs->trans(
"SendingMethod".strtoupper($code));
2070 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
2071 print $form->editfieldval(
"TrackingNumber",
'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer,
'safehtmlstring', $object->tracking_number);
2075 if (isModEnabled(
'incoterm')) {
2077 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2078 print $langs->trans(
'IncotermLabel');
2079 print
'<td><td class="right">';
2080 if ($user->rights->expedition->creer) {
2081 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit().
'</a>';
2085 print
'</td></tr></table>';
2087 print
'<td colspan="3">';
2088 if ($action !=
'editincoterm') {
2089 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2091 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2097 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
2098 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2099 print $hookmanager->resPrint;
2106 print
'<div class="clearboth"></div>';
2111 if ($action ==
'editline') {
2112 print
' <form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$line_id.
'" method="POST">
2113 <input type="hidden" name="token" value="' . newToken().
'">
2114 <input type="hidden" name="action" value="updateline">
2115 <input type="hidden" name="mode" value="">
2116 <input type="hidden" name="id" value="' . $object->id.
'">
2121 print
'<div class="div-table-responsive-no-min">';
2122 print
'<table class="noborder" width="100%" id="tablelines" >';
2124 print
'<tr class="liste_titre">';
2126 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
2127 print
'<td width="5" class="center linecolnum"> </td>';
2130 print
'<td class="linecoldescription" >'.$langs->trans(
"Products").
'</td>';
2132 print
'<td class="center linecolqty">'.$langs->trans(
"QtyOrdered").
'</td>';
2133 if ($origin && $origin_id > 0) {
2134 print
'<td class="center linecolqtyinothershipments">'.$langs->trans(
"QtyInOtherShipments").
'</td>';
2136 if ($action ==
'editline') {
2138 if (!isModEnabled(
'stock')) {
2141 if (empty($conf->productbatch->enabled)) {
2144 print
'<td class="center linecoleditlineotherinfo" colspan="'.$editColspan.
'">';
2145 if ($object->statut <= 1) {
2146 print $langs->trans(
"QtyToShip").
' - ';
2148 print $langs->trans(
"QtyShipped").
' - ';
2150 if (isModEnabled(
'stock')) {
2151 print $langs->trans(
"WarehouseSource").
' - ';
2153 if (isModEnabled(
'productbatch')) {
2154 print $langs->trans(
"Batch");
2158 if ($object->statut <= 1) {
2159 print
'<td class="center linecolqtytoship">'.$langs->trans(
"QtyToShip").
'</td>';
2161 print
'<td class="center linecolqtyshipped">'.$langs->trans(
"QtyShipped").
'</td>';
2163 if (isModEnabled(
'stock')) {
2164 print
'<td class="left linecolwarehousesource">'.$langs->trans(
"WarehouseSource").
'</td>';
2167 if (isModEnabled(
'productbatch')) {
2168 print
'<td class="left linecolbatch">'.$langs->trans(
"Batch").
'</td>';
2171 print
'<td class="center linecolweight">'.$langs->trans(
"CalculatedWeight").
'</td>';
2172 print
'<td class="center linecolvolume">'.$langs->trans(
"CalculatedVolume").
'</td>';
2174 if ($object->statut == 0) {
2175 print
'<td class="linecoledit"></td>';
2176 print
'<td class="linecoldelete" width="10"></td>';
2181 $outputlangs = $langs;
2183 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
2184 $object->fetch_thirdparty();
2186 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
2187 $newlang =
GETPOST(
'lang_id',
'aZ09');
2189 if (empty($newlang)) {
2190 $newlang = $object->thirdparty->default_lang;
2192 if (!empty($newlang)) {
2193 $outputlangs =
new Translate(
"", $conf);
2194 $outputlangs->setDefaultLang($newlang);
2199 $alreadysent = array();
2200 if ($origin && $origin_id > 0) {
2201 $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";
2202 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot";
2203 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
2205 $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';
2206 $sql .=
', p.description as product_desc';
2207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2208 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
2209 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
2211 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2212 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
2213 $sql .=
" AND obj.fk_".$origin.
" = ".((int) $origin_id);
2214 $sql .=
" AND obj.rowid = ed.fk_origin_line";
2215 $sql .=
" AND ed.fk_expedition = e.rowid";
2217 $sql .=
" ORDER BY obj.fk_product";
2219 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
2220 $resql = $db->query($sql);
2222 $num = $db->num_rows($resql);
2226 $obj = $db->fetch_object($resql);
2229 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
2230 'shipment_ref'=>$obj->shipment_ref,
'shipment_id'=>$obj->shipment_id,
'warehouse'=>$obj->fk_entrepot,
'qty_shipped'=>$obj->qty_shipped,
2231 'product_tosell'=>$obj->product_tosell,
'product_tobuy'=>$obj->product_tobuy,
'product_tobatch'=>$obj->product_tobatch,
2232 'date_valid'=>$db->jdate($obj->date_valid),
'date_delivery'=>$db->jdate($obj->date_delivery));
2243 for ($i = 0; $i < $num_prod; $i++) {
2244 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
2245 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
2250 if (empty($reshook)) {
2251 print
'<!-- origin line id = '.$lines[$i]->origin_line_id.
' -->';
2252 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'" >';
2255 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
2256 print
'<td class="center linecolnum">'.($i + 1).
'</td>';
2260 if ($lines[$i]->fk_product > 0) {
2262 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
2264 $prod->fetch($lines[$i]->fk_product);
2265 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
2267 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
2270 print
'<td class="linecoldescription">';
2273 $product_static->type = $lines[$i]->fk_product_type;
2274 $product_static->id = $lines[$i]->fk_product;
2275 $product_static->ref = $lines[$i]->ref;
2276 $product_static->status = $lines[$i]->product_tosell;
2277 $product_static->status_buy = $lines[$i]->product_tobuy;
2278 $product_static->status_batch = $lines[$i]->product_tobatch;
2280 $product_static->weight = $lines[$i]->weight;
2281 $product_static->weight_units = $lines[$i]->weight_units;
2282 $product_static->length = $lines[$i]->length;
2283 $product_static->length_units = $lines[$i]->length_units;
2284 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
2285 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
2286 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
2287 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
2288 $product_static->surface = $lines[$i]->surface;
2289 $product_static->surface_units = $lines[$i]->surface_units;
2290 $product_static->volume = $lines[$i]->volume;
2291 $product_static->volume_units = $lines[$i]->volume_units;
2293 $text = $product_static->getNomUrl(1);
2294 $text .=
' - '.$label;
2296 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
2297 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
2303 print
'<td class="linecoldescription" >';
2305 $text =
img_object($langs->trans(
'Service'),
'service');
2307 $text =
img_object($langs->trans(
'Product'),
'product');
2310 if (!empty($lines[$i]->label)) {
2311 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2312 print $form->textwithtooltip($text, $lines[$i]->
description, 3,
'',
'', $i);
2322 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2327 print
'<td class="center linecolqty">'.$lines[$i]->qty_asked.
' '.$unit_order.
'</td>';
2330 if ($origin && $origin_id > 0) {
2331 print
'<td class="linecolqtyinothershipments center nowrap">';
2333 $qtyalreadysent = 0;
2334 foreach ($alreadysent as $key => $val) {
2335 if ($lines[$i]->fk_origin_line == $key) {
2337 foreach ($val as $shipmentline_id => $shipmentline_var) {
2338 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
2344 $htmltooltip .=
'<br>';
2346 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
2347 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
2348 $htmltooltip .=
' - '.$shipmentline_var[
'qty_shipped'];
2349 $htmltooltip .=
' - '.$langs->trans(
"DateValidation").
' : '.(empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
2356 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
2359 $htmltooltip = $langs->trans(
"QtyInOtherShipments").
'...<br><br>'.$htmltooltip.
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
2363 print $form->textwithpicto($qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip'.$lines[$i]->
id);
2367 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2369 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding centpercent">';
2370 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
2371 print
'<!-- case edit 1 -->';
2373 foreach ($lines[$i]->detail_batch as $detail_batch) {
2376 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>';
2378 if ($lines[$i]->entrepot_id == 0) {
2380 $line->fetch($detail_batch->fk_expeditiondet);
2382 $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id;
2383 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>';
2389 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'_0" id="qtyl'.$line_id.
'_0" type="text" size="4" value="0"></td>';
2391 print
'<td>'.$formproduct->selectLotStock(
'',
'batchl'.$line_id.
'_0',
'', 1, 0, $lines[$i]->fk_product).
'</td>';
2393 } elseif (isModEnabled(
'stock')) {
2394 if ($lines[$i]->fk_product > 0) {
2395 if ($lines[$i]->entrepot_id > 0) {
2396 print
'<!-- case edit 2 -->';
2399 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>';
2401 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2403 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2405 } elseif (count($lines[$i]->details_entrepot) > 1) {
2406 print
'<!-- case edit 3 -->';
2407 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2410 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>';
2412 print
'<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl'.$detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2414 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2418 print
'<!-- case edit 4 -->';
2419 print
'<tr><td colspan="3">'.$langs->trans(
"NotEnoughStock").
'</td></tr>';
2422 print
'<!-- case edit 5 -->';
2425 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>';
2432 } elseif (!isModEnabled(
'stock') && empty($conf->productbatch->enabled)) {
2433 print
'<!-- case edit 6 -->';
2436 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2444 print
'</table></td>';
2447 print
'<td class="linecolqtytoship center">'.$lines[$i]->qty_shipped.
' '.$unit_order.
'</td>';
2450 if (isModEnabled(
'stock')) {
2451 print
'<td class="linecolwarehousesource left">';
2452 if ($lines[$i]->entrepot_id > 0) {
2454 $entrepot->fetch($lines[$i]->entrepot_id);
2455 print $entrepot->getNomUrl(1);
2456 } elseif (count($lines[$i]->details_entrepot) > 1) {
2458 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2459 if ($detail_entrepot->entrepot_id > 0) {
2461 $entrepot->fetch($detail_entrepot->entrepot_id);
2462 $detail .= $langs->trans(
"DetailWarehouseFormat", $entrepot->label, $detail_entrepot->qty_shipped).
'<br>';
2465 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
"DetailWarehouseNumber"), $detail);
2471 if (isModEnabled(
'productbatch')) {
2472 if (isset($lines[$i]->detail_batch)) {
2473 print
'<!-- Detail of lot -->';
2474 print
'<td class="linecolbatch">';
2475 if ($lines[$i]->product_tobatch) {
2477 foreach ($lines[$i]->detail_batch as $dbatch) {
2478 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
2479 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
2480 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
2482 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
2483 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
2485 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
2488 print $form->textwithtooltip(
img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $detail);
2490 print $langs->trans(
"NA");
2494 print
'<td class="linecolbatch" ></td>';
2500 print
'<td class="center linecolweight">';
2502 print $lines[$i]->weight * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
2509 print
'<td class="center linecolvolume">';
2511 print $lines[$i]->volume * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
2520 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2521 print
'<td class="center" colspan="2" valign="middle">';
2522 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2523 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2527 print
'<td class="linecoledit center">';
2528 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_edit().
'</a>';
2530 print
'<td class="linecoldelete" width="10">';
2531 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_delete().
'</a>';
2535 if (!empty($rowExtrafieldsStart)) {
2536 print $rowExtrafieldsStart;
2537 print $rowExtrafieldsView;
2545 if (!empty($extrafields)) {
2547 if ($origin && $origin_id > 0) {
2550 if (isModEnabled(
'productbatch')) {
2553 if (isModEnabled(
'stock')) {
2558 $line->fetch_optionals();
2561 if ($action ==
'editline' && $line->id == $line_id) {
2562 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'', 0,
'card');
2564 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'', 0,
'card');
2572 if (empty($num_prod)) {
2573 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")).
'</span></td></tr>';
2584 $object->fetchObjectLinked($object->id, $object->element);
2591 if (($user->socid == 0) && ($action !=
'presend')) {
2592 print
'<div class="tabsAction">';
2594 $parameters = array();
2595 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2597 if (empty($reshook)) {
2599 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
2600 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate))) {
2601 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=valid&token='.newToken().
'&id='.$object->id,
'');
2603 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2610 if ($user->hasRight(
'expedition',
'creer')) {
2611 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?action=setdraft&token='.newToken().
'&id='.$object->id,
'');
2615 if ($user->hasRight(
'expedition',
'creer')) {
2616 if (isModEnabled(
'facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2617 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnbilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.newToken().
'&id='.$object->id,
'');
2619 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.newToken().
'&id='.$object->id,
'');
2625 if (empty($user->socid)) {
2626 if ($object->statut > 0) {
2627 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) {
2628 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2630 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2637 if ($user->hasRight(
'facture',
'creer')) {
2640 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2647 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"].
'?action=create_delivery&token='.newToken().
'&id='.$object->id,
'');
2651 if ($user->rights->expedition->creer && $object->statut > 0 && !$object->billed) {
2652 $label =
"Close"; $paramaction =
'classifyclosed';
2654 if (isModEnabled(
'facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2655 $label =
"ClassifyBilled";
2656 $paramaction =
'classifybilled';
2658 print
dolGetButtonAction(
'', $langs->trans($label),
'default', $_SERVER[
"PHP_SELF"].
'?action='. $paramaction .
'&token='.newToken().
'&id='.$object->id,
'');
2664 if ($user->rights->expedition->supprimer) {
2665 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"].
'?action=cancel&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2670 if ($user->rights->expedition->supprimer) {
2671 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.$object->id,
'');
2683 if ($action !=
'presend' && $action !=
'editline') {
2684 print
'<div class="fichecenter"><div class="fichehalfleft">';
2687 $filedir = $conf->expedition->dir_output.
"/sending/".$objectref;
2689 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2691 $genallowed = $user->rights->expedition->lire;
2692 $delallowed = $user->rights->expedition->creer;
2694 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2698 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'shipping'));
2699 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2702 print
'</div><div class="fichehalfright">';
2705 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2707 $somethingshown =
$formactions->showactions($object,
'shipping', $socid, 1);
2709 print
'</div></div>';
2718 if (
GETPOST(
'modelselected')) {
2719 $action =
'presend';
2723 $modelmail =
'shipping_send';
2724 $defaulttopic = $langs->trans(
'SendShippingRef');
2725 $diroutput = $conf->expedition->dir_output.
'/sending';
2726 $trackid =
'shi'.$object->id;
2728 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage shipments.
const STATUS_DRAFT
Draft status.
const STATUS_CLOSED
Closed status.
const STATUS_VALIDATED
Validated status.
Classe to manage lines of shipment.
CRUD class for batch number management within shipment.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
Class to manage notifications.
Class to manage order lines.
Class to manage products or services.
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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
measuringUnitString($unit, $measuring_style='', $scale='', $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.