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'));
146$extrafields->fetch_name_optionals_label(
$object->table_element);
149include 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];
1148 $price_base_type = (empty(
$prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' :
$prod->multiprices_base_type[
$object->thirdparty->price_level]);
1150 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1151 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1153 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1154 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1159 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1160 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1161 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1162 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1165 $price_base_type = (empty(
$prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' :
$prod->multiprices_base_type[
$object->thirdparty->price_level]);
1167 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1168 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1170 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1171 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1176 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1180 $filter = array(
't.fk_product' => (
string)
$prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1182 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1185 if (count($prodcustprice->lines) > 0) {
1186 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1187 foreach ($prodcustprice->lines as $k => $custprice_line) {
1188 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1189 $pu_ht =
price($custprice_line->price);
1190 $pu_ttc =
price($custprice_line->price_ttc);
1191 $price_min =
price($custprice_line->price_min);
1192 $price_min_ttc =
price($custprice_line->price_min_ttc);
1193 $price_base_type = $custprice_line->price_base_type;
1211 if (
$prod->prices_by_qty[0]) {
1216 foreach (
$prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1217 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1221 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1222 $pu_ht = $priceforthequantityarray[
'unitprice'];
1224 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1232 if (!empty(
$object->thirdparty->price_level)) {
1234 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1235 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1236 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1237 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1238 $price_base_type = (empty(
$prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' :
$prod->multiprices_base_type[
$object->thirdparty->price_level]);
1240 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1241 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1243 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1244 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1248 if (!empty(
$object->thirdparty->price_level) && !empty(
$prod->prices_by_qty[
$object->thirdparty->price_level])) {
1252 foreach (
$prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1253 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1257 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1258 $pu_ht = $priceforthequantityarray[
'unitprice'];
1260 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1268 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1269 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string)
$prod->tva_tx));
1272 if (!empty($price_ht) || (
string) $price_ht ===
'0') {
1273 $pu_ht = (float)
price2num($price_ht,
'MU');
1274 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1275 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1276 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1277 $pu_ttc_devise = (float)
price2num((
float) $pu_ht_devise * (1 + ((float) $tmpvat / 100)),
'MU');
1280 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1281 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1282 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1283 } elseif (!empty($price_ttc_devise) || (
string) $price_ttc_devise ===
'0') {
1284 $pu_ttc_devise = (float)
price2num($price_ttc_devise,
'MU');
1285 $pu_ht_devise = (float)
price2num((
float) $pu_ttc_devise / (1 + ((float) $tmpvat / 100)),
'MU');
1288 } elseif ($tmpvat != $tmpprodvat) {
1290 if ($price_base_type !=
'HT') {
1291 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1293 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1301 $outputlangs = $langs;
1303 if (
GETPOST(
'lang_id',
'aZ09')) {
1304 $newlang =
GETPOST(
'lang_id',
'aZ09');
1306 if (empty($newlang)) {
1307 $newlang =
$object->thirdparty->default_lang;
1309 if (!empty($newlang)) {
1311 $outputlangs->setDefaultLang($newlang);
1314 $desc = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1316 $desc =
$prod->description;
1332 $outputlangs = $langs;
1334 if (
GETPOST(
'lang_id',
'alpha')) {
1335 $newlang =
GETPOST(
'lang_id',
'alpha');
1337 if (empty($newlang)) {
1338 $newlang =
$object->thirdparty->default_lang;
1340 if (!empty($newlang)) {
1342 $outputlangs->setDefaultLang($newlang);
1343 $outputlangs->load(
'products');
1345 if (!empty(
$prod->customcode)) {
1346 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1348 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1351 if (!empty(
$prod->country_code)) {
1352 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'',
$db, $outputlangs, 0);
1355 if (!empty(
$prod->customcode)) {
1356 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1358 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1361 if (!empty(
$prod->country_code)) {
1362 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'',
$db, $langs, 0);
1369 $type =
$prod->type;
1370 $fk_unit =
$prod->fk_unit;
1374 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1375 $tva_tx = str_replace(
'*',
'', $tva_tx);
1376 if (empty($tva_tx)) {
1379 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1382 $fk_unit =
GETPOST(
'units',
'alpha');
1383 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1384 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1386 if ($pu_ttc && !$pu_ht) {
1387 $price_base_type =
'TTC';
1401 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1402 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1405 $pu_equivalent = $pu_ht;
1406 $pu_equivalent_ttc = $pu_ttc;
1408 $currency_tx =
$object->multicurrency_tx;
1412 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1413 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1415 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1416 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1436 if ($usermustrespectpricemin) {
1437 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1438 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1441 } 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') {
1442 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1450 $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);
1462 $outputlangs = $langs;
1463 $newlang =
GETPOST(
'lang_id',
'alpha');
1465 $newlang =
$object->thirdparty->default_lang;
1467 if (!empty($newlang)) {
1469 $outputlangs->setDefaultLang($newlang);
1472 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1475 unset($_POST[
'prod_entry_mode']);
1477 unset($_POST[
'qty']);
1478 unset($_POST[
'type']);
1479 unset($_POST[
'remise_percent']);
1480 unset($_POST[
'price_ht']);
1481 unset($_POST[
'multicurrency_price_ht']);
1482 unset($_POST[
'price_ttc']);
1483 unset($_POST[
'tva_tx']);
1484 unset($_POST[
'product_ref']);
1485 unset($_POST[
'product_label']);
1486 unset($_POST[
'product_desc']);
1487 unset($_POST[
'fournprice']);
1488 unset($_POST[
'buying_price']);
1489 unset($_POST[
'np_marginRate']);
1490 unset($_POST[
'np_markRate']);
1491 unset($_POST[
'dp_desc']);
1492 unset($_POST[
'idprod']);
1493 unset($_POST[
'units']);
1495 unset($_POST[
'date_starthour']);
1496 unset($_POST[
'date_startmin']);
1497 unset($_POST[
'date_startsec']);
1498 unset($_POST[
'date_startday']);
1499 unset($_POST[
'date_startmonth']);
1500 unset($_POST[
'date_startyear']);
1501 unset($_POST[
'date_endhour']);
1502 unset($_POST[
'date_endmin']);
1503 unset($_POST[
'date_endsec']);
1504 unset($_POST[
'date_endday']);
1505 unset($_POST[
'date_endmonth']);
1506 unset($_POST[
'date_endyear']);
1514 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1517 $langs->load(
'subtotals');
1519 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1522 $subtotal_options = array();
1524 foreach (Commande::$TITLE_OPTIONS as $option) {
1525 $value =
GETPOST($option,
'alphanohtml');
1527 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1532 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1543 $outputlangs = $langs;
1544 $newlang =
GETPOST(
'lang_id',
'alpha');
1546 $newlang =
$object->thirdparty->default_lang;
1548 if (!empty($newlang)) {
1550 $outputlangs->setDefaultLang($newlang);
1553 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1558 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1561 $langs->load(
'subtotals');
1563 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1566 $subtotal_options = array();
1568 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1569 $value =
GETPOST($option,
'alphanohtml');
1571 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1576 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1584 $outputlangs = $langs;
1585 $newlang =
GETPOST(
'lang_id',
'alpha');
1587 $newlang =
$object->thirdparty->default_lang;
1589 if (!empty($newlang)) {
1591 $outputlangs->setDefaultLang($newlang);
1594 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1599 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1612 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1617 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1618 $vat_rate = str_replace(
'*',
'', $vat_rate);
1630 $pu_equivalent = $pu_ht;
1631 $pu_equivalent_ttc = $pu_ttc;
1633 $currency_tx =
$object->multicurrency_tx;
1637 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1638 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1640 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1641 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1656 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1660 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1661 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1663 if (is_array($extralabelsline)) {
1664 foreach ($extralabelsline as $key => $value) {
1665 unset($_POST[
"options_" . $key]);
1678 $price_base_type =
'HT';
1679 if (empty($pu) && !empty($pu_ttc)) {
1681 $price_base_type =
'TTC';
1686 if (!empty($productid)) {
1688 $product->fetch($productid);
1690 $type = $product->type;
1692 $price_min = $product->price_min;
1694 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1696 $price_min_ttc = $product->price_min_ttc;
1698 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1704 if ($usermustrespectpricemin) {
1705 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1706 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1709 $action =
'editline';
1710 } 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') {
1711 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1714 $action =
'editline';
1719 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1723 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1725 $action =
'editline';
1730 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1732 $action =
'editline';
1737 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1738 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1740 $action =
'editline';
1747 if (!$user->hasRight(
'margins',
'creer')) {
1748 foreach (
$object->lines as &$line) {
1750 $fournprice = $line->fk_fournprice;
1751 $buyingprice = $line->pa_ht;
1757 $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);
1765 $outputlangs = $langs;
1768 $newlang =
GETPOST(
'lang_id',
'aZ09');
1771 $newlang =
$object->thirdparty->default_lang;
1773 if (!empty($newlang)) {
1775 $outputlangs->setDefaultLang($newlang);
1779 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1782 unset($_POST[
'qty']);
1783 unset($_POST[
'type']);
1784 unset($_POST[
'productid']);
1785 unset($_POST[
'remise_percent']);
1786 unset($_POST[
'price_ht']);
1787 unset($_POST[
'multicurrency_price_ht']);
1788 unset($_POST[
'price_ttc']);
1789 unset($_POST[
'tva_tx']);
1790 unset($_POST[
'product_ref']);
1791 unset($_POST[
'product_label']);
1792 unset($_POST[
'product_desc']);
1793 unset($_POST[
'fournprice']);
1794 unset($_POST[
'buying_price']);
1796 unset($_POST[
'date_starthour']);
1797 unset($_POST[
'date_startmin']);
1798 unset($_POST[
'date_startsec']);
1799 unset($_POST[
'date_startday']);
1800 unset($_POST[
'date_startmonth']);
1801 unset($_POST[
'date_startyear']);
1802 unset($_POST[
'date_endhour']);
1803 unset($_POST[
'date_endmin']);
1804 unset($_POST[
'date_endsec']);
1805 unset($_POST[
'date_endday']);
1806 unset($_POST[
'date_endmonth']);
1807 unset($_POST[
'date_endyear']);
1814 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1815 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1817 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1820 $qualified_for_stock_change = 0;
1822 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1824 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1829 if (!$idwarehouse || $idwarehouse == -1) {
1831 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1837 $locationTarget =
'';
1841 $result =
$object->valid($user, $idwarehouse);
1846 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1849 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1850 &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1852 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1855 $forceFields = array();
1865 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1877 $outputlangs = $langs;
1880 $newlang =
GETPOST(
'lang_id',
'aZ09');
1883 $newlang =
$object->thirdparty->default_lang;
1885 if (!empty($newlang)) {
1887 $outputlangs->setDefaultLang($newlang);
1892 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1895 $deposit->fetch($deposit->id);
1896 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1900 if ($locationTarget) {
1901 header(
'Location: ' . $locationTarget);
1912 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1914 $idwarehouse =
GETPOST(
'idwarehouse');
1916 $qualified_for_stock_change = 0;
1918 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1920 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1925 if (!$idwarehouse || $idwarehouse == -1) {
1927 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1933 $result =
$object->setDraft($user, $idwarehouse);
1937 $outputlangs = $langs;
1940 $newlang =
GETPOST(
'lang_id',
'aZ09');
1943 $newlang =
$object->thirdparty->default_lang;
1945 if (!empty($newlang)) {
1947 $outputlangs->setDefaultLang($newlang);
1952 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1958 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1959 $result =
$object->cloture($user);
1963 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercancancel) {
1966 $qualified_for_stock_change = 0;
1968 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1970 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1975 if (!$idwarehouse || $idwarehouse == -1) {
1977 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1983 $result =
$object->cancel($user, $idwarehouse);
1991 if ($action ==
'update_extras' && $permissiontoeditextra) {
1994 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1997 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2004 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
2012 $action =
'edit_extras';
2018 $fromElement =
GETPOST(
'fromelement');
2019 $fromElementid =
GETPOSTINT(
'fromelementid');
2020 $importLines =
GETPOST(
'line_checkbox');
2022 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && preg_match(
'/^[a-zA-Z]+$/', $fromElement) && !empty($fromElementid)) {
2023 $lineParentField =
'';
2024 if ($fromElement ==
'commande') {
2025 dol_include_once(
'/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2026 $lineClassName =
'OrderLine';
2027 $lineParentField =
'fk_commande';
2028 } elseif ($fromElement ==
'propal') {
2029 dol_include_once(
'/comm/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2030 $lineClassName =
'PropaleLigne';
2031 $lineParentField =
'fk_propal';
2032 } elseif ($fromElement ==
'facture') {
2033 dol_include_once(
'/compta/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2034 $lineClassName =
'FactureLigne';
2035 $lineParentField =
'fk_facture';
2037 $nextRang = count(
$object->lines) + 1;
2041 $fromElementAllowed = ($lineParentField && $fromElementid > 0 &&
restrictedArea($user, $fromElement, $fromElementid,
'',
'',
'fk_soc',
'rowid', 0, 1));
2042 foreach ($importLines as $lineId) {
2043 if (!$fromElementAllowed) {
2047 $lineId = intval($lineId);
2048 $originLine =
new $lineClassName(
$db);
2049 if ($fromElementAllowed && $originLine->fetch($lineId) > 0 && $originLine->$lineParentField == $fromElementid) {
2050 $originLine->fetch_optionals();
2051 $desc = $originLine->desc;
2052 $pu_ht = $originLine->subprice;
2053 $qty = $originLine->qty;
2054 $txtva = $originLine->tva_tx;
2055 $txlocaltax1 = $originLine->localtax1_tx;
2056 $txlocaltax2 = $originLine->localtax2_tx;
2057 $fk_product = $originLine->fk_product;
2058 $remise_percent = $originLine->remise_percent;
2060 $date_end = $originLine->date_end;
2061 $fk_code_ventilation = 0;
2062 $info_bits = $originLine->info_bits;
2063 $fk_remise_except = $originLine->fk_remise_except;
2064 $price_base_type =
'HT';
2066 $type = $originLine->product_type;
2067 $rang = $nextRang++;
2068 $special_code = $originLine->special_code;
2069 $origin = $originLine->element;
2070 $origin_id = $originLine->id;
2071 $fk_parent_line = 0;
2072 $fk_fournprice = $originLine->fk_fournprice;
2073 $pa_ht = $originLine->pa_ht;
2074 $label = $originLine->label;
2075 $array_options = $originLine->array_options;
2076 $situation_percent = 100;
2078 $fk_unit = $originLine->fk_unit;
2079 $pu_ht_devise = $originLine->multicurrency_subprice;
2081 $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);
2100 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
2104 $permissiontoadd = $usercancreate;
2105 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
2108 $triggersendname =
'ORDER_SENTBYMAIL';
2110 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2111 $trackid =
'ord' .
$object->id;
2112 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
2116 if ($action ==
'addcontact') {
2120 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2124 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2127 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2128 $langs->load(
"errors");
2129 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2134 } elseif ($action ==
'swapstatut') {
2141 } elseif ($action ==
'deletecontact') {
2143 $result =
$object->delete_contact($lineid);
2146 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2160$title =
$object->ref .
" - " . $langs->trans(
'Card');
2161if ($action ==
'create') {
2162 $title = $langs->trans(
"NewOrder");
2164$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2166llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2178if ($action ==
'create' && $usercancreate) {
2183 $res = $soc->fetch($socid);
2186 $currency_code =
$conf->currency;
2188 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2189 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2190 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2193 if (!empty($origin) && !empty($originid)) {
2195 $element = $subelement = $origin;
2197 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2198 $element = $regs[1];
2199 $subelement = $regs[2];
2202 if ($element ==
'project') {
2203 $projectid = $originid;
2205 if (!$cond_reglement_id) {
2206 $cond_reglement_id = $soc->cond_reglement_id;
2208 if (!$deposit_percent) {
2209 $deposit_percent = $soc->deposit_percent;
2211 if (!$mode_reglement_id) {
2212 $mode_reglement_id = $soc->mode_reglement_id;
2214 if (!$remise_percent) {
2215 $remise_percent = $soc->remise_percent;
2219 if ($element ==
'order' || $element ==
'commande') {
2220 $element = $subelement =
'commande';
2221 } elseif ($element ==
'propal') {
2222 $element =
'comm/propal';
2223 $subelement =
'propal';
2224 } elseif ($element ==
'contract') {
2225 $element = $subelement =
'contrat';
2230 $classname = ucfirst($subelement);
2231 $objectsrc =
new $classname(
$db);
2232 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2233 $objectsrc->fetch($originid);
2234 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2235 $objectsrc->fetch_lines();
2237 $objectsrc->fetch_thirdparty();
2240 $objectsrc->fetch_optionals();
2241 $object->array_options = $objectsrc->array_options;
2243 $projectid = (int) $objectsrc->fk_project;
2244 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2246 $soc = $objectsrc->thirdparty;
2247 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2248 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2249 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2250 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2251 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2252 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2253 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2254 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2257 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2260 if (!empty($objectsrc->multicurrency_code)) {
2261 $currency_code = $objectsrc->multicurrency_code;
2263 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2264 $currency_tx = $objectsrc->multicurrency_tx;
2268 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2269 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2272 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2275 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2276 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2277 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2278 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2279 $availability_id = 0;
2280 $shipping_method_id = empty($soc->shipping_method_id) ? $shipping_method_id : $soc->shipping_method_id;
2281 $warehouse_id = $soc->fk_warehouse;
2282 $demand_reason_id = $soc->demand_reason_id;
2285 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2286 $currency_code = $soc->multicurrency_code;
2289 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2290 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2294 if (!
GETPOST(
'changecompany')) {
2296 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2302 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2310 if ($soc->fk_warehouse > 0) {
2311 $warehouse_id = $soc->fk_warehouse;
2318 $warehouse_id = $user->fk_warehouse;
2322 print
'<form name="crea_commande" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2323 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2324 print
'<input type="hidden" name="action" value="add">';
2325 print
'<input type="hidden" name="changecompany" value="0">';
2326 print
'<input type="hidden" name="remise_percent" value="' . $soc->remise_percent .
'">';
2327 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
2328 print
'<input type="hidden" name="originid" value="' . $originid .
'">';
2329 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
2330 if (!empty($currency_tx)) {
2331 print
'<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx .
'">';
2337 $parameters = array();
2339 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters, $object, $action);
2340 if (empty($reshook)) {
2341 print
'<table class="border centpercent">';
2348 print
'<td class="fieldrequired">' . $langs->trans(
'Customer') .
'</td>';
2351 print $soc->getNomUrl(1,
'customer');
2352 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
2355 print
'<td class="valuefieldcreate">';
2356 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2357 print
img_picto(
'',
'company',
'class="pictofixedwidth"') . $form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2361 $(document).ready(function() {
2362 $("#socid").change(function() {
2363 console.log("We have changed the company - Reload page");
2364 var socid = $(this).val();
2366 $("input[name=action]").val("create");
2367 $("input[name=changecompany]").val("1");
2368 $("form[name=crea_commande]").submit();
2373 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>';
2376 print
'</tr>' .
"\n";
2381 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2382 print $langs->trans(
'RefProposal') .
'</td><td>';
2383 print
'<input type="text" name="ref_client" value="' . $ref_client .
'">';
2385 print $form->textwithpicto($langs->trans(
'RefCustomer'), $langs->trans(
'RefOfOnCustomerSide', $langs->transnoentitiesnoconv(
"Order"))) .
'</td><td>';
2386 print
'<input type="text" name="ref_client" value="' .
GETPOST(
'ref_client') .
'">';
2396 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_" . $type_contact_code));
2398 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2400 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2404 print
'<tr><td>' . $langs->trans(
'Discounts') .
'</td><td>';
2406 $absolute_discount = $soc->getAvailableDiscounts();
2410 $backtopage = $_SERVER[
"PHP_SELF"] .
'?socid=' . $thirdparty->id .
'&action=' . $action .
'&origin=' . urlencode((
string) (
GETPOST(
'origin'))) .
'&originid=' . urlencode((
string) (
GETPOSTINT(
'originid')));
2411 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
2419 print
'<tr><td class="fieldrequired">' . $langs->trans(
'Date') .
'</td><td>';
2420 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2421 print $form->selectDate($dateorder,
're', 0, 0, 0,
"crea_commande", 1, 1);
2425 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
2426 print
'<td colspan="3">';
2427 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2428 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2429 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2434 print
'<tr class="fielddeliverydelay"><td>' . $langs->trans(
'AvailabilityPeriod') .
'</td><td>';
2435 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2436 $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2440 print
'<tr><td class="nowrap">' . $langs->trans(
'PaymentConditionsShort') .
'</td><td>';
2441 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2442 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2446 print
'<tr><td>' . $langs->trans(
'PaymentMode') .
'</td><td>';
2447 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2448 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2453 print
'<tr><td>' . $langs->trans(
'BankAccount') .
'</td><td>';
2454 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"') . $form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2460 print
'<tr><td>' . $langs->trans(
'SendingMethod') .
'</td><td>';
2461 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2462 $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');
2468 print
'<tr><td>' . $langs->trans(
'Warehouse') .
'</td><td>';
2469 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');
2474 print
'<tr><td>' . $langs->trans(
'Source') .
'</td><td>';
2475 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2476 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2483 $langs->load(
"projects");
2485 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2486 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');
2487 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>';
2495 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>';
2496 print
'<td class="maxwidthonsmartphone">';
2497 $incoterm_id =
GETPOST(
'incoterm_id');
2498 $location_incoterms =
GETPOST(
'location_incoterms');
2499 if (empty($incoterm_id)) {
2500 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2501 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2503 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2504 print $form->select_incoterms($incoterm_id, $location_incoterms);
2509 $parameters = array();
2510 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2511 $parameters[
'objectsrc'] = $objectsrc;
2513 $parameters[
'socid'] = $socid;
2516 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2517 print $hookmanager->resPrint;
2518 if (empty($reshook)) {
2519 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2522 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2523 if ($soc->fetch_optionals() > 0) {
2524 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2528 print
$object->showOptionals($extrafields,
'create', $parameters);
2532 include_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
2534 if (is_array($list) && count($list) > 0) {
2535 print
'<tr><td>' . $langs->trans(
'DefaultModel') .
'</td>';
2538 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2539 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2546 print
'<td>' . $form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0) .
'</td>';
2547 print
'<td class="maxwidthonsmartphone">';
2548 print
img_picto(
'',
'currency',
'class="pictofixedwidth"') . $form->selectMultiCurrency(((
GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2554 print
'<tr><td>' . $langs->trans(
"Categories") .
'</td><td colspan="3">';
2555 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
2561 print
'<td class="tdtop">' . $langs->trans(
'NotePublic') .
'</td>';
2564 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2565 print $doleditor->Create(1);
2570 if (empty($user->socid)) {
2572 print
'<td class="tdtop">' . $langs->trans(
'NotePrivate') .
'</td>';
2575 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2576 print $doleditor->Create(1);
2581 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($classname)) {
2583 if ($origin ==
'contrat') {
2585 $objectsrc->update_price(1);
2588 print
"\n<!-- " . $classname .
" info -->\n";
2589 print
'<input type="hidden" name="amount" value="' . $objectsrc->total_ht .
'">' .
"\n";
2590 print
'<input type="hidden" name="total" value="' . $objectsrc->total_ttc .
'">' .
"\n";
2591 print
'<input type="hidden" name="tva" value="' . $objectsrc->total_tva .
'">' .
"\n";
2592 print
'<input type="hidden" name="origin" value="' . $objectsrc->element .
'">';
2593 print
'<input type="hidden" name="originid" value="' . $objectsrc->id .
'">';
2595 switch ($classname) {
2597 $newclassname =
'CommercialProposal';
2600 $newclassname =
'Order';
2603 $newclassname =
'Sending';
2606 $newclassname =
'Contract';
2609 $newclassname = $classname;
2612 print
'<tr><td>' . $langs->trans($newclassname) .
'</td><td>' . $objectsrc->getNomUrl(1) .
'</td></tr>';
2615 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td><td>' .
price($objectsrc->total_ht) .
'</td></tr>';
2616 print
'<tr><td>' . $langs->trans(
'AmountVAT') .
'</td><td>' .
price($objectsrc->total_tva) .
"</td></tr>";
2617 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2618 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax1) .
"</td></tr>";
2621 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2622 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax2) .
"</td></tr>";
2625 print
'<tr><td>' . $langs->trans(
'AmountTTC') .
'</td><td>' .
price($objectsrc->total_ttc) .
"</td></tr>";
2628 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
2629 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2630 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2641 print $form->buttonsSaveCancel(
"CreateDraft");
2644 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2645 $title = $langs->trans(
'ProductsAndServices');
2648 print
'<div class="div-table-responsive-no-min">';
2649 print
'<table class="noborder centpercent">';
2651 $objectsrc->printOriginLinesList(
'', $selectedLines);
2669 $author->fetch(
$object->user_author_id);
2672 $res =
$object->fetch_optionals();
2675 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2680 if ($action ==
'delete') {
2681 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2685 if ($action ==
'validate') {
2687 $ref = substr(
$object->ref, 1, 4);
2688 if ($ref ==
'PROV' || $ref ==
'') {
2689 $numref =
$object->getNextNumRef($soc);
2690 if (empty($numref)) {
2698 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2700 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2703 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid, $object);
2706 $qualified_for_stock_change = 0;
2708 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2710 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2713 $formquestion = array();
2715 $langs->load(
"stocks");
2717 if (
$conf->browser->name ==
'ie') {
2720 $formquestion = array(
2724 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2730 foreach (
$object->lines as $line) {
2731 $res = $line->fetch_product();
2733 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2739 if ($nbMandated > 0) {
2741 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2744 $text .=
'<div><span class="clearboth nowraponall warning">' .
img_warning() . $langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate") .
'</span></div>';
2748 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2753 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2755 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2756 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2760 $eligibleForDepositGeneration =
true;
2762 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2763 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2764 '@phan-var-force Facture $invoice';
2766 $eligibleForDepositGeneration =
false;
2772 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2773 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2774 $proposal->fetchObjectLinked();
2776 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2777 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2778 '@phan-var-force Facture $invoice';
2780 $eligibleForDepositGeneration =
false;
2788 if ($eligibleForDepositGeneration) {
2789 $formquestion[] = array(
2790 'type' =>
'checkbox',
2792 'name' =>
'generate_deposit',
2793 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2796 $formquestion[] = array(
2798 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2800 'label' => $langs->trans(
'DateInvoice'),
2806 $formquestion[] = array(
2808 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2809 'name' =>
'date_pointoftax',
2810 'label' => $langs->trans(
'DatePointOfTax'),
2816 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2818 $formquestion[] = array(
2820 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2821 'name' =>
'cond_reglement_id',
2822 'label' => $langs->trans(
'PaymentTerm'),
2823 'value' => $paymentTermsSelect
2826 $formquestion[] = array(
2827 'type' =>
'checkbox',
2828 'tdclass' =>
'showonlyifgeneratedeposit',
2829 'name' =>
'validate_generated_deposit',
2830 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2833 $formquestion[] = array(
2834 'type' =>
'onecolumn',
2837 $(document).ready(function() {
2838 $("[name=generate_deposit]").change(function () {
2839 let $self = $(this);
2840 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2842 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2859 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2864 if ($action ==
'modif') {
2865 $qualified_for_stock_change = 0;
2867 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2869 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2872 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2873 $formquestion = array();
2875 $langs->load(
"stocks");
2877 if (
$conf->browser->name ==
'ie') {
2886 'name' =>
'idwarehouse',
2887 'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
2888 'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo)
2893 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2897 if ($action ==
'shipped') {
2898 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2902 if ($action ==
'cancel') {
2903 $qualified_for_stock_change = 0;
2905 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2907 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2910 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2911 $formquestion = array();
2913 $langs->load(
"stocks");
2915 if (
$conf->browser->name ==
'ie') {
2918 $formquestion = array(
2922 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2926 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2930 if ($action ==
'ask_deleteline') {
2931 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2935 if ($action ==
'ask_subtotal_deleteline') {
2936 $langs->load(
"subtotals");
2937 $title =
"DeleteSubtotalLine";
2938 $question =
"ConfirmDeleteSubtotalLine";
2939 if (
GETPOST(
'type') ==
'title') {
2940 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2941 $title =
"DeleteTitleLine";
2942 $question =
"ConfirmDeleteTitleLine";
2944 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2948 if ($action ==
'clone') {
2949 $filter =
'(s.client:IN:1,2,3)';
2951 $formquestion = array(
2952 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2954 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2958 if ($action ==
'add_title_line') {
2959 $langs->load(
'subtotals');
2961 $depth_array =
$object->getPossibleLevels($langs);
2962 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2963 } elseif ($action ==
'add_subtotal_line') {
2964 $langs->load(
'subtotals');
2966 $titles =
$object->getPossibleTitles();
2967 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2971 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2973 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2974 if (empty($reshook)) {
2975 $formconfirm .= $hookmanager->resPrint;
2976 } elseif ($reshook > 0) {
2977 $formconfirm = $hookmanager->resPrint;
2986 $linkback =
'<a href="' . DOL_URL_ROOT .
'/commande/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2988 $morehtmlref =
'<div class="refidno">';
2990 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client, $object, (
int) $usercancreate,
'string',
'', 0, 1);
2991 $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);
2993 $morehtmlref .=
'<br>' . $soc->getNomUrl(1,
'customer');
2995 $morehtmlref .=
' (<a href="' . DOL_URL_ROOT .
'/commande/list.php?socid=' . ((int)
$object->thirdparty->id) .
'">' . $langs->trans(
"OtherOrders") .
'</a>)';
2999 $langs->load(
"projects");
3000 $morehtmlref .=
'<br>';
3001 if ($usercancreate) {
3002 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3003 if ($action !=
'classify') {
3004 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
3006 $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');
3008 if (!empty(
$object->fk_project)) {
3010 $proj->fetch(
$object->fk_project);
3011 $morehtmlref .= $proj->getNomUrl(1);
3013 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
3018 $morehtmlref .=
'</div>';
3020 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3023 $parameters = array();
3025 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters, $object, $action);
3026 if (empty($reshook)) {
3027 print
'<div class="fichecenter">';
3028 print
'<div class="fichehalfleft">';
3029 print
'<div class="underbanner clearboth"></div>';
3031 print
'<table class="border tableforfield centpercent">';
3035 $langs->load(
"cashdesk");
3036 print
'<tr><td class="fieldname_type">';
3037 print
'<table class="nobordernopadding centpercent"><tr><td>';
3038 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3040 if ($action !=
'editposinfo' && $usercancreate) {
3041 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>';
3043 print
'</tr></table>';
3044 print
'</td><td class="valuefield fieldname_type">';
3045 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" name="formposinfo">';
3046 print
'<input type="hidden" name="action" value="setposinfo">';
3047 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3048 if ($action ==
'editposinfo') {
3049 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="' . $langs->trans(
"POSModule") .
'" value="' .
$object->module_source .
'"> ';
3050 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="' . $langs->trans(
"Terminal") .
'" value="' .
$object->pos_source .
'">';
3051 print
'<input type="submit" class="button" name="submitposinfo" value="' . $langs->trans(
"Submit") .
'">';
3054 print
'<span class="opacitymediumbycolor paddingleft">' .
dolPrintHTML(ucfirst(
$object->module_source) .
' - ' . $langs->transnoentitiesnoconv(
"Terminal") .
' ' .
$object->pos_source) .
'</span>';
3061 if ($soc->outstanding_limit) {
3063 print
'<tr><td class="titlefield">';
3064 print $langs->trans(
'OutstandingBill');
3065 print
'</td><td class="valuefield">';
3066 $arrayoutstandingbills = $soc->getOutstandingBills();
3067 print
price($arrayoutstandingbills[
'opened']) .
' / ';
3068 print
price($soc->outstanding_limit, 0,
'', 1, -1, -1,
$conf->currency);
3075 $filterabsolutediscount =
"fk_facture_source IS NULL";
3076 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3078 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3079 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3082 $addrelativediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remise.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditRelativeDiscounts") .
'</a>';
3083 $addabsolutediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remx.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditGlobalDiscounts") .
'</a>';
3084 $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>';
3086 print
'<tr><td class="titlefield">' . $langs->trans(
'Discounts') .
'</td><td class="valuefield">';
3088 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3089 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3090 $absolute_discount =
price2num($absolute_discount,
'MT');
3091 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3095 $backtopage = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id;
3096 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
3103 print $form->editfieldkey(
"Date",
'date',
'', $object, (
int) $editenable);
3104 print
'</td><td class="valuefield">';
3105 if ($action ==
'editdate') {
3106 print
'<form name="setdate" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3107 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3108 print
'<input type="hidden" name="action" value="setdate">';
3109 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3110 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3111 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3116 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3124 $editenable = $usercancreate;
3125 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, (
int) $editenable);
3126 print
'</td><td class="valuefield">';
3127 if ($action ==
'editdate_livraison') {
3128 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3129 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3130 print
'<input type="hidden" name="action" value="setdate_livraison">';
3131 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3132 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3133 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3138 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3143 $shippableInfos =
$object->getShippableInfos();
3145 if (!empty($shippableInfos[
'has_product'])) {
3147 print $form->textwithtooltip(
'', $shippableInfos[
'textinfo'], 2, 1, $shippableInfos[
'texticon'],
'', 2);
3149 if (!empty($shippableInfos[
'warning'])) {
3151 print $form->textwithtooltip(
'', $langs->trans(
"NotEnoughForAllOrders"), 2, 1,
img_picto(
'',
'error',
'', 0, 0, 0,
'',
'2'),
'', 2);
3159 print
'<tr class="fielddeliverydelay"><td>';
3160 $editenable = $usercancreate;
3161 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, (
int) $editenable);
3162 print
'</td><td class="valuefield">';
3163 if ($action ==
'editavailability') {
3164 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3166 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'none', 1);
3173 $editenable = $usercancreate;
3174 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, (
int) $editenable);
3175 print
'</td><td class="valuefield">';
3176 if ($action ==
'editshippingmethod') {
3177 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3179 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'none');
3187 $langs->load(
'stocks');
3189 $editenable = $usercancreate;
3190 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, (
int) $editenable);
3191 print
'</td><td class="valuefield">';
3192 if ($action ==
'editwarehouse') {
3193 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3195 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'none');
3203 $editenable = $usercancreate;
3204 print $form->editfieldkey(
"Source",
'demandreason',
'', $object, (
int) $editenable);
3205 print
'</td><td class="valuefield">';
3206 if ($action ==
'editdemandreason') {
3207 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3209 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'none');
3215 $editenable = $usercancreate;
3216 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, (
int) $editenable);
3217 print
'</td><td class="valuefield">';
3218 if ($action ==
'editconditions') {
3219 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3221 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3229 $editenable = $usercancreate;
3230 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, (
int) $editenable);
3231 print
'</td><td class="valuefield">';
3232 if ($action ==
'editmode') {
3233 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3235 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
3253 $tmparray =
$object->getTotalWeightVolume();
3254 $totalWeight = $tmparray[
'weight'];
3255 $totalVolume = $tmparray[
'volume'];
3257 print
'<tr><td>' . $langs->trans(
"CalculatedWeight") .
'</td>';
3258 print
'<td class="valuefield">';
3263 print
'<tr><td>' . $langs->trans(
"CalculatedVolume") .
'</td>';
3264 print
'<td class="valuefield">';
3274 $editenable = $usercancreate;
3275 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, (
int) $editenable);
3277 print
'<td class="valuefield">';
3278 if ($action !=
'editincoterm') {
3279 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3281 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3289 $editenable = $usercancreate;
3290 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, (
int) $editenable);
3291 print
'</td><td class="valuefield">';
3292 if ($action ==
'editbankaccount') {
3293 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3295 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
3304 print
'<table class="nobordernopadding centpercent"><tr><td>';
3305 print $langs->trans(
"Categories");
3306 print
'<td><td class="right">';
3307 if ($usercancreate) {
3308 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/commande/card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3312 print
'</td></tr></table>';
3315 if ($action ==
'edittags') {
3316 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
3317 print
'<input type="hidden" name="action" value="settags">';
3318 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3319 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
3320 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
3323 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3329 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3334 print
'<div class="fichehalfright">';
3335 print
'<div class="underbanner clearboth"></div>';
3337 print
'<table class="border tableforfield centpercent">';
3339 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_currency_amount.tpl.php';
3343 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3347 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3348 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3351 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3356 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3357 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3360 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3365 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3367 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
3368 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3372 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3378 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3380 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
3381 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3385 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3391 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3392 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3395 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3397 print
'</tr>' .
"\n";
3406 $formmargin->displayMarginInfos($object);
3413 print
'<div class="clearboth"></div><br>';
3416 $blocname =
'contacts';
3417 $title = $langs->trans(
'ContactsAddresses');
3418 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3422 $blocname =
'notes';
3423 $title = $langs->trans(
'Notes');
3424 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3432 $result =
$object->getLinesArray();
3436 global $inputalsopricewithtax;
3437 $inputalsopricewithtax = 1;
3439 print
'<form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="POST">
3440 <input type="hidden" name="token" value="' .
newToken() .
'">
3441 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
3442 <input type="hidden" name="mode" value="">
3443 <input type="hidden" name="page_y" value="">
3444 <input type="hidden" name="id" value="' .
$object->id .
'">
3445 <input type="hidden" name="backtopage" value="' . $backtopage .
'">
3450 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
3452 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3456 print
'<div class="div-table-responsive-no-min">';
3457 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3461 $object->printObjectLines($action,
$mysoc, $soc, $lineid, 1);
3468 if ($action !=
'editline') {
3471 $parameters = array();
3473 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3477 if (empty($reshook)) {
3481 $parameters = array();
3482 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3496 if ($action !=
'presend' && $action !=
'editline') {
3497 print
'<div class="tabsAction">';
3499 $parameters = array();
3500 $arrayforbutaction = array();
3502 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3503 if (empty($reshook)) {
3504 $numlines = count(
$object->lines);
3508 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=reopen&token=' .
newToken() .
'&id=' .
$object->id,
'');
3512 if (empty($user->socid)) {
3515 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3517 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3525 $langs->load(
'subtotals');
3527 $url_button = array();
3529 $url_button[] = array(
3530 'lang' =>
'subtotals',
3532 'perm' => (
bool) $usercancreate,
3533 'label' => $langs->trans(
'AddTitleLine'),
3534 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_title_line&token=' .
newToken()
3537 $url_button[] = array(
3538 'lang' =>
'subtotals',
3540 'perm' => (
bool) $usercancreate,
3541 'label' => $langs->trans(
'AddSubtotalLine'),
3542 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_subtotal_line&token=' .
newToken()
3544 print
dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
3549 if ($numlines > 0) {
3550 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id,
'action-validate', 1);
3552 $langs->load(
"errors");
3553 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id,
'action-validate', -1);
3558 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=modif&token=' .
newToken() .
'&id=' .
$object->id,
'action-modif');
3564 $arrayforbutaction[] = array(
3567 'perm' => $usercancreatepurchaseorder,
3568 'label' =>
'AddPurchaseOrder',
3569 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3581 $arrayforbutaction[] = array(
3582 'lang' =>
'interventions',
3584 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3585 'label' =>
'AddIntervention',
3586 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3592 $arrayforbutaction[] = [
3593 'lang' =>
'contracts',
3595 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3596 'label' =>
'AddContract',
3597 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3612 $numshipping =
$object->countNbOfShipments();
3615 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3617 $arrayforbutaction[] = array(
3618 'lang' =>
'sendings',
3620 'perm' => $user->hasRight(
'expedition',
'creer'),
3621 'label' =>
'CreateShipment',
3622 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3627 $arrayforbutaction[] = array(
3628 'lang' =>
'sendings',
3631 'label' =>
'CreateShipment',
3632 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3639 $arrayforbutaction[] = array(
3642 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3643 'label' =>
'CreateBill',
3644 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3653 $actionButtonsParameters = [
3654 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3657 if ($numlines > 0) {
3658 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3660 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3665 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=shipped&token=' .
newToken() .
'&id=' .
$object->id,
'');
3672 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3677 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"] .
'?action=classifyunbilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3682 if ($usercancreate) {
3688 print
'<a class="butActionDelete" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=cancel&token=' .
newToken() .
'">' . $langs->trans(
"CancelOrder") .
'</a>';
3692 if ($usercandelete) {
3693 if ($numshipping == 0) {
3696 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3704 if (
GETPOST(
'modelselected')) {
3705 $action =
'presend';
3708 if ($action !=
'presend') {
3709 print
'<div class="fichecenter"><div class="fichehalfleft">';
3710 print
'<a name="builddoc"></a>';
3713 $relativepath = $objref .
'/' . $objref .
'.pdf';
3714 $filedir =
$conf->commande->multidir_output[
$object->entity ??
$conf->entity] .
'/' . $objref;
3716 $genallowed = $usercanread;
3717 $delallowed = $usercancreate;
3718 $tooltipAfterComboOfModels =
'';
3720 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_ORDER_TERMSOFSALE'));
3723 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);
3727 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'order'), 1);
3728 $linktoelem = $tmparray[
'linktoelem'];
3729 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3730 print $htmltoenteralink;
3732 $compatibleImportElementsList =
false;
3737 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3739 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3743 include_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3744 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3745 $useonlinepayment = count($validpaymentmethod);
3748 $useonlinepayment = 0;
3751 print
'<br><!-- Link to pay -->';
3752 require_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3753 print showOnlinePaymentUrl(
'order',
$object->ref) .
'<br>';
3756 print
'</div><div class="fichehalfright">';
3761 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/messaging.php', [
'id' =>
$object->id]));
3762 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/agenda.php', [
'id' =>
$object->id]));
3765 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3767 $somethingshown = $formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3769 print
'</div></div>';
3773 $modelmail =
'order_send';
3774 $defaulttopic =
'SendOrderRef';
3776 $trackid =
'ord' .
$object->id;
3778 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, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.