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];
1146 $price_base_type =
$prod->multiprices_base_type[
$object->thirdparty->price_level];
1148 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1149 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1151 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1152 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1157 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1158 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1159 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1160 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1161 $price_base_type =
$prod->multiprices_base_type[
$object->thirdparty->price_level];
1163 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1164 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1166 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1167 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1172 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1176 $filter = array(
't.fk_product' => (
string)
$prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1178 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1181 if (count($prodcustprice->lines) > 0) {
1182 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1183 foreach ($prodcustprice->lines as $k => $custprice_line) {
1184 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1185 $pu_ht =
price($custprice_line->price);
1186 $pu_ttc =
price($custprice_line->price_ttc);
1187 $price_min =
price($custprice_line->price_min);
1188 $price_min_ttc =
price($custprice_line->price_min_ttc);
1189 $price_base_type = $custprice_line->price_base_type;
1207 if (
$prod->prices_by_qty[0]) {
1212 foreach (
$prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1213 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1217 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1218 $pu_ht = $priceforthequantityarray[
'unitprice'];
1220 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1228 if (!empty(
$object->thirdparty->price_level)) {
1230 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1231 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1232 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1233 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1234 $price_base_type = (empty(
$prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' :
$prod->multiprices_base_type[
$object->thirdparty->price_level]);
1236 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1237 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1239 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1240 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1244 if (!empty(
$object->thirdparty->price_level) && !empty(
$prod->prices_by_qty[
$object->thirdparty->price_level])) {
1248 foreach (
$prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1249 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1253 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1254 $pu_ht = $priceforthequantityarray[
'unitprice'];
1256 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1264 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1265 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string)
$prod->tva_tx));
1268 if (!empty($price_ht) || (
string) $price_ht ===
'0') {
1269 $pu_ht = (float)
price2num($price_ht,
'MU');
1270 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1271 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1272 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1273 $pu_ttc_devise = (float)
price2num((
float) $pu_ht_devise * (1 + ((float) $tmpvat / 100)),
'MU');
1276 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1277 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1278 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1279 } elseif (!empty($price_ttc_devise) || (
string) $price_ttc_devise ===
'0') {
1280 $pu_ttc_devise = (float)
price2num($price_ttc_devise,
'MU');
1281 $pu_ht_devise = (float)
price2num((
float) $pu_ttc_devise / (1 + ((float) $tmpvat / 100)),
'MU');
1284 } elseif ($tmpvat != $tmpprodvat) {
1286 if ($price_base_type !=
'HT') {
1287 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1289 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1297 $outputlangs = $langs;
1299 if (
GETPOST(
'lang_id',
'aZ09')) {
1300 $newlang =
GETPOST(
'lang_id',
'aZ09');
1302 if (empty($newlang)) {
1303 $newlang =
$object->thirdparty->default_lang;
1305 if (!empty($newlang)) {
1307 $outputlangs->setDefaultLang($newlang);
1310 $desc = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1312 $desc =
$prod->description;
1328 $outputlangs = $langs;
1330 if (
GETPOST(
'lang_id',
'alpha')) {
1331 $newlang =
GETPOST(
'lang_id',
'alpha');
1333 if (empty($newlang)) {
1334 $newlang =
$object->thirdparty->default_lang;
1336 if (!empty($newlang)) {
1338 $outputlangs->setDefaultLang($newlang);
1339 $outputlangs->load(
'products');
1341 if (!empty(
$prod->customcode)) {
1342 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1344 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1347 if (!empty(
$prod->country_code)) {
1348 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'',
$db, $outputlangs, 0);
1351 if (!empty(
$prod->customcode)) {
1352 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1354 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1357 if (!empty(
$prod->country_code)) {
1358 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'',
$db, $langs, 0);
1365 $type =
$prod->type;
1366 $fk_unit =
$prod->fk_unit;
1370 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1371 $tva_tx = str_replace(
'*',
'', $tva_tx);
1372 if (empty($tva_tx)) {
1375 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1378 $fk_unit =
GETPOST(
'units',
'alpha');
1379 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1380 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1382 if ($pu_ttc && !$pu_ht) {
1383 $price_base_type =
'TTC';
1397 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1398 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1401 $pu_equivalent = $pu_ht;
1402 $pu_equivalent_ttc = $pu_ttc;
1404 $currency_tx =
$object->multicurrency_tx;
1408 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1409 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1411 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1412 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1432 if ($usermustrespectpricemin) {
1433 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1434 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1437 } 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') {
1438 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1446 $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);
1458 $outputlangs = $langs;
1459 $newlang =
GETPOST(
'lang_id',
'alpha');
1461 $newlang =
$object->thirdparty->default_lang;
1463 if (!empty($newlang)) {
1465 $outputlangs->setDefaultLang($newlang);
1468 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1471 unset($_POST[
'prod_entry_mode']);
1473 unset($_POST[
'qty']);
1474 unset($_POST[
'type']);
1475 unset($_POST[
'remise_percent']);
1476 unset($_POST[
'price_ht']);
1477 unset($_POST[
'multicurrency_price_ht']);
1478 unset($_POST[
'price_ttc']);
1479 unset($_POST[
'tva_tx']);
1480 unset($_POST[
'product_ref']);
1481 unset($_POST[
'product_label']);
1482 unset($_POST[
'product_desc']);
1483 unset($_POST[
'fournprice']);
1484 unset($_POST[
'buying_price']);
1485 unset($_POST[
'np_marginRate']);
1486 unset($_POST[
'np_markRate']);
1487 unset($_POST[
'dp_desc']);
1488 unset($_POST[
'idprod']);
1489 unset($_POST[
'units']);
1491 unset($_POST[
'date_starthour']);
1492 unset($_POST[
'date_startmin']);
1493 unset($_POST[
'date_startsec']);
1494 unset($_POST[
'date_startday']);
1495 unset($_POST[
'date_startmonth']);
1496 unset($_POST[
'date_startyear']);
1497 unset($_POST[
'date_endhour']);
1498 unset($_POST[
'date_endmin']);
1499 unset($_POST[
'date_endsec']);
1500 unset($_POST[
'date_endday']);
1501 unset($_POST[
'date_endmonth']);
1502 unset($_POST[
'date_endyear']);
1510 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1513 $langs->load(
'subtotals');
1515 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1518 $subtotal_options = array();
1520 foreach (Commande::$TITLE_OPTIONS as $option) {
1521 $value =
GETPOST($option,
'alphanohtml');
1523 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1528 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1539 $outputlangs = $langs;
1540 $newlang =
GETPOST(
'lang_id',
'alpha');
1542 $newlang =
$object->thirdparty->default_lang;
1544 if (!empty($newlang)) {
1546 $outputlangs->setDefaultLang($newlang);
1549 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1554 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1557 $langs->load(
'subtotals');
1559 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1562 $subtotal_options = array();
1564 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1565 $value =
GETPOST($option,
'alphanohtml');
1567 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1572 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1580 $outputlangs = $langs;
1581 $newlang =
GETPOST(
'lang_id',
'alpha');
1583 $newlang =
$object->thirdparty->default_lang;
1585 if (!empty($newlang)) {
1587 $outputlangs->setDefaultLang($newlang);
1590 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1595 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1608 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1613 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1614 $vat_rate = str_replace(
'*',
'', $vat_rate);
1626 $pu_equivalent = $pu_ht;
1627 $pu_equivalent_ttc = $pu_ttc;
1629 $currency_tx =
$object->multicurrency_tx;
1633 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1634 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1636 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1637 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1652 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1656 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1657 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1659 if (is_array($extralabelsline)) {
1660 foreach ($extralabelsline as $key => $value) {
1661 unset($_POST[
"options_" . $key]);
1674 $price_base_type =
'HT';
1675 if (empty($pu) && !empty($pu_ttc)) {
1677 $price_base_type =
'TTC';
1682 if (!empty($productid)) {
1684 $product->fetch($productid);
1686 $type = $product->type;
1688 $price_min = $product->price_min;
1690 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1692 $price_min_ttc = $product->price_min_ttc;
1694 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1700 if ($usermustrespectpricemin) {
1701 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1702 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1705 $action =
'editline';
1706 } 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') {
1707 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1710 $action =
'editline';
1715 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1719 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1721 $action =
'editline';
1726 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1728 $action =
'editline';
1733 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1734 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1736 $action =
'editline';
1743 if (!$user->hasRight(
'margins',
'creer')) {
1744 foreach (
$object->lines as &$line) {
1746 $fournprice = $line->fk_fournprice;
1747 $buyingprice = $line->pa_ht;
1753 $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);
1761 $outputlangs = $langs;
1764 $newlang =
GETPOST(
'lang_id',
'aZ09');
1767 $newlang =
$object->thirdparty->default_lang;
1769 if (!empty($newlang)) {
1771 $outputlangs->setDefaultLang($newlang);
1775 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1778 unset($_POST[
'qty']);
1779 unset($_POST[
'type']);
1780 unset($_POST[
'productid']);
1781 unset($_POST[
'remise_percent']);
1782 unset($_POST[
'price_ht']);
1783 unset($_POST[
'multicurrency_price_ht']);
1784 unset($_POST[
'price_ttc']);
1785 unset($_POST[
'tva_tx']);
1786 unset($_POST[
'product_ref']);
1787 unset($_POST[
'product_label']);
1788 unset($_POST[
'product_desc']);
1789 unset($_POST[
'fournprice']);
1790 unset($_POST[
'buying_price']);
1792 unset($_POST[
'date_starthour']);
1793 unset($_POST[
'date_startmin']);
1794 unset($_POST[
'date_startsec']);
1795 unset($_POST[
'date_startday']);
1796 unset($_POST[
'date_startmonth']);
1797 unset($_POST[
'date_startyear']);
1798 unset($_POST[
'date_endhour']);
1799 unset($_POST[
'date_endmin']);
1800 unset($_POST[
'date_endsec']);
1801 unset($_POST[
'date_endday']);
1802 unset($_POST[
'date_endmonth']);
1803 unset($_POST[
'date_endyear']);
1810 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1811 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1813 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1816 $qualified_for_stock_change = 0;
1818 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1820 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1825 if (!$idwarehouse || $idwarehouse == -1) {
1827 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1833 $locationTarget =
'';
1837 $result =
$object->valid($user, $idwarehouse);
1842 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1845 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1846 &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1848 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1851 $forceFields = array();
1861 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1873 $outputlangs = $langs;
1876 $newlang =
GETPOST(
'lang_id',
'aZ09');
1879 $newlang =
$object->thirdparty->default_lang;
1881 if (!empty($newlang)) {
1883 $outputlangs->setDefaultLang($newlang);
1888 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1891 $deposit->fetch($deposit->id);
1892 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1896 if ($locationTarget) {
1897 header(
'Location: ' . $locationTarget);
1908 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1910 $idwarehouse =
GETPOST(
'idwarehouse');
1912 $qualified_for_stock_change = 0;
1914 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1916 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1921 if (!$idwarehouse || $idwarehouse == -1) {
1923 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1929 $result =
$object->setDraft($user, $idwarehouse);
1933 $outputlangs = $langs;
1936 $newlang =
GETPOST(
'lang_id',
'aZ09');
1939 $newlang =
$object->thirdparty->default_lang;
1941 if (!empty($newlang)) {
1943 $outputlangs->setDefaultLang($newlang);
1948 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1954 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1955 $result =
$object->cloture($user);
1959 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1962 $qualified_for_stock_change = 0;
1964 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1966 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1971 if (!$idwarehouse || $idwarehouse == -1) {
1973 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1979 $result =
$object->cancel($user, $idwarehouse);
1987 if ($action ==
'update_extras' && $permissiontoeditextra) {
1990 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1993 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2000 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
2008 $action =
'edit_extras';
2014 $fromElement =
GETPOST(
'fromelement');
2015 $fromElementid =
GETPOST(
'fromelementid');
2016 $importLines =
GETPOST(
'line_checkbox');
2018 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && preg_match(
'/^[a-zA-Z]+$/', $fromElement) && !empty($fromElementid)) {
2019 if ($fromElement ==
'commande') {
2020 dol_include_once(
'/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2021 $lineClassName =
'OrderLine';
2022 } elseif ($fromElement ==
'propal') {
2023 dol_include_once(
'/comm/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2024 $lineClassName =
'PropaleLigne';
2025 } elseif ($fromElement ==
'facture') {
2026 dol_include_once(
'/compta/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2027 $lineClassName =
'FactureLigne';
2029 $nextRang = count(
$object->lines) + 1;
2032 foreach ($importLines as $lineId) {
2033 $lineId = intval($lineId);
2034 $originLine =
new $lineClassName(
$db);
2035 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2036 $originLine->fetch_optionals();
2037 $desc = $originLine->desc;
2038 $pu_ht = $originLine->subprice;
2039 $qty = $originLine->qty;
2040 $txtva = $originLine->tva_tx;
2041 $txlocaltax1 = $originLine->localtax1_tx;
2042 $txlocaltax2 = $originLine->localtax2_tx;
2043 $fk_product = $originLine->fk_product;
2044 $remise_percent = $originLine->remise_percent;
2046 $date_end = $originLine->date_end;
2047 $fk_code_ventilation = 0;
2048 $info_bits = $originLine->info_bits;
2049 $fk_remise_except = $originLine->fk_remise_except;
2050 $price_base_type =
'HT';
2052 $type = $originLine->product_type;
2053 $rang = $nextRang++;
2054 $special_code = $originLine->special_code;
2055 $origin = $originLine->element;
2056 $origin_id = $originLine->id;
2057 $fk_parent_line = 0;
2058 $fk_fournprice = $originLine->fk_fournprice;
2059 $pa_ht = $originLine->pa_ht;
2060 $label = $originLine->label;
2061 $array_options = $originLine->array_options;
2062 $situation_percent = 100;
2064 $fk_unit = $originLine->fk_unit;
2065 $pu_ht_devise = $originLine->multicurrency_subprice;
2067 $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);
2086 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
2090 $permissiontoadd = $usercancreate;
2091 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
2094 $triggersendname =
'ORDER_SENTBYMAIL';
2096 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2097 $trackid =
'ord' .
$object->id;
2098 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
2102 if ($action ==
'addcontact') {
2106 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2110 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2113 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2114 $langs->load(
"errors");
2115 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2120 } elseif ($action ==
'swapstatut') {
2127 } elseif ($action ==
'deletecontact') {
2129 $result =
$object->delete_contact($lineid);
2132 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2146$title =
$object->ref .
" - " . $langs->trans(
'Card');
2147if ($action ==
'create') {
2148 $title = $langs->trans(
"NewOrder");
2150$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2152llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2164if ($action ==
'create' && $usercancreate) {
2169 $res = $soc->fetch($socid);
2172 $currency_code =
$conf->currency;
2174 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2175 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2176 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2179 if (!empty($origin) && !empty($originid)) {
2181 $element = $subelement = $origin;
2183 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2184 $element = $regs[1];
2185 $subelement = $regs[2];
2188 if ($element ==
'project') {
2189 $projectid = $originid;
2191 if (!$cond_reglement_id) {
2192 $cond_reglement_id = $soc->cond_reglement_id;
2194 if (!$deposit_percent) {
2195 $deposit_percent = $soc->deposit_percent;
2197 if (!$mode_reglement_id) {
2198 $mode_reglement_id = $soc->mode_reglement_id;
2200 if (!$remise_percent) {
2201 $remise_percent = $soc->remise_percent;
2205 if ($element ==
'order' || $element ==
'commande') {
2206 $element = $subelement =
'commande';
2207 } elseif ($element ==
'propal') {
2208 $element =
'comm/propal';
2209 $subelement =
'propal';
2210 } elseif ($element ==
'contract') {
2211 $element = $subelement =
'contrat';
2216 $classname = ucfirst($subelement);
2217 $objectsrc =
new $classname(
$db);
2218 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2219 $objectsrc->fetch($originid);
2220 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2221 $objectsrc->fetch_lines();
2223 $objectsrc->fetch_thirdparty();
2226 $objectsrc->fetch_optionals();
2227 $object->array_options = $objectsrc->array_options;
2229 $projectid = (int) $objectsrc->fk_project;
2230 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2232 $soc = $objectsrc->thirdparty;
2233 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2234 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2235 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2236 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2237 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2238 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2239 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2240 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2243 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2246 if (!empty($objectsrc->multicurrency_code)) {
2247 $currency_code = $objectsrc->multicurrency_code;
2249 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2250 $currency_tx = $objectsrc->multicurrency_tx;
2254 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2255 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2258 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2261 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2262 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2263 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2264 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2265 $availability_id = 0;
2266 $shipping_method_id = empty($soc->shipping_method_id) ? $shipping_method_id : $soc->shipping_method_id;
2267 $warehouse_id = $soc->fk_warehouse;
2268 $demand_reason_id = $soc->demand_reason_id;
2271 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2272 $currency_code = $soc->multicurrency_code;
2275 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2276 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2280 if (!
GETPOST(
'changecompany')) {
2282 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2288 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2296 if ($soc->fk_warehouse > 0) {
2297 $warehouse_id = $soc->fk_warehouse;
2304 $warehouse_id = $user->fk_warehouse;
2308 print
'<form name="crea_commande" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2309 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2310 print
'<input type="hidden" name="action" value="add">';
2311 print
'<input type="hidden" name="changecompany" value="0">';
2312 print
'<input type="hidden" name="remise_percent" value="' . $soc->remise_percent .
'">';
2313 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
2314 print
'<input type="hidden" name="originid" value="' . $originid .
'">';
2315 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
2316 if (!empty($currency_tx)) {
2317 print
'<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx .
'">';
2323 $parameters = array();
2325 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters, $object, $action);
2326 if (empty($reshook)) {
2327 print
'<table class="border centpercent">';
2334 print
'<td class="fieldrequired">' . $langs->trans(
'Customer') .
'</td>';
2337 print $soc->getNomUrl(1,
'customer');
2338 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
2341 print
'<td class="valuefieldcreate">';
2342 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2343 print
img_picto(
'',
'company',
'class="pictofixedwidth"') . $form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2347 $(document).ready(function() {
2348 $("#socid").change(function() {
2349 console.log("We have changed the company - Reload page");
2350 var socid = $(this).val();
2352 $("input[name=action]").val("create");
2353 $("input[name=changecompany]").val("1");
2354 $("form[name=crea_commande]").submit();
2359 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>';
2362 print
'</tr>' .
"\n";
2367 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2368 print $langs->trans(
'RefProposal') .
'</td><td>';
2369 print
'<input type="text" name="ref_client" value="' . $ref_client .
'">';
2371 print $form->textwithpicto($langs->trans(
'RefCustomer'), $langs->trans(
'RefOfOnCustomerSide', $langs->transnoentitiesnoconv(
"Order"))) .
'</td><td>';
2372 print
'<input type="text" name="ref_client" value="' .
GETPOST(
'ref_client') .
'">';
2382 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_" . $type_contact_code));
2384 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2386 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2390 print
'<tr><td>' . $langs->trans(
'Discounts') .
'</td><td>';
2392 $absolute_discount = $soc->getAvailableDiscounts();
2396 $backtopage = $_SERVER[
"PHP_SELF"] .
'?socid=' . $thirdparty->id .
'&action=' . $action .
'&origin=' . urlencode((
string) (
GETPOST(
'origin'))) .
'&originid=' . urlencode((
string) (
GETPOSTINT(
'originid')));
2397 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
2405 print
'<tr><td class="fieldrequired">' . $langs->trans(
'Date') .
'</td><td>';
2406 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2407 print $form->selectDate($dateorder,
're', 0, 0, 0,
"crea_commande", 1, 1);
2411 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
2412 print
'<td colspan="3">';
2413 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2414 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2415 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2420 print
'<tr class="fielddeliverydelay"><td>' . $langs->trans(
'AvailabilityPeriod') .
'</td><td>';
2421 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2422 $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2426 print
'<tr><td class="nowrap">' . $langs->trans(
'PaymentConditionsShort') .
'</td><td>';
2427 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2428 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2432 print
'<tr><td>' . $langs->trans(
'PaymentMode') .
'</td><td>';
2433 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2434 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2439 print
'<tr><td>' . $langs->trans(
'BankAccount') .
'</td><td>';
2440 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"') . $form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2446 print
'<tr><td>' . $langs->trans(
'SendingMethod') .
'</td><td>';
2447 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2448 $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');
2454 print
'<tr><td>' . $langs->trans(
'Warehouse') .
'</td><td>';
2455 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');
2460 print
'<tr><td>' . $langs->trans(
'Source') .
'</td><td>';
2461 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2462 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2469 $langs->load(
"projects");
2471 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2472 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');
2473 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>';
2481 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>';
2482 print
'<td class="maxwidthonsmartphone">';
2483 $incoterm_id =
GETPOST(
'incoterm_id');
2484 $location_incoterms =
GETPOST(
'location_incoterms');
2485 if (empty($incoterm_id)) {
2486 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2487 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2489 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2490 print $form->select_incoterms($incoterm_id, $location_incoterms);
2495 $parameters = array();
2496 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2497 $parameters[
'objectsrc'] = $objectsrc;
2499 $parameters[
'socid'] = $socid;
2502 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2503 print $hookmanager->resPrint;
2504 if (empty($reshook)) {
2505 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2508 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2509 if ($soc->fetch_optionals() > 0) {
2510 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2514 print
$object->showOptionals($extrafields,
'create', $parameters);
2518 include_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
2520 if (is_array($list) && count($list) > 0) {
2521 print
'<tr><td>' . $langs->trans(
'DefaultModel') .
'</td>';
2524 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2525 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2532 print
'<td>' . $form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0) .
'</td>';
2533 print
'<td class="maxwidthonsmartphone">';
2534 print
img_picto(
'',
'currency',
'class="pictofixedwidth"') . $form->selectMultiCurrency(((
GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2540 print
'<tr><td>' . $langs->trans(
"Categories") .
'</td><td colspan="3">';
2541 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
2547 print
'<td class="tdtop">' . $langs->trans(
'NotePublic') .
'</td>';
2550 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2551 print $doleditor->Create(1);
2556 if (empty($user->socid)) {
2558 print
'<td class="tdtop">' . $langs->trans(
'NotePrivate') .
'</td>';
2561 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2562 print $doleditor->Create(1);
2567 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($classname)) {
2569 if ($origin ==
'contrat') {
2571 $objectsrc->update_price(1);
2574 print
"\n<!-- " . $classname .
" info -->\n";
2575 print
'<input type="hidden" name="amount" value="' . $objectsrc->total_ht .
'">' .
"\n";
2576 print
'<input type="hidden" name="total" value="' . $objectsrc->total_ttc .
'">' .
"\n";
2577 print
'<input type="hidden" name="tva" value="' . $objectsrc->total_tva .
'">' .
"\n";
2578 print
'<input type="hidden" name="origin" value="' . $objectsrc->element .
'">';
2579 print
'<input type="hidden" name="originid" value="' . $objectsrc->id .
'">';
2581 switch ($classname) {
2583 $newclassname =
'CommercialProposal';
2586 $newclassname =
'Order';
2589 $newclassname =
'Sending';
2592 $newclassname =
'Contract';
2595 $newclassname = $classname;
2598 print
'<tr><td>' . $langs->trans($newclassname) .
'</td><td>' . $objectsrc->getNomUrl(1) .
'</td></tr>';
2601 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td><td>' .
price($objectsrc->total_ht) .
'</td></tr>';
2602 print
'<tr><td>' . $langs->trans(
'AmountVAT') .
'</td><td>' .
price($objectsrc->total_tva) .
"</td></tr>";
2603 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2604 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax1) .
"</td></tr>";
2607 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2608 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax2) .
"</td></tr>";
2611 print
'<tr><td>' . $langs->trans(
'AmountTTC') .
'</td><td>' .
price($objectsrc->total_ttc) .
"</td></tr>";
2614 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
2615 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2616 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2627 print $form->buttonsSaveCancel(
"CreateDraft");
2630 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2631 $title = $langs->trans(
'ProductsAndServices');
2634 print
'<div class="div-table-responsive-no-min">';
2635 print
'<table class="noborder centpercent">';
2637 $objectsrc->printOriginLinesList(
'', $selectedLines);
2655 $author->fetch(
$object->user_author_id);
2658 $res =
$object->fetch_optionals();
2661 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2666 if ($action ==
'delete') {
2667 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2671 if ($action ==
'validate') {
2673 $ref = substr(
$object->ref, 1, 4);
2674 if ($ref ==
'PROV' || $ref ==
'') {
2675 $numref =
$object->getNextNumRef($soc);
2676 if (empty($numref)) {
2684 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2686 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2689 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid, $object);
2692 $qualified_for_stock_change = 0;
2694 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2696 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2699 $formquestion = array();
2701 $langs->load(
"stocks");
2703 if (
$conf->browser->name ==
'ie') {
2706 $formquestion = array(
2710 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2716 foreach (
$object->lines as $line) {
2717 $res = $line->fetch_product();
2719 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2725 if ($nbMandated > 0) {
2727 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2730 $text .=
'<div><span class="clearboth nowraponall warning">' .
img_warning() . $langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate") .
'</span></div>';
2734 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2739 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2741 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2742 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2746 $eligibleForDepositGeneration =
true;
2748 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2749 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2750 '@phan-var-force Facture $invoice';
2752 $eligibleForDepositGeneration =
false;
2758 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2759 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2760 $proposal->fetchObjectLinked();
2762 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2763 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2764 '@phan-var-force Facture $invoice';
2766 $eligibleForDepositGeneration =
false;
2774 if ($eligibleForDepositGeneration) {
2775 $formquestion[] = array(
2776 'type' =>
'checkbox',
2778 'name' =>
'generate_deposit',
2779 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2782 $formquestion[] = array(
2784 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2786 'label' => $langs->trans(
'DateInvoice'),
2792 $formquestion[] = array(
2794 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2795 'name' =>
'date_pointoftax',
2796 'label' => $langs->trans(
'DatePointOfTax'),
2802 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2804 $formquestion[] = array(
2806 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2807 'name' =>
'cond_reglement_id',
2808 'label' => $langs->trans(
'PaymentTerm'),
2809 'value' => $paymentTermsSelect
2812 $formquestion[] = array(
2813 'type' =>
'checkbox',
2814 'tdclass' =>
'showonlyifgeneratedeposit',
2815 'name' =>
'validate_generated_deposit',
2816 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2819 $formquestion[] = array(
2820 'type' =>
'onecolumn',
2823 $(document).ready(function() {
2824 $("[name=generate_deposit]").change(function () {
2825 let $self = $(this);
2826 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2828 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2845 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2850 if ($action ==
'modif') {
2851 $qualified_for_stock_change = 0;
2853 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2855 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2858 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2859 $formquestion = array();
2861 $langs->load(
"stocks");
2863 if (
$conf->browser->name ==
'ie') {
2872 'name' =>
'idwarehouse',
2873 'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
2874 'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo)
2879 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2883 if ($action ==
'shipped') {
2884 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2888 if ($action ==
'cancel') {
2889 $qualified_for_stock_change = 0;
2891 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2893 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2896 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2897 $formquestion = array();
2899 $langs->load(
"stocks");
2901 if (
$conf->browser->name ==
'ie') {
2904 $formquestion = array(
2908 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2912 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2916 if ($action ==
'ask_deleteline') {
2917 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2921 if ($action ==
'ask_subtotal_deleteline') {
2922 $langs->load(
"subtotals");
2923 $title =
"DeleteSubtotalLine";
2924 $question =
"ConfirmDeleteSubtotalLine";
2925 if (
GETPOST(
'type') ==
'title') {
2926 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2927 $title =
"DeleteTitleLine";
2928 $question =
"ConfirmDeleteTitleLine";
2930 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2934 if ($action ==
'clone') {
2935 $filter =
'(s.client:IN:1,2,3)';
2937 $formquestion = array(
2938 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2940 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2944 if ($action ==
'add_title_line') {
2945 $langs->load(
'subtotals');
2947 $depth_array =
$object->getPossibleLevels($langs);
2948 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2949 } elseif ($action ==
'add_subtotal_line') {
2950 $langs->load(
'subtotals');
2952 $titles =
$object->getPossibleTitles();
2953 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2957 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2959 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2960 if (empty($reshook)) {
2961 $formconfirm .= $hookmanager->resPrint;
2962 } elseif ($reshook > 0) {
2963 $formconfirm = $hookmanager->resPrint;
2972 $linkback =
'<a href="' . DOL_URL_ROOT .
'/commande/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2974 $morehtmlref =
'<div class="refidno">';
2976 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client, $object, (
int) $usercancreate,
'string',
'', 0, 1);
2977 $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);
2979 $morehtmlref .=
'<br>' . $soc->getNomUrl(1,
'customer');
2981 $morehtmlref .=
' (<a href="' . DOL_URL_ROOT .
'/commande/list.php?socid=' . ((int)
$object->thirdparty->id) .
'">' . $langs->trans(
"OtherOrders") .
'</a>)';
2985 $langs->load(
"projects");
2986 $morehtmlref .=
'<br>';
2987 if ($usercancreate) {
2988 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2989 if ($action !=
'classify') {
2990 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2992 $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');
2994 if (!empty(
$object->fk_project)) {
2996 $proj->fetch(
$object->fk_project);
2997 $morehtmlref .= $proj->getNomUrl(1);
2999 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
3004 $morehtmlref .=
'</div>';
3006 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3009 $parameters = array();
3011 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters, $object, $action);
3012 if (empty($reshook)) {
3013 print
'<div class="fichecenter">';
3014 print
'<div class="fichehalfleft">';
3015 print
'<div class="underbanner clearboth"></div>';
3017 print
'<table class="border tableforfield centpercent">';
3021 $langs->load(
"cashdesk");
3022 print
'<tr><td class="fieldname_type">';
3023 print
'<table class="nobordernopadding centpercent"><tr><td>';
3024 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3026 if ($action !=
'editposinfo' && $usercancreate) {
3027 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>';
3029 print
'</tr></table>';
3030 print
'</td><td class="valuefield fieldname_type">';
3031 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" name="formposinfo">';
3032 print
'<input type="hidden" name="action" value="setposinfo">';
3033 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3034 if ($action ==
'editposinfo') {
3035 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="' . $langs->trans(
"POSModule") .
'" value="' .
$object->module_source .
'"> ';
3036 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="' . $langs->trans(
"Terminal") .
'" value="' .
$object->pos_source .
'">';
3037 print
'<input type="submit" class="button" name="submitposinfo" value="' . $langs->trans(
"Submit") .
'">';
3040 print
'<span class="opacitymediumbycolor paddingleft">' .
dolPrintHTML(ucfirst(
$object->module_source) .
' - ' . $langs->transnoentitiesnoconv(
"Terminal") .
' ' .
$object->pos_source) .
'</span>';
3047 if ($soc->outstanding_limit) {
3049 print
'<tr><td class="titlefield">';
3050 print $langs->trans(
'OutstandingBill');
3051 print
'</td><td class="valuefield">';
3052 $arrayoutstandingbills = $soc->getOutstandingBills();
3053 print
price($arrayoutstandingbills[
'opened']) .
' / ';
3054 print
price($soc->outstanding_limit, 0,
'', 1, -1, -1,
$conf->currency);
3061 $filterabsolutediscount =
"fk_facture_source IS NULL";
3062 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3064 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3065 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3068 $addrelativediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remise.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditRelativeDiscounts") .
'</a>';
3069 $addabsolutediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remx.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditGlobalDiscounts") .
'</a>';
3070 $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>';
3072 print
'<tr><td class="titlefield">' . $langs->trans(
'Discounts') .
'</td><td class="valuefield">';
3074 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3075 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3076 $absolute_discount =
price2num($absolute_discount,
'MT');
3077 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3081 $backtopage = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id;
3082 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
3089 print $form->editfieldkey(
"Date",
'date',
'', $object, (
int) $editenable);
3090 print
'</td><td class="valuefield">';
3091 if ($action ==
'editdate') {
3092 print
'<form name="setdate" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3093 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3094 print
'<input type="hidden" name="action" value="setdate">';
3095 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3096 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3097 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3102 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3110 $editenable = $usercancreate;
3111 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, (
int) $editenable);
3112 print
'</td><td class="valuefield">';
3113 if ($action ==
'editdate_livraison') {
3114 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3115 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3116 print
'<input type="hidden" name="action" value="setdate_livraison">';
3117 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3118 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3119 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3124 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3129 $shippableInfos =
$object->getShippableInfos();
3131 if (!empty($shippableInfos[
'has_product'])) {
3133 print $form->textwithtooltip(
'', $shippableInfos[
'textinfo'], 2, 1, $shippableInfos[
'texticon'],
'', 2);
3135 if (!empty($shippableInfos[
'warning'])) {
3137 print $form->textwithtooltip(
'', $langs->trans(
"NotEnoughForAllOrders"), 2, 1,
img_picto(
'',
'error',
'', 0, 0, 0,
'',
'2'),
'', 2);
3145 print
'<tr class="fielddeliverydelay"><td>';
3146 $editenable = $usercancreate;
3147 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, (
int) $editenable);
3148 print
'</td><td class="valuefield">';
3149 if ($action ==
'editavailability') {
3150 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3152 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'none', 1);
3159 $editenable = $usercancreate;
3160 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, (
int) $editenable);
3161 print
'</td><td class="valuefield">';
3162 if ($action ==
'editshippingmethod') {
3163 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3165 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'none');
3173 $langs->load(
'stocks');
3175 $editenable = $usercancreate;
3176 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, (
int) $editenable);
3177 print
'</td><td class="valuefield">';
3178 if ($action ==
'editwarehouse') {
3179 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3181 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'none');
3189 $editenable = $usercancreate;
3190 print $form->editfieldkey(
"Source",
'demandreason',
'', $object, (
int) $editenable);
3191 print
'</td><td class="valuefield">';
3192 if ($action ==
'editdemandreason') {
3193 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3195 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'none');
3201 $editenable = $usercancreate;
3202 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, (
int) $editenable);
3203 print
'</td><td class="valuefield">';
3204 if ($action ==
'editconditions') {
3205 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3207 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3215 $editenable = $usercancreate;
3216 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, (
int) $editenable);
3217 print
'</td><td class="valuefield">';
3218 if ($action ==
'editmode') {
3219 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3221 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
3239 $tmparray =
$object->getTotalWeightVolume();
3240 $totalWeight = $tmparray[
'weight'];
3241 $totalVolume = $tmparray[
'volume'];
3243 print
'<tr><td>' . $langs->trans(
"CalculatedWeight") .
'</td>';
3244 print
'<td class="valuefield">';
3249 print
'<tr><td>' . $langs->trans(
"CalculatedVolume") .
'</td>';
3250 print
'<td class="valuefield">';
3260 $editenable = $usercancreate;
3261 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, (
int) $editenable);
3263 print
'<td class="valuefield">';
3264 if ($action !=
'editincoterm') {
3265 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3267 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3275 $editenable = $usercancreate;
3276 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, (
int) $editenable);
3277 print
'</td><td class="valuefield">';
3278 if ($action ==
'editbankaccount') {
3279 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3281 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
3290 print
'<table class="nobordernopadding centpercent"><tr><td>';
3291 print $langs->trans(
"Categories");
3292 print
'<td><td class="right">';
3293 if ($usercancreate) {
3294 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/commande/card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3298 print
'</td></tr></table>';
3301 if ($action ==
'edittags') {
3302 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
3303 print
'<input type="hidden" name="action" value="settags">';
3304 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3305 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
3306 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
3309 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3315 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3320 print
'<div class="fichehalfright">';
3321 print
'<div class="underbanner clearboth"></div>';
3323 print
'<table class="border tableforfield centpercent">';
3325 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_currency_amount.tpl.php';
3329 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3333 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3334 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3337 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3342 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3343 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3346 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3351 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3353 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
3354 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3358 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3364 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3366 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
3367 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3371 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3377 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3378 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3381 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3383 print
'</tr>' .
"\n";
3392 $formmargin->displayMarginInfos($object);
3399 print
'<div class="clearboth"></div><br>';
3402 $blocname =
'contacts';
3403 $title = $langs->trans(
'ContactsAddresses');
3404 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3408 $blocname =
'notes';
3409 $title = $langs->trans(
'Notes');
3410 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3418 $result =
$object->getLinesArray();
3422 global $inputalsopricewithtax;
3423 $inputalsopricewithtax = 1;
3425 print
'<form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="POST">
3426 <input type="hidden" name="token" value="' .
newToken() .
'">
3427 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
3428 <input type="hidden" name="mode" value="">
3429 <input type="hidden" name="page_y" value="">
3430 <input type="hidden" name="id" value="' .
$object->id .
'">
3431 <input type="hidden" name="backtopage" value="' . $backtopage .
'">
3436 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
3438 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3442 print
'<div class="div-table-responsive-no-min">';
3443 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3447 $object->printObjectLines($action,
$mysoc, $soc, $lineid, 1);
3454 if ($action !=
'editline') {
3457 $parameters = array();
3459 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3463 if (empty($reshook)) {
3467 $parameters = array();
3468 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3482 if ($action !=
'presend' && $action !=
'editline') {
3483 print
'<div class="tabsAction">';
3485 $parameters = array();
3486 $arrayforbutaction = array();
3488 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3489 if (empty($reshook)) {
3490 $numlines = count(
$object->lines);
3494 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=reopen&token=' .
newToken() .
'&id=' .
$object->id,
'');
3498 if (empty($user->socid)) {
3501 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3503 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3511 $langs->load(
'subtotals');
3513 $url_button = array();
3515 $url_button[] = array(
3516 'lang' =>
'subtotals',
3518 'perm' => (
bool) $usercancreate,
3519 'label' => $langs->trans(
'AddTitleLine'),
3520 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_title_line&token=' .
newToken()
3523 $url_button[] = array(
3524 'lang' =>
'subtotals',
3526 'perm' => (
bool) $usercancreate,
3527 'label' => $langs->trans(
'AddSubtotalLine'),
3528 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_subtotal_line&token=' .
newToken()
3530 print
dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
3535 if ($numlines > 0) {
3536 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id,
'action-validate', 1);
3538 $langs->load(
"errors");
3539 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id,
'action-validate', -1);
3544 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=modif&token=' .
newToken() .
'&id=' .
$object->id,
'action-modif');
3550 $arrayforbutaction[] = array(
3553 'perm' => $usercancreatepurchaseorder,
3554 'label' =>
'AddPurchaseOrder',
3555 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3567 $arrayforbutaction[] = array(
3568 'lang' =>
'interventions',
3570 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3571 'label' =>
'AddIntervention',
3572 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3578 $arrayforbutaction[] = [
3579 'lang' =>
'contracts',
3581 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3582 'label' =>
'AddContract',
3583 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3598 $numshipping =
$object->countNbOfShipments();
3601 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3603 $arrayforbutaction[] = array(
3604 'lang' =>
'sendings',
3606 'perm' => $user->hasRight(
'expedition',
'creer'),
3607 'label' =>
'CreateShipment',
3608 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3613 $arrayforbutaction[] = array(
3614 'lang' =>
'sendings',
3617 'label' =>
'CreateShipment',
3618 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3625 $arrayforbutaction[] = array(
3628 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3629 'label' =>
'CreateBill',
3630 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3639 $actionButtonsParameters = [
3640 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3643 if ($numlines > 0) {
3644 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3646 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3651 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=shipped&token=' .
newToken() .
'&id=' .
$object->id,
'');
3658 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3663 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"] .
'?action=classifyunbilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3668 if ($usercancreate) {
3674 print
'<a class="butActionDelete" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=cancel&token=' .
newToken() .
'">' . $langs->trans(
"CancelOrder") .
'</a>';
3678 if ($usercandelete) {
3679 if ($numshipping == 0) {
3682 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3690 if (
GETPOST(
'modelselected')) {
3691 $action =
'presend';
3694 if ($action !=
'presend') {
3695 print
'<div class="fichecenter"><div class="fichehalfleft">';
3696 print
'<a name="builddoc"></a>';
3699 $relativepath = $objref .
'/' . $objref .
'.pdf';
3700 $filedir =
$conf->commande->multidir_output[
$object->entity ??
$conf->entity] .
'/' . $objref;
3702 $genallowed = $usercanread;
3703 $delallowed = $usercancreate;
3704 $tooltipAfterComboOfModels =
'';
3706 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_ORDER_TERMSOFSALE'));
3709 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);
3713 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'order'), 1);
3714 $linktoelem = $tmparray[
'linktoelem'];
3715 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3716 print $htmltoenteralink;
3718 $compatibleImportElementsList =
false;
3723 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3725 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3729 include_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3730 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3731 $useonlinepayment = count($validpaymentmethod);
3734 $useonlinepayment = 0;
3737 print
'<br><!-- Link to pay -->';
3738 require_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3739 print showOnlinePaymentUrl(
'order',
$object->ref) .
'<br>';
3742 print
'</div><div class="fichehalfright">';
3747 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/messaging.php', [
'id' =>
$object->id]));
3748 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/agenda.php', [
'id' =>
$object->id]));
3751 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3753 $somethingshown = $formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3755 print
'</div></div>';
3759 $modelmail =
'order_send';
3760 $defaulttopic =
'SendOrderRef';
3762 $trackid =
'ord' .
$object->id;
3764 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.