41 require
'../main.inc.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
69 $langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'deliveries',
'products',
'other'));
72 $langs->load(
'incoterm');
75 $langs->load(
'margins');
78 $langs->load(
'productbatch');
85 $action =
GETPOST(
'action',
'aZ09');
86 $cancel =
GETPOST(
'cancel',
'alpha');
87 $confirm =
GETPOST(
'confirm',
'alpha');
88 $backtopage =
GETPOST(
'backtopage',
'alpha');
93 $origin =
GETPOST(
'origin',
'alpha');
103 if (!empty($user->socid)) {
104 $socid = $user->socid;
108 $hookmanager->initHooks(array(
'ordercard',
'globalcard'));
116 $extrafields->fetch_name_optionals_label(
$object->table_element);
119 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
122 $usercanread = $user->hasRight(
"commande",
"lire");
123 $usercancreate = $user->hasRight(
"commande",
"creer");
124 $usercandelete = $user->hasRight(
"commande",
"supprimer");
127 $usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'close')));
128 $usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'validate')));
129 $usercancancel = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'annuler')));
130 $usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'send'));
131 $usercangeneretedoc = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
133 $usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
134 $usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
136 $permissionnote = $usercancreate;
137 $permissiondellink = $usercancreate;
138 $permissiontoadd = $usercancreate;
157 if (empty($reshook)) {
158 $backurlforlist = DOL_URL_ROOT.
'/commande/list.php';
160 if (empty($backtopage) || ($cancel && empty($id))) {
161 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
162 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
163 $backtopage = $backurlforlist;
165 $backtopage = DOL_URL_ROOT.
'/commande/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
170 $selectedLines =
GETPOST(
'toselect',
'array');
173 if (!empty($backtopageforcancel)) {
174 header(
"Location: ".$backtopageforcancel);
176 } elseif (!empty($backtopage)) {
177 header(
"Location: ".$backtopage);
183 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
185 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
187 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
190 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
192 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
198 $result =
$object->createFromClone($user, $socid);
200 $warningMsgLineList = array();
202 foreach (
$object->lines as $line) {
203 if (!is_object($line->product)) {
204 $line->fetch_product();
206 if (is_object($line->product) && $line->product->id > 0) {
207 if (empty($line->product->status)) {
208 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
212 if (!empty($warningMsgLineList)) {
216 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
225 } elseif ($action ==
'reopen' && $usercancreate) {
229 $result =
$object->setDraft($user, $idwarehouse);
234 $result =
$object->set_reopen($user);
242 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
244 $result =
$object->delete($user);
246 header(
'Location: list.php?restore_lastsearch_values=1');
251 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
253 $result =
$object->deleteLine($user, $lineid);
258 $outputlangs = $langs;
261 $newlang =
GETPOST(
'lang_id',
'aZ09');
264 $newlang =
$object->thirdparty->default_lang;
266 if (!empty($newlang)) {
268 $outputlangs->setDefaultLang($newlang);
272 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
275 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
280 } elseif ($action ==
'classin' && $usercancreate) {
283 } elseif ($action ==
'add' && $usercancreate) {
288 if ($datecommande ==
'') {
289 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
295 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
306 $object->date_commande = $datecommande;
319 $object->delivery_date = $date_delivery;
325 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
326 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
330 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
337 if (!empty($origin) && !empty($originid)) {
339 $element = $subelement = $origin;
341 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
342 $element = $regs [1];
343 $subelement = $regs [2];
347 if ($element ==
'order') {
348 $element = $subelement =
'commande';
350 if ($element ==
'propal') {
351 $element =
'comm/propal';
352 $subelement =
'propal';
354 if ($element ==
'contract') {
355 $element = $subelement =
'contrat';
359 $object->origin_id = $originid;
363 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
364 if (!empty($other_linked_objects)) {
365 $object->linked_objects = array_merge(
$object->linked_objects, $other_linked_objects);
369 $object_id =
$object->create($user);
371 if ($object_id > 0) {
374 $classname = ucfirst($subelement);
375 $srcobject =
new $classname($db);
378 $result = $srcobject->fetch(
$object->origin_id);
380 $lines = $srcobject->lines;
381 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
382 $srcobject->fetch_lines();
383 $lines = $srcobject->lines;
387 $num = count($lines);
389 for ($i = 0; $i < $num; $i++) {
390 if (!in_array($lines[$i]->
id, $selectedLines)) {
394 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
395 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
396 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
400 $date_start = $lines[$i]->date_debut_prevue;
401 if ($lines[$i]->date_debut_reel) {
402 $date_start = $lines[$i]->date_debut_reel;
404 if ($lines[$i]->date_start) {
405 $date_start = $lines[$i]->date_start;
407 $date_end = $lines[$i]->date_fin_prevue;
408 if ($lines[$i]->date_fin_reel) {
409 $date_end = $lines[$i]->date_fin_reel;
411 if ($lines[$i]->date_end) {
412 $date_end = $lines[$i]->date_end;
416 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
421 if (method_exists($lines[$i],
'fetch_optionals')) {
422 $lines[$i]->fetch_optionals();
423 $array_options = $lines[$i]->array_options;
426 $tva_tx = $lines[$i]->tva_tx;
427 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
428 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
433 $lines[$i]->subprice,
436 $lines[$i]->localtax1_tx,
437 $lines[$i]->localtax2_tx,
438 $lines[$i]->fk_product,
439 $lines[$i]->remise_percent,
440 $lines[$i]->info_bits,
441 $lines[$i]->fk_remise_except,
448 $lines[$i]->special_code,
450 $lines[$i]->fk_fournprice,
465 if ($result > 0 && $lines[$i]->product_type == 9) {
466 $fk_parent_line = $result;
518 $object_id =
$object->create($user);
523 if ($object_id > 0) {
537 if ($object_id > 0 && !$error) {
539 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object_id);
547 } elseif ($action ==
'classifybilled' && $usercancreate) {
548 $ret =
$object->classifyBilled($user);
553 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
554 $ret =
$object->classifyUnBilled($user);
558 } elseif ($action ==
'setref_client' && $usercancreate) {
564 } elseif ($action ==
'setremise' && $usercancreate) {
569 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
577 } elseif ($action ==
'setdate' && $usercancreate) {
580 $result =
$object->set_date($user, $date);
584 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
588 $result =
$object->setDeliveryDate($user, $date_delivery);
592 } elseif ($action ==
'setmode' && $usercancreate) {
597 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
599 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
600 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
603 } elseif ($action ==
'setavailability' && $usercancreate) {
608 } elseif ($action ==
'setdemandreason' && $usercancreate) {
613 } elseif ($action ==
'setconditions' && $usercancreate) {
620 $outputlangs = $langs;
621 $newlang =
GETPOST(
'lang_id',
'alpha');
623 $newlang =
$object->thirdparty->default_lang;
625 if (!empty($newlang)) {
627 $outputlangs->setDefaultLang($newlang);
631 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
634 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm')) {
640 } elseif ($action ==
'setbankaccount' && $usercancreate) {
646 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
652 } elseif ($action ==
'setwarehouse' && $usercancreate) {
662 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
666 foreach (
$object->lines as $line) {
667 if ($line->product_type == 1) {
668 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
'HT', $line->info_bits, $alldate_start, $alldate_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
671 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
673 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
674 $vat_rate = str_replace(
'*',
'', $vat_rate);
677 foreach (
$object->lines as $line) {
678 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate,
'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
680 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
682 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
683 $remise_percent = str_replace(
'*',
'', $remise_percent);
684 foreach (
$object->lines as $line) {
685 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
687 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && $usercancreate) {
688 $langs->load(
'errors');
696 $price_ht_devise =
'';
698 $price_ttc_devise =
'';
704 if (
GETPOST(
'price_ht') !==
'') {
707 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
710 if (
GETPOST(
'price_ttc') !==
'') {
713 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
717 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
718 if ($prod_entry_mode ==
'free') {
724 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
729 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
734 if (empty($remise_percent)) {
739 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
740 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
742 if (is_array($extralabelsline)) {
744 foreach ($extralabelsline as $key => $value) {
745 unset($_POST[
"options_".$key]);
749 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
750 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
753 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
754 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
757 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
758 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
762 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
766 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
769 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
770 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
774 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
775 if ($combinations =
GETPOST(
'combinations',
'array')) {
779 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
780 $idprod = $res->fk_product_child;
782 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
788 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
792 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
794 $price_min = $price_min_ttc = 0;
800 if (!empty($idprod) && $idprod > 0) {
802 $prod->fetch($idprod);
804 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
813 $pu_ht = $prod->price;
814 $pu_ttc = $prod->price_ttc;
815 $price_min = $prod->price_min;
816 $price_min_ttc = $prod->price_min_ttc;
817 $price_base_type = $prod->price_base_type;
821 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
822 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
823 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
824 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
825 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
827 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
828 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
830 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
831 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
836 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
840 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' =>
$object->thirdparty->id);
842 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
844 if (count($prodcustprice->lines) > 0) {
845 $pu_ht =
price($prodcustprice->lines[0]->price);
846 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
847 $price_min =
price($prodcustprice->lines[0]->price_min);
848 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
849 $price_base_type = $prodcustprice->lines[0]->price_base_type;
850 $tva_tx = $prodcustprice->lines[0]->tva_tx;
851 if ($prodcustprice->lines[0]->default_vat_code && !preg_match(
'/\(.*\)/', $tva_tx)) {
852 $tva_tx .=
' ('.$prodcustprice->lines[0]->default_vat_code.
')';
854 $tva_npr = $prodcustprice->lines[0]->recuperableonly;
855 if (empty($tva_tx)) {
864 if ($prod->prices_by_qty[0]) {
869 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
870 if ($priceforthequantityarray[
'rowid'] != $pqp) {
874 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
875 $pu_ht = $priceforthequantityarray[
'unitprice'];
877 $pu_ttc = $priceforthequantityarray[
'unitprice'];
885 if ($prod->prices_by_qty[
$object->thirdparty->price_level]) {
889 foreach ($prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
890 if ($priceforthequantityarray[
'rowid'] != $pqp) {
894 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
895 $pu_ht = $priceforthequantityarray[
'unitprice'];
897 $pu_ttc = $priceforthequantityarray[
'unitprice'];
905 $tmpvat = (
float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
906 $tmpprodvat = (
float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
909 if (!empty($price_ht) || $price_ht ===
'0') {
911 $pu_ttc =
price2num((
float) $pu_ht * (1 + ($tmpvat / 100)),
'MU');
912 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
914 $pu_ht =
price2num((
float) $pu_ttc / (1 + ($tmpvat / 100)),
'MU');
915 } elseif ($tmpvat != $tmpprodvat) {
917 if ($price_base_type !=
'HT') {
918 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
920 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
928 $outputlangs = $langs;
930 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
931 $newlang =
GETPOST(
'lang_id',
'aZ09');
933 if (empty($newlang)) {
934 $newlang =
$object->thirdparty->default_lang;
936 if (!empty($newlang)) {
938 $outputlangs->setDefaultLang($newlang);
941 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->description;
943 $desc = $prod->description;
952 $desc = $product_desc;
958 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
962 $outputlangs = $langs;
964 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
965 $newlang =
GETPOST(
'lang_id',
'alpha');
967 if (empty($newlang)) {
968 $newlang =
$object->thirdparty->default_lang;
970 if (!empty($newlang)) {
972 $outputlangs->setDefaultLang($newlang);
973 $outputlangs->load(
'products');
975 if (!empty($prod->customcode)) {
976 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
978 if (!empty($prod->customcode) && !empty($prod->country_code)) {
981 if (!empty($prod->country_code)) {
982 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
985 if (!empty($prod->customcode)) {
986 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
988 if (!empty($prod->customcode) && !empty($prod->country_code)) {
991 if (!empty($prod->country_code)) {
992 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
1000 $fk_unit = $prod->fk_unit;
1004 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1005 $tva_tx = str_replace(
'*',
'', $tva_tx);
1006 if (empty($tva_tx)) {
1009 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1010 $desc = $product_desc;
1012 $fk_unit =
GETPOST(
'units',
'alpha');
1013 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1014 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1016 if ($pu_ttc && !$pu_ht) {
1017 $price_base_type =
'TTC';
1035 $pu_equivalent = $pu_ht;
1036 $pu_equivalent_ttc = $pu_ttc;
1038 $currency_tx =
$object->multicurrency_tx;
1042 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1043 $pu_equivalent = (
float) $pu_ht_devise * (
float) $currency_tx;
1045 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1046 $pu_equivalent_ttc = (
float) $pu_ttc_devise * (
float) $currency_tx;
1063 if ($usermustrespectpricemin) {
1064 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1065 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1068 } elseif ($pu_equivalent_ttc && $price_min_ttc && (((
float)
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1069 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1077 $result =
$object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count(
$object->lines) + 1), 0,
GETPOST(
'fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit,
'', 0, $pu_ht_devise);
1085 $outputlangs = $langs;
1086 $newlang =
GETPOST(
'lang_id',
'alpha');
1088 $newlang =
$object->thirdparty->default_lang;
1090 if (!empty($newlang)) {
1091 $outputlangs =
new Translate(
"", $conf);
1092 $outputlangs->setDefaultLang($newlang);
1095 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1098 unset($_POST[
'prod_entry_mode']);
1100 unset($_POST[
'qty']);
1101 unset($_POST[
'type']);
1102 unset($_POST[
'remise_percent']);
1103 unset($_POST[
'price_ht']);
1104 unset($_POST[
'multicurrency_price_ht']);
1105 unset($_POST[
'price_ttc']);
1106 unset($_POST[
'tva_tx']);
1107 unset($_POST[
'product_ref']);
1108 unset($_POST[
'product_label']);
1109 unset($_POST[
'product_desc']);
1110 unset($_POST[
'fournprice']);
1111 unset($_POST[
'buying_price']);
1112 unset($_POST[
'np_marginRate']);
1113 unset($_POST[
'np_markRate']);
1114 unset($_POST[
'dp_desc']);
1115 unset($_POST[
'idprod']);
1116 unset($_POST[
'units']);
1118 unset($_POST[
'date_starthour']);
1119 unset($_POST[
'date_startmin']);
1120 unset($_POST[
'date_startsec']);
1121 unset($_POST[
'date_startday']);
1122 unset($_POST[
'date_startmonth']);
1123 unset($_POST[
'date_startyear']);
1124 unset($_POST[
'date_endhour']);
1125 unset($_POST[
'date_endmin']);
1126 unset($_POST[
'date_endsec']);
1127 unset($_POST[
'date_endday']);
1128 unset($_POST[
'date_endmonth']);
1129 unset($_POST[
'date_endyear']);
1135 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1147 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1152 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1153 $vat_rate = str_replace(
'*',
'', $vat_rate);
1165 $pu_equivalent = $pu_ht;
1166 $pu_equivalent_ttc = $pu_ttc;
1168 $currency_tx =
$object->multicurrency_tx;
1172 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1173 $pu_equivalent = (
float) $pu_ht_devise * (
float) $currency_tx;
1175 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1176 $pu_equivalent_ttc = (
float) $pu_ttc_devise * (
float) $currency_tx;
1195 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1196 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1198 if (is_array($extralabelsline)) {
1199 foreach ($extralabelsline as $key => $value) {
1200 unset($_POST[
"options_".$key]);
1205 $special_code =
GETPOST(
'special_code');
1214 if (!empty($productid)) {
1216 $product->fetch($productid);
1218 $type = $product->type;
1220 $price_min = $product->price_min;
1222 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1224 $price_min_ttc = $product->price_min_ttc;
1226 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1232 if ($usermustrespectpricemin) {
1233 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1234 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1237 $action =
'editline';
1238 } elseif ($pu_equivalent_ttc && $price_min_ttc && (((
float)
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1239 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1242 $action =
'editline';
1247 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1251 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1253 $action =
'editline';
1258 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1260 $action =
'editline';
1264 if (!$user->hasRight(
'margins',
'creer')) {
1265 foreach (
$object->lines as &$line) {
1267 $fournprice = $line->fk_fournprice;
1268 $buyingprice = $line->pa_ht;
1274 $price_base_type =
'HT';
1276 if (empty($pu) && !empty($pu_ttc)) {
1278 $price_base_type =
'TTC';
1281 $result =
$object->updateline(
GETPOSTINT(
'lineid'), $description, $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type,
GETPOST(
'fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options,
GETPOST(
'units'), $pu_ht_devise);
1286 $outputlangs = $langs;
1289 $newlang =
GETPOST(
'lang_id',
'aZ09');
1292 $newlang =
$object->thirdparty->default_lang;
1294 if (!empty($newlang)) {
1295 $outputlangs =
new Translate(
"", $conf);
1296 $outputlangs->setDefaultLang($newlang);
1300 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1303 unset($_POST[
'qty']);
1304 unset($_POST[
'type']);
1305 unset($_POST[
'productid']);
1306 unset($_POST[
'remise_percent']);
1307 unset($_POST[
'price_ht']);
1308 unset($_POST[
'multicurrency_price_ht']);
1309 unset($_POST[
'price_ttc']);
1310 unset($_POST[
'tva_tx']);
1311 unset($_POST[
'product_ref']);
1312 unset($_POST[
'product_label']);
1313 unset($_POST[
'product_desc']);
1314 unset($_POST[
'fournprice']);
1315 unset($_POST[
'buying_price']);
1317 unset($_POST[
'date_starthour']);
1318 unset($_POST[
'date_startmin']);
1319 unset($_POST[
'date_startsec']);
1320 unset($_POST[
'date_startday']);
1321 unset($_POST[
'date_startmonth']);
1322 unset($_POST[
'date_startyear']);
1323 unset($_POST[
'date_endhour']);
1324 unset($_POST[
'date_endmin']);
1325 unset($_POST[
'date_endsec']);
1326 unset($_POST[
'date_endday']);
1327 unset($_POST[
'date_endmonth']);
1328 unset($_POST[
'date_endyear']);
1333 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1334 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1336 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1339 $qualified_for_stock_change = 0;
1341 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1343 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1348 if (!$idwarehouse || $idwarehouse == -1) {
1350 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1356 $locationTarget =
'';
1360 $result =
$object->valid($user, $idwarehouse);
1368 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1369 &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1371 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1374 $forceFields = array();
1384 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1396 $outputlangs = $langs;
1399 $newlang =
GETPOST(
'lang_id',
'aZ09');
1402 $newlang =
$object->thirdparty->default_lang;
1404 if (!empty($newlang)) {
1405 $outputlangs =
new Translate(
"", $conf);
1406 $outputlangs->setDefaultLang($newlang);
1411 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1414 $deposit->fetch($deposit->id);
1415 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1419 if ($locationTarget) {
1420 header(
'Location: ' . $locationTarget);
1431 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1433 $idwarehouse =
GETPOST(
'idwarehouse');
1435 $qualified_for_stock_change = 0;
1437 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1439 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1444 if (!$idwarehouse || $idwarehouse == -1) {
1446 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1452 $result =
$object->setDraft($user, $idwarehouse);
1456 $outputlangs = $langs;
1459 $newlang =
GETPOST(
'lang_id',
'aZ09');
1462 $newlang =
$object->thirdparty->default_lang;
1464 if (!empty($newlang)) {
1465 $outputlangs =
new Translate(
"", $conf);
1466 $outputlangs->setDefaultLang($newlang);
1471 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1477 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1478 $result =
$object->cloture($user);
1482 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1485 $qualified_for_stock_change = 0;
1487 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1489 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1494 if (!$idwarehouse || $idwarehouse == -1) {
1496 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1502 $result =
$object->cancel($idwarehouse);
1510 if ($action ==
'update_extras') {
1514 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
1521 $result =
$object->insertExtraFields(
'ORDER_MODIFY');
1529 $action =
'edit_extras';
1534 if ($action ==
'import_lines_from_object'
1538 $fromElement =
GETPOST(
'fromelement');
1539 $fromElementid =
GETPOST(
'fromelementid');
1540 $importLines =
GETPOST(
'line_checkbox');
1542 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1543 if ($fromElement ==
'commande') {
1545 $lineClassName =
'OrderLine';
1546 } elseif ($fromElement ==
'propal') {
1547 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1548 $lineClassName =
'PropaleLigne';
1549 } elseif ($fromElement ==
'facture') {
1550 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1551 $lineClassName =
'FactureLigne';
1553 $nextRang = count(
$object->lines) + 1;
1556 foreach ($importLines as $lineId) {
1557 $lineId = intval($lineId);
1558 $originLine =
new $lineClassName($db);
1559 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
1560 $originLine->fetch_optionals();
1561 $desc = $originLine->desc;
1562 $pu_ht = $originLine->subprice;
1563 $qty = $originLine->qty;
1564 $txtva = $originLine->tva_tx;
1565 $txlocaltax1 = $originLine->localtax1_tx;
1566 $txlocaltax2 = $originLine->localtax2_tx;
1567 $fk_product = $originLine->fk_product;
1568 $remise_percent = $originLine->remise_percent;
1569 $date_start = $originLine->date_start;
1570 $date_end = $originLine->date_end;
1571 $fk_code_ventilation = 0;
1572 $info_bits = $originLine->info_bits;
1573 $fk_remise_except = $originLine->fk_remise_except;
1574 $price_base_type =
'HT';
1576 $type = $originLine->product_type;
1577 $rang = $nextRang++;
1578 $special_code = $originLine->special_code;
1579 $origin = $originLine->element;
1580 $origin_id = $originLine->id;
1581 $fk_parent_line = 0;
1582 $fk_fournprice = $originLine->fk_fournprice;
1583 $pa_ht = $originLine->pa_ht;
1584 $label = $originLine->label;
1585 $array_options = $originLine->array_options;
1586 $situation_percent = 100;
1588 $fk_unit = $originLine->fk_unit;
1589 $pu_ht_devise = $originLine->multicurrency_subprice;
1591 $res =
$object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise);
1610 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1613 $upload_dir = !empty($conf->commande->multidir_output[
$object->entity]) ? $conf->commande->multidir_output[
$object->entity] : $conf->commande->dir_output;
1614 $permissiontoadd = $usercancreate;
1615 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1618 $triggersendname =
'ORDER_SENTBYMAIL';
1620 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
1621 $trackid =
'ord'.$object->id;
1622 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1626 if ($action ==
'addcontact') {
1630 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1634 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1637 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1638 $langs->load(
"errors");
1639 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1644 } elseif ($action ==
'swapstatut') {
1651 } elseif ($action ==
'deletecontact') {
1653 $result =
$object->delete_contact($lineid);
1656 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1670 $title =
$object->ref.
" - ".$langs->trans(
'Card');
1671 if ($action ==
'create') {
1672 $title = $langs->trans(
"NewOrder");
1674 $help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
1676 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
1687 if ($action ==
'create' && $usercancreate) {
1692 $res = $soc->fetch($socid);
1697 $currency_code = $conf->currency;
1699 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
1700 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1701 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
1704 if (!empty($origin) && !empty($originid)) {
1706 $element = $subelement = $origin;
1708 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1709 $element = $regs[1];
1710 $subelement = $regs[2];
1713 if ($element ==
'project') {
1714 $projectid = $originid;
1716 if (!$cond_reglement_id) {
1717 $cond_reglement_id = $soc->cond_reglement_id;
1719 if (!$deposit_percent) {
1720 $deposit_percent = $soc->deposit_percent;
1722 if (!$mode_reglement_id) {
1723 $mode_reglement_id = $soc->mode_reglement_id;
1725 if (!$remise_percent) {
1726 $remise_percent = $soc->remise_percent;
1734 if ($element ==
'order' || $element ==
'commande') {
1735 $element = $subelement =
'commande';
1736 } elseif ($element ==
'propal') {
1737 $element =
'comm/propal';
1738 $subelement =
'propal';
1739 } elseif ($element ==
'contract') {
1740 $element = $subelement =
'contrat';
1745 $classname = ucfirst($subelement);
1746 $objectsrc =
new $classname($db);
1747 $objectsrc->fetch($originid);
1748 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1749 $objectsrc->fetch_lines();
1751 $objectsrc->fetch_thirdparty();
1754 $objectsrc->fetch_optionals();
1755 $object->array_options = $objectsrc->array_options;
1757 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1758 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1760 $soc = $objectsrc->thirdparty;
1761 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1762 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
1763 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1764 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1765 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
1766 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
1767 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1768 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
1773 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
1776 if (!empty($objectsrc->multicurrency_code)) {
1777 $currency_code = $objectsrc->multicurrency_code;
1779 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1780 $currency_tx = $objectsrc->multicurrency_tx;
1784 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private :
null));
1785 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public :
null));
1788 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1791 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1792 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1793 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1794 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
1795 $availability_id = 0;
1796 $shipping_method_id = $soc->shipping_method_id;
1797 $warehouse_id = $soc->fk_warehouse;
1798 $demand_reason_id = $soc->demand_reason_id;
1803 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1804 $currency_code = $soc->multicurrency_code;
1807 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1808 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1812 if (!
GETPOST(
'changecompany')) {
1814 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
1820 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
1828 if ($soc->fk_warehouse > 0) {
1829 $warehouse_id = $soc->fk_warehouse;
1836 $warehouse_id = $user->fk_warehouse;
1840 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1841 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1842 print
'<input type="hidden" name="action" value="add">';
1843 print
'<input type="hidden" name="changecompany" value="0">';
1844 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
1845 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1846 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1847 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1848 if (!empty($currency_tx)) {
1849 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1857 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder',
$parameters,
$object, $action);
1858 if (empty($reshook)) {
1859 print
'<table class="border centpercent">';
1862 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
1865 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
1866 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
1867 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
1869 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
1875 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1878 print $soc->getNomUrl(1,
'customer');
1879 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1882 print
'<td class="valuefieldcreate">';
1883 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1884 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1888 $(document).ready(function() {
1889 $("#socid").change(function() {
1890 console.log("We have changed the company - Reload page");
1891 var socid = $(this).val();
1893 $("input[name=action]").val("create");
1894 $("input[name=changecompany]").val("1");
1895 $("form[name=crea_commande]").submit();
1900 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>';
1908 print
"<tr><td>".$langs->trans(
"DefaultContact").
'</td><td>';
1909 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1911 print
$form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx',
true);
1915 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1917 $absolute_discount = $soc->getAvailableDiscounts();
1921 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode((
string) (
GETPOST(
'origin'))).
'&originid='.urlencode((
string) (
GETPOSTINT(
'originid')));
1922 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1928 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
1929 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1930 print
$form->selectDate(
'',
're', 0, 0, 0,
"crea_commande", 1, 1);
1934 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1935 print
'<td colspan="3">';
1936 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1937 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1938 print
$form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
1943 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
1944 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1945 $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1949 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1950 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1951 print
$form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', $deposit_percent);
1955 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
1956 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1957 print
$form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1962 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
1963 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1969 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
1970 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
1971 $form->selectShippingMethod(((
GETPOSTISSET(
'shipping_method_id') &&
GETPOSTINT(
'shipping_method_id') != 0) ?
GETPOST(
'shipping_method_id') : $shipping_method_id),
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
1977 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1979 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
1980 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses((
GETPOSTISSET(
'warehouse_id') ?
GETPOST(
'warehouse_id') : $warehouse_id),
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
1985 print
'<tr><td>'.$langs->trans(
'Channel').
'</td><td>';
1986 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1987 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1994 $langs->load(
"projects");
1996 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
1997 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), (
GETPOSTISSET(
'projectid') ?
GETPOST(
'projectid') : $projectid),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1998 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>';
2006 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms, 1).
'</label></td>';
2007 print
'<td class="maxwidthonsmartphone">';
2008 $incoterm_id =
GETPOST(
'incoterm_id');
2009 $location_incoterms =
GETPOST(
'location_incoterms');
2010 if (empty($incoterm_id)) {
2011 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2012 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2014 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2015 print
$form->select_incoterms($incoterm_id, $location_incoterms);
2021 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2027 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters,
$object, $action);
2028 print $hookmanager->resPrint;
2029 if (empty($reshook)) {
2030 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2033 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2034 if ($soc->fetch_optionals() > 0) {
2035 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2043 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2045 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2048 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2049 print
$form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2055 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'',
$object, 0).
'</td>';
2056 print
'<td class="maxwidthonsmartphone">';
2057 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((
GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'',
false,
'maxwidth200 widthcentpercentminusx');
2063 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2066 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2067 print $doleditor->Create(1);
2072 if (empty($user->socid)) {
2074 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2077 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2078 print $doleditor->Create(1);
2083 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2085 if ($origin ==
'contrat') {
2089 $objectsrc->update_price(1);
2092 print
"\n<!-- ".$classname.
" info -->";
2094 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2095 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2096 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2097 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2098 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2100 switch ($classname) {
2102 $newclassname =
'CommercialProposal';
2105 $newclassname =
'Order';
2108 $newclassname =
'Sending';
2111 $newclassname =
'Contract';
2114 $newclassname = $classname;
2117 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2120 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2121 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2122 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2123 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2126 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2127 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2130 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2133 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2134 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2135 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2146 print
$form->buttonsSaveCancel(
"CreateDraft");
2149 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2150 $title = $langs->trans(
'ProductsAndServices');
2153 print
'<div class="div-table-responsive-no-min">';
2154 print
'<table class="noborder centpercent">';
2156 $objectsrc->printOriginLinesList(
'', $selectedLines);
2168 $product_static =
new Product($db);
2173 $author =
new User($db);
2174 $author->fetch(
$object->user_author_id);
2177 $res =
$object->fetch_optionals();
2180 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order');
2185 if ($action ==
'delete') {
2186 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2190 if ($action ==
'validate') {
2192 $ref = substr(
$object->ref, 1, 4);
2193 if ($ref ==
'PROV' || $ref ==
'') {
2194 $numref =
$object->getNextNumRef($soc);
2195 if (empty($numref)) {
2203 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2205 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2206 $notify =
new Notify($db);
2208 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid,
$object);
2211 $qualified_for_stock_change = 0;
2213 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2215 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2218 $formquestion = array();
2220 $langs->load(
"stocks");
2221 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2224 if ($conf->browser->name ==
'ie') {
2227 $formquestion = array(
2231 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2237 foreach (
$object->lines as $line) {
2238 $res = $line->fetch_product();
2240 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2246 if ($nbMandated > 0) {
2247 $text .=
'<div><span class="clearboth nowraponall warning">'.$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2250 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2257 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2258 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2262 $eligibleForDepositGeneration =
true;
2264 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2265 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2267 $eligibleForDepositGeneration =
false;
2273 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2274 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2275 $proposal->fetchObjectLinked();
2277 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2278 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2280 $eligibleForDepositGeneration =
false;
2288 if ($eligibleForDepositGeneration) {
2289 $formquestion[] = array(
2290 'type' =>
'checkbox',
2292 'name' =>
'generate_deposit',
2293 'label' =>
$form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2296 $formquestion[] = array(
2298 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2300 'label' => $langs->trans(
'DateInvoice'),
2306 $formquestion[] = array(
2308 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2309 'name' =>
'date_pointoftax',
2310 'label' => $langs->trans(
'DatePointOfTax'),
2317 $paymentTermsSelect =
$form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2319 $formquestion[] = array(
2321 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2322 'name' =>
'cond_reglement_id',
2323 'label' => $langs->trans(
'PaymentTerm'),
2324 'value' => $paymentTermsSelect
2327 $formquestion[] = array(
2328 'type' =>
'checkbox',
2329 'tdclass' =>
'showonlyifgeneratedeposit',
2330 'name' =>
'validate_generated_deposit',
2331 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2334 $formquestion[] = array(
2335 'type' =>
'onecolumn',
2338 $(document).ready(function() {
2339 $("[name=generate_deposit]").change(function () {
2340 let $self = $(this);
2341 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2343 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2360 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
2365 if ($action ==
'modif') {
2366 $qualified_for_stock_change = 0;
2368 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2370 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2373 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2374 $formquestion = array();
2376 $langs->load(
"stocks");
2377 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2380 if ($conf->browser->name ==
'ie') {
2383 $formquestion = array(
2387 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2391 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2397 if ($action ==
'shipped') {
2398 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2404 if ($action ==
'cancel') {
2405 $qualified_for_stock_change = 0;
2407 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2409 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2412 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2413 $formquestion = array();
2415 $langs->load(
"stocks");
2416 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2419 if ($conf->browser->name ==
'ie') {
2422 $formquestion = array(
2426 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2430 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2434 if ($action ==
'ask_deleteline') {
2435 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2439 if ($action ==
'clone') {
2440 $filter =
'(s.client:IN:1,2,3)';
2442 $formquestion = array(
2443 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' =>
$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300'))
2445 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2452 if (empty($reshook)) {
2454 } elseif ($reshook > 0) {
2464 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2466 $morehtmlref =
'<div class="refidno">';
2468 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, $usercancreate,
'string',
'', 0, 1);
2469 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, $usercancreate,
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
2471 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2473 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2477 $langs->load(
"projects");
2478 $morehtmlref .=
'<br>';
2479 if ($usercancreate) {
2480 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2481 if ($action !=
'classify') {
2482 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2484 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2486 if (!empty(
$object->fk_project)) {
2488 $proj->fetch(
$object->fk_project);
2489 $morehtmlref .= $proj->getNomUrl(1);
2491 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2496 $morehtmlref .=
'</div>';
2499 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2504 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder',
$parameters,
$object, $action);
2505 if (empty($reshook)) {
2506 print
'<div class="fichecenter">';
2507 print
'<div class="fichehalfleft">';
2508 print
'<div class="underbanner clearboth"></div>';
2510 print
'<table class="border tableforfield centpercent">';
2512 if ($soc->outstanding_limit) {
2514 print
'<tr><td class="titlefield">';
2515 print $langs->trans(
'OutstandingBill');
2516 print
'</td><td class="valuefield">';
2517 $arrayoutstandingbills = $soc->getOutstandingBills();
2518 print
price($arrayoutstandingbills[
'opened']).
' / ';
2519 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1, $conf->currency);
2526 $filterabsolutediscount =
"fk_facture_source IS NULL";
2527 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2529 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2530 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2533 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
2534 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
2535 $addcreditnote =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&socid='.$soc->id.
'&type=2&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"AddCreditNote").
'</a>';
2537 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
2539 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2540 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2541 $absolute_discount =
price2num($absolute_discount,
'MT');
2542 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2546 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id;
2547 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2554 print
$form->editfieldkey(
"Date",
'date',
'',
$object, $editenable);
2555 print
'</td><td class="valuefield">';
2556 if ($action ==
'editdate') {
2557 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2558 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2559 print
'<input type="hidden" name="action" value="setdate">';
2560 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2561 print
$form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
2562 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2567 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
2575 $editenable = $usercancreate;
2576 print
$form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'',
$object, $editenable);
2577 print
'</td><td class="valuefield">';
2578 if ($action ==
'editdate_livraison') {
2579 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2580 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2581 print
'<input type="hidden" name="action" value="setdate_livraison">';
2582 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2583 print
$form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2584 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2589 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
2596 print
'<tr class="fielddeliverydelay"><td>';
2597 $editenable = $usercancreate;
2598 print
$form->editfieldkey(
"AvailabilityPeriod",
'availability',
'',
$object, $editenable);
2599 print
'</td><td class="valuefield">';
2600 if ($action ==
'editavailability') {
2601 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->availability_id,
'availability_id', 1);
2603 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->availability_id,
'none', 1);
2610 $editenable = $usercancreate;
2611 print
$form->editfieldkey(
"SendingMethod",
'shippingmethod',
'',
$object, $editenable);
2612 print
'</td><td class="valuefield">';
2613 if ($action ==
'editshippingmethod') {
2614 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->shipping_method_id,
'shipping_method_id', 1);
2616 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->shipping_method_id,
'none');
2624 $langs->load(
'stocks');
2625 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2628 $editenable = $usercancreate;
2629 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $editenable);
2630 print
'</td><td class="valuefield">';
2631 if ($action ==
'editwarehouse') {
2632 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
2634 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'none');
2642 $editenable = $usercancreate;
2643 print
$form->editfieldkey(
"Source",
'demandreason',
'',
$object, $editenable);
2644 print
'</td><td class="valuefield">';
2645 if ($action ==
'editdemandreason') {
2646 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->demand_reason_id,
'demand_reason_id', 1);
2648 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->demand_reason_id,
'none');
2654 $editenable = $usercancreate;
2655 print
$form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'',
$object, $editenable);
2656 print
'</td><td class="valuefield">';
2657 if ($action ==
'editconditions') {
2658 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2660 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2668 $editenable = $usercancreate;
2669 print
$form->editfieldkey(
"PaymentMode",
'mode',
'',
$object, $editenable);
2670 print
'</td><td class="valuefield">';
2671 if ($action ==
'editmode') {
2672 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2674 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
2684 print
$form->editfieldkey(
"Currency",
'multicurrencycode',
'',
$object, $editenable);
2685 print
'</td><td class="valuefield">';
2686 if ($action ==
'editmulticurrencycode') {
2687 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'multicurrency_code');
2689 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'none');
2694 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
2697 $editenable = $usercancreate &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency &&
$object->statut == $object::STATUS_DRAFT;
2698 print
$form->editfieldkey(
"CurrencyRate",
'multicurrencyrate',
'',
$object, $editenable);
2699 print
'</td><td class="valuefield">';
2700 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2701 if ($action ==
'actualizemulticurrencyrate') {
2704 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'multicurrency_tx',
$object->multicurrency_code);
2706 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
2707 if (
$object->statut == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
2708 print
'<div class="inline-block"> ';
2709 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2731 $tmparray =
$object->getTotalWeightVolume();
2732 $totalWeight = $tmparray[
'weight'];
2733 $totalVolume = $tmparray[
'volume'];
2735 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2736 print
'<td class="valuefield">';
2737 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');
2741 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2742 print
'<td class="valuefield">';
2743 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');
2752 $editenable = $usercancreate;
2753 print
$form->editfieldkey(
"IncotermLabel",
'incoterm',
'',
$object, $editenable);
2755 print
'<td class="valuefield">';
2756 if ($action !=
'editincoterm') {
2759 print
$form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
2767 $editenable = $usercancreate;
2768 print
$form->editfieldkey(
"BankAccount",
'bankaccount',
'',
$object, $editenable);
2769 print
'</td><td class="valuefield">';
2770 if ($action ==
'editbankaccount') {
2771 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
2773 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
2780 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2785 print
'<div class="fichehalfright">';
2786 print
'<div class="underbanner clearboth"></div>';
2788 print
'<table class="border tableforfield centpercent">';
2792 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
2796 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2797 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2800 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2805 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2806 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2809 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2814 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2816 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2817 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2821 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2827 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2829 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2830 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2834 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2840 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2841 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1, $conf->currency) .
'</td>';
2844 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
2855 $formmargin->displayMarginInfos(
$object);
2862 print
'<div class="clearboth"></div><br>';
2865 $blocname =
'contacts';
2866 $title = $langs->trans(
'ContactsAddresses');
2867 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2871 $blocname =
'notes';
2872 $title = $langs->trans(
'Notes');
2873 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2881 $result =
$object->getLinesArray();
2885 global $inputalsopricewithtax;
2886 $inputalsopricewithtax = 1;
2888 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">
2889 <input type="hidden" name="token" value="' .
newToken().
'">
2890 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2891 <input type="hidden" name="mode" value="">
2892 <input type="hidden" name="page_y" value="">
2893 <input type="hidden" name="id" value="' .
$object->id.
'">
2894 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2898 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2901 print
'<div class="div-table-responsive-no-min">';
2902 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2906 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
2913 if ($action !=
'editline') {
2918 $reshook = $hookmanager->executeHooks(
'formAddObjectLine',
$parameters,
$object, $action);
2922 if (empty($reshook)) {
2923 $object->formAddObjectLine(1, $mysoc, $soc);
2927 $reshook = $hookmanager->executeHooks(
'formEditObjectLine',
$parameters,
$object, $action);
2941 if ($action !=
'presend' && $action !=
'editline') {
2942 print
'<div class="tabsAction">';
2946 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters,
$object, $action);
2947 if (empty($reshook)) {
2948 $numlines = count(
$object->lines);
2956 if (empty($user->socid)) {
2959 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
2961 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2968 if ($numlines > 0) {
2971 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.
$object->id,
$object->id, 0);
2979 $arrayforbutaction = array();
2982 $arrayforbutaction[] = array(
'lang' =>
'orders',
'enabled' => (
isModEnabled(
"supplier_order") &&
$object->statut >
Commande::STATUS_DRAFT &&
$object->getNbOfServicesLines() > 0),
'perm' => $usercancreatepurchaseorder,
'label' =>
'AddPurchaseOrder',
'url' =>
'/fourn/commande/card.php?action=create&origin='.$object->element.
'&originid='.
$object->id);
3015 $numshipping =
$object->countNbOfShipments();
3020 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3029 $langs->load(
"errors");
3030 print
dolGetButtonAction($langs->trans(
'ErrorModuleSetupNotComplete'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3035 $arrayforbutaction[] = array(
3038 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3039 'label' =>
'CreateBill',
3040 'url' =>
'/compta/facture/card.php?action=create&token='.
newToken().
'&origin='.urlencode(
$object->element).
'&originid='.
$object->id.
'&socid='.
$object->socid
3049 $actionButtonsParameters = [
3050 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3053 if ($numlines > 0) {
3054 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
$object->id, 1, $actionButtonsParameters);
3056 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction,
$object->id, 0, $actionButtonsParameters);
3061 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.
newToken().
'&id='.
$object->id,
'');
3068 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3073 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.
newToken().
'&id='.
$object->id,
'');
3078 if ($usercancreate) {
3084 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"CancelOrder").
'</a>';
3088 if ($usercandelete) {
3089 if ($numshipping == 0) {
3092 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3100 if (
GETPOST(
'modelselected')) {
3101 $action =
'presend';
3104 if ($action !=
'presend') {
3105 print
'<div class="fichecenter"><div class="fichehalfleft">';
3106 print
'<a name="builddoc"></a>';
3109 $relativepath = $objref.
'/'.$objref.
'.pdf';
3110 $filedir = $conf->commande->multidir_output[
$object->entity].
'/'.$objref;
3111 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3112 $genallowed = $usercanread;
3113 $delallowed = $usercancreate;
3114 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'',
$object);
3118 $linktoelem =
$form->showLinkToObjectBlock(
$object,
null, array(
'order'));
3120 $compatibleImportElementsList =
false;
3123 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3125 $somethingshown =
$form->showLinkedObjectBlock(
$object, $linktoelem, $compatibleImportElementsList);
3131 $reshook = $hookmanager->executeHooks(
'doShowOnlinePaymentUrl',
$parameters,
$object, $action);
3133 if (isset($hookmanager->resArray[
'showonlinepaymenturl'])) {
3134 $useonlinepayment = $hookmanager->resArray[
'showonlinepaymenturl'];
3139 $useonlinepayment = 0;
3142 print
'<br><!-- Link to pay -->';
3143 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3144 print showOnlinePaymentUrl(
'order',
$object->ref).
'<br>';
3147 print
'</div><div class="fichehalfright">';
3151 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id);
3154 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3156 $somethingshown =
$formactions->showactions(
$object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3158 print
'</div></div>';
3162 $modelmail =
'order_send';
3163 $defaulttopic =
'SendOrderRef';
3165 $trackid =
'ord'.$object->id;
3167 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage a WYSIWYG editor.
static createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger=0, $autoValidateDeposit=false, $overrideFields=array())
Creates a deposit from a proposal or an order by grouping lines by VAT rates.
const TYPE_DEPOSIT
Deposit invoice.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
Class to manage the table of subscription to notifications.
Class ProductCombination Used to represent the relation between a product and one of its variants.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage projects.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists('str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists('str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files,...
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$formconfirm
if ($action == 'delbookkeepingyear') {
div float
Buy price without taxes.
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
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.