41require
'../main.inc.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/reception.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
65 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
67require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.orderline.class.php';
69require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.dispatch.class.php';
71 require_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
74 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
75 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
78$langs->loadLangs(array(
"receptions",
"companies",
"bills",
'orders',
'stocks',
'other',
'propal',
'sendings'));
81 $langs->load(
'incoterm');
84 $langs->load(
'productbatch');
87$origin =
GETPOST(
'origin',
'alpha');
90if (empty($origin_id) && !empty($origin)) {
93if (empty($origin_id) && !empty($origin)) {
96if (empty($origin_id) && !empty($origin)) {
103$action =
GETPOST(
'action',
'alpha');
108$confirm =
GETPOST(
'confirm',
'alpha');
109$cancel =
GETPOST(
'cancel',
'alpha');
110$backtopage =
GETPOST(
'backtopage',
'alpha');
111$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
117$cancel =
GETPOST(
'cancel',
'alpha');
120$backtopage =
GETPOST(
'backtopage',
'alpha');
131$extrafields->fetch_name_optionals_label(
$object->table_element);
132$extrafields->fetch_name_optionals_label(
$object->table_element_line);
133$extrafields->fetch_name_optionals_label($objectorder->table_element_line);
136include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
148 if (empty($origin)) {
149 if (!empty(
$object->origin_type)) {
150 $origin =
$object->origin_type;
152 $origin = (string)
$object->origin;
155 if (empty($origin_id)) {
156 $origin_id =
$object->origin_id;
161$hookmanager->initHooks(array(
'receptioncard',
'globalcard'));
168 $socid = $user->socid;
172if (
isModEnabled(
"reception") || $origin ==
'reception' || empty($origin)) {
176 if ($origin ==
'supplierorder' || $origin ==
'order_supplier') {
177 $result =
restrictedArea($user,
'fournisseur', $origin_id,
'commande_fournisseur',
'commande');
178 } elseif (!$user->hasRight($origin,
'lire') && !$user->hasRight($origin,
'read')) {
184 $permissiontoread = $user->hasRight(
'reception',
'lire');
185 $permissiontoadd = $user->hasRight(
'reception',
'creer');
186 $permissiontoedit = $user->hasRight(
'reception',
'creer');
187 $permissiondellink = $user->hasRight(
'reception',
'creer');
188 $permissiontovalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate')));
189 $permissiontodelete = $user->hasRight(
'reception',
'supprimer');
191 $permissiontoread = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
192 $permissiontoadd = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
193 $permissiondellink = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
194 $permissiontovalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande',
'receptionner')) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'fournisseur',
'commande_advance',
'check')));
195 $permissiontodelete = $user->hasRight(
'fournisseur',
'commande',
'receptionner');
197$permissiontoeditextra = $permissiontoadd;
198if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
200 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
207$shipping_method_id =
null;
218$parameters = array();
219$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
221 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
224if (empty($reshook)) {
225 $backurlforlist = DOL_URL_ROOT.
'/reception/list.php';
227 if (empty($backtopage) || ($cancel && empty($id))) {
228 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
229 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
230 $backtopage = $backurlforlist;
232 $backtopage = DOL_URL_ROOT.
'/reception/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
238 if (!empty($backtopageforcancel)) {
239 header(
"Location: ".$backtopageforcancel);
241 } elseif (!empty($backtopage)) {
242 header(
"Location: ".$backtopage);
256 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
259 if ($action ==
'reopen' && $permissiontoadd) {
267 if ($action ==
'modif' && $permissiontoadd) {
268 $result =
$object->setDraft($user);
272 $outputlangs = $langs;
275 $newlang =
GETPOST(
'lang_id',
'aZ09');
278 $newlang =
$object->thirdparty->default_lang;
280 if (!empty($newlang)) {
282 $outputlangs->setDefaultLang($newlang);
286 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
294 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
298 if ($action ==
'setref_supplier' && $permissiontoadd) {
303 $result =
$object->setValueFrom(
'ref_supplier',
GETPOST(
'ref_supplier',
'alpha'),
'',
null,
'text',
'', $user,
'RECEPTION_MODIFY');
306 $action =
'editref_supplier';
308 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
313 if ($action ==
'update_extras' && $permissiontoeditextra) {
316 $attribute_name =
GETPOST(
'attribute',
'aZ09');
319 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
325 $result =
$object->updateExtraField($attribute_name,
'RECEPTION_MODIFY');
333 $action =
'edit_extras';
338 if ($action ==
'add' && $permissiontoadd) {
344 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
353 $object->origin_type = $origin;
354 $object->origin_id = $origin_id;
365 $object->date_delivery = $date_delivery;
366 $object->date_reception = $date_reception;
372 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
377 $ret = $extrafields->setOptionalsFromPost(
null, $object);
390 if ($origin && $origin_id > 0) {
394 $object->origin_type = $origin;
395 $object->origin_id = $origin_id;
407 $object->date_delivery = $date_delivery;
408 $object->date_reception = $date_reception;
414 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
416 if (
$object->origin ==
"supplierorder") {
417 $object->origin =
'order_supplier';
418 $object->origin_type =
'order_supplier';
419 $classname =
'CommandeFournisseur';
421 $classname = ucfirst(
$object->origin_type);
423 $objectsrc =
new $classname($db);
424 $objectsrc->fetch(
$object->origin_id);
426 $object->socid = $objectsrc->socid;
429 $batch_line = array();
430 $stockLine = array();
431 $array_options = array();
436 foreach ($_POST as $key => $value) {
439 if (strpos($key,
'qtyasked') !==
false) {
445 for ($i = 1; $i <= $num; $i++) {
457 if (
GETPOST($qty,
'alpha') > 0) {
462 $array_options[$i] = $extrafields->getOptionalsFromPost(
$object->table_element_line, (
string) $i);
467 for ($i = 1; $i <= $num; $i++) {
471 foreach ($objectsrc->lines as $linesrc) {
472 if ($linesrc->id == $lineId) {
473 $lineToTest = $linesrc;
477 if (empty($lineToTest)) {
481 $comment =
"comment".$i;
486 $cost_price =
"cost_price".$i;
505 if ($entrepot_id < 0) {
512 $eatby =
GETPOST($eatby,
'alpha');
513 $sellby =
GETPOST($sellby,
'alpha');
514 $eatbydate = str_replace(
'/',
'-', $eatby);
515 $sellbydate = str_replace(
'/',
'-', $sellby);
518 $ret =
$object->addline($entrepot_id,
GETPOSTINT($idl), (
float)
price2num(
GETPOST($qty),
'MS'), $array_options[$i],
GETPOST($comment), strtotime($eatbydate), strtotime($sellbydate),
GETPOST($batch),
GETPOSTFLOAT($cost_price,
'MU'));
530 $ret = $extrafields->setOptionalsFromPost(
null, $object);
544 $outputlangs = $langs;
547 $newlang =
GETPOST(
'lang_id',
'aZ09');
550 $newlang =
$object->thirdparty->default_lang;
552 if (!empty($newlang)) {
554 $outputlangs->setDefaultLang($newlang);
559 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
567 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"QtyToReceive").
'/'.$langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
573 header(
"Location: card.php?id=" .
$object->id);
580 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $permissiontovalidate) {
583 $result =
$object->valid($user);
586 $langs->load(
"errors");
587 setEventMessages($langs->trans(
$object->error),
null,
'errors');
591 $outputlangs = $langs;
594 $newlang =
GETPOST(
'lang_id',
'aZ09');
597 $newlang =
$object->thirdparty->default_lang;
599 if (!empty($newlang)) {
601 $outputlangs->setDefaultLang($newlang);
606 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
612 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
614 $result =
$object->delete($user);
616 header(
"Location: ".DOL_URL_ROOT.
'/reception/index.php');
628 } elseif ($action ==
'setdate_livraison' && $permissiontoadd) {
632 $result =
$object->setDeliveryDate($user, $datedelivery);
636 } elseif ($action ==
'setdate_reception' && $user->hasRight(
'reception',
'creer')) {
640 $result =
$object->setReceptionDate($user, $datereception);
644 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $permissiontoadd) {
646 $result =
$object->deleteLine($user, $lineid);
651 $outputlangs = $langs;
654 $newlang =
GETPOST(
'lang_id',
'aZ09');
657 $newlang =
$object->thirdparty->default_lang;
659 if (!empty($newlang)) {
661 $outputlangs->setDefaultLang($newlang);
665 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
668 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
673 } elseif (in_array($action, array(
'setwarehouse',
'settracking_number',
'settracking_url',
'settrueWeight',
'settrueWidth',
'settrueHeight',
'settrueDepth',
'setshipping_method_id')) && $permissiontoadd) {
677 if ($action ==
'setwarehouse') {
681 if (
$object->update($user) < 0) {
687 if ($action ==
'settracking_number') {
688 $object->tracking_number = trim(
GETPOST(
'tracking_number',
'alpha'));
690 if ($action ==
'settracking_url') {
691 $object->tracking_url = trim(
GETPOST(
'tracking_url',
'restricthtml'));
693 if ($action ==
'settrueWeight') {
697 if ($action ==
'settrueWidth') {
700 if ($action ==
'settrueHeight') {
704 if ($action ==
'settrueDepth') {
707 if ($action ==
'setshipping_method_id') {
711 if (
$object->update($user) >= 0) {
712 header(
"Location: card.php?id=" .
$object->id);
718 } elseif ($action ==
'builddoc' && $permissiontoread) {
727 $outputlangs = $langs;
730 $newlang =
GETPOST(
'lang_id',
'aZ09');
733 $newlang =
$object->thirdparty->default_lang;
735 if (!empty($newlang)) {
737 $outputlangs->setDefaultLang($newlang);
739 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
744 } elseif ($action ==
'remove_file' && $permissiontoadd) {
746 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
748 $upload_dir =
$conf->reception->dir_output;
749 $file = $upload_dir.
'/'.
GETPOST(
'file');
752 setEventMessages($langs->trans(
"FileWasRemoved",
GETPOST(
'urlfile')),
null,
'mesgs');
754 setEventMessages($langs->trans(
"ErrorFailToDeleteFile",
GETPOST(
'urlfile')),
null,
'errors');
756 } elseif ($action ==
'classifybilled' && $permissiontoadd) {
757 $result =
$object->setBilled();
759 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
765 } elseif ($action ==
'classifyclosed' && $permissiontoread) {
766 $result =
$object->setClosed();
768 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
774 } elseif ($action ==
'deleteline' && !empty($line_id) && $permissiontoread) {
779 $num_prod = count($lines);
780 for ($i = 0; $i < $num_prod; $i++) {
781 if ($lines[$i]->
id == $line_id) {
783 $line->id = $line_id;
784 if (!$error && $line->delete($user) < 0) {
788 unset($_POST[
"lineid"]);
792 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
795 setEventMessages($line->error, $line->errors,
'errors');
797 } elseif ($action ==
'updateline' &&
GETPOST(
'save') && $permissiontoadd) {
802 if (!
$object->fetch($id) > 0) {
803 dol_print_error($db);
807 $qty =
GETPOST(
'qty',
'alpha');
809 $element_type =
'reception';
815 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
816 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
818 if (is_array($extralabelsline)) {
820 foreach ($extralabelsline as $key => $value) {
821 unset($_POST[
"options_" . $key]);
833 $result =
$object->updatelinefree(
GETPOSTINT(
'lineid'), (
float) $qty, $element_type, $fk_product,
GETPOSTINT(
'units'), $rang, $description, 0, $array_options,
GETPOSTISSET(
'cost_price') ?
price2num(
GETPOST(
'cost_price',
'alpha')) : null,
GETPOSTISSET(
'fourn_ref') ?
GETPOST(
'fourn_ref',
'alphanohtml') : null, $wh_line,
GETPOSTISSET(
'batch') ?
GETPOST(
'batch',
'alphanohtml') : null);
838 $outputlangs = $langs;
841 $newlang =
GETPOST(
'lang_id',
'aZ09');
844 $newlang =
$object->thirdparty->default_lang;
846 if (!empty($newlang)) {
848 $outputlangs->setDefaultLang($newlang);
849 $outputlangs->load(
'products');
853 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
855 unset($_POST[
'qty']);
856 unset($_POST[
'units']);
861 } elseif ($origin && $origin_id > 0) {
869 $num_prod = count($lines);
870 for ($i = 0; $i < $num_prod; $i++) {
871 if ($lines[$i]->
id == $line_id) {
873 $line->fetch($line_id);
875 $extrafields->fetch_name_optionals_label(
$object->table_element_line);
876 $line->array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
878 $line->fk_product = $lines[$i]->fk_product;
880 if ($lines[$i]->fk_product > 0) {
882 $stockLocation =
"entl".$line_id;
883 $qty =
"qtyl".$line_id;
884 $comment =
"comment".$line_id;
886 $line->id = $line_id;
887 $line->fk_entrepot =
GETPOSTINT($stockLocation);
889 $line->comment =
GETPOST($comment,
'alpha');
892 $batch =
"batch".$line_id;
893 $dlc =
"dlc".$line_id;
894 $dluo =
"dluo".$line_id;
896 $eatby =
GETPOST($dluo,
'alpha');
897 $eatbydate = str_replace(
'/',
'-', $eatby);
899 $sellby =
GETPOST($dlc,
'alpha');
900 $sellbydate = str_replace(
'/',
'-', $sellby);
901 $line->batch =
GETPOST($batch,
'alpha');
902 $line->eatby = strtotime($eatbydate);
903 $line->sellby = strtotime($sellbydate);
906 if ($line->update($user) < 0) {
907 setEventMessages($line->error, $line->errors,
'errors');
911 $qty =
"qtyl".$line_id;
912 $line->id = $line_id;
914 $line->fk_entrepot = 0;
915 if ($line->update($user) < 0) {
916 setEventMessages($line->error, $line->errors,
'errors');
924 unset($_POST[
"lineid"]);
929 $outputlangs = $langs;
932 $newlang =
GETPOST(
'lang_id',
'aZ09');
935 $newlang =
$object->thirdparty->default_lang;
937 if (!empty($newlang)) {
939 $outputlangs->setDefaultLang($newlang);
943 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
949 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
952 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
956 } elseif ($action ==
'updateline' && $permissiontoadd &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
957 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
959 } elseif ($action ==
'addline' && !$origin &&
getDolGlobalString(
'RECEPTION_STANDALONE') && $permissiontoadd) {
960 $langs->load(
'errors');
966 $element_type =
'reception';
972 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
973 $cost_price_from_pfp = 0;
974 $reffourn_from_pfp =
'';
975 if ($prod_entry_mode ==
'free') {
979 if (empty($idprod) &&
GETPOSTISSET(
'idprodfournprice')) {
981 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
982 $ipfp =
GETPOST(
'idprodfournprice',
'alpha');
984 if (preg_match(
'/^idprod_([0-9]+)$/', $ipfp, $reg)) {
985 $idprod = (int) $reg[1];
986 } elseif ((
int) $ipfp > 0) {
988 $idprod = $productsupplier->get_buyprice((
int) $ipfp, (
float)
price2num(
GETPOST(
'qty',
'alpha'),
'MS'));
990 $cost_price_from_pfp =
price2num($productsupplier->fourn_unitprice);
991 $reffourn_from_pfp = $productsupplier->ref_supplier;
995 if ($prod_entry_mode !=
'free' && $idprod <= 0) {
996 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1000 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1008 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1009 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1011 if (is_array($extralabelsline)) {
1013 foreach ($extralabelsline as $key => $value) {
1014 unset($_POST[
"options_".$key]);
1018 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1019 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1024 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1028 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1031 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1032 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1036 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1037 if ($combinations =
GETPOST(
'combinations',
'array')) {
1041 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1042 $idprod = $res->fk_product_child;
1043 $fk_product = $idprod;
1045 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1051 if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1053 if (!empty($idprod) && $idprod > 0) {
1055 $prod->fetch($idprod);
1056 $desc =
$prod->label;
1057 $description = $desc;
1060 $outputlangs = $langs;
1062 if (
GETPOST(
'lang_id',
'aZ09')) {
1063 $newlang =
GETPOST(
'lang_id',
'aZ09');
1065 if (empty($newlang)) {
1066 $newlang =
$object->thirdparty->default_lang;
1068 if (!empty($newlang)) {
1070 $outputlangs->setDefaultLang($newlang);
1073 $description = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1075 $description =
$prod->description;
1080 $description = $line_desc;
1087 $outputlangs = $langs;
1089 if (
GETPOST(
'lang_id',
'alpha')) {
1090 $newlang =
GETPOST(
'lang_id',
'alpha');
1092 if (empty($newlang)) {
1093 $newlang =
$object->thirdparty->default_lang;
1095 if (!empty($newlang)) {
1097 $outputlangs->setDefaultLang($newlang);
1098 $outputlangs->load(
'products');
1100 if (!empty(
$prod->customcode)) {
1101 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.
$prod->customcode;
1103 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1106 if (!empty(
$prod->country_code)) {
1107 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry(
$prod->country_code,
'', $db, $outputlangs, 0);
1110 if (!empty(
$prod->customcode)) {
1111 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.
$prod->customcode;
1113 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1116 if (!empty(
$prod->country_code)) {
1117 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry(
$prod->country_code,
'', $db, $langs, 0);
1123 $type =
$prod->type;
1124 $fk_unit =
$prod->fk_unit;
1126 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1129 $fk_unit =
GETPOST(
'units',
'alpha');
1130 $description = $desc;
1131 $fk_elementdet =
'';
1139 if (!(
float) $typedcost) {
1142 $finalcost = ((float) $typedcost > 0) ? (float) $typedcost : (float) $cost_price_from_pfp;
1143 $reffourn_line =
GETPOST(
'fourn_ref',
'alphanohtml');
1144 if ($reffourn_line ===
'' && !empty($reffourn_from_pfp)) {
1145 $reffourn_line = $reffourn_from_pfp;
1147 $wh_line = max(0,
GETPOSTINT(
'entrepot_id'));
1148 $result =
$object->addlinefree((
float) $qty, $element_type, $idprod, $fk_unit, min($rank, count(
$object->lines) + 1), $description, $array_options, (
float) $finalcost, $reffourn_line, $wh_line,
GETPOST(
'batch',
'alphanohtml'));
1155 $outputlangs = $langs;
1156 $newlang =
GETPOST(
'lang_id',
'alpha');
1158 $newlang =
$object->thirdparty->default_lang;
1160 if (!empty($newlang)) {
1162 $outputlangs->setDefaultLang($newlang);
1164 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1167 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1174 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1180 $triggersendname =
'RECEPTION_SENTBYMAIL';
1182 $mode =
'emailfromreception';
1183 $autocopy =
'MAIN_MAIL_AUTOCOPY_RECEPTION_TO';
1184 $trackid =
'rec'.$object->id;
1185 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1193$title =
$object->ref.
' - '.$langs->trans(
'Reception');
1194if ($action ==
'create') {
1195 $title = $langs->trans(
"NewReception");
1197llxHeader(
'', $title,
'Reception',
'', 0, 0,
'',
'',
'',
'mod-reception page-card');
1199$form =
new Form($db);
1206 $formproject =
null;
1209$product_static =
new Product($db);
1211$warehousestatic =
new Entrepot($db);
1213if ($action ==
'create' && $origin !=
'supplierorder' && !
getDolGlobalString(
'RECEPTION_STANDALONE')) {
1214 print
load_fiche_titre($langs->trans(
"CreateReception"),
'',
'dollyrevert');
1216 print
'<br>'.$langs->trans(
"ReceptionCreationIsDoneFromOrder");
1223if ($action ==
'create' && $permissiontoadd) {
1230 $res = $soc->fetch($socid);
1233 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1234 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1236 print
'<form name="crea_reception" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
1237 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1238 print
'<input type="hidden" name="action" value="add">';
1239 print
'<input type="hidden" name="changecompany" value="0">';
1240 print
'<input type="hidden" name="originid" value="' .
$id .
'">';
1241 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
1245 print
'<table class="border centpercent">';
1250 print
'<td class="fieldrequired">' . $langs->trans(
'ThirdParty') .
'</td>';
1253 print $soc->getNomUrl(1);
1254 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
1257 print
'<td class="valuefieldcreate">';
1258 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1262 $(document).ready(function() {
1263 $("#socid").change(function() {
1264 console.log("We have changed the company - Reload page");
1265 var socid = $(this).val();
1267 $("input[name=action]").val("create");
1268 $("input[name=changecompany]").val("1");
1269 $("form[name=crea_reception]").submit();
1274 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1281 $langs->load(
'stocks');
1282 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td>';
1284 print img_picto(
'',
'stock',
'class="pictofixedwidth"');
1285 print $formproduct->selectWarehouses(
GETPOSTINT(
'fk_warehouse') > 0 ?
GETPOSTINT(
'fk_warehouse') :
'ifone',
'fk_warehouse',
'', 1, 0, 0,
'', 1, 0, array(),
'minwidth200');
1286 print
'</td></tr>'.
"\n";
1290 if (
isModEnabled(
'project') && is_object($formproject)) {
1292 if (empty($projectid) && !empty(
$object->fk_project)) {
1293 $projectid = (int)
$object->fk_project;
1295 $langs->load(
"projects");
1297 print
'<td>' . $langs->trans(
"Project") .
'</td><td colspan="2">';
1298 print img_picto(
'',
'project',
'class="pictofixedwidth"');
1299 print $formproject->select_projects($soc->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 1, 0,
'widthcentpercentminusxx');
1300 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>';
1306 print
'<tr><td>'.$langs->trans(
"DateReception").
'</td>';
1307 print
'<td colspan="3">';
1308 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1309 $date_reception = ($date_reception ? $date_reception :
$object->date_reception);
1310 print $form->selectDate($date_reception ? $date_reception : -1,
'date_reception', 1, 1, 1);
1315 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1316 print
'<td colspan="3">';
1317 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1318 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1319 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1325 print $langs->trans(
"Weight");
1326 print
'</td><td colspan="3">';
1327 print img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1328 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'"> ';
1329 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOSTINT(
'weight_units'), 0, 2);
1330 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1331 print $form->textwithpicto($text, $htmltext);
1336 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
1337 print
' </td><td colspan="3">';
1338 print img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1339 print
'<input name="sizeW" size="4" value="'.GETPOST(
'sizeW').
'">';
1340 print
' x <input name="sizeH" size="4" value="'.GETPOST(
'sizeH').
'">';
1341 print
' x <input name="sizeS" size="4" value="'.GETPOST(
'sizeS').
'">';
1343 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size", (
string)
GETPOSTINT(
'size_units'), 0, 2);
1344 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1345 print $form->textwithpicto($text, $htmltext);
1349 print
"<tr><td>".$langs->trans(
"ReceptionMethod").
"</td>";
1350 print
'<td colspan="3">';
1351 $recept->fetch_delivery_methods();
1352 print $form->selectarray(
"shipping_method_id", $recept->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1);
1354 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1356 print
"</td></tr>\n";
1359 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1360 print
'<td colspan="3">';
1361 print img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1362 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1363 print
"</td></tr>\n";
1366 $extrafields->fetch_name_optionals_label(
$object->table_element);
1367 if (empty($reshook) && !empty($extrafields->attributes[
$object->table_element][
'label'])) {
1368 if (
$object->fetch_optionals() > 0) {
1369 $recept->array_options = array_merge($recept->array_options,
$object->array_options);
1371 print $recept->showOptionals($extrafields,
'create', $parameters);
1377 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"),
$object->label_incoterms, 1).
'</label></td>';
1378 print
'<td colspan="3" class="maxwidthonsmartphone">';
1379 print img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1380 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1386 if (is_countable($list) && count($list) > 0) {
1387 print
'<tr><td>'.$langs->trans(
'Model').
'</td>';
1388 print
'<td colspan="2">';
1389 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1390 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
1391 print $form->selectarray(
'model', $list,
getDolGlobalString(
'RECEPTION_ADDON_PDF'), 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
1398 print
'<td class="tdtop">';
1399 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext);
1401 print
'<td valign="top" colspan="2">';
1402 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1403 print $doleditor->Create(1);
1406 if (!$user->socid) {
1408 print
'<td class="tdtop">';
1409 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext);
1411 print
'<td valign="top" colspan="2">';
1412 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1413 print $doleditor->Create(1);
1421 print $form->buttonsSaveCancel(
"CreateDraft");
1424 } elseif ($origin) {
1425 if ($origin ==
'supplierorder') {
1426 $classname =
'CommandeFournisseur';
1428 $classname = ucfirst($origin);
1431 $objectsrc =
new $classname($db);
1432 if ($objectsrc->fetch($origin_id)) {
1434 $soc->fetch($objectsrc->socid);
1436 $author =
new User($db);
1437 $author->fetch($objectsrc->user_author_id);
1443 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1444 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1445 print
'<input type="hidden" name="action" value="add">';
1446 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1447 print
'<input type="hidden" name="origin_id" value="'.$objectsrc->id.
'">';
1448 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
1449 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1451 print
'<input type="hidden" name="entrepot_id" value="'.GETPOSTINT(
'entrepot_id').
'">';
1456 print
'<table class="border centpercent">';
1459 print
'<tr><td class="titlefieldcreate fieldrequired">';
1460 if ($origin ==
'supplierorder' &&
isModEnabled(
"supplier_order")) {
1461 print $langs->trans(
"RefOrder").
'</td><td colspan="3"><a href="'.DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$objectsrc->id.
'">'.img_object($langs->trans(
"ShowOrder"),
'order').
' '.$objectsrc->ref;
1464 print $langs->trans(
"RefProposal").
'</td><td colspan="3"><a href="'.DOL_URL_ROOT.
'/comm/card.php?id='.$objectsrc->id.
'">'.img_object($langs->trans(
"ShowProposal"),
'propal').
' '.$objectsrc->ref;
1471 if ($origin ==
'supplier_order') {
1472 print $langs->trans(
'SupplierOrder');
1474 print $langs->trans(
'RefSupplier');
1476 print
'</td><td colspan="3">';
1477 print
'<input type="text" name="ref_supplier" value="'.$objectsrc->ref_supplier.
'" />';
1482 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Company').
'</td>';
1483 print
'<td colspan="3">'.$soc->getNomUrl(1).
'</td>';
1487 if (
isModEnabled(
'project') && $formproject !==
null) {
1489 if (empty($projectid) && !empty($objectsrc->fk_project)) {
1490 $projectid = $objectsrc->fk_project;
1492 if ($origin ==
'project') {
1493 $projectid = ($origin_id ? $origin_id : 0);
1496 $langs->load(
"projects");
1498 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1499 print img_picto(
'',
'project',
'class="paddingright"');
1500 print $formproject->select_projects((!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $soc->id : -1), (string) $projectid,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1, 0,
'maxwidth500');
1501 print
' <a 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" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1507 print
'<tr><td>'.$langs->trans(
"DateReception").
'</td>';
1508 print
'<td colspan="3">';
1509 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1510 $date_reception = ($date_reception ? $date_reception :
$object->date_reception);
1511 print $form->selectDate($date_reception ? $date_reception : -1,
'date_reception', 1, 1, 1);
1516 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1517 print
'<td colspan="3">';
1518 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1519 $date_delivery = ($date_delivery ? $date_delivery : $objectsrc->delivery_date);
1520 print $form->selectDate($date_delivery ? $date_delivery : -1,
'date_delivery', 1, 1, 1);
1525 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td>';
1526 print
'<td colspan="3">';
1527 $doleditor =
new DolEditor(
'note_public', $objectsrc->note_public,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1528 print $doleditor->Create(1);
1532 if ($objectsrc->note_private && !$user->socid) {
1533 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td>';
1534 print
'<td colspan="3">';
1535 $doleditor =
new DolEditor(
'note_private', $objectsrc->note_private,
'', 60,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1536 print $doleditor->Create(1);
1542 print $langs->trans(
"Weight");
1543 print
'</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST(
'weight').
'"> ';
1544 $text = $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
GETPOSTINT(
'weight_units'), 0, 2);
1545 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1546 print $form->textwithpicto($text, $htmltext);
1550 print $langs->trans(
"Width").
' x '.$langs->trans(
"Height").
' x '.$langs->trans(
"Depth");
1551 print
' </td><td colspan="3"><input name="trueWidth" size="4" value="'.GETPOST(
'trueWidth').
'">';
1552 print
' x <input name="trueHeight" size="4" value="'.GETPOST(
'trueHeight').
'">';
1553 print
' x <input name="trueDepth" size="4" value="'.GETPOST(
'trueDepth').
'">';
1555 $text = $formproduct->selectMeasuringUnits(
"size_units",
"size", (
string)
GETPOSTINT(
'size_units'), 0, 2);
1556 $htmltext = $langs->trans(
"KeepEmptyForAutoCalculation");
1557 print $form->textwithpicto($text, $htmltext);
1561 print
"<tr><td>".$langs->trans(
"ReceptionMethod").
"</td>";
1562 print
'<td colspan="3">';
1563 $recept->fetch_delivery_methods();
1564 print $form->selectarray(
"shipping_method_id", $recept->meths,
GETPOSTINT(
'shipping_method_id'), 1, 0, 0,
"", 1);
1566 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1568 print
"</td></tr>\n";
1571 print
"<tr><td>".$langs->trans(
"TrackingNumber").
"</td>";
1572 print
'<td colspan="3">';
1573 print
'<input name="tracking_number" size="20" value="'.GETPOST(
'tracking_number',
'alpha').
'">';
1574 print
"</td></tr>\n";
1577 $parameters = array(
'objectsrc' => $objectsrc,
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'socid' => $socid);
1578 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $recept, $action);
1579 print $hookmanager->resPrint;
1582 $extrafields->fetch_name_optionals_label(
$object->table_element);
1583 if (empty($reshook) && !empty($extrafields->attributes[
$object->table_element][
'label'])) {
1585 if ($objectsrc->fetch_optionals() > 0) {
1586 $recept->array_options = array_merge($recept->array_options, $objectsrc->array_options);
1588 print $recept->showOptionals($extrafields,
'create', $parameters);
1594 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $objectsrc->label_incoterms, 1).
'</label></td>';
1595 print
'<td colspan="3" class="maxwidthonsmartphone">';
1596 print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms :
''), (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms :
''));
1601 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
1604 if (is_array($list) && count($list) > 1) {
1605 print
"<tr><td>".$langs->trans(
"DefaultModel").
"</td>";
1606 print
'<td colspan="3">';
1608 print
"</td></tr>\n";
1622 $suffix2numAsked = array();
1623 $dispatchLines = array();
1625 foreach ($_POST as $key => $value) {
1630 if (preg_match(
'/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
1632 $paramSuffix = $reg[1] .
'_' . $reg[2];
1633 $suffix2numAsked[$paramSuffix] = $numAsked;
1636 $numline = $numAsked;
1638 $prod =
"product_" . $paramSuffix;
1639 $qty =
"qty_" . $paramSuffix;
1640 $ent =
"entrepot_" . $paramSuffix;
1641 $pu =
"pu_" . $paramSuffix;
1642 $fk_commandefourndet =
"fk_commandefourndet_" . $paramSuffix;
1647 if (preg_match(
'/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
1649 $paramSuffix = $reg[1] .
'_' . $reg[2];
1650 $suffix2numAsked[$paramSuffix] = $numAsked;
1654 $numline = $numAsked;
1656 $prod =
'product_batch_' . $paramSuffix;
1657 $qty =
'qty_' . $paramSuffix;
1658 $ent =
'entrepot_' . $paramSuffix;
1659 $pu =
'pu_' . $paramSuffix;
1660 $lot =
'lot_number_' . $paramSuffix;
1663 $fk_commandefourndet =
'fk_commandefourndet_'.$paramSuffix;
1664 $dispatchLines[$numAsked] = array(
'paramSuffix' => $paramSuffix,
'prod' =>
GETPOSTINT(
$prod),
'qty' =>
price2num(
GETPOST($qty),
'MS'),
'ent' =>
GETPOSTINT($ent),
'pu' =>
price2num(
GETPOST($pu),
'MU'),
'comment' =>
GETPOST(
'comment'),
'fk_commandefourndet' =>
GETPOSTINT($fk_commandefourndet),
'DLC' => $dDLC,
'DLUO' => $dDLUO,
'lot' =>
GETPOST($lot));
1668 if (preg_match(
'/^productl([0-9]+)$/i', $key, $reg)) {
1670 $paramSuffix = $reg[1];
1671 $suffix2numAsked[$paramSuffix] = $numAsked;
1675 $numline = $numAsked;
1677 $prod =
'productid'.$paramSuffix;
1678 $comment =
'comment'.$paramSuffix;
1679 $qty =
'qtyl'.$paramSuffix;
1680 $ent =
'entl'.$paramSuffix;
1681 $pu =
'pul'.$paramSuffix;
1682 $lot =
'batch'.$paramSuffix;
1685 $fk_commandefourndet =
'fk_commandefournisseurdet'.$paramSuffix;
1686 $dispatchLines[$numAsked] = array(
'prod' =>
GETPOSTINT(
$prod),
'qty' =>
price2num(
GETPOST($qty),
'MS'),
'ent' =>
GETPOSTINT($ent),
'pu' =>
price2num(
GETPOST($pu),
'MU'),
'comment' =>
GETPOST($comment),
'fk_commandefourndet' =>
GETPOSTINT($fk_commandefourndet),
'DLC' => $dDLC,
'DLUO' => $dDLUO,
'lot' =>
GETPOSTINT($lot));
1693 foreach ($suffix2numAsked as $suffix => $n) {
1694 $dispatchLines[$n][
'array_options'] = $extrafields->getOptionalsFromPost(
'receptiondet_batch',
'_' . $suffix,
'');
1697 $reshook = $hookmanager->executeHooks(
'dataProcessing', $parameters, $object, $action);
1699 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1700 } elseif (empty($reshook)) {
1702 if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
1704 $tempMerged = array_merge($dispatchLines, $hookmanager->resArray);
1708 foreach ($dispatchLines as $idx => $val) {
1709 if (!is_array($tempMerged[$idx]) || !isset($tempMerged[$idx][
'fk_commandefourndet'])) {
1716 $dispatchLines = $tempMerged;
1719 error_log(
"WARNING: Hook dataProcessing returned invalid data, ignoring merge.");
1722 } elseif ($reshook > 0) {
1724 $dispatchLines = $hookmanager->resArray;
1725 array_unshift($dispatchLines,
null);
1726 unset($dispatchLines[0]);
1727 $numAsked = count($dispatchLines);
1730 print
'<script type="text/javascript">
1731 jQuery(document).ready(function() {
1732 jQuery("#autofill").click(function(event) {
1733 event.preventDefault();';
1735 while ($i <= $numAsked) {
1736 print
'jQuery("#qtyl'.$i.
'").val(jQuery("#qtyasked'.$i.
'").val() - jQuery("#qtydelivered'.$i.
'").val());'.
"\n";
1740 jQuery("#autoreset").click(function(event) {
1741 event.preventDefault();';
1743 while ($i <= $numAsked) {
1744 print
'jQuery("#qtyl'.$i.
'").val(0);'.
"\n";
1753 print
'<table class="noborder centpercent">';
1756 $objectsrc->loadReceptions();
1759 print
'<tr class="liste_titre">';
1760 print
'<td>'.$langs->trans(
"Description").
'</td>';
1761 print
'<td>'.$langs->trans(
"Comment").
'</td>';
1762 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
1763 print
'<td class="center">'.$langs->trans(
"QtyReceived").
'</td>';
1764 print
'<td class="center">'.$langs->trans(
"QtyToReceive");
1766 print
'<td>'.$langs->trans(
"BuyingPrice").
'</td>';
1769 print
' <br><center><a href="#" id="autofill"><span class="fas fa-fill pictofixedwidth" style=""></span> '.$langs->trans(
"Fill").
'</a>';
1770 print
' <a href="#" id="autoreset"><span class="fas fa-eraser pictofixedwidth" style=""></span>'.$langs->trans(
"Reset").
'</a></center><br>';
1774 print
'<td class="left">'.$langs->trans(
"Warehouse").
' ('.$langs->trans(
"Stock").
')</td>';
1777 print
'<td class="left">'.$langs->trans(
"batch_number").
'</td>';
1779 print
'<td class="left">'.$langs->trans(
"SellByDate").
'</td>';
1782 print
'<td class="left">'.$langs->trans(
"EatByDate").
'</td>';
1786 $parameters = array();
1787 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1789 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1791 print $hookmanager->resPrint;
1799 $arrayofpurchaselinealreadyoutput = array();
1803 while ($indiceAsked <= $numAsked) {
1808 foreach ($objectsrc->lines as $supplierLine) {
1809 if ($dispatchLines[$indiceAsked][
'fk_commandefourndet'] == $supplierLine->id) {
1810 $line = $supplierLine;
1818 $type = $line->product_type ? $line->product_type : $line->fk_product_type;
1820 if (!empty($line->date_start)) {
1823 if (!empty($line->date_end)) {
1827 print
'<!-- line fk_commandefourndet='.$line->id.
' for product='.$line->fk_product.
' -->'.
"\n";
1828 print
'<tr class="oddeven">'.
"\n";
1831 if ($line->fk_product > 0) {
1832 $product->fetch($line->fk_product);
1833 $product->load_stock(
'warehouseopen');
1838 print
'<a name="'.$line->id.
'"></a>';
1840 print
'<input type="hidden" name="productl'.$indiceAsked.
'" value="'.$line->fk_product.
'">';
1842 if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) {
1843 print
'<input type="hidden" name="productid'.$indiceAsked.
'" value="'.$line->fk_product.
'">';
1846 $product_static = $product;
1848 $text = $product_static->getNomUrl(1);
1849 $text .=
' - '.(!empty($line->label) ? $line->label : $line->product_label);
1851 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
1854 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1858 print ($line->desc && $line->desc != $line->product_label) ?
'<br>'.dol_htmlentitiesbr($line->desc) :
'';
1864 if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) {
1866 $text = img_object($langs->trans(
'Service'),
'service');
1868 $text = img_object($langs->trans(
'Product'),
'product');
1871 if (!empty($line->label)) {
1872 $text .=
' <strong>'.$line->label.
'</strong>';
1873 print $form->textwithtooltip($text, $line->desc, 3, 0,
'', (
string) $i);
1875 print $text.
' '.nl2br($line->desc);
1879 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end));
1886 $defaultcomment = $dispatchLines[$indiceAsked][
'comment'];
1888 print
'<input type="text" class="maxwidth100" name="comment'.$indiceAsked.
'" value="'.$defaultcomment.
'">';
1892 print
'<td class="center">';
1893 if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) {
1896 print
'<input type="hidden" name="fk_commandefournisseurdet'.$indiceAsked.
'" value="'.$line->id.
'">';
1897 print
'<input type="hidden" name="pul'.$indiceAsked.
'" value="'.$line->subprice.
'">';
1898 print
'<input name="qtyasked'.$indiceAsked.
'" id="qtyasked'.$indiceAsked.
'" type="hidden" value="'.$line->qty.
'">';
1900 $qtyProdCom = $line->qty;
1903 print
'<td class="center">';
1904 $quantityDelivered = isset($objectsrc->receptions[$line->id]) ? $objectsrc->receptions[$line->id] : 0;
1905 if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) {
1906 print $quantityDelivered;
1908 print
'<input name="qtydelivered'.$indiceAsked.
'" id="qtydelivered'.$indiceAsked.
'" type="hidden" value="'.$quantityDelivered.
'">';
1913 $quantityToBeDelivered = 0;
1915 $quantityToBeDelivered = $dispatchLines[$indiceAsked][
'qty'];
1917 $warehouse_id = $dispatchLines[$indiceAsked][
'ent'];
1920 $warehouseObject =
null;
1923 print
'<!-- Case warehouse already known or product not a predefined product -->';
1924 if (array_key_exists($dispatchLines[$indiceAsked][
'ent'], $product->stock_warehouse)) {
1925 $stock = +$product->stock_warehouse[$dispatchLines[$indiceAsked][
'ent']]->real;
1927 $deliverableQty = $dispatchLines[$indiceAsked][
'qty'];
1928 $cost_price = $dispatchLines[$indiceAsked][
'pu'];
1931 print
'<td class="center">';
1934 $defaultqty =
GETPOSTINT(
'qtyl'.$indiceAsked);
1936 print
'<input name="idl'.$indiceAsked.
'" type="hidden" value="'.$line->id.
'">';
1937 print
'<input class="right" name="qtyl'.$indiceAsked.
'" id="qtyl'.$indiceAsked.
'" type="text" size="4" value="'.$deliverableQty.
'">';
1939 print $langs->trans(
"NA");
1945 print
'<input class="width75 right" name="cost_price'.$indiceAsked.
'" id="cost_price'.$indiceAsked.
'" value="'.
price($cost_price).
'">';
1951 print
'<td class="left">';
1954 $ent =
"entl".$indiceAsked;
1955 $idl =
"idl".$indiceAsked;
1957 if ($line->fk_product > 0) {
1958 print
'<!-- Show warehouse selection -->';
1959 print $formproduct->selectWarehouses($tmpentrepot_id,
'entl'.$indiceAsked,
'', 0, 0, $line->fk_product,
'', 1);
1962 print $langs->trans(
"Service");
1968 if (!empty($product->status_batch)) {
1969 print
'<td><input name="batch'.$indiceAsked.
'" value="'.$dispatchLines[$indiceAsked][
'lot'].
'"></td>';
1971 print
'<td class="nowraponall">';
1972 print $form->selectDate($dispatchLines[$indiceAsked][
'DLC'],
'dlc'.$indiceAsked, 0, 0, 1,
"");
1976 print
'<td class="nowraponall">';
1977 print $form->selectDate($dispatchLines[$indiceAsked][
'DLUO'],
'dluo'.$indiceAsked, 0, 0, 1,
"");
1981 print
'<td colspan="3"></td>';
1985 $parameters = array();
1986 $parameters[
'dispatchLine'] = $dispatchLines[$indiceAsked];
1987 $parameters[
'indiceAsked'] = $indiceAsked;
1988 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1990 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1992 print $hookmanager->resPrint;
1996 $arrayofpurchaselinealreadyoutput[$line->id] = $line->id;
2002 if (!empty($extrafields)) {
2016 $srcLine->id = $line->id;
2017 $srcLine->fetch_optionals();
2019 if (empty($recLine->array_options) && !empty($dispatchLines[$indiceAsked][
'array_options'])) {
2020 $recLine->array_options = $dispatchLines[$indiceAsked][
'array_options'];
2022 $recLine->array_options = array_merge($recLine->array_options, $srcLine->array_options);
2024 print $recLine->showOptionals($extrafields,
'edit', array(
'style' =>
'class="oddeven"',
'colspan' => $colspan), (
string) $indiceAsked,
'',
'1');
2034 print $form->buttonsSaveCancel(
"Create");
2040 dol_print_error($db);
2051 $num_prod = count($lines);
2055 print $langs->trans(
"NoRecordFound");
2062 $typeobject =
$object->origin;
2064 $origin_id =
$object->origin_id;
2071 $res =
$object->fetch_optionals();
2074 print
dol_get_fiche_head($head,
'reception', $langs->trans(
"Reception"), -1,
'dollyrevert', 0,
'',
'', 0,
'', 1);
2079 if ($action ==
'delete') {
2080 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'DeleteReception'), $langs->trans(
"ConfirmDeleteReception",
$object->ref),
'confirm_delete',
'', 0, 1);
2084 if ($action ==
'valid') {
2085 $objectref = substr(
$object->ref, 1, 4);
2086 if ($objectref ==
'PROV') {
2087 $numref =
$object->getNextNumRef($soc);
2089 $numref = (string)
$object->ref;
2092 $text = $langs->trans(
"ConfirmValidateReception", $numref);
2094 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementWillBeRecorded").
'.';
2096 $text .=
'<br>'.img_picto(
'',
'movement',
'class="pictofixedwidth"').$langs->trans(
"StockMovementNotYetRecorded").
'.';
2100 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2101 $notify =
new Notify($db);
2103 $text .= $notify->confirmMessage(
'RECEPTION_VALIDATE',
$object->socid, $object);
2106 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'ValidateReception'), $text,
'confirm_valid',
'', 0, 1, 250);
2110 if ($action ==
'annuler') {
2111 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelReception'), $langs->trans(
"ConfirmCancelReception",
$object->ref),
'confirm_cancel',
'', 0, 1);
2114 if (!$formconfirm) {
2115 $parameters = array(
'formConfirm' => $formconfirm);
2116 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2117 if (empty($reshook)) {
2118 $formconfirm .= $hookmanager->resPrint;
2119 } elseif ($reshook > 0) {
2120 $formconfirm = $hookmanager->resPrint;
2130 $tmparray =
$object->getTotalWeightVolume();
2131 $totalWeight = $tmparray[
'weight'];
2132 $totalVolume = $tmparray[
'volume'];
2137 $objectsrc->fetch(
$object->origin_object->id);
2140 $objectsrc =
new Propal($db);
2141 $objectsrc->fetch(
$object->origin_object->id);
2143 if (($typeobject ==
'supplier_order' || $typeobject ==
'CommandeFournisseur') &&
$object->origin_object->id &&
isModEnabled(
"supplier_order")) {
2145 $objectsrc->fetch(
$object->origin_object->id);
2148 $linkback =
'<a href="'.DOL_URL_ROOT.
'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2149 $morehtmlref =
'<div class="refidno">';
2152 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'', 0, 1);
2153 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'reception',
'creer'),
'string',
'',
null,
null,
'', 1);
2156 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
2158 if ($origin && $origin_id > 0) {
2160 $langs->load(
"projects");
2161 $morehtmlref .=
'<br>';
2163 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2164 if ($action !=
'classify') {
2165 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2167 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $objectsrc->socid, (
string) $objectsrc->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2169 if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
2171 $proj->fetch($objectsrc->fk_project);
2172 $morehtmlref .= $proj->getNomUrl(1);
2174 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2182 $langs->load(
"projects");
2183 $morehtmlref .=
'<br>';
2184 if ($permissiontoadd) {
2185 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2186 if ($action !=
'classify') {
2187 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2189 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2191 if (!empty(
$object->fk_project)) {
2193 $proj->fetch(
$object->fk_project);
2194 $morehtmlref .= $proj->getNomUrl(1);
2196 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2202 $morehtmlref .=
'</div>';
2204 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2207 print
'<div class="fichecenter">';
2208 print
'<div class="fichehalfleft">';
2209 print
'<div class="underbanner clearboth"></div>';
2211 print
'<table class="border centpercent tableforfield">';
2216 print $langs->trans(
"RefOrder").
'</td>';
2217 print
'<td colspan="3">';
2218 print $objectsrc->getNomUrl(1,
'commande');
2224 print $langs->trans(
"RefProposal").
'</td>';
2225 print
'<td colspan="3">';
2226 print $objectsrc->getNomUrl(1,
'reception');
2230 if (($typeobject ==
'supplier_order' || $typeobject ==
'CommandeFournisseur') &&
$object->origin_object->id &&
isModEnabled(
"propal")) {
2232 print $langs->trans(
"SupplierOrder").
'</td>';
2233 print
'<td colspan="3">';
2234 print $objectsrc->getNomUrl(1,
'reception');
2240 print
'<tr><td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
2241 print
'<td colspan="3">'.dol_print_date(
$object->date_creation,
"dayhour",
"tzuserrel").
"</td>\n";
2245 print
'<tr><td height="10">';
2246 print
'<table class="nobordernopadding centpercent"><tr><td>';
2247 print $langs->trans(
'DateReception');
2249 if ($action !=
'editdate_reception') {
2250 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editdate_reception&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->trans(
'SetReceptionDate'), 1) .
'</a></td>';
2252 print
'</tr></table>';
2254 if ($action ==
'editdate_reception') {
2255 print
'<form name="setdate_reception" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
2256 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2257 print
'<input type="hidden" name="action" value="setdate_reception">';
2258 print $form->selectDate(
$object->date_reception ?
$object->date_reception : -1,
'recep_', 1, 1, 0,
"setdate_reception", 1, 0);
2259 print
'<input type="submit" class="button button-edit smallpaddingimp" value="' . $langs->trans(
'Modify') .
'">';
2268 print
'<tr><td height="10">';
2269 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2270 print $langs->trans(
'DateDeliveryPlanned');
2273 if ($action !=
'editdate_livraison' && $permissiontoadd) {
2274 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>';
2276 print
'</tr></table>';
2277 print
'</td><td colspan="2">';
2278 if ($action ==
'editdate_livraison') {
2279 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2280 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2281 print
'<input type="hidden" name="action" value="setdate_livraison">';
2282 print $form->selectDate(
$object->date_delivery ?
$object->date_delivery : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2283 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2293 print $form->editfieldkey(
"Weight",
'trueWeight', (
string)
$object->trueWeight, $object, $user->hasRight(
'reception',
'creer'));
2294 print
'</td><td colspan="3">';
2296 if ($action ==
'edittrueWeight') {
2297 print
'<form name="settrueweight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2298 print
'<input name="action" value="settrueWeight" type="hidden">';
2299 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2300 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2301 print
'<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.
'" type="text">';
2302 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", (
string)
$object->weight_units, 0, 2);
2303 print
' <input class="button" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2304 print
' <input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2308 print (
$object->trueWeight &&
$object->weight_units !=
'') ?
' '.measuringUnitString(0,
"weight",
$object->weight_units) :
'';
2312 if ($totalWeight > 0) {
2313 if (!empty(
$object->trueWeight)) {
2314 print
' ('.$langs->trans(
"SumOfProductWeights").
': ';
2317 if (!empty(
$object->trueWeight)) {
2324 print
'<tr><td>'.$form->editfieldkey(
"Width",
'trueWidth', (
string)
$object->trueWidth, $object, $user->hasRight(
'reception',
'creer')).
'</td><td colspan="3">';
2325 print $form->editfieldval(
"Width",
'trueWidth',
$object->trueWidth, $object, $user->hasRight(
'reception',
'creer'));
2326 print (
$object->trueWidth &&
$object->width_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->width_units) :
'';
2330 print
'<tr><td>'.$form->editfieldkey(
"Height",
'trueHeight', (
string)
$object->trueHeight, $object, $user->hasRight(
'reception',
'creer')).
'</td><td colspan="3">';
2331 if ($action ==
'edittrueHeight') {
2332 print
'<form name="settrueHeight" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2333 print
'<input name="action" value="settrueHeight" type="hidden">';
2334 print
'<input name="id" value="'.$object->id.
'" type="hidden">';
2335 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2336 print
'<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.
'" type="text">';
2337 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
$object->size_units, 0, 2);
2338 print
' <input class="button" name="modify" value="'.$langs->trans(
"Modify").
'" type="submit">';
2339 print
' <input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
2343 print (
$object->trueHeight &&
$object->height_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->height_units) :
'';
2349 print
'<tr><td>'.$form->editfieldkey(
"Depth",
'trueDepth', (
string)
$object->trueDepth, $object, $user->hasRight(
'reception',
'creer')).
'</td><td colspan="3">';
2350 print $form->editfieldval(
"Depth",
'trueDepth',
$object->trueDepth, $object, $user->hasRight(
'reception',
'creer'));
2351 print (
$object->trueDepth &&
$object->depth_units !=
'') ?
' '.measuringUnitString(0,
"size",
$object->depth_units) :
'';
2356 $langs->load(
'stocks');
2357 print
'<tr><td><table class="nobordernopadding centpercent"><tr><td>';
2358 print $langs->trans(
'Warehouse');
2360 if ($action !=
'editwarehouse' &&
$object->statut == Reception::STATUS_DRAFT && $user->hasRight(
'reception',
'creer')) {
2361 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editwarehouse&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->trans(
'SetWarehouse'), 1).
'</a></td>';
2363 print
'</tr></table></td><td colspan="3">';
2364 if ($action ==
'editwarehouse' && $permissiontoadd) {
2365 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'warehouse_id', 1);
2367 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'none');
2374 print $langs->trans(
"Volume");
2376 print
'<td colspan="3">';
2377 $calculatedVolume = 0;
2381 $volumeUnit =
$object->size_units * 3;
2384 if ($calculatedVolume > 0) {
2385 if ($volumeUnit < 50) {
2391 if ($totalVolume > 0) {
2392 if ($calculatedVolume) {
2393 print
' ('.$langs->trans(
"SumOfProductVolumes").
': ';
2397 if ($calculatedVolume) {
2407 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2412 print
'<div class="fichehalfright">';
2413 print
'<div class="underbanner clearboth"></div>';
2415 print
'<table class="border centpercent tableforfield">';
2418 print
'<tr><td height="10">';
2419 print
'<table class="nobordernopadding centpercent"><tr><td>';
2420 print $langs->trans(
'ReceptionMethod');
2423 if ($action !=
'editshipping_method_id' && $permissiontoadd) {
2424 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editshipping_method_id&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->trans(
'SetReceptionMethod'), 1).
'</a></td>';
2426 print
'</tr></table>';
2427 print
'</td><td colspan="2">';
2428 if ($action ==
'editshipping_method_id') {
2429 print
'<form name="setshipping_method_id" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2430 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2431 print
'<input type="hidden" name="action" value="setshipping_method_id">';
2432 $object->fetch_delivery_methods();
2433 print $form->selectarray(
"shipping_method_id",
$object->meths,
$object->shipping_method_id, 1, 0, 0,
"", 1);
2435 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2437 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2440 if (
$object->shipping_method_id > 0) {
2442 $code = $langs->getLabelFromKey($db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
2443 print $langs->trans(
"SendingMethod".strtoupper($code));
2450 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"TrackingNumber",
'tracking_number',
$object->tracking_number, $object, $user->hasRight(
'reception',
'creer')).
'</td><td colspan="3">';
2451 print $form->editfieldval(
"TrackingNumber",
'tracking_number',
$object->tracking_url, $object, $user->hasRight(
'reception',
'creer'),
'safehtmlstring',
$object->tracking_number);
2457 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2458 print $langs->trans(
'IncotermLabel');
2459 print
'<td><td class="right">';
2460 if ($user->hasRight(
'reception',
'creer')) {
2461 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/reception/card.php?id='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.img_edit().
'</a>';
2465 print
'</td></tr></table>';
2467 print
'<td colspan="3">';
2468 if ($action !=
'editincoterm') {
2469 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
2471 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
2481 print
'<div class="clearboth"></div>';
2487 if (!empty(
$object->table_element_line)) {
2489 $result =
$object->getLinesArray();
2491 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
2492 <input type="hidden" name="token" value="' .
newToken().
'">
2493 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2494 <input type="hidden" name="mode" value="">
2495 <input type="hidden" name="page_y" value="">
2496 <input type="hidden" name="id" value="' .
$object->id.
'">
2499 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == $object::STATUS_DRAFT) {
2500 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2503 print
'<div class="div-table-responsive-no-min">';
2504 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
2505 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2513 if (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines') {
2514 if ($action !=
'editline') {
2517 $parameters = array();
2518 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2520 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2522 if (empty($reshook)) {
2523 $senderissupplier = 2;
2529 if (!empty(
$object->lines) || (
$object->status == Reception::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
2538 if ($action ==
'editline') {
2539 print
'<form name="updateline" id="updateline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$line_id.
'" method="POST">
2540 <input type="hidden" name="token" value="' .
newToken().
'">
2541 <input type="hidden" name="action" value="updateline">
2542 <input type="hidden" name="mode" value="">
2543 <input type="hidden" name="id" value="' .
$object->id.
'">';
2547 print
'<div class="div-table-responsive-no-min">';
2548 print
'<table id="tablelines" class="noborder centpercent">';
2550 print
'<tr class="liste_titre">';
2553 print
'<td width="5" class="center"> </td>';
2556 print
'<td>'.$langs->trans(
"Products").
'</td>';
2558 print
'<td>'.$langs->trans(
"Comment").
'</td>';
2560 print
'<td class="center">'.$langs->trans(
"QtyOrdered").
'</td>';
2561 if ($origin && $origin_id > 0) {
2562 print
'<td class="center">'.$langs->trans(
"QtyInOtherReceptions").
'</td>';
2566 if ($action ==
'editline') {
2570 if (empty(
$conf->productbatch->enabled)) {
2573 print
'<td class="center" colspan="'.$editColspan.
'">';
2575 print $langs->trans(
"QtyToReceive").
' - ';
2577 print $langs->trans(
"QtyReceived").
' - ';
2580 print $langs->trans(
"WarehouseTarget").
' - ';
2583 print $langs->trans(
"Batch");
2587 $parameters = array();
2588 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2590 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2592 print $hookmanager->resPrint;
2595 $statusreceived = $object::STATUS_CLOSED;
2597 $statusreceived = $object::STATUS_VALIDATED;
2600 $statusreceived = $object::STATUS_CLOSED;
2602 if (
$object->statut < $statusreceived) {
2603 print
'<td class="center">'.$langs->trans(
"QtyToReceive").
'</td>';
2605 print
'<td class="center">'.$langs->trans(
"QtyReceived").
'</td>';
2608 print
'<td class="left">'.$langs->trans(
"WarehouseTarget").
'</td>';
2612 print
'<td class="left">'.$langs->trans(
"Batch").
'</td>';
2615 $parameters = array();
2616 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2618 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2620 print $hookmanager->resPrint;
2623 print
'<td class="center">'.$langs->trans(
"CalculatedWeight").
'</td>';
2624 print
'<td class="center">'.$langs->trans(
"CalculatedVolume").
'</td>';
2627 print
'<td class="linecoledit"></td>';
2628 print
'<td class="linecoldelete" width="10"></td>';
2635 $outputlangs = $langs;
2639 if (
GETPOST(
'lang_id',
'aZ09')) {
2640 $newlang =
GETPOST(
'lang_id',
'aZ09');
2642 if (empty($newlang)) {
2643 $newlang =
$object->thirdparty->default_lang;
2645 if (!empty($newlang)) {
2647 $outputlangs->setDefaultLang($newlang);
2652 $alreadysent = array();
2654 $origin = (string) $origin;
2658 if (empty($origin) || $origin ==
'order_supplier') {
2659 $origin =
'supplier_order';
2663 if (!in_array($origin, array(
'supplier_proposal',
'supplier_order',
'commande_fournisseur',
'facture_fourn',
'propal',
'commande',
'facture'))) {
2664 dol_print_error($db,
'Bad value for parameter origin in reception/card.php');
2668 if ($origin_id > 0) {
2669 $tablenametouse = (($origin ==
'supplier_order') ?
'commande_fournisseur' : (($origin ==
'facture_fourn') ?
'facture_fourn_' : $origin));
2671 $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";
2672 $sql .=
", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot";
2673 $sql .=
", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception";
2674 $sql .=
', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch';
2675 $sql .=
', p.description as product_desc';
2676 $sql .=
" FROM ".MAIN_DB_PREFIX.
"receptiondet_batch as ed";
2677 $sql .=
", ".MAIN_DB_PREFIX.
"reception as e";
2678 $sql .=
", ".MAIN_DB_PREFIX.$db->sanitize($tablenametouse).
"det as obj";
2679 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON obj.fk_product = p.rowid";
2680 $sql .=
" WHERE e.entity IN (".getEntity(
'reception').
")";
2681 $sql .=
" AND obj.fk_commande = ".((int) $origin_id);
2682 $sql .=
" AND obj.rowid = ed.fk_elementdet";
2683 $sql .=
" AND ed.fk_reception = e.rowid";
2684 $sql .=
" AND ed.fk_reception !=".((int)
$object->id);
2685 $sql .=
" ORDER BY obj.fk_product";
2687 dol_syslog(
"get list of reception lines", LOG_DEBUG);
2688 $resql = $db->query($sql);
2690 $num = $db->num_rows($resql);
2694 $obj = $db->fetch_object($resql);
2697 $alreadysent[$obj->rowid][$obj->receptionline_id] = array(
'reception_ref' => $obj->reception_ref,
'reception_id' => $obj->reception_id,
'warehouse' => $obj->fk_entrepot,
'qty' => $obj->qty,
'date_valid' => $obj->date_valid,
'date_delivery' => $obj->date_delivery);
2705 $arrayofpurchaselinealreadyoutput = array();
2709 for ($i = 0; $i < $num_prod; $i++) {
2710 print
'<!-- origin line id = '.(!empty($lines[$i]->origin_line_id) ? $lines[$i]->origin_line_id : 0).
' -->';
2711 print
'<tr class="oddeven" id="row-'.$lines[$i]->id.
'" data-id="'.$lines[$i]->id.
'" data-element="'.$lines[$i]->element.
'">';
2715 print
'<td class="center">'.($i + 1).
'</td>';
2719 if ($lines[$i]->fk_product > 0) {
2723 $prod->fetch($lines[$i]->fk_product);
2724 $label = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"label"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"label"] : $lines[$i]->product->label;
2726 $label = (!empty($lines[$i]->product->label) ? $lines[$i]->product->label : $lines[$i]->product->product_label);
2729 print
'<td class="linecoldescription">';
2730 if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
2731 $text = $lines[$i]->product->getNomUrl(1);
2732 $text .=
' - '.$label;
2734 print $form->textwithtooltip($text, $description, 3, 0,
'', (
string) $i);
2735 print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : 0, !empty($lines[$i]->date_end) ? $lines[$i]->date_end : 0);
2742 print
'<td class="linecoldescription">';
2743 if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
2745 $text = img_object($langs->trans(
'Service'),
'service');
2747 $text = img_object($langs->trans(
'Product'),
'product');
2750 if (!empty($lines[$i]->label)) {
2751 $text .=
' <strong>'.$lines[$i]->label.
'</strong>';
2752 print $form->textwithtooltip($text, $lines[$i]->
description, 3, 0,
'', (
string) $i);
2762 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2763 print
'<td><input name="comment'.$line_id.
'" id="comment'.$line_id.
'" value="'.
dol_escape_htmltag($lines[$i]->comment).
'"></td>';
2765 print
'<td style="white-space: pre-wrap; max-width: 200px;">'.dol_escape_htmltag($lines[$i]->comment).
'</td>';
2770 print
'<td class="center linecolqty">';
2771 if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
2772 print $lines[$i]->qty_asked;
2778 if ($origin_id > 0) {
2779 print
'<td class="center nowrap linecolqtyinotherreceptions">';
2781 $qtyalreadyreceived = 0;
2782 if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) {
2783 foreach ($alreadysent as $key => $val) {
2784 if ($lines[$i]->fk_commandefourndet == $key) {
2786 foreach ($val as $receptionline_id => $receptionline_var) {
2787 if ($receptionline_var[
'reception_id'] == $lines[$i]->fk_reception) {
2793 $htmltooltip .=
'<br>';
2795 if (empty(
$conf->cache[
'reception'][$receptionline_var[
'reception_id']])) {
2797 $reception_static->fetch($receptionline_var[
'reception_id']);
2798 $conf->cache[
'reception'][$receptionline_var[
'reception_id']] = $reception_static;
2800 $reception_static =
$conf->cache[
'reception'][$receptionline_var[
'reception_id']];
2802 $htmltooltip .= $reception_static->getNomUrl(1,
'nolink', 0, 0, 1);
2803 $htmltooltip .=
' - '.$receptionline_var[
'qty'];
2805 $htmltext = $langs->trans(
"DateValidation").
' : '.(empty($receptionline_var[
'date_valid']) ? $langs->trans(
"Draft") :
dol_print_date($receptionline_var[
'date_valid'],
'dayhour'));
2806 if (
isModEnabled(
'stock') && $receptionline_var[
'warehouse'] > 0) {
2807 if (empty(
$conf->cache[
'warehouse'][$receptionline_var[
'warehouse']])) {
2808 $warehousestatic =
new Entrepot($db);
2809 $warehousestatic->fetch($receptionline_var[
'warehouse']);
2810 $conf->cache[
'warehouse'][$receptionline_var[
'warehouse']] = $warehousestatic;
2812 $warehousestatic =
$conf->cache[
'warehouse'][$receptionline_var[
'warehouse']];
2814 $htmltext .=
'<br>'.$langs->trans(
"From").
' : '.$warehousestatic->getNomUrl(1,
'', 0, 1);
2816 $htmltooltip .=
' '.$form->textwithpicto(
'', $htmltext, 1);
2818 $qtyalreadyreceived += $receptionline_var[
'qty'];
2821 $htmltooltip = $langs->trans(
"QtyInOtherReceptions").
'...<br><br>'.$htmltooltip.
'<br><input type="submit" name="dummyhiddenbuttontogetfocus" style="display:none" autofocus>';
2826 print $form->textwithpicto((
string) $qtyalreadyreceived, $htmltooltip, 1,
'info',
'', 0, 3,
'tooltip'.$lines[$i]->
id);
2830 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2832 print
'<td colspan="'.$editColspan.
'" class="center"><table class="nobordernopadding">';
2834 if ($lines[$i]->fk_product > 0) {
2835 print
'<!-- case edit 1 -->';
2838 print
'<td><input name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty.
'"></td>';
2840 print
'<td>'.$formproduct->selectWarehouses($lines[$i]->fk_entrepot,
'entl'.$line_id,
'', 1, 0, $lines[$i]->fk_product,
'', 1).
'</td>';
2842 if (
$conf->productbatch->enabled && !empty($lines[$i]->product->status_batch)) {
2843 print
'<td class="nowraponall left"><input name="batch'.$line_id.
'" id="batch'.$line_id.
'" type="text" value="'.$lines[$i]->batch.
'"><br>';
2845 print $langs->trans(
'SellByDate').
' : ';
2846 print $form->selectDate($lines[$i]->sellby,
'dlc'.$line_id, 0, 0, 1,
"").
'<br>';
2849 print $langs->trans(
'EatByDate').
' : ';
2850 print $form->selectDate($lines[$i]->eatby,
'dluo'.$line_id, 0, 0, 1,
"");
2856 print
'<!-- case edit 2 -->';
2859 print
'<td><input name="qtyl'.$line_id.
'" id="qtyl'.$line_id.
'" type="text" size="4" value="'.$lines[$i]->qty.
'"></td>';
2867 print
'</table></td>';
2869 $parameters = array();
2870 $parameters[
'line'] = $lines[$i];
2871 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2873 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2875 print $hookmanager->resPrint;
2879 print
'<td class="center linecolqtytoreceive">'.$lines[$i]->qty.
'</td>';
2883 if ($lines[$i]->fk_entrepot > 0) {
2885 $entrepot->fetch($lines[$i]->fk_entrepot);
2887 print
'<td class="left tdoverflowmax150" title="'.dol_escape_htmltag($entrepot->label).
'">';
2888 print $entrepot->getNomUrl(1);
2897 if (isset($lines[$i]->batch)) {
2898 print
'<!-- Detail of lot -->';
2899 print
'<td class="linecolbatch nowrap">';
2900 $detail = $langs->trans(
"NA");
2901 if ($lines[$i]->product->status_batch > 0 && $lines[$i]->fk_product > 0) {
2902 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
2904 $reslot = $productlot->fetch(0, $lines[$i]->fk_product, $lines[$i]->batch);
2906 $detail = $productlot->getNomUrl(1);
2909 $batchinfo = $langs->trans(
"Batch").
': '.$lines[$i]->batch;
2911 $batchinfo .=
' - '.$langs->trans(
"SellByDate").
': '.
dol_print_date($lines[$i]->sellby,
"day");
2914 $batchinfo .=
' - '.$langs->trans(
"EatByDate").
': '.
dol_print_date($lines[$i]->eatby,
"day");
2916 $detail = $form->textwithtooltip(img_picto(
'',
'object_barcode').
' '.$langs->trans(
"DetailBatchNumber"), $batchinfo);
2919 print $detail .
'</td>';
2925 $parameters = array();
2926 $parameters[
'line'] = $lines[$i];
2927 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2929 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2931 print $hookmanager->resPrint;
2936 print
'<td class="center linecolweight">';
2938 print $lines[$i]->product->weight * $lines[$i]->qty.
' '.
measuringUnitString(0,
"weight", $lines[$i]->product->weight_units);
2945 print
'<td class="center linecolvolume">';
2947 print $lines[$i]->product->volume * $lines[$i]->qty.
' '.
measuringUnitString(0,
"volume", $lines[$i]->product->volume_units);
2954 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
2955 print
'<td class="center valignmiddle" colspan="2">';
2956 print
'<input type="submit" class="button small button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
2957 print
'<input type="submit" class="button small button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"><br>';
2959 } elseif (
$object->statut == Reception::STATUS_DRAFT) {
2961 print
'<td class="linecoledit center">';
2962 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.img_edit().
'</a>';
2964 print
'<td class="linecoldelete" width="10">';
2965 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$lines[$i]->id.
'">'.img_delete().
'</a>';
2969 if (isset($rowExtrafieldsStart, $rowExtrafieldsView, $rowEnd)) {
2970 print $rowExtrafieldsStart;
2971 print $rowExtrafieldsView;
2977 $arrayofpurchaselinealreadyoutput[$lines[$i]->fk_commandefourndet] = $lines[$i]->fk_commandefourndet;
2979 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2981 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2983 print $hookmanager->resPrint;
2987 $extralabelslines = $extrafields->attributes[$lines[$i]->table_element];
2988 if (!empty($extralabelslines) && is_array($extralabelslines) && count($extralabelslines) > 0) {
2998 $line->id = $lines[$i]->id;
2999 $line->fetch_optionals();
3001 if ($action ==
'editline' && $lines[$i]->
id == $line_id) {
3002 print $line->showOptionals($extrafields,
'edit', array(
'colspan' => $colspan),
'');
3004 print $line->showOptionals($extrafields,
'view', array(
'colspan' => $colspan),
'');
3026 if (($user->socid == 0) && ($action !=
'presend') && ($action !=
'editline')) {
3027 print
'<div class="tabsAction">';
3029 $parameters = array();
3030 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3031 if (empty($reshook)) {
3032 if (
$object->statut == Reception::STATUS_DRAFT && $num_prod > 0) {
3033 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'creer'))
3034 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'reception',
'reception_advance',
'validate'))) {
3035 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'">'.$langs->trans(
"Validate").
'</a>';
3037 print
'<a class="butActionRefused" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Validate").
'</a>';
3041 if (
$object->statut == Reception::STATUS_VALIDATED && $user->hasRight(
'reception',
'creer')) {
3042 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.
'&action=modif&token='.
newToken().
'">'.$langs->trans(
'SetToDraft').
'</a></div>';
3047 if (
$object->statut == Reception::STATUS_CLOSED && $user->hasRight(
'reception',
'creer')) {
3048 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
"ReOpen").
'</a>';
3052 if (empty($user->socid)) {
3054 if (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'reception',
'reception_advance',
'send')) {
3055 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendByMail').
'</a>';
3057 print
'<a class="butActionRefused" href="#">'.$langs->trans(
'SendByMail').
'</a>';
3064 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
3066 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->socid.
'">'.$langs->trans(
"CreateBill").
'</a>';
3073 if (
$object->statut == Reception::STATUS_VALIDATED) {
3074 if ($user->hasRight(
'reception',
'creer') &&
$object->statut > 0) {
3076 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=classifybilled&token='.
newToken().
'">'.$langs->trans(
'ClassifyBilled').
'</a>';
3078 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=classifyclosed&token='.
newToken().
'">'.$langs->trans(
"Close").
'</a>';
3082 if ($user->hasRight(
'reception',
'supprimer')) {
3083 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
3095 if ($action !=
'presend' && $action !=
'editline') {
3096 print
'<div class="fichecenter"><div class="fichehalfleft">';
3099 $filedir =
$conf->reception->dir_output.
"/".$objectref;
3101 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3103 $genallowed = $user->hasRight(
'reception',
'lire');
3104 $delallowed = $user->hasRight(
'reception',
'creer');
3106 print $formfile->showdocuments(
'reception', $objectref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
3110 $somethingshown = $form->showLinkedObjectBlock($object,
'');
3112 print
'</div><div class="fichehalfright">';
3114 print
'</div></div>';
3118 $modelmail =
'reception_send';
3119 $defaulttopic =
'SendReceptionRef';
3120 $diroutput =
$conf->reception->dir_output;
3121 $trackid =
'rec'.$object->id;
3123 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage table ReceptionLineBatch.
Class to manage predefined suppliers products.
Class to manage line orders.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class with list of lots and properties.
Class to manage projects.
Class to manage proposals.
Class to manage receptions.
Class to manage table commandefournisseurdispatch.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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 a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
reception_prepare_head(Reception $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.