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',
'productbatch'));
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');
85$line_id =
GETPOST(
'lineid',
'int') ?
GETPOST(
'lineid',
'int') :
'';
86$facid =
GETPOST(
'facid',
'int');
88$action =
GETPOST(
'action',
'alpha');
89$confirm =
GETPOST(
'confirm',
'alpha');
90$cancel =
GETPOST(
'cancel',
'alpha');
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->hasRight(
'expedition',
'creer')) {
163 $result = $object->setDraft($user, 0);
167 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
172 if ($action ==
'reopen' && $user->hasRight(
'expedition',
'creer')) {
174 $result = $object->reOpen();
178 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
184 if ($action ==
'set_incoterms' && isModEnabled(
'incoterm')) {
185 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
188 if ($action ==
'setref_customer') {
189 $result = $object->fetch($id);
194 $result = $object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'SHIPMENT_MODIFY');
197 $action =
'editref_customer';
199 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
204 if ($action ==
'update_extras') {
205 $object->oldcopy =
dol_clone($object, 2);
208 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
215 $result = $object->insertExtraFields(
'SHIPMENT_MODIFY');
223 $action =
'edit_extras';
228 if ($action ==
'add' && $user->hasRight(
'expedition',
'creer')) {
233 $object->note =
GETPOST(
'note',
'restricthtml');
234 $object->note_private =
GETPOST(
'note',
'restricthtml');
235 $object->origin = $origin;
236 $object->origin_id = $origin_id;
237 $object->fk_project =
GETPOST(
'projectid',
'int');
238 $object->weight =
GETPOST(
'weight',
'int') ==
'' ?
"NULL" :
GETPOST(
'weight',
'int');
239 $object->sizeH =
GETPOST(
'sizeH',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeH',
'int');
240 $object->sizeW =
GETPOST(
'sizeW',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeW',
'int');
241 $object->sizeS =
GETPOST(
'sizeS',
'int') ==
'' ?
"NULL" :
GETPOST(
'sizeS',
'int');
242 $object->size_units =
GETPOST(
'size_units',
'int');
243 $object->weight_units =
GETPOST(
'weight_units',
'int');
248 $classname = ucfirst($object->origin);
249 $objectsrc =
new $classname($db);
250 $objectsrc->fetch($object->origin_id);
252 $object->socid = $objectsrc->socid;
253 $object->ref_customer =
GETPOST(
'ref_customer',
'alpha');
254 $object->model_pdf =
GETPOST(
'model');
255 $object->date_delivery = $date_delivery;
256 $object->fk_delivery_address = $objectsrc->fk_delivery_address;
257 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
258 $object->tracking_number =
GETPOST(
'tracking_number',
'alpha');
259 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
260 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
261 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
262 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
264 $batch_line = array();
265 $stockLine = array();
266 $array_options = array();
268 $num = count($objectsrc->lines);
271 $product_batch_used = array();
273 for ($i = 0; $i < $num; $i++) {
280 $batch =
"batchl".$i.
"_0";
281 $stockLocation =
"ent1".$i.
"_0";
284 $is_batch_or_serial=0;
285 if (!empty($objectsrc->lines[$i]->fk_product)) {
286 $resultFetch = $product->fetch($objectsrc->lines[$i]->fk_product,
'',
'',
'', 1, 1, 1);
287 if ($resultFetch < 0) {
290 $is_batch_or_serial = $product->status_batch;
294 if (isModEnabled(
'productbatch') && $objectsrc->lines[$i]->product_tobatch) {
295 if (GETPOSTISSET($batch)) {
298 while (GETPOSTISSET($batch)) {
301 $sub_qty[$j][
'id_batch'] =
GETPOST($batch,
'int');
302 $subtotalqty += $sub_qty[$j][
'q'];
310 if ($is_batch_or_serial==2 && ($sub_qty[$j][
'q']>1 || ($sub_qty[$j][
'q']>0 && in_array($sub_qty[$j][
'id_batch'], $product_batch_used)))) {
311 setEventMessages($langs->trans(
"TooManyQtyForSerialNumber", $product->ref,
''),
null,
'errors');
316 if ($is_batch_or_serial==2 && $sub_qty[$j][
'q']>0) {
317 $product_batch_used[$j] = $sub_qty[$j][
'id_batch'];
321 $batch =
"batchl".$i.
"_".$j;
322 $qty =
"qtyl".$i.
'_'.$j;
325 $batch_line[$i][
'detail'] = $sub_qty;
326 $batch_line[$i][
'qty'] = $subtotalqty;
327 $batch_line[$i][
'ix_l'] =
GETPOST($idl,
'int');
329 $totalqty += $subtotalqty;
336 setEventMessages($langs->trans(
"StockIsRequiredToChooseWhichLotToUse").
' ('.$langs->trans(
"Line").
' '.
GETPOST($idl,
'int').
')',
null,
'errors');
340 } elseif (GETPOSTISSET($stockLocation)) {
343 while (GETPOSTISSET($stockLocation)) {
346 $stockLine[$i][$j][
'warehouse_id'] =
GETPOST($stockLocation,
'int');
347 $stockLine[$i][$j][
'ix_l'] =
GETPOST($idl,
'int');
353 $stockLocation =
"ent1".$i.
"_".$j;
354 $qty =
"qtyl".$i.
'_'.$j;
358 if (
GETPOST($qty,
'int') > 0) {
365 if (
getDolGlobalInt(
"MAIN_DONT_SHIP_MORE_THAN_ORDERED") && $subtotalqty > $objectsrc->lines[$i]->qty) {
366 setEventMessages($langs->trans(
"ErrorTooMuchShipped", $i+1),
null,
'errors');
372 $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i);
374 if (isset($extrafields->attributes[$object->table_element_line][
'label']) && is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
376 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
377 unset($_POST[
"options_".$key]);
383 if (($totalqty > 0 ||
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS')) && !$error) {
384 for ($i = 0; $i < $num; $i++) {
387 if (!isset($batch_line[$i])) {
389 if (isset($stockLine[$i])) {
391 $nbstockline = count($stockLine[$i]);
392 for ($j = 0; $j < $nbstockline; $j++) {
393 if ($stockLine[$i][$j][
'qty'] > 0 || ($stockLine[$i][$j][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
394 $ret = $object->addline($stockLine[$i][$j][
'warehouse_id'], $stockLine[$i][$j][
'ix_l'], $stockLine[$i][$j][
'qty'], $array_options[$i]);
405 $entrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') :
GETPOST(
'entrepot_id',
'int');
406 if ($entrepot_id < 0) {
409 if (!($objectsrc->lines[$i]->fk_product > 0)) {
413 $ret = $object->addline($entrepot_id,
GETPOST($idl,
'int'),
price2num(
GETPOST($qty,
'alpha'),
'MS'), $array_options[$i]);
422 if ($batch_line[$i][
'qty'] > 0 || ($batch_line[$i][
'qty'] == 0 &&
getDolGlobalString(
'SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
423 $ret = $object->addline_batch($batch_line[$i], $array_options[$i]);
432 $ret = $extrafields->setOptionalsFromPost(
null, $object);
438 $ret = $object->create($user);
445 $labelfieldmissing = $langs->transnoentitiesnoconv(
"QtyToShip");
446 if (isModEnabled(
'stock')) {
447 $labelfieldmissing .=
'/'.$langs->transnoentitiesnoconv(
"Warehouse");
449 setEventMessages($langs->trans(
"ErrorFieldRequired", $labelfieldmissing),
null,
'errors');
455 header(
"Location: card.php?id=".$object->id);
459 $_GET[
"commande_id"] =
GETPOST(
'commande_id',
'int');
462 } elseif ($action ==
'create_delivery' &&
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer')) {
466 $result = $object->create_delivery($user);
470 header(
"Location: ".DOL_URL_ROOT.
'/delivery/card.php?action=create_delivery&id='.$result);
477 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' &&
478 ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
479 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate')))
481 $object->fetch_thirdparty();
483 $result = $object->valid($user);
490 $outputlangs = $langs;
493 $newlang =
GETPOST(
'lang_id',
'aZ09');
496 $newlang = $object->thirdparty->default_lang;
498 if (!empty($newlang)) {
500 $outputlangs->setDefaultLang($newlang);
502 $model = $object->model_pdf;
503 $ret = $object->fetch($id);
505 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
511 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
512 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
513 $result = $object->cancel(0, $also_update_stock);
515 $result = $object->setStatut(-1);
519 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'expedition',
'supprimer')) {
520 $also_update_stock = (
GETPOST(
'alsoUpdateStock',
'alpha') ? 1 : 0);
521 $result = $object->delete(0, $also_update_stock);
523 header(
"Location: ".DOL_URL_ROOT.
'/expedition/index.php');
537 } elseif ($action ==
'setdate_livraison' && $user->hasRight(
'expedition',
'creer')) {
538 $datedelivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
541 $result = $object->setDeliveryDate($user, $datedelivery);
545 } elseif (($action ==
'settracking_number'
546 || $action ==
'settracking_url'
547 || $action ==
'settrueWeight'
548 || $action ==
'settrueWidth'
549 || $action ==
'settrueHeight'
550 || $action ==
'settrueDepth'
551 || $action ==
'setshipping_method_id')
552 && $user->hasRight(
'expedition',
'creer')
557 if ($action ==
'settracking_number') {
558 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
560 if ($action ==
'settracking_url') {
561 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'int'));
563 if ($action ==
'settrueWeight') {
564 $object->trueWeight = trim(
GETPOST(
'trueWeight',
'int'));
565 $object->weight_units =
GETPOST(
'weight_units',
'int');
567 if ($action ==
'settrueWidth') {
568 $object->trueWidth = trim(
GETPOST(
'trueWidth',
'int'));
570 if ($action ==
'settrueHeight') {
571 $object->trueHeight = trim(
GETPOST(
'trueHeight',
'int'));
572 $object->size_units =
GETPOST(
'size_units',
'int');
574 if ($action ==
'settrueDepth') {
575 $object->trueDepth = trim(
GETPOST(
'trueDepth',
'int'));
577 if ($action ==
'setshipping_method_id') {
578 $object->shipping_method_id = trim(
GETPOST(
'shipping_method_id',
'int'));
582 if ($object->update($user) >= 0) {
583 header(
"Location: card.php?id=".$object->id);
590 } elseif ($action ==
'classifybilled') {
592 $result = $object->setBilled();
594 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
598 } elseif ($action ==
'classifyclosed') {
600 $result = $object->setClosed();
602 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
606 } elseif ($action ==
'deleteline' && !empty($line_id)) {
609 $lines = $object->lines;
611 $line->fk_expedition = $object->id;
613 $num_prod = count($lines);
614 for ($i = 0; $i < $num_prod; $i++) {
615 if ($lines[$i]->
id == $line_id) {
616 if (count($lines[$i]->details_entrepot) > 1) {
618 foreach ($lines[$i]->details_entrepot as $details_entrepot) {
619 $line->id = $details_entrepot->line_id;
620 if (!$error && $line->delete($user) < 0) {
626 $line->id = $line_id;
627 if (!$error && $line->delete($user) < 0) {
632 unset($_POST[
"lineid"]);
636 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
641 } elseif ($action ==
'updateline' && $user->hasRight(
'expedition',
'creer') &&
GETPOST(
'save')) {
648 $lines = $object->lines;
649 $num_prod = count($lines);
650 for ($i = 0; $i < $num_prod; $i++) {
651 if ($lines[$i]->
id == $line_id) {
652 $update_done =
false;
654 $line->fk_expedition = $object->id;
657 $line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
659 if (is_array($extrafields->attributes[$object->table_element_line][
'label'])) {
660 foreach ($extrafields->attributes[$object->table_element_line][
'label'] as $key => $value) {
661 unset($_POST[
"options_".$key]);
664 $line->fk_product = $lines[$i]->fk_product;
665 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
667 foreach ($lines[$i]->detail_batch as $detail_batch) {
669 $batch =
"batchl".$detail_batch->fk_expeditiondet.
"_".$detail_batch->fk_origin_stock;
670 $qty =
"qtyl".$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id;
671 $batch_id =
GETPOST($batch,
'int');
672 $batch_qty =
GETPOST($qty,
'int');
673 if (!empty($batch_id)) {
674 if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) {
675 if ($lines[$i]->entrepot_id != 0) {
677 $line->entrepot_id = $lotStock->warehouseid;
681 if (empty($line->detail_batch)) {
682 $line->detail_batch =
new stdClass();
685 $line->detail_batch->fk_origin_stock = $batch_id;
686 $line->detail_batch->batch = $lotStock->batch;
687 $line->detail_batch->id = $detail_batch->id;
688 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
689 $line->detail_batch->qty = $batch_qty;
690 if ($line->update($user) < 0) {
701 unset($_POST[$batch]);
706 $batch =
"batchl".$line_id.
"_0";
707 $qty =
"qtyl".$line_id.
"_0";
708 $batch_id =
GETPOST($batch,
'int');
709 $batch_qty =
GETPOST($qty,
'int');
711 if ($batch_qty > 0 && !empty($batch_id)) {
712 if ($lotStock->fetch($batch_id) > 0) {
714 if ($lines[$i]->entrepot_id > 0) {
716 if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
717 $lineIdToAddLot = $line_id;
719 } elseif (count($lines[$i]->details_entrepot) > 1) {
721 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
722 if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
723 $lineIdToAddLot = $detail_entrepot->line_id;
727 if ($lineIdToAddLot) {
729 if ($line->fetch($lineIdToAddLot) > 0) {
730 $line->detail_batch->fk_origin_stock = $batch_id;
731 $line->detail_batch->batch = $lotStock->batch;
732 $line->detail_batch->entrepot_id = $lotStock->warehouseid;
733 $line->detail_batch->qty = $batch_qty;
734 if ($line->update($user) < 0) {
746 $line->origin_line_id = $lines[$i]->origin_line_id;
747 $line->entrepot_id = $lotStock->warehouseid;
749 $line->detail_batch[0]->fk_origin_stock = $batch_id;
750 $line->detail_batch[0]->batch = $lotStock->batch;
751 $line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
752 $line->detail_batch[0]->qty = $batch_qty;
753 if ($object->create_line_batch($line, $line->array_options) < 0) {
766 if ($lines[$i]->fk_product > 0) {
768 if ($lines[$i]->entrepot_id == 0) {
770 $stockLocation =
"entl".$line_id;
771 $qty =
"qtyl".$line_id;
772 $line->id = $line_id;
773 $line->entrepot_id =
GETPOST($stockLocation,
'int');
774 $line->qty =
GETPOST($qty,
'int');
775 if ($line->update($user) < 0) {
779 unset($_POST[$stockLocation]);
781 } elseif ($lines[$i]->entrepot_id > 0) {
783 $stockLocation =
"entl".$line_id;
784 $qty =
"qtyl".$line_id;
785 $line->id = $line_id;
786 $line->entrepot_id =
GETPOST($stockLocation,
'int');
787 $line->qty =
GETPOST($qty,
'int');
788 if ($line->update($user) < 0) {
792 unset($_POST[$stockLocation]);
794 } elseif (count($lines[$i]->details_entrepot) > 1) {
796 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
798 $stockLocation =
"entl".$detail_entrepot->line_id;
799 $qty =
"qtyl".$detail_entrepot->line_id;
800 $warehouse =
GETPOST($stockLocation,
'int');
801 if (!empty($warehouse)) {
802 $line->id = $detail_entrepot->line_id;
803 $line->entrepot_id = $warehouse;
804 $line->qty =
GETPOST($qty,
'int');
805 if ($line->update($user) < 0) {
812 unset($_POST[$stockLocation]);
816 } elseif (!isModEnabled(
'stock') && empty($conf->productbatch->enabled)) {
817 $qty =
"qtyl".$line_id;
818 $line->id = $line_id;
819 $line->qty =
GETPOST($qty,
'int');
820 $line->entrepot_id = 0;
821 if ($line->update($user) < 0) {
831 $qty =
"qtyl".$line_id;
832 $line->id = $line_id;
833 $line->qty =
GETPOST($qty,
'int');
834 $line->entrepot_id = 0;
835 if ($line->update($user) < 0) {
845 if (empty($update_done)) {
846 $line->id = $lines[$i]->id;
847 $line->insertExtraFields();
852 unset($_POST[
"lineid"]);
857 $outputlangs = $langs;
860 $newlang =
GETPOST(
'lang_id',
'aZ09');
863 $newlang = $object->thirdparty->default_lang;
865 if (!empty($newlang)) {
867 $outputlangs->setDefaultLang($newlang);
870 $ret = $object->fetch($object->id);
871 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
874 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
877 } elseif ($action ==
'updateline' && $user->hasRight(
'expedition',
'creer') &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
878 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
882 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
888 $triggersendname =
'SHIPPING_SENTBYMAIL';
890 $autocopy =
'MAIN_MAIL_AUTOCOPY_SHIPMENT_TO';
891 $mode =
'emailfromshipment';
892 $trackid =
'shi'.$object->id;
893 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
901$title = $object->ref.
' - '.$langs->trans(
"Shipment");
902if ($action ==
'create2') {
903 $title = $langs->trans(
"CreateShipment");
905$help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
913$form =
new Form($db);
916if (isModEnabled(
'project')) {
920$product_static =
new Product($db);
922$warehousestatic =
new Entrepot($db);
924if ($action ==
'create2') {
927 print
'<br>'.$langs->trans(
"ShipmentCreationIsDoneFromOrder");
934if ($action ==
'create') {
944 $classname = ucfirst($origin);
946 $object =
new $classname($db);
947 if ($object->fetch($origin_id)) {
949 $soc->fetch($object->socid);
951 $author =
new User($db);
952 $author->fetch($object->user_author_id);
954 if (isModEnabled(
'stock')) {
958 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
959 print
'<input type="hidden" name="token" value="'.newToken().
'">';
960 print
'<input type="hidden" name="action" value="add">';
961 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
962 print
'<input type="hidden" name="origin_id" value="'.$object->id.
'">';
963 if (
GETPOST(
'entrepot_id',
'int')) {
964 print
'<input type="hidden" name="entrepot_id" value="'.GETPOST(
'entrepot_id',
'int').
'">';
969 print
'<table class="border centpercent">';
972 print
'<tr><td class="titlefieldcreate fieldrequired">';
973 if ($origin ==
'commande' && isModEnabled(
'commande')) {
974 print $langs->trans(
"RefOrder");
976 if ($origin ==
'propal' && isModEnabled(
"propal")) {
977 print $langs->trans(
"RefProposal");
979 print
'</td><td colspan="3">';
980 print $object->getNomUrl(1);
986 if ($origin ==
'commande') {
987 print $langs->trans(
'RefCustomerOrder');
988 } elseif ($origin ==
'propal') {
989 print $langs->trans(
'RefCustomerOrder');
991 print $langs->trans(
'RefCustomer');
993 print
'</td><td colspan="3">';
994 print
'<input type="text" name="ref_customer" value="'.$object->ref_client.
'" />';
999 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Company').
'</td>';
1000 print
'<td colspan="3">'.$soc->getNomUrl(1).
'</td>';
1004 if (isModEnabled(
'project')) {
1005 $projectid =
GETPOST(
'projectid',
'int') ?
GETPOST(
'projectid',
'int') : 0;
1006 if (empty($projectid) && !empty($object->fk_project)) {
1007 $projectid = $object->fk_project;
1009 if ($origin ==
'project') {
1010 $projectid = ($originid ? $originid : 0);
1013 $langs->load(
"projects");
1015 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1016 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1017 $numprojet = $formproject->select_projects($soc->id, $projectid,
'projectid', 0);
1018 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>';
1024 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1025 print
'<td colspan="3">';
1026 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1027 $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date);
1028 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1033 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
1034 print
'<td colspan="3">';
1035 $doleditor =
new DolEditor(
'note_public', $object->note_public,
'', 60,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1036 print $doleditor->Create(1);
1040 if ($object->note_private && !$user->socid) {
1041 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
1042 print
'<td colspan="3">';
1043 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 60,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1044 print $doleditor->Create(1);
1050 print $langs->trans(
"Weight");
1051 print
'</td><td colspan="3">';
1052 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1053 print
'<input name="weight" size="4" value="'.GETPOST(
'weight',
'int').
'"> ';
1054 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOST(
'weight_units',
'int'), 0, 2);
1055 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1056 print $form->textwithpicto($text, $htmltext);
1060 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
1061 print
' </td><td colspan="3">';
1062 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1063 print
'<input name="sizeW" size="4" value="'.GETPOST(
'sizeW',
'int').
'">';
1064 print
' x <input name="sizeH" size="4" value="'.GETPOST(
'sizeH',
'int').
'">';
1065 print
' x <input name="sizeS" size="4" value="'.GETPOST(
'sizeS',
'int').
'">';
1067 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOST(
'size_units',
'int'), 0, 2);
1068 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1069 print $form->textwithpicto($text, $htmltext);
1073 print
"<tr><td>".$langs->trans(
"DeliveryMethod").
"</td>";
1074 print
'<td colspan="3">';
1075 $expe->fetch_delivery_methods();
1076 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1077 print $form->selectarray(
"shipping_method_id", $expe->meths,
GETPOST(
'shipping_method_id',
'int'), 1, 0, 0,
"", 1);
1079 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1081 print
"</td></tr>\n";
1084 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1085 print
'<td colspan="3">';
1086 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1087 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1088 print
"</td></tr>\n";
1091 $parameters = array(
'objectsrc' => isset($objectsrc) ? $objectsrc :
'',
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1092 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $expe, $action);
1093 print $hookmanager->resPrint;
1095 if (empty($reshook)) {
1097 if ($object->fetch_optionals() > 0) {
1098 $expe->array_options = array_merge($expe->array_options, $object->array_options);
1100 print $expe->showOptionals($extrafields,
'edit', $parameters);
1105 if (isModEnabled(
'incoterm')) {
1107 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $object->label_incoterms, 1).
'</label></td>';
1108 print
'<td colspan="3" class="maxwidthonsmartphone">';
1109 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1110 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1115 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
1117 if (count($list) > 1) {
1118 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1119 print
'<td colspan="3">';
1120 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1121 print $form->selectarray(
'model', $list, $conf->global->EXPEDITION_ADDON_PDF);
1122 print
"</td></tr>\n";
1132 $numAsked = count($object->lines);
1134 print
'<script type="text/javascript">'.
"\n";
1135 print
'jQuery(document).ready(function() {'.
"\n";
1136 print
'jQuery("#autofill").click(function() {';
1138 while ($i < $numAsked) {
1139 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1140 if (isModEnabled(
'productbatch')) {
1141 print
'jQuery("#qtyl'.$i.
'_'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1145 print
'return false; });'.
"\n";
1146 print
'jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0);'.
"\n";
1147 print
'return false; });'.
"\n";
1149 print
'</script>'.
"\n";
1153 print
'<table class="noborder centpercent">';
1156 $object->loadExpeditions();
1159 $alreadyQtyBatchSetted = $alreadyQtySetted = array();
1162 print
'<tr class="liste_titre">';
1163 print
'<td>'.$langs->trans(
"Description").
'</td>';
1164 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1165 print
'<td class="center">'.$langs->trans(
"QtyShipped").
'</td>';
1166 print
'<td class="center">'.$langs->trans(
"QtyToShip");
1167 if (empty($conf->productbatch->enabled)) {
1168 print
'<br><a href="#" id="autofill" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Autofill"),
'autofill',
'class="paddingrightonly"').
'</a>';
1173 print
'<span id="autoreset" class="opacitymedium link cursor cursorpointer">'.img_picto($langs->trans(
"Reset"),
'eraser').
'</span>';
1175 if (isModEnabled(
'stock')) {
1176 if (empty($conf->productbatch->enabled)) {
1177 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1179 print
'<td class="left">'.$langs->trans(
"Warehouse").
' / '.$langs->trans(
"Batch").
' ('.$langs->trans(
"Stock").
')</td>';
1183 print
'<td class="left">'.$langs->trans(
'StockEntryDate').
'</td>';
1188 $warehouse_id =
GETPOST(
'entrepot_id',
'int');
1189 $warehousePicking = array();
1191 if ($warehouse_id > 0) {
1192 $warehousePicking[] = $warehouse_id;
1194 $warehouseObj->get_children_warehouses($warehouse_id, $warehousePicking);
1198 while ($indiceAsked < $numAsked) {
1201 $line = $object->lines[$indiceAsked];
1203 $parameters = array(
'i' => $indiceAsked,
'line' => $line,
'num' => $numAsked);
1204 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
1209 if (empty($reshook)) {
1211 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1214 if (!empty($line->date_start)) {
1217 if (!empty($line->date_end)) {
1221 print
'<!-- line for order line '.$line->id.
' -->'.
"\n";
1222 print
'<tr class="oddeven" id="row-'.$line->id.
'">'.
"\n";
1225 if ($line->fk_product > 0) {
1226 $res = $product->fetch($line->fk_product);
1230 $product->load_stock(
'warehouseopen');
1234 print
'<a name="'.$line->id.
'"></a>';
1237 $product_static->type = $line->fk_product_type;
1238 $product_static->id = $line->fk_product;
1239 $product_static->ref = $line->ref;
1240 $product_static->status = $line->product_tosell;
1241 $product_static->status_buy = $line->product_tobuy;
1242 $product_static->status_batch = $line->product_tobatch;
1244 $showdescinproductdesc =
getDolGlobalString(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE');
1246 $text = $product_static->getNomUrl(1);
1247 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1250 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
1253 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1256 if ($showdescinproductdesc) {
1257 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1264 $text =
img_object($langs->trans(
'Service'),
'service');
1266 $text =
img_object($langs->trans(
'Product'),
'product');
1269 if (!empty($line->label)) {
1270 $text .=
' <strong>'.$line->label.
'</strong>';
1271 print $form->textwithtooltip($text, $line->desc, 3,
'',
'', $i);
1273 print $text.
' '.nl2br($line->desc);
1277 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1288 print
'<td class="center">'.$line->qty;
1289 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1290 print
''.$unit_order.
'</td>';
1291 $qtyProdCom = $line->qty;
1294 print
'<td class="center">';
1295 $quantityDelivered = isset($object->expeditions[$line->id]) ? $object->expeditions[$line->id] :
'';
1296 print $quantityDelivered;
1297 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1298 print
''.$unit_order.
'</td>';
1301 $quantityAsked = $line->qty;
1303 $quantityToBeDelivered = 0;
1305 if (is_numeric($quantityDelivered)) {
1306 $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
1308 $quantityToBeDelivered = $quantityAsked;
1312 $warehouseObject =
null;
1313 if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !isModEnabled(
'stock')) {
1314 print
'<!-- Case warehouse already known or product not a predefined product -->';
1316 $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0);
1318 $deliverableQty = $quantityToBeDelivered;
1320 $deliverableQty = min($quantityToBeDelivered, $stock);
1322 if ($deliverableQty < 0) {
1323 $deliverableQty = 0;
1325 if (empty($conf->productbatch->enabled) || !$product->hasbatch()) {
1327 print
'<td class="center">';
1329 if (
GETPOST(
'qtyl'.$indiceAsked,
'int')) {
1330 $deliverableQty =
GETPOST(
'qtyl'.$indiceAsked,
'int');
1332 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1333 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" class="qtyl right" type="text" size="4" value="'.$deliverableQty.
'">';
1336 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1337 print
'<input name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1340 print $langs->trans(
"NA");
1345 if (isModEnabled(
'stock')) {
1346 print
'<td class="left">';
1349 $ent =
"entl".$indiceAsked;
1350 $idl =
"idl".$indiceAsked;
1351 $tmpentrepot_id = is_numeric(
GETPOST($ent,
'int')) ?
GETPOST($ent,
'int') : $warehouse_id;
1352 if ($line->fk_product > 0) {
1353 print
'<!-- Show warehouse selection -->';
1359 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 1, 0, $line->fk_product,
'', 1, 0, array(),
'minwidth200',
'', 1, $stockMin,
'stock DESC, e.ref');
1361 if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) {
1363 if ($stock < $quantityToBeDelivered) {
1364 print
' '.img_warning($langs->trans(
"StockTooLow"));
1369 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span><input name="entl'.$indiceAsked.
'" id="entl'.$indiceAsked.
'" type="hidden" value="0">';
1380 $product->get_sousproduits_arbo();
1381 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1382 if (count($prods_arbo) > 0) {
1383 foreach ($prods_arbo as $key => $value) {
1386 if ($value[
'stock'] < $value[
'stock_alert']) {
1389 print
"<tr class=\"oddeven\"><td> ->
1390 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1391 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1392 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1402 print
'<td></td><td></td>';
1407 print
'<!-- Case product need lot -->';
1409 $staticwarehouse =
new Entrepot($db);
1410 if ($warehouse_id > 0) {
1411 $staticwarehouse->fetch($warehouse_id);
1417 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1418 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1422 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1423 if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch)) {
1424 foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) {
1426 $batchStock = + $dbatch->qty;
1427 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1430 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1431 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1433 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1434 $alreadyQtyBatchSetted[$line->fk_product] = array();
1437 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1438 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1441 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1444 if ($deliverableQty < 0) $deliverableQty = 0;
1446 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1447 if (GETPOSTISSET($inputName)) {
1448 $deliverableQty =
GETPOST($inputName,
'int');
1451 $tooltipClass = $tooltipTitle =
'';
1452 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1453 $tooltipClass =
' classfortooltip';
1454 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1456 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1458 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1460 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1461 print
'<td colspan="3" ></td><td class="center">';
1462 print
'<input class="qtyl '.$tooltipClass.
' right" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1465 print
'<!-- Show details of lot -->';
1466 print
'<td class="left">';
1468 print $staticwarehouse->getNomUrl(0).
' / ';
1470 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1473 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
1475 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1478 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1480 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
1484 $quantityToBeDelivered -= $deliverableQty;
1485 if ($quantityToBeDelivered < 0) {
1486 $quantityToBeDelivered = 0;
1491 print
'<td>'.dol_print_date($dbatch->context[
'stock_entry_date'],
'day').
'</td>';
1496 print
'<!-- Case there is no details of lot at all -->';
1497 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1498 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0" disabled="disabled"> ';
1501 print
'<td class="left">';
1502 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $staticwarehouse->label);
1512 if (empty($conf->productbatch->enabled) || !$product->hasbatch()) {
1513 print
'<!-- Case warehouse not already known and product does not need lot -->';
1514 print
'<td></td><td></td>';
1520 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1525 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1526 if ($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1530 $tmpwarehouseObject =
new Entrepot($db);
1531 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1533 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1538 $tmpwarehouseObject->fetch($warehouse_id);
1539 if ($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
1540 $stock = + $stock_warehouse->real;
1541 $deliverableQty = min($quantityToBeDelivered, $stock);
1542 $deliverableQty = max(0, $deliverableQty);
1544 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'>';
1545 print
'<td colspan="3" ></td><td class="center"><!-- qty to ship (no lot management for product line indiceAsked='.$indiceAsked.
') -->';
1547 if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1548 $deliverableQty = min($quantityToBeDelivered, $stock - $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]);
1550 if (!isset($alreadyQtySetted[$line->fk_product])) {
1551 $alreadyQtySetted[$line->fk_product] = array();
1554 $deliverableQty = min($quantityToBeDelivered, $stock);
1557 if ($deliverableQty < 0) {
1558 $deliverableQty = 0;
1561 $tooltipClass = $tooltipTitle =
'';
1562 if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) {
1563 $tooltipClass =
' classfortooltip';
1564 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1566 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0;
1569 $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)];
1571 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1572 if (GETPOSTISSET($inputName)) {
1573 $deliverableQty =
GETPOST($inputName,
'int');
1576 print
'<input class="qtyl'.$tooltipClass.
' right" title="'.$tooltipTitle.
'" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1577 print
'<input name="ent1'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$warehouse_id.
'">';
1580 print
'<input name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'" type="hidden" value="0">';
1583 print $langs->trans(
"NA");
1588 if (isModEnabled(
'stock')) {
1589 print
'<td class="left">';
1591 print $tmpwarehouseObject->getNomUrl(0).
' ';
1593 print
'<!-- Show details of stock -->';
1594 print
'('.$stock.
')';
1596 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
1600 $quantityToBeDelivered -= $deliverableQty;
1601 if ($quantityToBeDelivered < 0) {
1602 $quantityToBeDelivered = 0;
1613 $product->get_sousproduits_arbo();
1614 $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
1615 if (count($prods_arbo) > 0) {
1616 foreach ($prods_arbo as $key => $value) {
1619 if ($value[
'stock'] < $value[
'stock_alert']) {
1622 print
'<tr class"oddeven"><td>';
1623 print
" ->
1624 <a href=\"".DOL_URL_ROOT.
"/product/card.php?id=".$value[
'id'].
"\">".$value[
'fullpath'].
"
1625 </a> (".$value[
'nb'].
")</td><td class=\"center\"> ".$value[
'nb_total'].
"</td><td> </td><td> </td>
1626 <td class=\"center\">".$value[
'stock'].
" ".$img.
"</td>";
1635 print
'<!-- Case warehouse not already known and product need lot -->';
1636 print
'<td></td><td></td>';
1643 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1645 $tmpwarehouseObject =
new Entrepot($db);
1650 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1651 if (($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) && (count($stock_warehouse->detail_batch))) {
1652 $nbofsuggested+=count($stock_warehouse->detail_batch);
1656 foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) {
1658 if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) {
1663 $tmpwarehouseObject->fetch($warehouse_id);
1664 if (($stock_warehouse->real > 0 || !empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) && (count($stock_warehouse->detail_batch))) {
1665 foreach ($stock_warehouse->detail_batch as $dbatch) {
1666 $batchStock = + $dbatch->qty;
1667 if (isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1668 $deliverableQty = min($quantityToBeDelivered, $batchStock - $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]);
1670 if (!isset($alreadyQtyBatchSetted[$line->fk_product])) {
1671 $alreadyQtyBatchSetted[$line->fk_product] = array();
1674 if (!isset($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch])) {
1675 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch] = array();
1678 $deliverableQty = min($quantityToBeDelivered, $batchStock);
1681 if ($deliverableQty < 0) {
1682 $deliverableQty = 0;
1685 $inputName =
'qtyl'.$indiceAsked.
'_'.$subj;
1686 if (GETPOSTISSET($inputName)) {
1687 $deliverableQty =
GETPOST($inputName,
'int');
1690 $tooltipClass = $tooltipTitle =
'';
1691 if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) {
1692 $tooltipClass =
' classfortooltip';
1693 $tooltipTitle = $langs->trans(
'StockQuantitiesAlreadyAllocatedOnPreviousLines').
' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1695 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ;
1697 $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)];
1699 print
'<!-- subj='.$subj.
'/'.$nbofsuggested.
' --><tr '.((($subj + 1) == $nbofsuggested) ?
'oddeven' :
'').
'><td colspan="3"></td><td class="center">';
1700 print
'<input class="qtyl right '.$tooltipClass.
'" title="'.$tooltipTitle.
'" name="'.$inputName.
'" id="'.$inputName.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1703 print
'<td class="left">';
1705 print $tmpwarehouseObject->getNomUrl(0).
' / ';
1707 print
'<!-- Show details of lot -->';
1708 print
'<input name="batchl'.$indiceAsked.
'_'.$subj.
'" type="hidden" value="'.$dbatch->id.
'">';
1711 print $langs->trans(
"Batch").
': ';
1712 $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
1714 print $productlotObject->getNomUrl(1);
1716 print $langs->trans(
"TableLotIncompleteRunRepairWithParamStandardEqualConfirmed");
1719 print
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
1722 print
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
1724 print
' ('.$dbatch->qty.
')';
1725 $quantityToBeDelivered -= $deliverableQty;
1726 if ($quantityToBeDelivered < 0) {
1727 $quantityToBeDelivered = 0;
1733 print
'<td class="left">'.dol_print_date($dbatch->context[
'stock_entry_date'],
'day').
'</td>';
1741 $warehouse_selected_id =
GETPOST(
'entrepot_id',
'int');
1743 print
'<!-- line not shown yet, we show it -->';
1744 print
'<tr class="oddeven"><td colspan="3"></td><td class="center">';
1748 if (isModEnabled(
'productbatch') && $product->hasbatch()) {
1749 $disabled =
'disabled="disabled"';
1751 if ($warehouse_selected_id <= 0) {
1752 $disabled =
'disabled="disabled"';
1754 print
'<input class="qtyl right" name="qtyl'.$indiceAsked.
'_'.$subj.
'" id="qtyl'.$indiceAsked.
'_'.$subj.
'" type="text" size="4" value="0"'.($disabled ?
' '.$disabled :
'').
'> ';
1756 print
'<input name="ent1' . $indiceAsked .
'_' . $subj .
'" type="hidden" value="' . $warehouse_selected_id .
'">';
1759 print $langs->trans(
"NA");
1763 print
'<td class="left">';
1765 if ($warehouse_selected_id > 0) {
1766 $warehouseObject =
new Entrepot($db);
1767 $warehouseObject->fetch($warehouse_selected_id);
1768 print
img_warning().
' '.$langs->trans(
"NoProductToShipFoundIntoStock", $warehouseObject->label);
1770 if ($line->fk_product) {
1771 print
img_warning().
' '.$langs->trans(
"StockTooLow");
1777 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
1789 if (!empty($extrafields)) {
1795 $srcLine->id = $line->id;
1796 $srcLine->fetch_optionals();
1798 $expLine->array_options = array_merge($expLine->array_options, $srcLine->array_options);
1800 print $expLine->showOptionals($extrafields,
'edit', array(
'style'=>
'class="drag drop oddeven"',
'colspan'=>$colspan), $indiceAsked,
'', 1);
1811 print $form->buttonsSaveCancel(
"Create");
1820} elseif ($object->id > 0) {
1826 $lines = $object->lines;
1828 $num_prod = count($lines);
1830 if (!empty($object->origin) && $object->origin_id > 0) {
1831 $typeobject = $object->origin;
1832 $origin = $object->origin;
1833 $origin_id = $object->origin_id;
1835 $object->fetch_origin();
1839 $soc->fetch($object->socid);
1841 $res = $object->fetch_optionals();
1844 print
dol_get_fiche_head($head,
'shipping', $langs->trans(
"Shipment"), -1, $object->picto);
1849 if ($action ==
'delete') {
1850 $formquestion = array();
1852 $formquestion = array(
1854 'label' => $langs->trans(
'ShipmentIncrementStockOnDelete'),
1855 'name' =>
'alsoUpdateStock',
1856 'type' =>
'checkbox',
1861 $formconfirm = $form->formconfirm(
1862 $_SERVER[
'PHP_SELF'].
'?id='.$object->id,
1863 $langs->trans(
'DeleteSending'),
1864 $langs->trans(
"ConfirmDeleteSending", $object->ref),
1873 if ($action ==
'valid') {
1874 $objectref = substr($object->ref, 1, 4);
1875 if ($objectref ==
'PROV') {
1876 $numref = $object->getNextNumRef($soc);
1878 $numref = $object->ref;
1881 $text = $langs->trans(
"ConfirmValidateSending", $numref);
1883 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementWillBeRecorded").
'.';
1885 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementNotYetRecorded").
'.';
1888 if (isModEnabled(
'notification')) {
1889 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1890 $notify =
new Notify($db);
1892 $text .= $notify->confirmMessage(
'SHIPPING_VALIDATE', $object->socid, $object);
1895 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'ValidateSending'), $text,
'confirm_valid',
'', 0, 1, 250);
1898 if ($action ==
'cancel') {
1899 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'CancelSending'), $langs->trans(
"ConfirmCancelSending", $object->ref),
'confirm_cancel',
'', 0, 1);
1903 $parameters = array(
'formConfirm' => $formconfirm);
1904 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1905 if (empty($reshook)) {
1906 $formconfirm .= $hookmanager->resPrint;
1907 } elseif ($reshook > 0) {
1908 $formconfirm = $hookmanager->resPrint;
1916 $tmparray = $object->getTotalWeightVolume();
1917 $totalWeight = $tmparray[
'weight'];
1918 $totalVolume = $tmparray[
'volume'];
1920 if (!empty($typeobject) && $typeobject ===
'commande' && is_object($object->$typeobject) && $object->$typeobject->id && isModEnabled(
'commande')) {
1922 $objectsrc->fetch($object->$typeobject->id);
1924 if (!empty($typeobject) && $typeobject ===
'propal' && is_object($object->$typeobject) && $object->$typeobject->id && isModEnabled(
"propal")) {
1925 $objectsrc =
new Propal($db);
1926 $objectsrc->fetch($object->$typeobject->id);
1930 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1931 $morehtmlref =
'<div class="refidno">';
1933 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string',
'', 0, 1);
1934 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $user->hasRight(
'expedition',
'creer'),
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
1936 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
1938 if (isModEnabled(
'project')) {
1939 $langs->load(
"projects");
1940 $morehtmlref .=
'<br>';
1942 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1943 if ($action !=
'classify') {
1944 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1946 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1948 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
1950 $proj->fetch($objectsrc->fk_project);
1951 $morehtmlref .= $proj->getNomUrl(1);
1953 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1958 $morehtmlref .=
'</div>';
1961 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1964 print
'<div class="fichecenter">';
1965 print
'<div class="fichehalfleft">';
1966 print
'<div class="underbanner clearboth"></div>';
1968 print
'<table class="border tableforfield centpercent">';
1971 if (!empty($typeobject) && $typeobject ==
'commande' && $object->$typeobject->id && isModEnabled(
'commande')) {
1973 print $langs->trans(
"RefOrder").
'</td>';
1974 print
'<td colspan="3">';
1975 print $objectsrc->getNomUrl(1,
'commande');
1979 if (!empty($typeobject) && $typeobject ==
'propal' && $object->$typeobject->id && isModEnabled(
"propal")) {
1981 print $langs->trans(
"RefProposal").
'</td>';
1982 print
'<td colspan="3">';
1983 print $objectsrc->getNomUrl(1,
'expedition');
1989 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
1990 print
'<td colspan="3">'.dol_print_date($object->date_creation,
"dayhour").
"</td>\n";
1994 print
'<tr><td height="10">';
1995 print
'<table class="nobordernopadding centpercent"><tr><td>';
1996 print $langs->trans(
'DateDeliveryPlanned');
1999 if ($action !=
'editdate_livraison') {
2000 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>';
2002 print
'</tr></table>';
2003 print
'</td><td colspan="2">';
2004 if ($action ==
'editdate_livraison') {
2005 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2006 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2007 print
'<input type="hidden" name="action" value="setdate_livraison">';
2008 print $form->selectDate($object->date_delivery ? $object->date_delivery : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
2009 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2012 print $object->date_delivery ?
dol_print_date($object->date_delivery,
'dayhour') :
' ';
2019 print $form->editfieldkey(
"Weight",
'trueWeight', $object->trueWeight, $object, $user->hasRight(
'expedition',
'creer'));
2020 print
'</td><td colspan="3">';
2022 if ($action ==
'edittrueWeight') {
2023 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2024 print
'<input name="action" value="settrueWeight" type="hidden">';
2025 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2026 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2027 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text" class="width50 valignmiddle">';
2028 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $object->weight_units, 0, 2,
'maxwidth125 valignmiddle');
2029 print
' <input class="button smallpaddingimp valignmiddle" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2030 print
' <input class="button button-cancel smallpaddingimp valignmiddle" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2033 print $object->trueWeight;
2034 print ($object->trueWeight && $object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight", $object->weight_units) :
'';
2038 if ($totalWeight > 0) {
2039 if (!empty($object->trueWeight)) {
2040 print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
2042 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');
2043 if (!empty($object->trueWeight)) {
2050 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth', $object->trueWidth, $object, $user->hasRight(
'expedition',
'creer')).
'</td><td colspan="3">';
2051 print $form->editfieldval(
"Width",
'trueWidth', $object->trueWidth, $object, $user->hasRight(
'expedition',
'creer'));
2052 print ($object->trueWidth && $object->width_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->width_units) :
'';
2056 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight', $object->trueHeight, $object, $user->hasRight(
'expedition',
'creer')).
'</td><td colspan="3">';
2057 if ($action ==
'edittrueHeight') {
2058 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2059 print
'<input name="action" value="settrueHeight" type="hidden">';
2060 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2061 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2062 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text" class="width50">';
2063 print $formproduct->selectMeasuringUnits(
"size_units",
"size", $object->size_units, 0, 2);
2064 print
' <input class="button smallpaddingimp" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2065 print
' <input class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2068 print $object->trueHeight;
2069 print ($object->trueHeight && $object->height_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->height_units) :
'';
2075 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->hasRight(
'expedition',
'creer')).
'</td><td colspan="3">';
2076 print $form->editfieldval(
"Depth",
'trueDepth', $object->trueDepth, $object, $user->hasRight(
'expedition',
'creer'));
2077 print ($object->trueDepth && $object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size", $object->depth_units) :
'';
2082 print $langs->trans(
"Volume");
2084 print
'<td colspan="3">';
2085 $calculatedVolume = 0;
2087 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
2088 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
2089 $volumeUnit = $object->size_units * 3;
2092 if ($calculatedVolume > 0) {
2093 if ($volumeUnit < 50) {
2094 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');
2099 if ($totalVolume > 0) {
2100 if ($calculatedVolume) {
2101 print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
2103 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');
2105 if ($calculatedVolume) {
2114 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2119 print
'<div class="fichehalfright">';
2120 print
'<div class="underbanner clearboth"></div>';
2122 print
'<table class="border centpercent tableforfield">';
2125 print
'<tr><td height="10">';
2126 print
'<table class="nobordernopadding centpercent"><tr><td>';
2127 print $langs->trans(
'SendingMethod');
2130 if ($action !=
'editshipping_method_id') {
2131 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>';
2133 print
'</tr></table>';
2134 print
'</td><td colspan="2">';
2135 if ($action ==
'editshipping_method_id') {
2136 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2137 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2138 print
'<input type="hidden" name="action" value="setshipping_method_id">';
2139 $object->fetch_delivery_methods();
2140 print $form->selectarray(
"shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0,
"", 1);
2142 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2144 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
2147 if ($object->shipping_method_id > 0) {
2149 $code = $langs->getLabelFromKey($db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
2150 print $langs->trans(
"SendingMethod".strtoupper($code));
2157 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number', $object->tracking_number, $object, $user->hasRight(
'expedition',
'creer')).
'</td><td colspan="3">';
2158 print $form->editfieldval(
"TrackingNumber",
'tracking_number', $object->tracking_url, $object, $user->hasRight(
'expedition',
'creer'),
'safehtmlstring', $object->tracking_number);
2162 if (isModEnabled(
'incoterm')) {
2164 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2165 print $langs->trans(
'IncotermLabel');
2166 print
'<td><td class="right">';
2167 if ($user->hasRight(
'expedition',
'creer')) {
2168 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/expedition/card.php?id='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit().
'</a>';
2172 print
'</td></tr></table>';
2174 print
'<td colspan="3">';
2175 if ($action !=
'editincoterm') {
2176 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2178 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2184 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3');
2185 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2186 print $hookmanager->resPrint;
2193 print
'<div class="clearboth"></div>';
2198 if ($action ==
'editline') {
2199 print
' <form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$line_id.
'" method="POST">
2200 <input type="hidden" name="token" value="' . newToken().
'">
2201 <input type="hidden" name="action" value="updateline">
2202 <input type="hidden" name="mode" value="">
2203 <input type="hidden" name="id" value="' . $object->id.
'">
2208 print
'<div class="div-table-responsive-no-min">';
2209 print
'<table class="noborder" width="100%" id="tablelines" >';
2211 print
'<tr class="liste_titre">';
2214 print
'<td width="5" class="center linecolnum"> </td>';
2217 print
'<td class="linecoldescription" >'.$langs->trans(
"Products").
'</td>';
2219 print
'<td class="center linecolqty">'.$langs->trans(
"QtyOrdered").
'</td>';
2220 if ($origin && $origin_id > 0) {
2221 print
'<td class="center linecolqtyinothershipments">'.$langs->trans(
"QtyInOtherShipments").
'</td>';
2223 if ($action ==
'editline') {
2225 if (!isModEnabled(
'stock')) {
2228 if (empty($conf->productbatch->enabled)) {
2231 print
'<td class="center linecoleditlineotherinfo" colspan="'.$editColspan.
'">';
2232 if ($object->statut <= 1) {
2233 print $langs->trans(
"QtyToShip").
' - ';
2235 print $langs->trans(
"QtyShipped").
' - ';
2237 if (isModEnabled(
'stock')) {
2238 print $langs->trans(
"WarehouseSource").
' - ';
2240 if (isModEnabled(
'productbatch')) {
2241 print $langs->trans(
"Batch");
2245 if ($object->statut <= 1) {
2246 print
'<td class="center linecolqtytoship">'.$langs->trans(
"QtyToShip").
'</td>';
2248 print
'<td class="center linecolqtyshipped">'.$langs->trans(
"QtyShipped").
'</td>';
2250 if (isModEnabled(
'stock')) {
2251 print
'<td class="left linecolwarehousesource">'.$langs->trans(
"WarehouseSource").
'</td>';
2254 if (isModEnabled(
'productbatch')) {
2255 print
'<td class="left linecolbatch">'.$langs->trans(
"Batch").
'</td>';
2258 print
'<td class="center linecolweight">'.$langs->trans(
"CalculatedWeight").
'</td>';
2259 print
'<td class="center linecolvolume">'.$langs->trans(
"CalculatedVolume").
'</td>';
2261 if ($object->statut == 0) {
2262 print
'<td class="linecoledit"></td>';
2263 print
'<td class="linecoldelete" width="10"></td>';
2268 $outputlangs = $langs;
2271 $object->fetch_thirdparty();
2273 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
2274 $newlang =
GETPOST(
'lang_id',
'aZ09');
2276 if (empty($newlang)) {
2277 $newlang = $object->thirdparty->default_lang;
2279 if (!empty($newlang)) {
2280 $outputlangs =
new Translate(
"", $conf);
2281 $outputlangs->setDefaultLang($newlang);
2286 $alreadysent = array();
2287 if ($origin && $origin_id > 0) {
2288 $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";
2289 $sql .=
", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot";
2290 $sql .=
", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition";
2292 $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';
2293 $sql .=
', p.description as product_desc';
2294 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expeditiondet as ed";
2295 $sql .=
", ".MAIN_DB_PREFIX.
"expedition as e";
2296 $sql .=
", ".MAIN_DB_PREFIX.$origin.
"det as obj";
2298 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2299 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
2300 $sql .=
" AND obj.fk_".$origin.
" = ".((int) $origin_id);
2301 $sql .=
" AND obj.rowid = ed.fk_origin_line";
2302 $sql .=
" AND ed.fk_expedition = e.rowid";
2304 $sql .=
" ORDER BY obj.fk_product";
2306 dol_syslog(
"expedition/card.php get list of shipment lines", LOG_DEBUG);
2307 $resql = $db->query($sql);
2309 $num = $db->num_rows($resql);
2313 $obj = $db->fetch_object($resql);
2316 $alreadysent[$obj->rowid][$obj->shipmentline_id] = array(
2317 'shipment_ref'=>$obj->shipment_ref,
'shipment_id'=>$obj->shipment_id,
'warehouse'=>$obj->fk_entrepot,
'qty_shipped'=>$obj->qty_shipped,
2318 'product_tosell'=>$obj->product_tosell,
'product_tobuy'=>$obj->product_tobuy,
'product_tobatch'=>$obj->product_tobatch,
2319 'date_valid'=>$db->jdate($obj->date_valid),
'date_delivery'=>$db->jdate($obj->date_delivery));
2330 for ($i = 0; $i < $num_prod; $i++) {
2331 $parameters = array(
'i' => $i,
'line' => $lines[$i],
'line_id' => $line_id,
'num' => $num_prod,
'alreadysent' => $alreadysent,
'editColspan' => !empty($editColspan) ? $editColspan : 0,
'outputlangs' => $outputlangs);
2332 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
2337 if (empty($reshook)) {
2338 print
'<!-- origin line id = '.$lines[$i]->origin_line_id.
' -->';
2339 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'" >';
2343 print
'<td class="center linecolnum">'.($i + 1).
'</td>';
2347 if ($lines[$i]->fk_product > 0) {
2351 $prod->fetch($lines[$i]->fk_product);
2352 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"label"])) ? $prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product_label;
2354 $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);
2357 print
'<td class="linecoldescription">';
2360 $product_static->type = $lines[$i]->fk_product_type;
2361 $product_static->id = $lines[$i]->fk_product;
2362 $product_static->ref = $lines[$i]->ref;
2363 $product_static->status = $lines[$i]->product_tosell;
2364 $product_static->status_buy = $lines[$i]->product_tobuy;
2365 $product_static->status_batch = $lines[$i]->product_tobatch;
2367 $product_static->weight = $lines[$i]->weight;
2368 $product_static->weight_units = $lines[$i]->weight_units;
2369 $product_static->length = $lines[$i]->length;
2370 $product_static->length_units = $lines[$i]->length_units;
2371 $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0;
2372 $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0;
2373 $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0;
2374 $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0;
2375 $product_static->surface = $lines[$i]->surface;
2376 $product_static->surface_units = $lines[$i]->surface_units;
2377 $product_static->volume = $lines[$i]->volume;
2378 $product_static->volume_units = $lines[$i]->volume_units;
2380 $text = $product_static->getNomUrl(1);
2381 $text .=
' - '.$label;
2383 print $form->textwithtooltip($text, $description, 3,
'',
'', $i);
2384 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start :
'', !empty($lines[$i]->date_end) ? $lines[$i]->date_end :
'');
2390 print
'<td class="linecoldescription" >';
2392 $text =
img_object($langs->trans(
'Service'),
'service');
2394 $text =
img_object($langs->trans(
'Product'),
'product');
2397 if (!empty($lines[$i]->label)) {
2398 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2399 print $form->textwithtooltip($text, $lines[$i]->
description, 3,
'',
'', $i);
2414 print
'<td class="center linecolqty">'.$lines[$i]->qty_asked.
' '.$unit_order.
'</td>';
2417 if ($origin && $origin_id > 0) {
2418 print
'<td class="linecolqtyinothershipments center nowrap">';
2420 $qtyalreadysent = 0;
2421 foreach ($alreadysent as $key => $val) {
2422 if ($lines[$i]->fk_origin_line == $key) {
2424 foreach ($val as $shipmentline_id => $shipmentline_var) {
2425 if ($shipmentline_var[
'shipment_id'] == $lines[$i]->fk_expedition) {
2431 $htmltooltip .=
'<br>';
2433 $shipment_static->fetch($shipmentline_var[
'shipment_id']);
2434 $htmltooltip .= $shipment_static->getNomUrl(1,
'', 0, 0, 1);
2435 $htmltooltip .=
' - '.$shipmentline_var[
'qty_shipped'];
2436 $htmltooltip .=
' - '.$langs->trans(
"DateValidation").
' : '.(empty($shipmentline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($shipmentline_var[
'date_valid'],
'dayhour'));
2443 $qtyalreadysent += $shipmentline_var[
'qty_shipped'];
2446 $htmltooltip = $langs->trans(
"QtyInOtherShipments").
'...<br><br>'.$htmltooltip.
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
2450 print $form->textwithpicto($qtyalreadysent, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip'.$lines[$i]->
id);
2454 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2456 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding centpercent">';
2457 if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
2458 print
'<!-- case edit 1 -->';
2460 foreach ($lines[$i]->detail_batch as $detail_batch) {
2463 print
'<td><input class="qtyl right" name="qtyl'.$detail_batch->fk_expeditiondet.
'_'.$detail_batch->id.
'" id="qtyl'.$line_id.
'_'.$detail_batch->id.
'" type="text" size="4" value="'.$detail_batch->qty.
'"></td>';
2465 if ($lines[$i]->entrepot_id == 0) {
2467 $line->fetch($detail_batch->fk_expeditiondet);
2469 $entrepot_id = !empty($detail_batch->entrepot_id) ? $detail_batch->entrepot_id : $lines[$i]->entrepot_id;
2470 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>';
2476 print
'<td><input class="qtyl" name="qtyl'.$line_id.
'_0" id="qtyl'.$line_id.
'_0" type="text" size="4" value="0"></td>';
2478 print
'<td>'.$formproduct->selectLotStock(
'',
'batchl'.$line_id.
'_0',
'', 1, 0, $lines[$i]->fk_product).
'</td>';
2480 } elseif (isModEnabled(
'stock')) {
2481 if ($lines[$i]->fk_product > 0) {
2482 if ($lines[$i]->entrepot_id > 0) {
2483 print
'<!-- case edit 2 -->';
2486 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'">'.$unit_order.
'</td>';
2488 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2490 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2492 } elseif (count($lines[$i]->details_entrepot) > 1) {
2493 print
'<!-- case edit 3 -->';
2494 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2497 print
'<td><input class="qtyl right" name="qtyl'.$detail_entrepot->line_id.
'" id="qtyl'.$detail_entrepot->line_id.
'" type="text" size="4" value="'.$detail_entrepot->qty_shipped.
'">'.$unit_order.
'</td>';
2499 print
'<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id,
'entl'.$detail_entrepot->line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2501 print
'<td> - '.$langs->trans(
"NA").
'</td>';
2505 print
'<!-- case edit 4 -->';
2508 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2509 print
'<td><span class="opacitymedium">('.$langs->trans(
"Service").
')</span></td>';
2513 print
'<!-- case edit 5 -->';
2514 print
'<tr><td colspan="3">'.$langs->trans(
"NotEnoughStock").
'</td></tr>';
2517 print
'<!-- case edit 6 -->';
2520 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'">'.$unit_order.
'</td>';
2527 } elseif (!isModEnabled(
'stock') && empty($conf->productbatch->enabled)) {
2528 print
'<!-- case edit 7 -->';
2531 print
'<td><input class="qtyl right" name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty_shipped.
'"></td>';
2539 print
'</table></td>';
2542 print
'<td class="linecolqtytoship center">'.$lines[$i]->qty_shipped.
' '.$unit_order.
'</td>';
2545 if (isModEnabled(
'stock')) {
2546 print
'<td class="linecolwarehousesource tdoverflowmax200">';
2548 print
'<span class="opacitymedium">('.$langs->trans(
"Service").
')</span>';
2549 } elseif ($lines[$i]->entrepot_id > 0) {
2551 $entrepot->fetch($lines[$i]->entrepot_id);
2552 print $entrepot->getNomUrl(1);
2553 } elseif (count($lines[$i]->details_entrepot) > 1) {
2555 foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
2556 if ($detail_entrepot->entrepot_id > 0) {
2558 $entrepot->fetch($detail_entrepot->entrepot_id);
2559 $detail .= $langs->trans(
"DetailWarehouseFormat", $entrepot->label, $detail_entrepot->qty_shipped).
'<br>';
2562 print $form->textwithtooltip(
img_picto(
'',
'object_stock').
' '.$langs->trans(
"DetailWarehouseNumber"), $detail);
2568 if (isModEnabled(
'productbatch')) {
2569 if (isset($lines[$i]->detail_batch)) {
2570 print
'<!-- Detail of lot -->';
2571 print
'<td class="linecolbatch">';
2572 if ($lines[$i]->product_tobatch) {
2574 foreach ($lines[$i]->detail_batch as $dbatch) {
2575 $detail .= $langs->trans(
"Batch").
': '.$dbatch->batch;
2577 $detail .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($dbatch->sellby,
"day");
2580 $detail .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($dbatch->eatby,
"day");
2582 $detail .=
' - '.$langs->trans(
"Qty").
': '.$dbatch->qty;
2585 print $form->textwithtooltip(
img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $detail);
2587 print $langs->trans(
"NA");
2591 print
'<td class="linecolbatch" ></td>';
2597 print
'<td class="center linecolweight">';
2599 print $lines[$i]->weight * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"weight", $lines[$i]->weight_units);
2606 print
'<td class="center linecolvolume">';
2608 print $lines[$i]->volume * $lines[$i]->qty_shipped.
' '.
measuringUnitString(0,
"volume", $lines[$i]->volume_units);
2617 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2618 print
'<td class="center" colspan="2" valign="middle">';
2619 print
'<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2620 print
'<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2624 print
'<td class="linecoledit center">';
2625 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=editline&token='.newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_edit().
'</a>';
2627 print
'<td class="linecoldelete" width="10">';
2628 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.newToken().
'&lineid='.$lines[$i]->id.
'">'.
img_delete().
'</a>';
2632 if (!empty($rowExtrafieldsStart)) {
2633 print $rowExtrafieldsStart;
2634 print $rowExtrafieldsView;
2642 if (!empty($extrafields)) {
2644 if ($origin && $origin_id > 0) {
2647 if (isModEnabled(
'productbatch')) {
2650 if (isModEnabled(
'stock')) {
2655 $line->fetch_optionals();
2658 if ($action ==
'editline' && $line->id == $line_id) {
2659 print $lines[$i]->showOptionals($extrafields,
'edit', array(
'colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'', 0,
'card');
2661 print $lines[$i]->showOptionals($extrafields,
'view', array(
'colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked :
'',
'', 0,
'card');
2669 if (empty($num_prod)) {
2670 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv(
"ShipmentDistribution")).
'</span></td></tr>';
2681 $object->fetchObjectLinked($object->id, $object->element);
2688 if (($user->socid == 0) && ($action !=
'presend')) {
2689 print
'<div class="tabsAction">';
2691 $parameters = array();
2692 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2694 if (empty($reshook)) {
2696 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'creer'))
2697 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'expedition',
'shipping_advance',
'validate'))) {
2698 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=valid&token='.newToken().
'&id='.$object->id,
'');
2700 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2706 if ($user->hasRight(
'expedition',
'creer')) {
2707 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?action=setdraft&token='.newToken().
'&id='.$object->id,
'');
2711 if ($user->hasRight(
'expedition',
'creer')) {
2712 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.newToken().
'&id='.$object->id,
'');
2717 if (empty($user->socid)) {
2718 if ($object->statut > 0) {
2719 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'expedition',
'shipping_advance',
'send')) {
2720 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2722 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2729 if ($user->hasRight(
'facture',
'creer')) {
2731 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2739 print
dolGetButtonAction(
'', $langs->trans(
'CreateDeliveryOrder'),
'default', $_SERVER[
"PHP_SELF"].
'?action=create_delivery&token='.newToken().
'&id='.$object->id,
'');
2744 if ($user->hasRight(
'expedition',
'creer') && $object->statut > 0) {
2746 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.newToken().
'&id='.$object->id,
'');
2748 print
dolGetButtonAction(
'', $langs->trans(
"Close"),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifyclosed&token='.newToken().
'&id='.$object->id,
'');
2754 if ($user->hasRight(
'expedition',
'creer')) {
2755 print
dolGetButtonAction(
'', $langs->trans(
'Cancel'),
'danger', $_SERVER[
"PHP_SELF"].
'?action=cancel&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2760 if ($user->hasRight(
'expedition',
'supprimer')) {
2761 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.$object->id,
'');
2773 if ($action !=
'presend' && $action !=
'editline') {
2774 print
'<div class="fichecenter"><div class="fichehalfleft">';
2777 $filedir = $conf->expedition->dir_output.
"/sending/".$objectref;
2779 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2781 $genallowed = $user->rights->expedition->lire;
2782 $delallowed = $user->rights->expedition->creer;
2784 print $formfile->showdocuments(
'expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2788 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'shipping'));
2789 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2792 print
'</div><div class="fichehalfright">';
2795 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2797 $somethingshown =
$formactions->showactions($object,
'shipping', $socid, 1);
2799 print
'</div></div>';
2808 if (
GETPOST(
'modelselected')) {
2809 $action =
'presend';
2813 $modelmail =
'shipping_send';
2814 $defaulttopic =
'SendShippingRef';
2815 $diroutput = $conf->expedition->dir_output.
'/sending';
2816 $trackid =
'shi'.$object->id;
2818 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 a 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.