42require
'../main.inc.php';
53require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
56require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formorder.class.php';
57require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmargin.class.php';
58require_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
59require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
60require_once DOL_DOCUMENT_ROOT .
'/core/lib/order.lib.php';
62require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
63require_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
64require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
67 require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
71 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
72 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
76 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductCombination.class.php';
81$langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'products',
'other'));
84 $langs->load(
'incoterm');
87 $langs->load(
'margins');
90 $langs->load(
'productbatch');
97$action =
GETPOST(
'action',
'aZ09');
98$cancel =
GETPOST(
'cancel',
'alpha');
99$confirm =
GETPOST(
'confirm',
'alpha');
100$backtopage =
GETPOST(
'backtopage',
'alpha');
101$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
106$origin =
GETPOST(
'origin',
'alpha');
119if (!empty($user->socid)) {
120 $socid = $user->socid;
125$price_base_type =
null;
126$lineClassName =
null;
127$remise_percent =
null;
129$availability_id =
null;
130$shipping_method_id =
null;
132$demand_reason_id =
null;
141$hookmanager->initHooks(array(
'ordercard',
'globalcard'));
148$extrafields->fetch_name_optionals_label(
$object->table_element);
151include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
154$usercanread = $user->hasRight(
"commande",
"lire");
155$usercancreate = $user->hasRight(
"commande",
"creer");
156$usercandelete = $user->hasRight(
"commande",
"supprimer");
159$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'close')));
160$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'validate')));
161$usercancancel = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'annuler')));
162$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'send'));
163$usercangeneratedoc = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
165$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
166$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
168$permissionnote = $usercancreate;
169$permissiondellink = $usercancreate;
170$permissiontoadd = $usercancreate;
171$permissiontoeditextra = $usercancreate;
172if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
174 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
181$selectedLines = array();
188$parameters = array(
'socid' => $socid);
190$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
195if (empty($reshook)) {
196 $backurlforlist = DOL_URL_ROOT .
'/commande/list.php';
198 if (empty($backtopage) || ($cancel && empty($id))) {
199 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
200 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
201 $backtopage = $backurlforlist;
203 $backtopage = DOL_URL_ROOT .
'/commande/card.php?id=' . ((!empty($id) &&
$id > 0) ? $id :
'__ID__');
208 $selectedLines =
GETPOST(
'toselect',
'array:int');
211 if (!empty($backtopageforcancel)) {
212 header(
"Location: " . $backtopageforcancel);
214 } elseif (!empty($backtopage)) {
215 header(
"Location: " . $backtopage);
221 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
223 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
225 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
228 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
230 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
236 $result = $objectutil->createFromClone($user, $socid, (
GETPOSTISSET(
'entity') ?
GETPOSTINT(
'entity') : null));
238 $warningMsgLineList = array();
240 foreach ($objectutil->lines as $line) {
241 if (!is_object($line->product)) {
242 $line->fetch_product();
244 if (is_object($line->product) && $line->product->id > 0) {
245 if (empty($line->product->status)) {
246 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
250 if (!empty($warningMsgLineList)) {
254 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $result);
262 } elseif ($action ==
'reopen' && $usercancreate) {
267 $result =
$object->setDraft($user, $idwarehouse);
272 $result =
$object->set_reopen($user);
280 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
282 $result =
$object->delete($user);
284 header(
'Location: list.php?restore_lastsearch_values=1');
289 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
291 $result =
$object->deleteLine($user, $lineid);
296 $outputlangs = $langs;
299 $newlang =
GETPOST(
'lang_id',
'aZ09');
302 $newlang =
$object->thirdparty->default_lang;
304 if (!empty($newlang)) {
306 $outputlangs->setDefaultLang($newlang);
310 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
313 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
318 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
319 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
324 $outputlangs = $langs;
327 $newlang =
GETPOST(
'lang_id',
'aZ09');
330 $newlang =
$object->thirdparty->default_lang;
332 if (!empty($newlang)) {
334 $outputlangs->setDefaultLang($newlang);
338 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
341 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
346 } elseif ($action ==
'classin' && $usercancreate) {
349 } elseif ($action ==
'add' && $usercancreate) {
354 if ($datecommande ==
'') {
355 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
361 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
372 $object->date_commande = $datecommande;
385 $object->delivery_date = $date_delivery;
391 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
392 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
395 $ret = $extrafields->setOptionalsFromPost(
null, $object);
401 if (!empty($origin) && !empty($originid)) {
403 $element = $subelement = $origin;
405 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
407 $subelement = $regs[2];
411 if ($element ==
'order') {
412 $element = $subelement =
'commande';
414 if ($element ==
'propal') {
415 $element =
'comm/propal';
416 $subelement =
'propal';
418 if ($element ==
'contract') {
419 $element = $subelement =
'contrat';
423 $object->origin_type = $origin;
424 $object->origin_id = $originid;
428 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
429 if (!empty($other_linked_objects)) {
430 $object->linked_objects = array_merge(
$object->linked_objects, $other_linked_objects);
434 $object_id =
$object->create($user);
436 if ($object_id > 0) {
439 $classname = ucfirst($subelement);
440 $srcobject =
new $classname(
$db);
441 '@phan-var-force Commande|Propal|Contrat $srcobject';
444 dol_syslog(
"Try to find source object origin=" .
$object->origin .
" originid=" .
$object->origin_id .
" to add lines");
445 $result = $srcobject->fetch(
$object->origin_id);
447 $lines = $srcobject->lines;
448 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
449 $srcobject->fetch_lines();
450 $lines = $srcobject->lines;
454 $num = count($lines);
456 for ($i = 0; $i < $num; $i++) {
457 if (!in_array($lines[$i]->
id, $selectedLines)) {
461 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
462 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
463 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
468 if ($lines[$i]->date_debut_reel) {
471 if ($lines[$i]->date_start) {
474 $date_end = $lines[$i]->date_fin_prevue;
475 if ($lines[$i]->date_fin_reel) {
476 $date_end = $lines[$i]->date_fin_reel;
478 if ($lines[$i]->date_end) {
479 $date_end = $lines[$i]->date_end;
483 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
488 if (method_exists($lines[$i],
'fetch_optionals')) {
489 $lines[$i]->fetch_optionals();
490 $array_options = $lines[$i]->array_options;
493 $tva_tx = $lines[$i]->tva_tx;
494 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
495 $tva_tx .=
' (' . $lines[$i]->vat_src_code .
')';
500 $lines[$i]->subprice,
503 $lines[$i]->localtax1_tx,
504 $lines[$i]->localtax2_tx,
505 $lines[$i]->fk_product,
506 $lines[$i]->remise_percent,
507 $lines[$i]->info_bits,
508 $lines[$i]->fk_remise_except,
515 $lines[$i]->special_code,
517 $lines[$i]->fk_fournprice,
534 foreach (
$object->lines as $line) {
535 if ($line->id == $result) {
536 $line->extraparams = $lines[$i]->extraparams;
537 $line->setExtraParameters();
542 if ($result > 0 && $lines[$i]->product_type == 9) {
543 $fk_parent_line = $result;
577 $parameters = array(
'objFrom' => $srcobject);
579 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
594 $object_id =
$object->create($user);
599 if ($object_id > 0) {
602 $result =
$object->add_contact(
GETPOSTINT(
'contactid'), $type_contact_code,
'external');
614 $categories =
GETPOST(
'categories',
'array');
615 if (method_exists($object,
'setCategories')) {
616 $object->setCategories($categories);
621 if ($object_id > 0 && !$error) {
623 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object_id);
631 } elseif ($action ==
'classifybilled' && $usercancreate) {
632 $ret =
$object->classifyBilled($user);
637 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
638 $ret =
$object->classifyUnBilled($user);
642 } elseif ($action ==
'setref_client' && $usercancreate) {
648 } elseif ($action ==
'setremise' && $usercancreate) {
653 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
661 } elseif ($action ==
'setdate' && $usercancreate) {
664 $result =
$object->set_date($user, $date);
668 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
672 $result =
$object->setDeliveryDate($user, $date_delivery);
676 } elseif ($action ==
'setmode' && $usercancreate) {
681 } elseif ($action ==
'setposinfo' && $usercancreate) {
685 $result =
$object->update($user);
689 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
691 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
692 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
695 } elseif ($action ==
'setavailability' && $usercancreate) {
700 } elseif ($action ==
'setdemandreason' && $usercancreate) {
705 } elseif ($action ==
'setconditions' && $usercancreate) {
712 $outputlangs = $langs;
713 $newlang =
GETPOST(
'lang_id',
'alpha');
715 $newlang =
$object->thirdparty->default_lang;
717 if (!empty($newlang)) {
719 $outputlangs->setDefaultLang($newlang);
723 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
726 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
732 } elseif ($action ==
'setbankaccount' && $usercancreate) {
738 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
744 } elseif ($action ==
'setwarehouse' && $usercancreate) {
750 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
755 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
756 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
757 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
758 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
759 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
760 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
761 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
765 foreach (
$object->lines as $line) {
766 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
769 if ($line->product_type == 1) {
770 $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);
773 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
775 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
776 $vat_rate = str_replace(
'*',
'', $vat_rate);
779 foreach (
$object->lines as $line) {
780 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
783 $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);
785 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
787 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
788 $remise_percent = str_replace(
'*',
'', $remise_percent);
789 foreach (
$object->lines as $line) {
790 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
793 $tvatx = $line->tva_tx;
794 if (!empty($line->vat_src_code)) {
795 $tvatx .=
' (' . $line->vat_src_code .
')';
797 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, (
float) $remise_percent, $tvatx, $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);
799 } elseif ($action ==
'addline' && $usercancreate && (
800 (
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines',
'alpha') !==
'') ||
801 (
GETPOST(
'submitforallmark',
'alpha') &&
GETPOST(
'markforalllines',
'alpha') !==
'')
805 $margin_rate =
GETPOSTISSET(
'marginforalllines') ?
GETPOST(
'marginforalllines',
'int') :
'';
807 foreach (
$object->lines as &$line) {
808 if ($line->subprice > 0) {
809 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
812 $subprice_multicurrency = $line->subprice;
813 if (is_numeric($margin_rate) && $margin_rate > 0) {
814 $line->subprice = (float)
price2num((
float) $line->pa_ht * (1 + (float) $margin_rate / 100),
'MU');
815 } elseif (is_numeric($mark_rate) && $mark_rate > 0) {
816 $line->subprice = (float) ($line->pa_ht / (1 - ((
float) $mark_rate / 100)));
818 $line->subprice = (float) $line->pa_ht;
821 if ($line->fk_product > 0) {
823 $res =
$prod->fetch($line->fk_product);
825 if (
$prod->price_min > $line->subprice) {
826 $price_subprice =
price($line->subprice, 0, $outlangs, 1, -1, -1,
'auto');
827 $price_price_min =
price(
$prod->price_min, 0, $outlangs, 1, -1, -1,
'auto');
828 setEventMessages(
$prod->ref .
' - ' .
$prod->label .
' (' . $price_subprice .
' < ' . $price_price_min .
' ' . strtolower($langs->trans(
"MinPrice")) .
')' .
"\n",
null,
'warnings');
838 $multicurrency_subprice = (float) $line->subprice * $line->multicurrency_subprice / $subprice_multicurrency;
840 $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, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->product_ref, $line->special_code, $line->array_options, $line->fk_unit, $multicurrency_subprice);
843 if (is_numeric($margin_rate) && empty($mark_rate)) {
844 $line->marge_tx = $margin_rate;
845 } elseif (is_numeric($mark_rate) && empty($margin_rate)) {
846 $line->marque_tx = $mark_rate;
848 $line->total_ht = $line->qty * (float) $line->subprice;
849 $line->total_tva = $line->tva_tx * $line->qty * (float) $line->subprice;
850 $line->total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $line->subprice;
852 $line->multicurrency_total_ht = $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
853 $line->multicurrency_total_tva = $line->tva_tx * $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
854 $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
856 $line->multicurrency_subprice = $multicurrency_subprice;
862 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
865 $langs->load(
'subtotals');
867 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
868 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
870 $subtotal_options = array();
872 foreach (Commande::$TITLE_OPTIONS as $option) {
873 $value =
GETPOST($option,
'alphanohtml');
875 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
880 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
891 $outputlangs = $langs;
892 $newlang =
GETPOST(
'lang_id',
'alpha');
894 $newlang =
$object->thirdparty->default_lang;
896 if (!empty($newlang)) {
898 $outputlangs->setDefaultLang($newlang);
901 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
906 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
908 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
911 $langs->load(
'subtotals');
913 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
914 foreach (
$object->lines as $line) {
915 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
917 $depth = -$line->qty;
921 $subtotal_options = array();
923 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
924 $value =
GETPOST($option,
'alphanohtml');
926 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
931 if (isset($desc) && isset($depth)) {
932 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
935 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
944 $outputlangs = $langs;
945 $newlang =
GETPOST(
'lang_id',
'alpha');
947 $newlang =
$object->thirdparty->default_lang;
949 if (!empty($newlang)) {
951 $outputlangs->setDefaultLang($newlang);
954 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
959 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
961 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && $usercancreate) {
962 $langs->load(
'errors');
970 $price_ht_devise =
'';
972 $price_ttc_devise =
'';
974 if (
GETPOST(
'price_ht') !==
'') {
977 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
980 if (
GETPOST(
'price_ttc') !==
'') {
983 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
987 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
988 if ($prod_entry_mode ==
'free') {
994 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
999 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
1004 if (empty($remise_percent)) {
1005 $remise_percent = 0;
1009 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1010 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1012 if (is_array($extralabelsline)) {
1014 foreach ($extralabelsline as $key => $value) {
1015 unset($_POST[
"options_" . $key]);
1019 $price_to_test_sign = ($price_ht ? $price_ht : $price_ttc);
1021 if ((empty($idprod) || $idprod < 0) && ($price_to_test_sign < 0) && ($qty < 0)) {
1022 $langs->load(
"errors");
1023 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1026 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1027 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1030 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
1031 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1035 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1040 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1044 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1045 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1049 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1050 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1054 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1055 $idprod = $res->fk_product_child;
1057 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1063 if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1071 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1082 if (!empty($idprod) && $idprod > 0) {
1084 $prod->fetch($idprod);
1096 $pu_ht =
$prod->price;
1097 $pu_ttc =
$prod->price_ttc;
1098 $price_min =
$prod->price_min;
1099 $price_min_ttc =
$prod->price_min_ttc;
1100 $price_base_type =
$prod->price_base_type;
1104 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1108 $filter = array(
't.fk_product' => (
string)
$prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1111 $pricebycustomerexist =
false;
1112 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1115 if (count($prodcustprice->lines) > 0) {
1116 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1117 foreach ($prodcustprice->lines as $k => $custprice_line) {
1118 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1119 $pricebycustomerexist =
true;
1120 $pu_ht =
price($custprice_line->price);
1121 $pu_ttc =
price($custprice_line->price_ttc);
1122 $price_min =
price($custprice_line->price_min);
1123 $price_min_ttc =
price($custprice_line->price_min_ttc);
1124 $price_base_type = $custprice_line->price_base_type;
1141 if (!$pricebycustomerexist && !empty(
$object->thirdparty->price_level)) {
1142 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1143 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1144 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1145 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1146 $price_base_type =
$prod->multiprices_base_type[
$object->thirdparty->price_level];
1148 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1149 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1151 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1152 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1157 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1158 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1159 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1160 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1161 $price_base_type =
$prod->multiprices_base_type[
$object->thirdparty->price_level];
1163 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1164 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1166 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1167 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1172 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1176 $filter = array(
't.fk_product' => (
string)
$prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1178 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1181 if (count($prodcustprice->lines) > 0) {
1182 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1183 foreach ($prodcustprice->lines as $k => $custprice_line) {
1184 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1185 $pu_ht =
price($custprice_line->price);
1186 $pu_ttc =
price($custprice_line->price_ttc);
1187 $price_min =
price($custprice_line->price_min);
1188 $price_min_ttc =
price($custprice_line->price_min_ttc);
1189 $price_base_type = $custprice_line->price_base_type;
1207 if (
$prod->prices_by_qty[0]) {
1212 foreach (
$prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1213 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1217 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1218 $pu_ht = $priceforthequantityarray[
'unitprice'];
1220 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1228 if (
$prod->prices_by_qty[
$object->thirdparty->price_level]) {
1232 foreach (
$prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1233 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1237 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1238 $pu_ht = $priceforthequantityarray[
'unitprice'];
1240 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1248 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1249 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string)
$prod->tva_tx));
1252 if (!empty($price_ht) || (
string) $price_ht ===
'0') {
1253 $pu_ht = (float)
price2num($price_ht,
'MU');
1254 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1255 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1256 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1257 $pu_ttc_devise = (float)
price2num((
float) $pu_ht_devise * (1 + ((float) $tmpvat / 100)),
'MU');
1260 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1261 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1262 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1263 } elseif (!empty($price_ttc_devise) || (
string) $price_ttc_devise ===
'0') {
1264 $pu_ttc_devise = (float)
price2num($price_ttc_devise,
'MU');
1265 $pu_ht_devise = (float)
price2num((
float) $pu_ttc_devise / (1 + ((float) $tmpvat / 100)),
'MU');
1268 } elseif ($tmpvat != $tmpprodvat) {
1270 if ($price_base_type !=
'HT') {
1271 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1273 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1281 $outputlangs = $langs;
1283 if (
GETPOST(
'lang_id',
'aZ09')) {
1284 $newlang =
GETPOST(
'lang_id',
'aZ09');
1286 if (empty($newlang)) {
1287 $newlang =
$object->thirdparty->default_lang;
1289 if (!empty($newlang)) {
1291 $outputlangs->setDefaultLang($newlang);
1294 $desc = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1296 $desc =
$prod->description;
1312 $outputlangs = $langs;
1314 if (
GETPOST(
'lang_id',
'alpha')) {
1315 $newlang =
GETPOST(
'lang_id',
'alpha');
1317 if (empty($newlang)) {
1318 $newlang =
$object->thirdparty->default_lang;
1320 if (!empty($newlang)) {
1322 $outputlangs->setDefaultLang($newlang);
1323 $outputlangs->load(
'products');
1325 if (!empty(
$prod->customcode)) {
1326 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1328 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1331 if (!empty(
$prod->country_code)) {
1332 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'',
$db, $outputlangs, 0);
1335 if (!empty(
$prod->customcode)) {
1336 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1338 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1341 if (!empty(
$prod->country_code)) {
1342 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'',
$db, $langs, 0);
1349 $type =
$prod->type;
1350 $fk_unit =
$prod->fk_unit;
1354 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1355 $tva_tx = str_replace(
'*',
'', $tva_tx);
1356 if (empty($tva_tx)) {
1359 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1362 $fk_unit =
GETPOST(
'units',
'alpha');
1363 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1364 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1366 if ($pu_ttc && !$pu_ht) {
1367 $price_base_type =
'TTC';
1381 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1382 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1385 $pu_equivalent = $pu_ht;
1386 $pu_equivalent_ttc = $pu_ttc;
1388 $currency_tx =
$object->multicurrency_tx;
1392 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1393 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1395 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1396 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1416 if ($usermustrespectpricemin) {
1417 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1418 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1421 } 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') {
1422 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1430 $result =
$object->addline($desc, $pu_ht, (
float) $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,
GETPOSTINT(
'fk_parent_line'), (
int) $fournprice, $buyingprice, $label, $array_options, $fk_unit,
'', 0, (
float) $pu_ht_devise);
1442 $outputlangs = $langs;
1443 $newlang =
GETPOST(
'lang_id',
'alpha');
1445 $newlang =
$object->thirdparty->default_lang;
1447 if (!empty($newlang)) {
1449 $outputlangs->setDefaultLang($newlang);
1452 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1455 unset($_POST[
'prod_entry_mode']);
1457 unset($_POST[
'qty']);
1458 unset($_POST[
'type']);
1459 unset($_POST[
'remise_percent']);
1460 unset($_POST[
'price_ht']);
1461 unset($_POST[
'multicurrency_price_ht']);
1462 unset($_POST[
'price_ttc']);
1463 unset($_POST[
'tva_tx']);
1464 unset($_POST[
'product_ref']);
1465 unset($_POST[
'product_label']);
1466 unset($_POST[
'product_desc']);
1467 unset($_POST[
'fournprice']);
1468 unset($_POST[
'buying_price']);
1469 unset($_POST[
'np_marginRate']);
1470 unset($_POST[
'np_markRate']);
1471 unset($_POST[
'dp_desc']);
1472 unset($_POST[
'idprod']);
1473 unset($_POST[
'units']);
1475 unset($_POST[
'date_starthour']);
1476 unset($_POST[
'date_startmin']);
1477 unset($_POST[
'date_startsec']);
1478 unset($_POST[
'date_startday']);
1479 unset($_POST[
'date_startmonth']);
1480 unset($_POST[
'date_startyear']);
1481 unset($_POST[
'date_endhour']);
1482 unset($_POST[
'date_endmin']);
1483 unset($_POST[
'date_endsec']);
1484 unset($_POST[
'date_endday']);
1485 unset($_POST[
'date_endmonth']);
1486 unset($_POST[
'date_endyear']);
1494 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1497 $langs->load(
'subtotals');
1499 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1502 $subtotal_options = array();
1504 foreach (Commande::$TITLE_OPTIONS as $option) {
1505 $value =
GETPOST($option,
'alphanohtml');
1507 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1512 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1523 $outputlangs = $langs;
1524 $newlang =
GETPOST(
'lang_id',
'alpha');
1526 $newlang =
$object->thirdparty->default_lang;
1528 if (!empty($newlang)) {
1530 $outputlangs->setDefaultLang($newlang);
1533 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1538 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1541 $langs->load(
'subtotals');
1543 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1546 $subtotal_options = array();
1548 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1549 $value =
GETPOST($option,
'alphanohtml');
1551 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1556 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1564 $outputlangs = $langs;
1565 $newlang =
GETPOST(
'lang_id',
'alpha');
1567 $newlang =
$object->thirdparty->default_lang;
1569 if (!empty($newlang)) {
1571 $outputlangs->setDefaultLang($newlang);
1574 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1579 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1592 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1597 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1598 $vat_rate = str_replace(
'*',
'', $vat_rate);
1610 $pu_equivalent = $pu_ht;
1611 $pu_equivalent_ttc = $pu_ttc;
1613 $currency_tx =
$object->multicurrency_tx;
1617 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1618 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1620 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1621 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1636 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1640 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1641 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1643 if (is_array($extralabelsline)) {
1644 foreach ($extralabelsline as $key => $value) {
1645 unset($_POST[
"options_" . $key]);
1658 $price_base_type =
'HT';
1659 if (empty($pu) && !empty($pu_ttc)) {
1661 $price_base_type =
'TTC';
1666 if (!empty($productid)) {
1668 $product->fetch($productid);
1670 $type = $product->type;
1672 $price_min = $product->price_min;
1674 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1676 $price_min_ttc = $product->price_min_ttc;
1678 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1684 if ($usermustrespectpricemin) {
1685 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1686 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1689 $action =
'editline';
1690 } elseif ($pu_equivalent_ttc && $price_min_ttc && (((
float)
price2num($pu_equivalent_ttc) * (1 - (
float) $remise_percent / 100)) < (
float)
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1691 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1694 $action =
'editline';
1699 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1703 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1705 $action =
'editline';
1710 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1712 $action =
'editline';
1717 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1718 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1720 $action =
'editline';
1727 if (!$user->hasRight(
'margins',
'creer')) {
1728 foreach (
$object->lines as &$line) {
1730 $fournprice = $line->fk_fournprice;
1731 $buyingprice = $line->pa_ht;
1737 $result =
$object->updateline(
GETPOSTINT(
'lineid'), $description, (
float) $pu, (
float) $qty, (
float) $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits,
$date_start, $date_end, $type,
GETPOSTINT(
'fk_parent_line'), 0, (
int) $fournprice, $buyingprice, $label, $special_code, $array_options,
GETPOSTINT(
'units'), (
float) $pu_ht_devise);
1745 $outputlangs = $langs;
1748 $newlang =
GETPOST(
'lang_id',
'aZ09');
1751 $newlang =
$object->thirdparty->default_lang;
1753 if (!empty($newlang)) {
1755 $outputlangs->setDefaultLang($newlang);
1759 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1762 unset($_POST[
'qty']);
1763 unset($_POST[
'type']);
1764 unset($_POST[
'productid']);
1765 unset($_POST[
'remise_percent']);
1766 unset($_POST[
'price_ht']);
1767 unset($_POST[
'multicurrency_price_ht']);
1768 unset($_POST[
'price_ttc']);
1769 unset($_POST[
'tva_tx']);
1770 unset($_POST[
'product_ref']);
1771 unset($_POST[
'product_label']);
1772 unset($_POST[
'product_desc']);
1773 unset($_POST[
'fournprice']);
1774 unset($_POST[
'buying_price']);
1776 unset($_POST[
'date_starthour']);
1777 unset($_POST[
'date_startmin']);
1778 unset($_POST[
'date_startsec']);
1779 unset($_POST[
'date_startday']);
1780 unset($_POST[
'date_startmonth']);
1781 unset($_POST[
'date_startyear']);
1782 unset($_POST[
'date_endhour']);
1783 unset($_POST[
'date_endmin']);
1784 unset($_POST[
'date_endsec']);
1785 unset($_POST[
'date_endday']);
1786 unset($_POST[
'date_endmonth']);
1787 unset($_POST[
'date_endyear']);
1794 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1795 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1797 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1800 $qualified_for_stock_change = 0;
1802 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1804 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1809 if (!$idwarehouse || $idwarehouse == -1) {
1811 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1817 $locationTarget =
'';
1821 $result =
$object->valid($user, $idwarehouse);
1826 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1829 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1830 &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1832 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1835 $forceFields = array();
1845 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1857 $outputlangs = $langs;
1860 $newlang =
GETPOST(
'lang_id',
'aZ09');
1863 $newlang =
$object->thirdparty->default_lang;
1865 if (!empty($newlang)) {
1867 $outputlangs->setDefaultLang($newlang);
1872 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1875 $deposit->fetch($deposit->id);
1876 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1880 if ($locationTarget) {
1881 header(
'Location: ' . $locationTarget);
1892 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1894 $idwarehouse =
GETPOST(
'idwarehouse');
1896 $qualified_for_stock_change = 0;
1898 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1900 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1905 if (!$idwarehouse || $idwarehouse == -1) {
1907 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1913 $result =
$object->setDraft($user, $idwarehouse);
1917 $outputlangs = $langs;
1920 $newlang =
GETPOST(
'lang_id',
'aZ09');
1923 $newlang =
$object->thirdparty->default_lang;
1925 if (!empty($newlang)) {
1927 $outputlangs->setDefaultLang($newlang);
1932 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1938 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1939 $result =
$object->cloture($user);
1943 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1946 $qualified_for_stock_change = 0;
1948 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1950 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1955 if (!$idwarehouse || $idwarehouse == -1) {
1957 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1963 $result =
$object->cancel($user, $idwarehouse);
1971 if ($action ==
'update_extras' && $permissiontoeditextra) {
1974 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1977 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1984 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
1992 $action =
'edit_extras';
1998 $fromElement =
GETPOST(
'fromelement');
1999 $fromElementid =
GETPOST(
'fromelementid');
2000 $importLines =
GETPOST(
'line_checkbox');
2002 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && preg_match(
'/^[a-zA-Z]+$/', $fromElement) && !empty($fromElementid)) {
2003 if ($fromElement ==
'commande') {
2004 dol_include_once(
'/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2005 $lineClassName =
'OrderLine';
2006 } elseif ($fromElement ==
'propal') {
2007 dol_include_once(
'/comm/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2008 $lineClassName =
'PropaleLigne';
2009 } elseif ($fromElement ==
'facture') {
2010 dol_include_once(
'/compta/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2011 $lineClassName =
'FactureLigne';
2013 $nextRang = count(
$object->lines) + 1;
2016 foreach ($importLines as $lineId) {
2017 $lineId = intval($lineId);
2018 $originLine =
new $lineClassName(
$db);
2019 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2020 $originLine->fetch_optionals();
2021 $desc = $originLine->desc;
2022 $pu_ht = $originLine->subprice;
2023 $qty = $originLine->qty;
2024 $txtva = $originLine->tva_tx;
2025 $txlocaltax1 = $originLine->localtax1_tx;
2026 $txlocaltax2 = $originLine->localtax2_tx;
2027 $fk_product = $originLine->fk_product;
2028 $remise_percent = $originLine->remise_percent;
2030 $date_end = $originLine->date_end;
2031 $fk_code_ventilation = 0;
2032 $info_bits = $originLine->info_bits;
2033 $fk_remise_except = $originLine->fk_remise_except;
2034 $price_base_type =
'HT';
2036 $type = $originLine->product_type;
2037 $rang = $nextRang++;
2038 $special_code = $originLine->special_code;
2039 $origin = $originLine->element;
2040 $origin_id = $originLine->id;
2041 $fk_parent_line = 0;
2042 $fk_fournprice = $originLine->fk_fournprice;
2043 $pa_ht = $originLine->pa_ht;
2044 $label = $originLine->label;
2045 $array_options = $originLine->array_options;
2046 $situation_percent = 100;
2048 $fk_unit = $originLine->fk_unit;
2049 $pu_ht_devise = $originLine->multicurrency_subprice;
2051 $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);
2070 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
2074 $permissiontoadd = $usercancreate;
2075 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
2078 $triggersendname =
'ORDER_SENTBYMAIL';
2080 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2081 $trackid =
'ord' .
$object->id;
2082 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
2086 if ($action ==
'addcontact') {
2090 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2094 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2097 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2098 $langs->load(
"errors");
2099 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2104 } elseif ($action ==
'swapstatut') {
2111 } elseif ($action ==
'deletecontact') {
2113 $result =
$object->delete_contact($lineid);
2116 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2130$title =
$object->ref .
" - " . $langs->trans(
'Card');
2131if ($action ==
'create') {
2132 $title = $langs->trans(
"NewOrder");
2134$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2136llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2148if ($action ==
'create' && $usercancreate) {
2153 $res = $soc->fetch($socid);
2156 $currency_code =
$conf->currency;
2158 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2159 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2160 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2163 if (!empty($origin) && !empty($originid)) {
2165 $element = $subelement = $origin;
2167 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2168 $element = $regs[1];
2169 $subelement = $regs[2];
2172 if ($element ==
'project') {
2173 $projectid = $originid;
2175 if (!$cond_reglement_id) {
2176 $cond_reglement_id = $soc->cond_reglement_id;
2178 if (!$deposit_percent) {
2179 $deposit_percent = $soc->deposit_percent;
2181 if (!$mode_reglement_id) {
2182 $mode_reglement_id = $soc->mode_reglement_id;
2184 if (!$remise_percent) {
2185 $remise_percent = $soc->remise_percent;
2189 if ($element ==
'order' || $element ==
'commande') {
2190 $element = $subelement =
'commande';
2191 } elseif ($element ==
'propal') {
2192 $element =
'comm/propal';
2193 $subelement =
'propal';
2194 } elseif ($element ==
'contract') {
2195 $element = $subelement =
'contrat';
2200 $classname = ucfirst($subelement);
2201 $objectsrc =
new $classname(
$db);
2202 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2203 $objectsrc->fetch($originid);
2204 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2205 $objectsrc->fetch_lines();
2207 $objectsrc->fetch_thirdparty();
2210 $objectsrc->fetch_optionals();
2211 $object->array_options = $objectsrc->array_options;
2213 $projectid = (int) $objectsrc->fk_project;
2214 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2216 $soc = $objectsrc->thirdparty;
2217 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2218 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2219 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2220 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2221 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2222 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2223 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2224 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2227 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2230 if (!empty($objectsrc->multicurrency_code)) {
2231 $currency_code = $objectsrc->multicurrency_code;
2233 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2234 $currency_tx = $objectsrc->multicurrency_tx;
2238 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2239 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2242 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2245 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2246 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2247 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2248 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2249 $availability_id = 0;
2250 $shipping_method_id = empty($soc->shipping_method_id) ? $shipping_method_id : $soc->shipping_method_id;
2251 $warehouse_id = $soc->fk_warehouse;
2252 $demand_reason_id = $soc->demand_reason_id;
2255 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2256 $currency_code = $soc->multicurrency_code;
2259 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2260 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2264 if (!
GETPOST(
'changecompany')) {
2266 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2272 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2280 if ($soc->fk_warehouse > 0) {
2281 $warehouse_id = $soc->fk_warehouse;
2288 $warehouse_id = $user->fk_warehouse;
2292 print
'<form name="crea_commande" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2293 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2294 print
'<input type="hidden" name="action" value="add">';
2295 print
'<input type="hidden" name="changecompany" value="0">';
2296 print
'<input type="hidden" name="remise_percent" value="' . $soc->remise_percent .
'">';
2297 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
2298 print
'<input type="hidden" name="originid" value="' . $originid .
'">';
2299 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
2300 if (!empty($currency_tx)) {
2301 print
'<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx .
'">';
2307 $parameters = array();
2309 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters, $object, $action);
2310 if (empty($reshook)) {
2311 print
'<table class="border centpercent">';
2318 print
'<td class="fieldrequired">' . $langs->trans(
'Customer') .
'</td>';
2321 print $soc->getNomUrl(1,
'customer');
2322 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
2325 print
'<td class="valuefieldcreate">';
2326 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2327 print
img_picto(
'',
'company',
'class="pictofixedwidth"') . $form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2331 $(document).ready(function() {
2332 $("#socid").change(function() {
2333 console.log("We have changed the company - Reload page");
2334 var socid = $(this).val();
2336 $("input[name=action]").val("create");
2337 $("input[name=changecompany]").val("1");
2338 $("form[name=crea_commande]").submit();
2343 print
' <a href="' . DOL_URL_ROOT .
'/societe/card.php?action=create&customer=3&fournisseur=0&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?action=create') .
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans(
"AddThirdParty") .
'"></span></a>';
2346 print
'</tr>' .
"\n";
2351 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2352 print $langs->trans(
'RefProposal') .
'</td><td>';
2353 print
'<input type="text" name="ref_client" value="' . $ref_client .
'">';
2355 print $form->textwithpicto($langs->trans(
'RefCustomer'), $langs->trans(
'RefOfOnCustomerSide', $langs->transnoentitiesnoconv(
"Order"))) .
'</td><td>';
2356 print
'<input type="text" name="ref_client" value="' .
GETPOST(
'ref_client') .
'">';
2366 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_" . $type_contact_code));
2368 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2370 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2374 print
'<tr><td>' . $langs->trans(
'Discounts') .
'</td><td>';
2376 $absolute_discount = $soc->getAvailableDiscounts();
2380 $backtopage = $_SERVER[
"PHP_SELF"] .
'?socid=' . $thirdparty->id .
'&action=' . $action .
'&origin=' . urlencode((
string) (
GETPOST(
'origin'))) .
'&originid=' . urlencode((
string) (
GETPOSTINT(
'originid')));
2381 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
2389 print
'<tr><td class="fieldrequired">' . $langs->trans(
'Date') .
'</td><td>';
2390 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2391 print $form->selectDate($dateorder,
're', 0, 0, 0,
"crea_commande", 1, 1);
2395 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
2396 print
'<td colspan="3">';
2397 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2398 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2399 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2404 print
'<tr class="fielddeliverydelay"><td>' . $langs->trans(
'AvailabilityPeriod') .
'</td><td>';
2405 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2406 $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2410 print
'<tr><td class="nowrap">' . $langs->trans(
'PaymentConditionsShort') .
'</td><td>';
2411 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2412 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2416 print
'<tr><td>' . $langs->trans(
'PaymentMode') .
'</td><td>';
2417 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2418 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2423 print
'<tr><td>' . $langs->trans(
'BankAccount') .
'</td><td>';
2424 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"') . $form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2430 print
'<tr><td>' . $langs->trans(
'SendingMethod') .
'</td><td>';
2431 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2432 $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');
2438 print
'<tr><td>' . $langs->trans(
'Warehouse') .
'</td><td>';
2439 print
img_picto(
'',
'stock',
'class="pictofixedwidth"') . $formproduct->selectWarehouses(((
GETPOSTISSET(
'warehouse_id') && !
GETPOSTINT(
'changecompany')) ?
GETPOST(
'warehouse_id') : $warehouse_id),
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2444 print
'<tr><td>' . $langs->trans(
'Source') .
'</td><td>';
2445 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2446 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2453 $langs->load(
"projects");
2455 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2456 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects((($soc->id > 0 && !
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_CUSTOMERS')) ? $soc->id : -1), (
GETPOSTISSET(
'projectid') ?
GETPOST(
'projectid') : $projectid),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2457 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>';
2465 print
'<td><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? (
string) $objectsrc->fk_incoterms : (
string) $soc->fk_incoterms, 1) .
'</label></td>';
2466 print
'<td class="maxwidthonsmartphone">';
2467 $incoterm_id =
GETPOST(
'incoterm_id');
2468 $location_incoterms =
GETPOST(
'location_incoterms');
2469 if (empty($incoterm_id)) {
2470 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2471 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2473 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2474 print $form->select_incoterms($incoterm_id, $location_incoterms);
2479 $parameters = array();
2480 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2481 $parameters[
'objectsrc'] = $objectsrc;
2483 $parameters[
'socid'] = $socid;
2486 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2487 print $hookmanager->resPrint;
2488 if (empty($reshook)) {
2489 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2492 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2493 if ($soc->fetch_optionals() > 0) {
2494 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2498 print
$object->showOptionals($extrafields,
'create', $parameters);
2502 include_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
2504 if (is_array($list) && count($list) > 0) {
2505 print
'<tr><td>' . $langs->trans(
'DefaultModel') .
'</td>';
2508 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2509 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2516 print
'<td>' . $form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0) .
'</td>';
2517 print
'<td class="maxwidthonsmartphone">';
2518 print
img_picto(
'',
'currency',
'class="pictofixedwidth"') . $form->selectMultiCurrency(((
GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2524 print
'<tr><td>' . $langs->trans(
"Categories") .
'</td><td colspan="3">';
2525 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
2531 print
'<td class="tdtop">' . $langs->trans(
'NotePublic') .
'</td>';
2534 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2535 print $doleditor->Create(1);
2540 if (empty($user->socid)) {
2542 print
'<td class="tdtop">' . $langs->trans(
'NotePrivate') .
'</td>';
2545 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2546 print $doleditor->Create(1);
2551 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($classname)) {
2553 if ($origin ==
'contrat') {
2555 $objectsrc->update_price(1);
2558 print
"\n<!-- " . $classname .
" info -->\n";
2559 print
'<input type="hidden" name="amount" value="' . $objectsrc->total_ht .
'">' .
"\n";
2560 print
'<input type="hidden" name="total" value="' . $objectsrc->total_ttc .
'">' .
"\n";
2561 print
'<input type="hidden" name="tva" value="' . $objectsrc->total_tva .
'">' .
"\n";
2562 print
'<input type="hidden" name="origin" value="' . $objectsrc->element .
'">';
2563 print
'<input type="hidden" name="originid" value="' . $objectsrc->id .
'">';
2565 switch ($classname) {
2567 $newclassname =
'CommercialProposal';
2570 $newclassname =
'Order';
2573 $newclassname =
'Sending';
2576 $newclassname =
'Contract';
2579 $newclassname = $classname;
2582 print
'<tr><td>' . $langs->trans($newclassname) .
'</td><td>' . $objectsrc->getNomUrl(1) .
'</td></tr>';
2585 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td><td>' .
price($objectsrc->total_ht) .
'</td></tr>';
2586 print
'<tr><td>' . $langs->trans(
'AmountVAT') .
'</td><td>' .
price($objectsrc->total_tva) .
"</td></tr>";
2587 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2588 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax1) .
"</td></tr>";
2591 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2592 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax2) .
"</td></tr>";
2595 print
'<tr><td>' . $langs->trans(
'AmountTTC') .
'</td><td>' .
price($objectsrc->total_ttc) .
"</td></tr>";
2598 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
2599 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2600 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2611 print $form->buttonsSaveCancel(
"CreateDraft");
2614 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2615 $title = $langs->trans(
'ProductsAndServices');
2618 print
'<div class="div-table-responsive-no-min">';
2619 print
'<table class="noborder centpercent">';
2621 $objectsrc->printOriginLinesList(
'', $selectedLines);
2639 $author->fetch(
$object->user_author_id);
2642 $res =
$object->fetch_optionals();
2645 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2650 if ($action ==
'delete') {
2651 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2655 if ($action ==
'validate') {
2657 $ref = substr(
$object->ref, 1, 4);
2658 if ($ref ==
'PROV' || $ref ==
'') {
2659 $numref =
$object->getNextNumRef($soc);
2660 if (empty($numref)) {
2668 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2670 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2673 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid, $object);
2676 $qualified_for_stock_change = 0;
2678 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2680 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2683 $formquestion = array();
2685 $langs->load(
"stocks");
2687 if (
$conf->browser->name ==
'ie') {
2690 $formquestion = array(
2694 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2700 foreach (
$object->lines as $line) {
2701 $res = $line->fetch_product();
2703 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2709 if ($nbMandated > 0) {
2711 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2714 $text .=
'<div><span class="clearboth nowraponall warning">' .
img_warning() . $langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate") .
'</span></div>';
2718 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2723 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2725 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2726 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2730 $eligibleForDepositGeneration =
true;
2732 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2733 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2734 '@phan-var-force Facture $invoice';
2736 $eligibleForDepositGeneration =
false;
2742 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2743 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2744 $proposal->fetchObjectLinked();
2746 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2747 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2748 '@phan-var-force Facture $invoice';
2750 $eligibleForDepositGeneration =
false;
2758 if ($eligibleForDepositGeneration) {
2759 $formquestion[] = array(
2760 'type' =>
'checkbox',
2762 'name' =>
'generate_deposit',
2763 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2766 $formquestion[] = array(
2768 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2770 'label' => $langs->trans(
'DateInvoice'),
2776 $formquestion[] = array(
2778 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2779 'name' =>
'date_pointoftax',
2780 'label' => $langs->trans(
'DatePointOfTax'),
2786 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2788 $formquestion[] = array(
2790 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2791 'name' =>
'cond_reglement_id',
2792 'label' => $langs->trans(
'PaymentTerm'),
2793 'value' => $paymentTermsSelect
2796 $formquestion[] = array(
2797 'type' =>
'checkbox',
2798 'tdclass' =>
'showonlyifgeneratedeposit',
2799 'name' =>
'validate_generated_deposit',
2800 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2803 $formquestion[] = array(
2804 'type' =>
'onecolumn',
2807 $(document).ready(function() {
2808 $("[name=generate_deposit]").change(function () {
2809 let $self = $(this);
2810 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2812 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2829 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2834 if ($action ==
'modif') {
2835 $qualified_for_stock_change = 0;
2837 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2839 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2842 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2843 $formquestion = array();
2845 $langs->load(
"stocks");
2847 if (
$conf->browser->name ==
'ie') {
2856 'name' =>
'idwarehouse',
2857 'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
2858 'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo)
2863 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2867 if ($action ==
'shipped') {
2868 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2872 if ($action ==
'cancel') {
2873 $qualified_for_stock_change = 0;
2875 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2877 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2880 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2881 $formquestion = array();
2883 $langs->load(
"stocks");
2885 if (
$conf->browser->name ==
'ie') {
2888 $formquestion = array(
2892 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2896 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2900 if ($action ==
'ask_deleteline') {
2901 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2905 if ($action ==
'ask_subtotal_deleteline') {
2906 $langs->load(
"subtotals");
2907 $title =
"DeleteSubtotalLine";
2908 $question =
"ConfirmDeleteSubtotalLine";
2909 if (
GETPOST(
'type') ==
'title') {
2910 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2911 $title =
"DeleteTitleLine";
2912 $question =
"ConfirmDeleteTitleLine";
2914 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2918 if ($action ==
'clone') {
2919 $filter =
'(s.client:IN:1,2,3)';
2921 $formquestion = array(
2922 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2924 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2928 if ($action ==
'add_title_line') {
2929 $langs->load(
'subtotals');
2931 $depth_array =
$object->getPossibleLevels($langs);
2932 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2933 } elseif ($action ==
'add_subtotal_line') {
2934 $langs->load(
'subtotals');
2936 $titles =
$object->getPossibleTitles();
2937 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2941 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2943 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2944 if (empty($reshook)) {
2945 $formconfirm .= $hookmanager->resPrint;
2946 } elseif ($reshook > 0) {
2947 $formconfirm = $hookmanager->resPrint;
2956 $linkback =
'<a href="' . DOL_URL_ROOT .
'/commande/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2958 $morehtmlref =
'<div class="refidno">';
2960 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client, $object, (
int) $usercancreate,
'string',
'', 0, 1);
2961 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_client, $object, (
int) $usercancreate,
'string' . (isset(
$conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
2963 $morehtmlref .=
'<br>' . $soc->getNomUrl(1,
'customer');
2965 $morehtmlref .=
' (<a href="' . DOL_URL_ROOT .
'/commande/list.php?socid=' . ((int)
$object->thirdparty->id) .
'">' . $langs->trans(
"OtherOrders") .
'</a>)';
2969 $langs->load(
"projects");
2970 $morehtmlref .=
'<br>';
2971 if ($usercancreate) {
2972 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2973 if ($action !=
'classify') {
2974 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2976 $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');
2978 if (!empty(
$object->fk_project)) {
2980 $proj->fetch(
$object->fk_project);
2981 $morehtmlref .= $proj->getNomUrl(1);
2983 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2988 $morehtmlref .=
'</div>';
2990 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2993 $parameters = array();
2995 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters, $object, $action);
2996 if (empty($reshook)) {
2997 print
'<div class="fichecenter">';
2998 print
'<div class="fichehalfleft">';
2999 print
'<div class="underbanner clearboth"></div>';
3001 print
'<table class="border tableforfield centpercent">';
3005 $langs->load(
"cashdesk");
3006 print
'<tr><td class="fieldname_type">';
3007 print
'<table class="nobordernopadding centpercent"><tr><td>';
3008 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3010 if ($action !=
'editposinfo' && $usercancreate) {
3011 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editposinfo&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->trans(
'SetPOSInfo'), 1) .
'</a></td>';
3013 print
'</tr></table>';
3014 print
'</td><td class="valuefield fieldname_type">';
3015 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" name="formposinfo">';
3016 print
'<input type="hidden" name="action" value="setposinfo">';
3017 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3018 if ($action ==
'editposinfo') {
3019 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="' . $langs->trans(
"POSModule") .
'" value="' .
$object->module_source .
'"> ';
3020 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="' . $langs->trans(
"Terminal") .
'" value="' .
$object->pos_source .
'">';
3021 print
'<input type="submit" class="button" name="submitposinfo" value="' . $langs->trans(
"Submit") .
'">';
3024 print
'<span class="opacitymediumbycolor paddingleft">' .
dolPrintHTML(ucfirst(
$object->module_source) .
' - ' . $langs->transnoentitiesnoconv(
"Terminal") .
' ' .
$object->pos_source) .
'</span>';
3031 if ($soc->outstanding_limit) {
3033 print
'<tr><td class="titlefield">';
3034 print $langs->trans(
'OutstandingBill');
3035 print
'</td><td class="valuefield">';
3036 $arrayoutstandingbills = $soc->getOutstandingBills();
3037 print
price($arrayoutstandingbills[
'opened']) .
' / ';
3038 print
price($soc->outstanding_limit, 0,
'', 1, -1, -1,
$conf->currency);
3045 $filterabsolutediscount =
"fk_facture_source IS NULL";
3046 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3048 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3049 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3052 $addrelativediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remise.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditRelativeDiscounts") .
'</a>';
3053 $addabsolutediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remx.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditGlobalDiscounts") .
'</a>';
3054 $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>';
3056 print
'<tr><td class="titlefield">' . $langs->trans(
'Discounts') .
'</td><td class="valuefield">';
3058 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3059 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3060 $absolute_discount =
price2num($absolute_discount,
'MT');
3061 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3065 $backtopage = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id;
3066 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
3073 print $form->editfieldkey(
"Date",
'date',
'', $object, (
int) $editenable);
3074 print
'</td><td class="valuefield">';
3075 if ($action ==
'editdate') {
3076 print
'<form name="setdate" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3077 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3078 print
'<input type="hidden" name="action" value="setdate">';
3079 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3080 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3081 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3086 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3094 $editenable = $usercancreate;
3095 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, (
int) $editenable);
3096 print
'</td><td class="valuefield">';
3097 if ($action ==
'editdate_livraison') {
3098 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3099 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3100 print
'<input type="hidden" name="action" value="setdate_livraison">';
3101 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3102 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3103 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3108 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3113 $shippableInfos =
$object->getShippableInfos();
3115 if (!empty($shippableInfos[
'has_product'])) {
3117 print $form->textwithtooltip(
'', $shippableInfos[
'textinfo'], 2, 1, $shippableInfos[
'texticon'],
'', 2);
3119 if (!empty($shippableInfos[
'warning'])) {
3121 print $form->textwithtooltip(
'', $langs->trans(
"NotEnoughForAllOrders"), 2, 1,
img_picto(
'',
'error',
'', 0, 0, 0,
'',
'2'),
'', 2);
3129 print
'<tr class="fielddeliverydelay"><td>';
3130 $editenable = $usercancreate;
3131 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, (
int) $editenable);
3132 print
'</td><td class="valuefield">';
3133 if ($action ==
'editavailability') {
3134 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3136 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'none', 1);
3143 $editenable = $usercancreate;
3144 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, (
int) $editenable);
3145 print
'</td><td class="valuefield">';
3146 if ($action ==
'editshippingmethod') {
3147 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3149 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'none');
3157 $langs->load(
'stocks');
3159 $editenable = $usercancreate;
3160 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, (
int) $editenable);
3161 print
'</td><td class="valuefield">';
3162 if ($action ==
'editwarehouse') {
3163 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3165 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'none');
3173 $editenable = $usercancreate;
3174 print $form->editfieldkey(
"Source",
'demandreason',
'', $object, (
int) $editenable);
3175 print
'</td><td class="valuefield">';
3176 if ($action ==
'editdemandreason') {
3177 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3179 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'none');
3185 $editenable = $usercancreate;
3186 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, (
int) $editenable);
3187 print
'</td><td class="valuefield">';
3188 if ($action ==
'editconditions') {
3189 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3191 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3199 $editenable = $usercancreate;
3200 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, (
int) $editenable);
3201 print
'</td><td class="valuefield">';
3202 if ($action ==
'editmode') {
3203 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3205 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
3223 $tmparray =
$object->getTotalWeightVolume();
3224 $totalWeight = $tmparray[
'weight'];
3225 $totalVolume = $tmparray[
'volume'];
3227 print
'<tr><td>' . $langs->trans(
"CalculatedWeight") .
'</td>';
3228 print
'<td class="valuefield">';
3233 print
'<tr><td>' . $langs->trans(
"CalculatedVolume") .
'</td>';
3234 print
'<td class="valuefield">';
3244 $editenable = $usercancreate;
3245 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, (
int) $editenable);
3247 print
'<td class="valuefield">';
3248 if ($action !=
'editincoterm') {
3249 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3251 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3259 $editenable = $usercancreate;
3260 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, (
int) $editenable);
3261 print
'</td><td class="valuefield">';
3262 if ($action ==
'editbankaccount') {
3263 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3265 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
3274 print
'<table class="nobordernopadding centpercent"><tr><td>';
3275 print $langs->trans(
"Categories");
3276 print
'<td><td class="right">';
3277 if ($usercancreate) {
3278 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/commande/card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3282 print
'</td></tr></table>';
3285 if ($action ==
'edittags') {
3286 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
3287 print
'<input type="hidden" name="action" value="settags">';
3288 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3289 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
3290 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
3293 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3299 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3304 print
'<div class="fichehalfright">';
3305 print
'<div class="underbanner clearboth"></div>';
3307 print
'<table class="border tableforfield centpercent">';
3309 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_currency_amount.tpl.php';
3313 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3317 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3318 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3321 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3326 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3327 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3330 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3335 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3337 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
3338 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3342 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3348 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3350 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
3351 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3355 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3361 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3362 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3365 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3367 print
'</tr>' .
"\n";
3376 $formmargin->displayMarginInfos($object);
3383 print
'<div class="clearboth"></div><br>';
3386 $blocname =
'contacts';
3387 $title = $langs->trans(
'ContactsAddresses');
3388 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3392 $blocname =
'notes';
3393 $title = $langs->trans(
'Notes');
3394 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3402 $result =
$object->getLinesArray();
3406 global $inputalsopricewithtax;
3407 $inputalsopricewithtax = 1;
3409 print
'<form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="POST">
3410 <input type="hidden" name="token" value="' .
newToken() .
'">
3411 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
3412 <input type="hidden" name="mode" value="">
3413 <input type="hidden" name="page_y" value="">
3414 <input type="hidden" name="id" value="' .
$object->id .
'">
3415 <input type="hidden" name="backtopage" value="' . $backtopage .
'">
3420 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
3422 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3426 print
'<div class="div-table-responsive-no-min">';
3427 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3431 $object->printObjectLines($action,
$mysoc, $soc, $lineid, 1);
3438 if ($action !=
'editline') {
3441 $parameters = array();
3443 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3447 if (empty($reshook)) {
3451 $parameters = array();
3452 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3466 if ($action !=
'presend' && $action !=
'editline') {
3467 print
'<div class="tabsAction">';
3469 $parameters = array();
3470 $arrayforbutaction = array();
3472 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3473 if (empty($reshook)) {
3474 $numlines = count(
$object->lines);
3478 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=reopen&token=' .
newToken() .
'&id=' .
$object->id,
'');
3482 if (empty($user->socid)) {
3485 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3487 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3495 $langs->load(
'subtotals');
3497 $url_button = array();
3499 $url_button[] = array(
3500 'lang' =>
'subtotals',
3502 'perm' => (
bool) $usercancreate,
3503 'label' => $langs->trans(
'AddTitleLine'),
3504 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_title_line&token=' .
newToken()
3507 $url_button[] = array(
3508 'lang' =>
'subtotals',
3510 'perm' => (
bool) $usercancreate,
3511 'label' => $langs->trans(
'AddSubtotalLine'),
3512 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_subtotal_line&token=' .
newToken()
3514 print
dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
3519 if ($numlines > 0) {
3520 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id,
'action-validate', 1);
3522 $langs->load(
"errors");
3523 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id,
'action-validate', -1);
3528 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=modif&token=' .
newToken() .
'&id=' .
$object->id,
'action-modif');
3534 $arrayforbutaction[] = array(
3537 'perm' => $usercancreatepurchaseorder,
3538 'label' =>
'AddPurchaseOrder',
3539 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3551 $arrayforbutaction[] = array(
3552 'lang' =>
'interventions',
3554 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3555 'label' =>
'AddIntervention',
3556 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3562 $arrayforbutaction[] = [
3563 'lang' =>
'contracts',
3565 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3566 'label' =>
'AddContract',
3567 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3582 $numshipping =
$object->countNbOfShipments();
3585 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3587 $arrayforbutaction[] = array(
3588 'lang' =>
'sendings',
3590 'perm' => $user->hasRight(
'expedition',
'creer'),
3591 'label' =>
'CreateShipment',
3592 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3597 $arrayforbutaction[] = array(
3598 'lang' =>
'sendings',
3601 'label' =>
'CreateShipment',
3602 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3609 $arrayforbutaction[] = array(
3612 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3613 'label' =>
'CreateBill',
3614 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3623 $actionButtonsParameters = [
3624 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3627 if ($numlines > 0) {
3628 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3630 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3635 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=shipped&token=' .
newToken() .
'&id=' .
$object->id,
'');
3642 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3647 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"] .
'?action=classifyunbilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3652 if ($usercancreate) {
3658 print
'<a class="butActionDelete" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=cancel&token=' .
newToken() .
'">' . $langs->trans(
"CancelOrder") .
'</a>';
3662 if ($usercandelete) {
3663 if ($numshipping == 0) {
3666 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3674 if (
GETPOST(
'modelselected')) {
3675 $action =
'presend';
3678 if ($action !=
'presend') {
3679 print
'<div class="fichecenter"><div class="fichehalfleft">';
3680 print
'<a name="builddoc"></a>';
3683 $relativepath = $objref .
'/' . $objref .
'.pdf';
3684 $filedir =
$conf->commande->multidir_output[
$object->entity ??
$conf->entity] .
'/' . $objref;
3686 $genallowed = $usercanread;
3687 $delallowed = $usercancreate;
3688 $tooltipAfterComboOfModels =
'';
3690 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_ORDER_TERMSOFSALE'));
3693 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, (
int) $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'', $object, 0,
'remove_file', $tooltipAfterComboOfModels);
3697 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'order'), 1);
3698 $linktoelem = $tmparray[
'linktoelem'];
3699 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3700 print $htmltoenteralink;
3702 $compatibleImportElementsList =
false;
3707 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3709 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3713 include_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3714 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3715 $useonlinepayment = count($validpaymentmethod);
3718 $useonlinepayment = 0;
3721 print
'<br><!-- Link to pay -->';
3722 require_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3723 print showOnlinePaymentUrl(
'order',
$object->ref) .
'<br>';
3726 print
'</div><div class="fichehalfright">';
3731 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/messaging.php', [
'id' =>
$object->id]));
3732 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/agenda.php', [
'id' =>
$object->id]));
3735 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3737 $somethingshown = $formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3739 print
'</div></div>';
3743 $modelmail =
'order_send';
3744 $defaulttopic =
'SendOrderRef';
3746 $trackid =
'ord' .
$object->id;
3748 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 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.
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.
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.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
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.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
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.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
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'.
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.
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...
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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 a 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 rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.