37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
49 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
50 if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
51 if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
52 if (!empty($conf->projet->enabled)) {
53 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
58 $langs->loadLangs(array(
"sendings",
"companies",
"bills",
'deliveries',
'orders',
'stocks',
'other',
'propal'));
60 if (!empty($conf->incoterm->enabled)) $langs->load(
'incoterm');
61 if (!empty($conf->productbatch->enabled)) $langs->load(
'productbatch');
63 $origin =
GETPOST(
'origin',
'alpha') ?
GETPOST(
'origin',
'alpha') :
'expedition';
66 if (empty($origin_id)) $origin_id =
GETPOST(
'origin_id',
'int');
67 if (empty($origin_id)) $origin_id =
GETPOST(
'object_id',
'int');
69 $line_id =
GETPOST(
'lineid',
'int') ?
GETPOST(
'lineid',
'int') :
'';
73 if ($user->socid) $socid = $user->socid;
75 if ($origin ==
'expedition') $result =
restrictedArea($user, $origin, $id);
78 if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read))
accessforbidden();
81 $action =
GETPOST(
'action',
'alpha');
82 $confirm =
GETPOST(
'confirm',
'alpha');
83 $cancel =
GETPOST(
'cancel',
'alpha');
86 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
95 $extrafields->fetch_name_optionals_label($object->table_element);
96 $extrafields->fetch_name_optionals_label($object->table_element_line);
97 $extrafields->fetch_name_optionals_label($objectorder->table_element_line);
100 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
103 $hookmanager->initHooks(array(
'expeditioncard',
'globalcard'));
105 $permissiondellink = $user->rights->expedition->delivery->creer;
108 $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'));
115 $parameters = array();
116 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
117 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
127 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
130 $upload_dir = $conf->expedition->dir_output.
'/sending';
131 $permissiontoadd = $user->rights->expedition->creer;
132 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
135 if ($action ==
'reopen' && $user->rights->expedition->creer)
138 $result = $object->reOpen();
142 if ($action ==
'set_incoterms' && !empty($conf->incoterm->enabled))
144 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
147 if ($action ==
'setref_customer')
149 $result = $object->fetch($id);
154 $result = $object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'', null,
'text',
'', $user,
'SHIPMENT_MODIFY');
157 $action =
'editref_customer';
159 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
164 if ($action ==
'update_extras')
169 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
170 if ($ret < 0) $error++;
175 $result = $object->insertExtraFields(
'SHIPMENT_MODIFY');
184 $action =
'edit_extras';
188 if ($action ==
'add' && $user->rights->expedition->creer)
195 $object->note =
GETPOST(
'note',
'alpha');
196 $object->origin = $origin;
197 $object->origin_id = $origin_id;
198 $object->fk_project =
GETPOST(
'projectid',
'int');
199 $object->weight =
GETPOST(
'weight',
'int') ==
'' ?
"NULL" :
GETPOST(
'weight',
'int');
200 $object->sizeH =
GETPOST(
'sizeH',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeH',
'int');
201 $object->sizeW =
GETPOST(
'sizeW',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeW',
'int');
202 $object->sizeS =
GETPOST(
'sizeS',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeS',
'int');
203 $object->size_units =
GETPOST(
'size_units',
'int');
204 $object->weight_units =
GETPOST(
'weight_units',
'int');
207 $classname = ucfirst($object->origin);
208 $objectsrc =
new $classname($db);
209 $objectsrc->fetch($object->origin_id);
211 $object->socid = $objectsrc->socid;
212 $object->ref_customer =
GETPOST(
'ref_customer',
'alpha');
213 $object->model_pdf =
GETPOST(
'model');
214 $object->date_delivery = $date_delivery;
215 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
216 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
217 $object->tracking_number =
GETPOST(
'tracking_number',
'alpha');
218 $object->ref_int =
GETPOST(
'ref_int',
'alpha');
219 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
220 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
221 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
222 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
224 $batch_line = array();
225 $stockLine = array();
226 $array_options = array();
228 $num = count($objectsrc->lines);
231 for ($i = 0; $i < $num; $i++)
239 $batch =
"batchl".$i.
"_0";
240 $stockLocation =
"ent1".$i.
"_0";
243 if (!empty($conf->productbatch->enabled) && $objectsrc->lines[$i]->product_tobatch)
252 $sub_qty[$j][
'q'] =
GETPOST($qty,
'int');
253 $sub_qty[$j][
'id_batch'] =
GETPOST($batch,
'int');
254 $subtotalqty += $sub_qty[$j][
'q'];
259 $batch =
"batchl".$i.
"_".$j;
260 $qty =
"qtyl".$i.
'_'.$j;
263 $batch_line[$i][
'detail'] = $sub_qty;
264 $batch_line[$i][
'qty'] = $subtotalqty;
265 $batch_line[$i][
'ix_l'] =
GETPOST($idl,
'int');
267 $totalqty += $subtotalqty;
270 if (!empty($_POST[$qty]))
275 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse"), null,
'errors');
285 $stockLine[$i][$j][
'warehouse_id'] =
GETPOST($stockLocation,
'int');
286 $stockLine[$i][$j][
'ix_l'] =
GETPOST($idl,
'int');
291 $stockLocation =
"ent1".$i.
"_".$j;
292 $qty =
"qtyl".$i.
'_'.$j;
301 $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i);
303 if (is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
305 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
306 unset($_POST[
"options_".$key]);
316 for ($i = 0; $i < $num; $i++)
319 if (!isset($batch_line[$i]))
322 if (isset($stockLine[$i]))
325 $nbstockline = count($stockLine[$i]);
326 for ($j = 0; $j < $nbstockline; $j++)
328 if ($stockLine[$i][$j][
'qty'] > 0)
330 $ret = $object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], $stockLine[$i][$j][
'qty'], $array_options[$i]);
339 if (
GETPOST($qty,
'int') > 0 || (
GETPOST($qty,
'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS))
343 $entrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') :
GETPOST(
'entrepot_id',
'int');
344 if ($entrepot_id < 0) $entrepot_id =
'';
345 if (!($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0;
347 $ret = $object->addline($entrepot_id,
GETPOST($idl,
'int'),
GETPOST($qty,
'int'), $array_options[$i]);
357 if ($batch_line[$i][
'qty'] > 0)
359 $ret = $object->addline_batch($batch_line[$i], $array_options[$i]);
369 $ret = $extrafields->setOptionalsFromPost(null, $object);
370 if ($ret < 0) $error++;
374 $ret = $object->create($user);
382 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"QtyToShip").
'/'.$langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
389 header(
"Location: card.php?id=".$object->id);
393 $_GET[
"commande_id"] =
GETPOST(
'commande_id',
'int');
401 elseif ($action ==
'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)
403 $result = $object->create_delivery($user);
406 header(
"Location: ".DOL_URL_ROOT.
'/delivery/card.php?action=create_delivery&id='.$result);
411 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' &&
412 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
413 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))
416 $object->fetch_thirdparty();
418 $result = $object->valid($user);
424 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
426 $outputlangs = $langs;
428 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
429 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
430 if (!empty($newlang)) {
432 $outputlangs->setDefaultLang($newlang);
434 $model = $object->model_pdf;
435 $ret = $object->fetch($id);
437 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
441 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->rights->expedition->supprimer)
443 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
444 $result = $object->cancel(0, $also_update_stock);
447 $result = $object->setStatut(-1);
451 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->expedition->supprimer)
453 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
454 $result = $object->delete(0, $also_update_stock);
457 header(
"Location: ".DOL_URL_ROOT.
'/expedition/index.php');
473 elseif ($action ==
'setdate_livraison' && $user->rights->expedition->creer)
476 $datedelivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
479 $result = $object->setDeliveryDate($user, $datedelivery);
488 ($action ==
'settracking_number'
489 || $action ==
'settracking_url'
490 || $action ==
'settrueWeight'
491 || $action ==
'settrueWidth'
492 || $action ==
'settrueHeight'
493 || $action ==
'settrueDepth'
494 || $action ==
'setshipping_method_id')
495 && $user->rights->expedition->creer
500 if ($action ==
'settracking_number') $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
501 if ($action ==
'settracking_url') $object->tracking_url = trim(
GETPOST(
'tracking_url',
'int'));
502 if ($action ==
'settrueWeight') {
503 $object->trueWeight = trim(
GETPOST(
'trueWeight',
'int'));
504 $object->weight_units =
GETPOST(
'weight_units',
'int');
506 if ($action ==
'settrueWidth') $object->trueWidth = trim(
GETPOST(
'trueWidth',
'int'));
507 if ($action ==
'settrueHeight') {
508 $object->trueHeight = trim(
GETPOST(
'trueHeight',
'int'));
509 $object->size_units =
GETPOST(
'size_units',
'int');
511 if ($action ==
'settrueDepth') $object->trueDepth = trim(
GETPOST(
'trueDepth',
'int'));
512 if ($action ==
'setshipping_method_id') $object->shipping_method_id = trim(
GETPOST(
'shipping_method_id',
'int'));
516 if ($object->update($user) >= 0)
518 header(
"Location: card.php?id=".$object->id);
525 } elseif ($action ==
'classifybilled')
528 $result = $object->set_billed();
530 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
534 } elseif ($action ==
'classifyclosed')
537 $result = $object->setClosed();
539 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
548 elseif ($action ==
'deleteline' && !empty($line_id))
551 $lines = $object->lines;
554 $num_prod = count($lines);
555 for ($i = 0; $i < $num_prod; $i++)
557 if ($lines[$i]->
id == $line_id)
559 if (count($lines[$i]->details_entrepot) > 1)
562 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
563 $line->id = $details_entrepot->line_id;
564 if (!$error && $line->delete($user) < 0)
571 $line->id = $line_id;
572 if (!$error && $line->delete($user) < 0)
578 unset($_POST[
"lineid"]);
582 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
592 elseif ($action ==
'updateline' && $user->rights->expedition->creer &&
GETPOST(
'save'))
599 $lines = $object->lines;
600 $num_prod = count($lines);
601 for ($i = 0; $i < $num_prod; $i++)
603 if ($lines[$i]->
id == $line_id)
608 $line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
610 if (is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
611 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
612 unset($_POST[
"options_".$key]);
615 $line->fk_product = $lines[$i]->fk_product;
616 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
619 foreach ($lines[$i]->detail_batch as $detail_batch)
622 $batch =
"batchl".$detail_batch->fk_expeditiondet.
"_".$detail_batch->fk_origin_stock;
623 $qty =
"qtyl".$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id;
624 $batch_id =
GETPOST($batch,
'int');
625 $batch_qty =
GETPOST($qty,
'int');
626 if (!empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty))
628 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0)
630 if ($lines[$i]->entrepot_id != 0)
633 $line->entrepot_id = $lotStock->warehouseid;
637 if (empty($line->detail_batch)) $line->detail_batch =
new stdClass();
639 $line->detail_batch->fk_origin_stock = $batch_id;
640 $line->detail_batch->batch = $lotStock->batch;
641 $line->detail_batch->id = $detail_batch->id;
642 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
643 $line->detail_batch->qty = $batch_qty;
644 if ($line->update($user) < 0) {
653 unset($_POST[$batch]);
658 $batch =
"batchl".$line_id.
"_0";
659 $qty =
"qtyl".$line_id.
"_0";
660 $batch_id =
GETPOST($batch,
'int');
661 $batch_qty =
GETPOST($qty,
'int');
663 if ($batch_qty > 0 && !empty($batch_id))
665 if ($lotStock->fetch($batch_id) > 0)
668 if ($lines[$i]->entrepot_id > 0)
671 if ($lines[$i]->entrepot_id == $lotStock->warehouseid)
673 $lineIdToAddLot = $line_id;
675 } elseif (count($lines[$i]->details_entrepot) > 1)
678 foreach ($lines[$i]->details_entrepot as $detail_entrepot)
680 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid)
682 $lineIdToAddLot = $detail_entrepot->line_id;
689 if ($line->fetch($lineIdToAddLot) > 0)
691 $line->detail_batch->fk_origin_stock = $batch_id;
692 $line->detail_batch->batch = $lotStock->batch;
693 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
694 $line->detail_batch->qty = $batch_qty;
695 if ($line->update($user) < 0) {
705 $line->origin_line_id = $lines[$i]->origin_line_id;
706 $line->entrepot_id = $lotStock->warehouseid;
708 $line->detail_batch[0]->fk_origin_stock = $batch_id;
709 $line->detail_batch[0]->batch = $lotStock->batch;
710 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
711 $line->detail_batch[0]->qty = $batch_qty;
712 if ($object->create_line_batch($line, $line->array_options) < 0)
724 if ($lines[$i]->fk_product > 0)
727 if ($lines[$i]->entrepot_id > 0)
730 $stockLocation =
"entl".$line_id;
731 $qty =
"qtyl".$line_id;
732 $line->id = $line_id;
733 $line->entrepot_id =
GETPOST($stockLocation,
'int');
734 $line->qty =
GETPOST($qty,
'int');
735 if ($line->update($user) < 0) {
739 unset($_POST[$stockLocation]);
741 } elseif (count($lines[$i]->details_entrepot) > 1)
744 foreach ($lines[$i]->details_entrepot as $detail_entrepot)
747 $stockLocation =
"entl".$detail_entrepot->line_id;
748 $qty =
"qtyl".$detail_entrepot->line_id;
749 $warehouse =
GETPOST($stockLocation,
'int');
750 if (!empty($warehouse))
752 $line->id = $detail_entrepot->line_id;
753 $line->entrepot_id = $warehouse;
754 $line->qty =
GETPOST($qty,
'int');
755 if ($line->update($user) < 0) {
760 unset($_POST[$stockLocation]);
767 $qty =
"qtyl".$line_id;
768 $line->id = $line_id;
769 $line->qty =
GETPOST($qty,
'int');
770 $line->entrepot_id = 0;
771 if ($line->update($user) < 0) {
781 unset($_POST[
"lineid"]);
784 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
786 $outputlangs = $langs;
788 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09'))
789 $newlang =
GETPOST(
'lang_id',
'aZ09');
790 if ($conf->global->MAIN_MULTILANGS && empty($newlang))
791 $newlang = $object->thirdparty->default_lang;
792 if (!empty($newlang)) {
794 $outputlangs->setDefaultLang($newlang);
797 $ret = $object->fetch($object->id);
798 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
801 header(
'Location: '.
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
804 } elseif ($action ==
'updateline' && $user->rights->expedition->creer &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
805 header(
'Location: '.
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
809 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
812 if (empty($id)) $id = $facid;
813 $triggersendname =
'SHIPPING_SENTBYMAIL';
815 $mode =
'emailfromshipment';
816 $trackid =
'shi'.$object->id;
817 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
825 llxHeader(
'', $langs->trans(
'Shipment'),
'Expedition');
827 $form =
new Form($db);
830 if (!empty($conf->projet->enabled)) { $formproject =
new FormProjets($db); }
832 $product_static =
new Product($db);
834 $warehousestatic =
new Entrepot($db);
836 if ($action ==
'create2')
840 print '<br>'.$langs->trans(
"ShipmentCreationIsDoneFromOrder");
841 $action =
''; $id =
''; $ref =
'';
845 if ($action ==
'create')
858 $classname = ucfirst($origin);
860 $object =
new $classname($db);
861 if ($object->fetch($origin_id))
864 $soc->fetch($object->socid);
866 $author =
new User($db);
867 $author->fetch($object->user_author_id);
869 if (!empty($conf->stock->enabled)) $entrepot =
new Entrepot($db);
871 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
872 print '<input type="hidden" name="token" value="'.newToken().
'">';
873 print '<input type="hidden" name="action" value="add">';
874 print '<input type="hidden" name="origin" value="'.$origin.
'">';
875 print '<input type="hidden" name="origin_id" value="'.$object->id.
'">';
876 print '<input type="hidden" name="ref_int" value="'.$object->ref_int.
'">';
877 if (
GETPOST(
'entrepot_id',
'int'))
879 print '<input type="hidden" name="entrepot_id" value="'.GETPOST(
'entrepot_id',
'int').
'">';
884 print '<table class="border centpercent">';
887 print '<tr><td class="titlefieldcreate fieldrequired">';
888 if ($origin ==
'commande' && !empty($conf->commande->enabled))
890 print $langs->trans(
"RefOrder");
892 if ($origin ==
'propal' && !empty($conf->propal->enabled))
894 print $langs->trans(
"RefProposal");
896 print '</td><td colspan="3">';
897 print $object->getNomUrl(1);
903 if ($origin ==
'commande')
print $langs->trans(
'RefCustomerOrder');
904 elseif ($origin ==
'propal')
print $langs->trans('RefCustomerOrder');
906 print '</td><td colspan="3">';
907 print '<input
type="text"
name="ref_customer" value="'.$object->ref_client.'" />';
912 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Company').'</td>';
913 print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
917 if (!empty($conf->projet->enabled))
919 $projectid =
GETPOST(
'projectid',
'int') ?
GETPOST(
'projectid',
'int') : 0;
920 if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project;
921 if ($origin ==
'project') $projectid = ($originid ? $originid : 0);
923 $langs->load(
"projects");
925 print '<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
927 $numprojet = $formproject->select_projects($soc->id, $projectid,
'projectid', 0);
928 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>';
934 print '<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
935 print '<td colspan="3">';
936 $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date);
937 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
942 print '<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
943 print '<td colspan="3">';
944 $doleditor =
new DolEditor(
'note_public', $object->note_public,
'', 60,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
945 print $doleditor->Create(1);
949 if ($object->note_private && !$user->socid)
951 print '<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
952 print '<td colspan="3">';
953 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 60,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
954 print $doleditor->Create(1);
960 print $langs->trans(
"Weight");
961 print '</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST(
'weight',
'int').
'"> ';
962 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units',
'int'), 0, 2);
963 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
964 print $form->textwithpicto($text, $htmltext);
968 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
969 print ' </td><td colspan="3"><input name="sizeW" size="4" value="'.GETPOST(
'sizeW',
'int').
'">';
970 print ' x <input name="sizeH" size="4" value="'.GETPOST(
'sizeH',
'int').
'">';
971 print ' x <input name="sizeS" size="4" value="'.GETPOST(
'sizeS',
'int').
'">';
973 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units',
'int'), 0, 2);
974 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
975 print $form->textwithpicto($text, $htmltext);
979 print "<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
980 print '<td colspan="3">';
981 $expe->fetch_delivery_methods();
982 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOST(
'shipping_method_id',
'int'), 1, 0, 0,
"", 1);
983 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
984 print "</td></tr>\n";
987 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
988 print
'<td colspan="3">';
989 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
990 print
"</td></tr>\n";
993 $parameters = array(
'objectsrc' => $objectsrc,
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
994 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
995 print $hookmanager->resPrint;
997 if (empty($reshook)) {
999 if ($object->fetch_optionals() > 0) {
1000 $expe->array_options = array_merge($expe->array_options, $object->array_options);
1002 print $expe->showOptionals($extrafields,
'edit', $parameters);
1007 if (!empty($conf->incoterm->enabled))
1010 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $object->label_incoterms, 1).
'</label></td>';
1011 print
'<td colspan="3" class="maxwidthonsmartphone">';
1012 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1017 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1019 if (count($liste) > 1)
1021 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1022 print
'<td colspan="3">';
1023 print $form->selectarray(
'model', $liste, $conf->global->EXPEDITION_ADDON_PDF);
1024 print
"</td></tr>\n";
1034 $numAsked = count($object->lines);
1036 print
'<script type="text/javascript" language="javascript">
1037 jQuery(document).ready(function() {
1038 jQuery("#autofill").click(function() {';
1040 while ($i < $numAsked)
1042 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1043 if (!empty($conf->productbatch->enabled)) print
'jQuery("#qtyl'.$i.
'_'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1047 jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0); });
1053 print
'<table class="noborder centpercent">';
1056 $object->loadExpeditions();
1060 print
'<tr class="liste_titre">';
1061 print
'<td>'.$langs->trans(
"Description").
'</td>';
1062 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1063 print
'<td class="center">'.$langs->trans(
"QtyShipped").
'</td>';
1064 print
'<td class="center">'.$langs->trans(
"QtyToShip");
1065 if (empty($conf->productbatch->enabled))
1067 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.$langs->trans(
"Fill").
'</a>';
1072 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Reset"),
'eraser').
'</span>';
1074 if (!empty($conf->stock->enabled))
1076 if (empty($conf->productbatch->enabled))
1078 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1080 print
'<td class="left">'.$langs->trans(
"Warehouse").
' / '.$langs->trans(
"Batch").
' ('.$langs->trans(
"Stock").
')</td>';
1087 while ($indiceAsked < $numAsked)
1091 $line = $object->lines[$indiceAsked];
1093 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1094 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1095 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1097 if (empty($reshook))
1100 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1103 if (!empty($line->date_start)) $type = 1;
1104 if (!empty($line->date_end)) $type = 1;
1106 print
'<!-- line '.$line->id.
' for product -->'.
"\n";
1107 print
'<tr class="oddeven">'.
"\n";
1110 if ($line->fk_product > 0)
1112 $product->fetch($line->fk_product);
1113 $product->load_stock(
'warehouseopen');
1117 print
'<a name="'.$line->id.
'"></a>';
1120 $product_static->type = $line->fk_product_type;
1121 $product_static->id = $line->fk_product;
1122 $product_static->ref = $line->ref;
1123 $product_static->status = $line->product_tosell;
1124 $product_static->status_buy = $line->product_tobuy;
1125 $product_static->status_batch = $line->product_tobatch;
1127 $text = $product_static->getNomUrl(1);
1128 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1129 $description = ($conf->global->PRODUIT_DESC_IN_FORM ?
'' :
dol_htmlentitiesbr($line->desc));
1130 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
1133 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1136 if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
1138 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1144 if ($type == 1) $text =
img_object($langs->trans(
'Service'),
'service');
1145 else $text =
img_object($langs->trans(
'Product'),
'product');
1147 if (!empty($line->label)) {
1148 $text .=
' <strong>'.$line->label.
'</strong>';
1149 print $form->textwithtooltip($text, $line->desc, 3,
'',
'', $i);
1151 print $text.
' '.nl2br($line->desc);
1155 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1160 print
'<td class="center">'.$line->qty;
1161 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1163 $qtyProdCom = $line->qty;
1166 print
'<td class="center">';
1167 $quantityDelivered = $object->expeditions[$line->id];
1168 print $quantityDelivered;
1169 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1173 $quantityAsked = $line->qty;
1174 if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES))
1176 $quantityToBeDelivered = 0;
1178 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
1180 $warehouse_id =
GETPOST(
'entrepot_id',
'int');
1182 $warehouseObject = null;
1183 if ($warehouse_id > 0 || !($line->fk_product > 0) || empty($conf->stock->enabled))
1185 print
'<!-- Case warehouse already known or product not a predefined product -->';
1187 $stock = + $product->stock_warehouse[$warehouse_id]->real;
1188 $deliverableQty = min($quantityToBeDelivered, $stock);
1189 if ($deliverableQty < 0) $deliverableQty = 0;
1190 if (empty($conf->productbatch->enabled) || !$product->hasbatch())
1193 print
'<td class="center">';
1196 if (
GETPOST(
'qtyl'.$indiceAsked,
'int')) $deliverableQty =
GETPOST(
'qtyl'.$indiceAsked,
'int');
1197 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1198 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1199 }
else print $langs->trans(
"NA");
1203 if (!empty($conf->stock->enabled))
1205 print
'<td class="left">';
1209 $ent =
"entl".$indiceAsked;
1210 $idl =
"idl".$indiceAsked;
1211 $tmpentrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') : $warehouse_id;
1212 if ($line->fk_product > 0)
1214 print
'<!-- Show warehouse selection -->';
1217 if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1220 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200',
'', 1, $stockMin,
'stock DESC, e.ref');
1222 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id)
1225 if ($stock < $quantityToBeDelivered)
1227 print
' '.img_warning($langs->trans(
"StockTooLow"));
1232 print $langs->trans(
"Service");
1240 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
1242 $product->get_sousproduits_arbo();
1243 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1244 if (count($prods_arbo) > 0)
1246 foreach ($prods_arbo as $key => $value)
1250 if ($value[
'stock'] < $value[
'stock_alert'])
1254 print
"<tr class=\"oddeven\"><td> ->
1255 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1256 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1257 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td></tr>";
1263 print
'<td></td><td></td></tr>';
1264 print
'<!-- Case product need lot -->';
1266 $staticwarehouse =
new Entrepot($db);
1267 if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id);
1272 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch))
1274 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch)
1279 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1280 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch))
1282 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch)
1285 $batchStock = + $dbatch->qty;
1286 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1287 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] :
'').
'>';
1288 print
'<td colspan="3" ></td><td class="center">';
1289 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1292 print
'<!-- Show details of lot -->';
1293 print
'<td class="left">';
1295 print $staticwarehouse->getNomUrl(0).
' / ';
1297 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1300 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
1301 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
1302 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1304 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
1305 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1307 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
1311 $quantityToBeDelivered -= $deliverableQty;
1312 if ($quantityToBeDelivered < 0)
1314 $quantityToBeDelivered = 0;
1320 print
'<!-- Case there is no details of lot at all -->';
1321 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1322 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0" disabled="disabled"> ';
1325 print
'<td class="left">';
1326 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
1332 if (empty($conf->productbatch->enabled) || !$product->hasbatch())
1334 print
'<!-- Case warehouse not already known and product does not need lot -->';
1335 print
'<td></td><td></td></tr>'.
"\n";
1337 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1341 foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
1343 if ($stock_warehouse->real > 0)
1348 $tmpwarehouseObject =
new Entrepot($db);
1349 foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
1351 $tmpwarehouseObject->fetch($warehouse_id);
1352 if ($stock_warehouse->real > 0)
1354 $stock = + $stock_warehouse->real;
1355 $deliverableQty = min($quantityToBeDelivered, $stock);
1356 $deliverableQty = max(0, $deliverableQty);
1358 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] :
'').
'>';
1359 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked='.$indiceAsked.
') -->';
1362 print
'<input name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1363 print
'<input name="ent1'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$warehouse_id.
'">';
1364 }
else print $langs->trans(
"NA");
1368 if (!empty($conf->stock->enabled))
1370 print
'<td class="left">';
1373 print $tmpwarehouseObject->getNomUrl(0).
' ';
1375 print
'<!-- Show details of stock -->';
1376 print
'('.$stock.
')';
1378 print $langs->trans(
"Service");
1382 $quantityToBeDelivered -= $deliverableQty;
1383 if ($quantityToBeDelivered < 0)
1385 $quantityToBeDelivered = 0;
1392 if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
1394 $product->get_sousproduits_arbo();
1395 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1396 if (count($prods_arbo) > 0)
1398 foreach ($prods_arbo as $key => $value)
1402 if ($value[
'stock'] < $value[
'stock_alert'])
1406 print
'<tr class"oddeven"><td>';
1407 print
" ->
1408 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1409 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1410 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1416 print
'<!-- Case warehouse not already known and product need lot -->';
1417 print
'<td></td><td></td></tr>';
1420 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1422 $tmpwarehouseObject =
new Entrepot($db);
1426 foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
1428 if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
1429 foreach ($stock_warehouse->detail_batch as $dbatch)
1435 foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
1437 $tmpwarehouseObject->fetch($warehouse_id);
1438 if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
1439 foreach ($stock_warehouse->detail_batch as $dbatch)
1442 $batchStock = + $dbatch->qty;
1443 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1444 if ($deliverableQty < 0) $deliverableQty = 0;
1445 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] :
'').
'><td colspan="3"></td><td class="center">';
1446 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1449 print
'<td class="left">';
1451 print $tmpwarehouseObject->getNomUrl(0).
' / ';
1453 print
'<!-- Show details of lot -->';
1454 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1457 print $langs->trans(
"Batch").
': ';
1458 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
1459 if ($result > 0) print $productlotObject->getNomUrl(1);
1460 else print
'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
1461 print
' ('.$dbatch->qty.
')';
1462 $quantityToBeDelivered -= $deliverableQty;
1463 if ($quantityToBeDelivered < 0)
1465 $quantityToBeDelivered = 0;
1476 $warehouse_selected_id =
GETPOST(
'entrepot_id',
'int');
1478 print
'<!-- line not shown yet, we show it -->';
1479 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1484 if (!empty($conf->productbatch->enabled) && $product->hasbatch())
1486 $disabled =
'disabled="disabled"';
1488 if ($warehouse_selected_id <= 0) {
1489 $disabled =
'disabled="disabled"';
1491 print
'<input class="qtyl" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').
'> ';
1493 print $langs->trans(
"NA");
1497 print
'<td class="left">';
1500 if ($warehouse_selected_id > 0)
1502 $warehouseObject =
new Entrepot($db);
1503 $warehouseObject->fetch($warehouse_selected_id);
1504 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
1506 if ($line->fk_product) print
img_warning().
' '.$langs->trans(
"StockTooLow");
1510 print $langs->trans(
"Service");
1518 if (!empty($extrafields))
1525 $srcLine->id = $line->id;
1526 $srcLine->fetch_optionals();
1527 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
1529 print $expLine->showOptionals($extrafields,
'edit', array(
'style'=>
'class="drag drop oddeven"',
'colspan'=>$colspan), $indiceAsked,
'', 1);
1540 print
'<div class="center">';
1541 print
'<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'">';
1543 print
'<input type="'.($backtopage ?
"submit" :
"button").
'" class="button button-cancel" name="cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'"'.($backtopage ?
'' :
' onclick="javascript:history.go(-1)"').
'>';
1553 } elseif ($id || $ref)
1560 $lines = $object->lines;
1562 $num_prod = count($lines);
1564 if ($object->id > 0)
1566 if (!empty($object->origin) && $object->origin_id > 0)
1568 $typeobject = $object->origin;
1569 $origin = $object->origin;
1570 $origin_id = $object->origin_id;
1571 $object->fetch_origin();
1575 $soc->fetch($object->socid);
1577 $res = $object->fetch_optionals();
1580 print
dol_get_fiche_head($head,
'shipping', $langs->trans(
"Shipment"), -1,
'sending');
1585 if ($action ==
'delete')
1587 $formquestion = array();
1589 $formquestion = array(
1591 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
1592 'name' =>
'alsoUpdateStock',
1593 'type' =>
'checkbox',
1598 $formconfirm = $form->formconfirm(
1599 $_SERVER[
'PHP_SELF'].
'?id='.$object->id,
1600 $langs->trans(
'DeleteSending'),
1601 $langs->trans(
"ConfirmDeleteSending", $object->ref),
1610 if ($action ==
'valid')
1612 $objectref = substr($object->ref, 1, 4);
1613 if ($objectref ==
'PROV')
1615 $numref = $object->getNextNumRef($soc);
1617 $numref = $object->ref;
1620 $text = $langs->trans(
"ConfirmValidateSending", $numref);
1622 if (!empty($conf->notification->enabled))
1624 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1625 $notify =
new Notify($db);
1627 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE', $object->socid, $object);
1630 $formconfirm = $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1);
1633 if ($action ==
'cancel')
1635 $formconfirm = $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending", $object->ref),
'confirm_cancel',
'', 0, 1);
1639 $parameters = array(
'formConfirm' => $formconfirm);
1640 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1641 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
1642 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
1649 $tmparray = $object->getTotalWeightVolume();
1650 $totalWeight = $tmparray['weight'];
1651 $totalVolume = $tmparray['volume'];
1654 if ($typeobject == 'commande' && $object->$typeobject->
id && !empty($conf->commande->enabled))
1657 $objectsrc->fetch($object->$typeobject->id);
1659 if ($typeobject ==
'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
1661 $objectsrc =
new Propal($db);
1662 $objectsrc->fetch($object->$typeobject->id);
1666 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1667 $morehtmlref =
'<div class="refidno">';
1669 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'', 0, 1);
1670 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'', null, null,
'', 1);
1672 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
1674 if (!empty($conf->projet->enabled)) {
1675 $langs->load(
"projects");
1676 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
1678 if ($action !=
'classify') {
1679 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
1681 if ($action ==
'classify') {
1683 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
1684 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1685 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1686 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1687 $morehtmlref .=
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
1688 $morehtmlref .=
'</form>';
1690 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
1695 $morehtmlref .=
' : ';
1696 if (!empty($objectsrc->fk_project)) {
1698 $proj->fetch($objectsrc->fk_project);
1699 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$objectsrc->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
1700 $morehtmlref .= $proj->ref;
1701 $morehtmlref .=
'</a>';
1707 $morehtmlref .=
'</div>';
1710 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1713 print
'<div class="fichecenter">';
1714 print
'<div class="fichehalfleft">';
1715 print
'<div class="underbanner clearboth"></div>';
1717 print
'<table class="border tableforfield" width="100%">';
1720 if ($typeobject ==
'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
1723 print $langs->trans(
"RefOrder").
'</td>';
1724 print
'<td colspan="3">';
1725 print $objectsrc->getNomUrl(1,
'commande');
1729 if ($typeobject ==
'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
1732 print $langs->trans(
"RefProposal").
'</td>';
1733 print
'<td colspan="3">';
1734 print $objectsrc->getNomUrl(1,
'expedition');
1740 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
1741 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour").
"</td>\n";
1745 print
'<tr><td height="10">';
1746 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1747 print $langs->trans(
'DateDeliveryPlanned');
1750 if ($action !=
'editdate_livraison') print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate_livraison&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetDeliveryDate'), 1).
'</a></td>';
1751 print
'</tr></table>';
1752 print
'</td><td colspan="2">';
1753 if ($action ==
'editdate_livraison')
1755 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1756 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1757 print
'<input type="hidden" name="action" value="setdate_livraison">';
1758 print $form->selectDate($object->date_delivery ? $object->date_delivery : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
1759 print
'<input type="submit" class="button" value="'.$langs->trans(
'Modify').
'">';
1762 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
1769 print $form->editfieldkey(
"Weight",
'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer);
1770 print
'</td><td colspan="3">';
1772 if ($action ==
'edittrueWeight')
1774 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1775 print
'<input name="action" value="settrueWeight" type="hidden">';
1776 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
1777 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1778 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text" class="width50">';
1779 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $object->weight_units, 0, 2);
1780 print
' <input class="button" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
1781 print
' <input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1784 print $object->trueWeight;
1785 print ($object->trueWeight && $object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight", $object->weight_units) :
'';
1789 if ($totalWeight > 0)
1791 if (!empty($object->trueWeight)) print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
1792 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');
1793 if (!empty($object->trueWeight)) print
')';
1798 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1799 print $form->editfieldval(
"Width",
'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer);
1800 print ($object->trueWidth && $object->width_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->width_units) :
'';
1804 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1805 if ($action ==
'edittrueHeight')
1807 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1808 print
'<input name="action" value="settrueHeight" type="hidden">';
1809 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
1810 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1811 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text" class="width50">';
1812 print $formproduct->selectMeasuringUnits(
"size_units",
"size", $object->size_units, 0, 2);
1813 print
' <input class="button" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
1814 print
' <input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1817 print $object->trueHeight;
1818 print ($object->trueHeight && $object->height_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->height_units) :
'';
1824 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1825 print $form->editfieldval(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer);
1826 print ($object->trueDepth && $object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->depth_units) :
'';
1831 print $langs->trans(
"Volume");
1833 print
'<td colspan="3">';
1834 $calculatedVolume = 0;
1836 if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
1838 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
1839 $volumeUnit = $object->size_units * 3;
1842 if ($calculatedVolume > 0)
1844 if ($volumeUnit < 50)
1846 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');
1849 if ($totalVolume > 0)
1851 if ($calculatedVolume) print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
1852 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');
1854 if ($calculatedVolume) print
')';
1861 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1866 print
'<div class="fichehalfright">';
1867 print
'<div class="ficheaddleft">';
1868 print
'<div class="underbanner clearboth"></div>';
1870 print
'<table class="border centpercent tableforfield">';
1873 print
'<tr><td height="10">';
1874 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1875 print $langs->trans(
'SendingMethod');
1878 if ($action !=
'editshipping_method_id') print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editshipping_method_id&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetSendingMethod'), 1).
'</a></td>';
1879 print
'</tr></table>';
1880 print
'</td><td colspan="2">';
1881 if ($action ==
'editshipping_method_id')
1883 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
1884 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1885 print
'<input type="hidden" name="action" value="setshipping_method_id">';
1886 $object->fetch_delivery_methods();
1887 print $form->selectarray(
"shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0,
"", 1);
1888 if ($user->admin) print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1889 print
'<input type="submit" class="button" value="'.$langs->trans(
'Modify').
'">';
1892 if ($object->shipping_method_id > 0)
1895 $code = $langs->getLabelFromKey($db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
1896 print $langs->trans(
"SendingMethod".strtoupper($code));
1903 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).
'</td><td colspan="3">';
1904 print $form->editfieldval(
"TrackingNumber",
'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer,
'safehtmlstring', $object->tracking_number);
1908 if (!empty($conf->incoterm->enabled))
1911 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1912 print $langs->trans(
'IncotermLabel');
1913 print
'<td><td class="right">';
1914 if ($user->rights->expedition->creer) print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
1915 else print
' ';
1916 print
'</td></tr></table>';
1918 print
'<td colspan="3">';
1919 if ($action !=
'editincoterm')
1921 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
1923 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''),
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1929 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
1930 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1931 print $hookmanager->resPrint;
1939 print
'<div class="clearboth"></div>';
1944 if ($action ==
'editline')
1946 print
' <form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$line_id.
'" method="POST">
1947 <input type="hidden" name="token" value="' .
newToken().
'">
1948 <input type="hidden" name="action" value="updateline">
1949 <input type="hidden" name="mode" value="">
1950 <input type="hidden" name="id" value="' . $object->id.
'">
1955 print
'<div class="div-table-responsive-no-min">';
1956 print
'<table class="noborder" width="100%" id="tablelines" >';
1958 print
'<tr class="liste_titre">';
1960 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER))
1962 print
'<td width="5" class="center linecolnum"> </td>';
1965 print
'<td class="linecoldescription" >'.$langs->trans(
"Products").
'</td>';
1967 print
'<td class="center linecolqty">'.$langs->trans(
"QtyOrdered").
'</td>';
1968 if ($origin && $origin_id > 0)
1970 print
'<td class="center linecolqtyinothershipments">'.$langs->trans(
"QtyInOtherShipments").
'</td>';
1972 if ($action ==
'editline')
1975 if (empty($conf->stock->enabled)) $editColspan--;
1976 if (empty($conf->productbatch->enabled)) $editColspan--;
1977 print
'<td class="center linecoleditlineotherinfo" colspan="'.$editColspan.
'">';
1978 if ($object->statut <= 1)
1980 print $langs->trans(
"QtyToShip").
' - ';
1982 print $langs->trans(
"QtyShipped").
' - ';
1984 if (!empty($conf->stock->enabled))
1986 print $langs->trans(
"WarehouseSource").
' - ';
1988 if (!empty($conf->productbatch->enabled))
1990 print $langs->trans(
"Batch");
1994 if ($object->statut <= 1)
1996 print
'<td class="center linecolqtytoship">'.$langs->trans(
"QtyToShip").
'</td>';
1998 print
'<td class="center linecolqtyshipped">'.$langs->trans(
"QtyShipped").
'</td>';
2000 if (!empty($conf->stock->enabled))
2002 print
'<td class="left linecolwarehousesource">'.$langs->trans(
"WarehouseSource").
'</td>';
2005 if (!empty($conf->productbatch->enabled))
2007 print
'<td class="left linecolbatch">'.$langs->trans(
"Batch").
'</td>';
2010 print
'<td class="center linecolweight">'.$langs->trans(
"CalculatedWeight").
'</td>';
2011 print
'<td class="center linecolvolume">'.$langs->trans(
"CalculatedVolume").
'</td>';
2013 if ($object->statut == 0)
2015 print
'<td class="linecoledit"></td>';
2016 print
'<td class="linecoldelete" width="10"></td>';
2021 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
2023 $object->fetch_thirdparty();
2024 $outputlangs = $langs;
2026 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
2027 if (empty($newlang)) $newlang = $object->thirdparty->default_lang;
2028 if (!empty($newlang))
2030 $outputlangs =
new Translate(
"", $conf);
2031 $outputlangs->setDefaultLang($newlang);
2036 $alreadysent = array();
2037 if ($origin && $origin_id > 0)
2039 $sql =
"SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
2040 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot";
2041 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
2043 $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';
2044 $sql .=
', p.description as product_desc';
2045 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2046 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
2047 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
2049 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2050 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
2051 $sql .=
" AND obj.fk_".$origin.
" = ".$origin_id;
2052 $sql .=
" AND obj.rowid = ed.fk_origin_line";
2053 $sql .=
" AND ed.fk_expedition = e.rowid";
2055 $sql .=
" ORDER BY obj.fk_product";
2057 dol_syslog(
"get list of shipment lines", LOG_DEBUG);
2058 $resql = $db->query($sql);
2061 $num = $db->num_rows(
$resql);
2066 $obj = $db->fetch_object(
$resql);
2070 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
2071 'shipment_ref'=>$obj->shipment_ref,
'shipment_id'=>$obj->shipment_id,
'warehouse'=>$obj->fk_entrepot,
'qty_shipped'=>$obj->qty_shipped,
2072 'product_tosell'=>$obj->product_tosell,
'product_tobuy'=>$obj->product_tobuy,
'product_tobatch'=>$obj->product_tobatch,
2073 'date_valid'=>$db->jdate($obj->date_valid),
'date_delivery'=>$db->jdate($obj->date_delivery));
2084 for ($i = 0; $i < $num_prod; $i++)
2086 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => $editColspan,
'outputlangs' => $outputlangs);
2087 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
2088 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2090 if (empty($reshook))
2092 print
'<!-- origin line id = '.$lines[$i]->origin_line_id.
' -->';
2093 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'" >';
2096 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2098 print
'<td class="center linecolnum">'.($i + 1).
'</td>';
2102 if ($lines[$i]->fk_product > 0)
2105 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
2108 $prod->fetch($lines[$i]->fk_product);
2109 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
2110 }
else $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
2112 print
'<td class="linecoldescription">';
2115 $product_static->type = $lines[$i]->fk_product_type;
2116 $product_static->id = $lines[$i]->fk_product;
2117 $product_static->ref = $lines[$i]->ref;
2118 $product_static->status = $lines[$i]->product_tosell;
2119 $product_static->status_buy = $lines[$i]->product_tobuy;
2120 $product_static->status_batch = $lines[$i]->product_tobatch;
2122 $product_static->weight = $lines[$i]->weight;
2123 $product_static->weight_units = $lines[$i]->weight_units;
2124 $product_static->length = $lines[$i]->length;
2125 $product_static->length_units = $lines[$i]->length_units;
2126 $product_static->width = $lines[$i]->width;
2127 $product_static->width_units = $lines[$i]->width_units;
2128 $product_static->height = $lines[$i]->height;
2129 $product_static->height_units = $lines[$i]->height_units;
2130 $product_static->surface = $lines[$i]->surface;
2131 $product_static->surface_units = $lines[$i]->surface_units;
2132 $product_static->volume = $lines[$i]->volume;
2133 $product_static->volume_units = $lines[$i]->volume_units;
2135 $text = $product_static->getNomUrl(1);
2136 $text .=
' - '.$label;
2138 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
2140 if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
2146 print
'<td class="linecoldescription" >';
2148 else $text =
img_object($langs->trans(
'Product'),
'product');
2150 if (!empty($lines[$i]->label)) {
2151 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2152 print $form->textwithtooltip($text, $lines[$i]->
description, 3,
'',
'', $i);
2162 print
'<td class="center linecolqty">'.$lines[$i]->qty_asked.
'</td>';
2165 if ($origin && $origin_id > 0)
2167 print
'<td class="linecolqtyinothershipments center nowrap">';
2168 foreach ($alreadysent as $key => $val)
2170 if ($lines[$i]->fk_origin_line == $key)
2173 foreach ($val as $shipmentline_id=> $shipmentline_var)
2175 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition)
continue;
2178 if ($j > 1) print
'<br>';
2179 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
2180 print $shipment_static->getNomUrl(1);
2181 print
' - '.$shipmentline_var[
'qty_shipped'];
2182 $htmltext = $langs->trans(
"DateValidation").
' : '.(empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
2183 if (!empty($conf->stock->enabled) && $shipmentline_var[
'warehouse'] > 0)
2185 $warehousestatic->fetch($shipmentline_var[
'warehouse']);
2186 $htmltext .=
'<br>'.$langs->trans(
"FromLocation").
' : '.$warehousestatic->getNomUrl(1,
'', 0, 1);
2188 print
' '.$form->textwithpicto(
'', $htmltext, 1);
2195 if ($action ==
'editline' && $lines[$i]->
id == $line_id)
2198 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding">';
2199 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
2201 print
'<!-- case edit 1 -->';
2203 foreach ($lines[$i]->detail_batch as $detail_batch)
2207 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>';
2209 if ($lines[$i]->entrepot_id == 0)
2212 $line->fetch($detail_batch->fk_expeditiondet);
2214 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, $line->entrepot_id).
'</td>';
2220 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'_0" id="qtyl'.$line_id.
'_0" type="text" size="4" value="0"></td>';
2222 print
'<td>'.$formproduct->selectLotStock(
'',
'batchl'.$line_id.
'_0',
'', 1, 0, $lines[$i]->fk_product).
'</td>';
2224 } elseif (!empty($conf->stock->enabled))
2226 if ($lines[$i]->fk_product > 0)
2228 if ($lines[$i]->entrepot_id > 0)
2230 print
'<!-- case edit 2 -->';
2233 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2235 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2237 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2239 } elseif (count($lines[$i]->details_entrepot) > 1)
2241 print
'<!-- case edit 3 -->';
2242 foreach ($lines[$i]->details_entrepot as $detail_entrepot)
2246 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.
'"></td>';
2248 print
'<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl'.$detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2250 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2254 print
'<!-- case edit 4 -->';
2255 print
'<tr><td colspan="3">'.$langs->trans(
"NotEnoughStock").
'</td></tr>';
2258 print
'<!-- case edit 5 -->';
2261 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2270 print
'</table></td>';
2273 print
'<td class="linecolqtytoship center">'.$lines[$i]->qty_shipped.
'</td>';
2276 if (!empty($conf->stock->enabled))
2278 print
'<td class="linecolwarehousesource left">';
2279 if ($lines[$i]->entrepot_id > 0)
2282 $entrepot->fetch($lines[$i]->entrepot_id);
2283 print $entrepot->getNomUrl(1);
2284 } elseif (count($lines[$i]->details_entrepot) > 1)
2287 foreach ($lines[$i]->details_entrepot as $detail_entrepot)
2289 if ($detail_entrepot->entrepot_id > 0)
2292 $entrepot->fetch($detail_entrepot->entrepot_id);
2293 $detail .= $langs->trans(
"DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).
'<br/>';
2296 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
"DetailWarehouseNumber"), $detail);
2302 if (!empty($conf->productbatch->enabled))
2304 if (isset($lines[$i]->detail_batch))
2306 print
'<!-- Detail of lot -->';
2307 print
'<td class="linecolbatch">';
2308 if ($lines[$i]->product_tobatch)
2311 foreach ($lines[$i]->detail_batch as $dbatch)
2313 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
2314 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
2315 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
2317 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
2318 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
2320 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
2323 print $form->textwithtooltip(
img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $detail);
2325 print $langs->trans(
"NA");
2329 print
'<td class="linecolbatch" ></td>';
2335 print
'<td class="center linecolweight">';
2337 else print
' ';
2341 print
'<td class="center linecolvolume">';
2343 else print
' ';
2349 if ($action ==
'editline' && $lines[$i]->
id == $line_id)
2351 print
'<td class="center" colspan="2" valign="middle">';
2352 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2353 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2358 print
'<td class="linecoledit center">';
2359 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&lineid='.$lines[$i]->id.
'">'.
img_edit().
'</a>';
2361 print
'<td class="linecoldelete" width="10">';
2362 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_delete().
'</a>';
2366 if (!empty($rowExtrafieldsStart))
2368 print $rowExtrafieldsStart;
2369 print $rowExtrafieldsView;
2376 if (!empty($extrafields)) {
2378 if ($origin && $origin_id > 0) $colspan++;
2379 if (!empty($conf->productbatch->enabled)) $colspan++;
2380 if (!empty($conf->stock->enabled)) $colspan++;
2383 $line->fetch_optionals();
2385 if ($action ==
'editline' && $line->id == $line_id)
2387 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan'=>$colspan), $indiceAsked);
2389 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan'=>$colspan), $indiceAsked);
2406 $object->fetchObjectLinked($object->id, $object->element);
2413 if (($user->socid == 0) && ($action !=
'presend'))
2415 print
'<div class="tabsAction">';
2417 $parameters = array();
2418 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2420 if (empty($reshook))
2424 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
2425 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))
2427 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=valid">'.$langs->trans(
"Validate").
'</a>';
2429 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Validate").
'</a>';
2437 if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))
2439 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reopen">'.$langs->trans(
"ClassifyUnbilled").
'</a>';
2441 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reopen">'.$langs->trans(
"ReOpen").
'</a>';
2446 if (empty($user->socid)) {
2447 if ($object->statut > 0)
2449 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send)
2451 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
2452 }
else print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a>';
2459 if ($user->rights->facture->creer)
2463 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"CreateBill").
'</a>';
2471 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=create_delivery">'.$langs->trans(
"CreateDeliveryOrder").
'</a>';
2476 if ($user->rights->expedition->creer && $object->statut > 0 && !$object->billed)
2478 $label =
"Close"; $paramaction =
'classifyclosed';
2480 if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))
2482 $label =
"ClassifyBilled";
2483 $paramaction =
'classifybilled';
2485 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action='.$paramaction.
'">'.$langs->trans($label).
'</a>';
2492 if ($user->rights->expedition->supprimer)
2494 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=cancel">'.$langs->trans(
"Cancel").
'</a>';
2499 if ($user->rights->expedition->supprimer)
2501 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
"Delete").
'</a>';
2513 if ($action !=
'presend' && $action !=
'editline')
2515 print
'<div class="fichecenter"><div class="fichehalfleft">';
2518 $filedir = $conf->expedition->dir_output.
"/sending/".$objectref;
2520 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2522 $genallowed = $user->rights->expedition->lire;
2523 $delallowed = $user->rights->expedition->creer;
2525 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2530 $somethingshown = $form->showLinkedObjectBlock($object,
'');
2533 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
2536 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2538 $somethingshown =
$formactions->showactions($object,
'shipping', $socid, 1);
2540 print
'</div></div></div>';
2549 if (
GETPOST(
'modelselected')) {
2550 $action =
'presend';
2554 $modelmail =
'shipping_send';
2555 $defaulttopic =
'SendShippingRef';
2556 $diroutput = $conf->expedition->dir_output.
'/sending';
2557 $trackid =
'shi'.$object->id;
2559 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
shipping_prepare_head($object)
Prepare array with list of tabs.
Class to manage notifications.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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.
Class with list of lots and properties.
Classe to manage lines of shipment.
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...
CRUD class for batch number management within shipment.
const STATUS_DRAFT
Draft status.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Class to manage products or services.
Class to manage Dolibarr users.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
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...
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
$conf db name
Only used if Module[ID]Name translation string is not found.
const STATUS_CLOSED
Closed status.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
Class to manage order lines.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no')
Output a dimension with best unit.
Class to manage shipments.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
const STATUS_VALIDATED
Validated status.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Manage record for batch number management.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
print_date_range($date_start, $date_end, $format= '', $outputlangs= '')
Format output for start and end date.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
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.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Class to manage proposals.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
Class to manage warehouses.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...