42require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/extrafields.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
46require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formorder.class.php';
48require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmargin.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
50require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
51require_once DOL_DOCUMENT_ROOT .
'/core/lib/order.lib.php';
53require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
54require_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
57 require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
61 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
62 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
66 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductCombination.class.php';
80$langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'products',
'other'));
83 $langs->load(
'incoterm');
86 $langs->load(
'margins');
89 $langs->load(
'productbatch');
96$action =
GETPOST(
'action',
'aZ09');
97$cancel =
GETPOST(
'cancel',
'alpha');
98$confirm =
GETPOST(
'confirm',
'alpha');
99$backtopage =
GETPOST(
'backtopage',
'alpha');
104$origin =
GETPOST(
'origin',
'alpha');
117if (!empty($user->socid)) {
118 $socid = $user->socid;
123$price_base_type =
null;
124$lineClassName =
null;
125$remise_percent =
null;
127$availability_id =
null;
128$shipping_method_id =
null;
130$demand_reason_id =
null;
138$hookmanager->initHooks(array(
'ordercard',
'globalcard'));
147$extrafields->fetch_name_optionals_label(
$object->table_element);
150include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
153$usercanread = $user->hasRight(
"commande",
"lire");
154$usercancreate = $user->hasRight(
"commande",
"creer");
155$usercandelete = $user->hasRight(
"commande",
"supprimer");
158$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'close')));
159$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'validate')));
160$usercancancel = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'annuler')));
161$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'send'));
162$usercangeneratedoc = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
164$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
165$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
167$permissionnote = $usercancreate;
168$permissiondellink = $usercancreate;
169$permissiontoadd = $usercancreate;
170$permissiontoeditextra = $usercancreate;
171if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
173 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
180$selectedLines = array();
187$parameters = array(
'socid' => $socid);
189$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
194if (empty($reshook)) {
195 $backurlforlist = DOL_URL_ROOT .
'/commande/list.php';
197 if (empty($backtopage) || ($cancel && empty($id))) {
198 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
199 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
200 $backtopage = $backurlforlist;
202 $backtopage = DOL_URL_ROOT .
'/commande/card.php?id=' . ((!empty($id) &&
$id > 0) ? $id :
'__ID__');
207 $selectedLines =
GETPOST(
'toselect',
'array:int');
210 if (!empty($backtopageforcancel)) {
211 header(
"Location: " . $backtopageforcancel);
213 } elseif (!empty($backtopage)) {
214 header(
"Location: " . $backtopage);
220 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
222 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
224 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
227 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
229 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
235 $result = $objectutil->createFromClone($user, $socid);
237 $warningMsgLineList = array();
239 foreach (
$object->lines as $line) {
240 if (!is_object($line->product)) {
241 $line->fetch_product();
243 if (is_object($line->product) && $line->product->id > 0) {
244 if (empty($line->product->status)) {
245 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
249 if (!empty($warningMsgLineList)) {
253 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $result);
261 } elseif ($action ==
'reopen' && $usercancreate) {
266 $result =
$object->setDraft($user, $idwarehouse);
271 $result =
$object->set_reopen($user);
279 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
281 $result =
$object->delete($user);
283 header(
'Location: list.php?restore_lastsearch_values=1');
288 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
290 $result =
$object->deleteLine($user, $lineid);
295 $outputlangs = $langs;
298 $newlang =
GETPOST(
'lang_id',
'aZ09');
301 $newlang =
$object->thirdparty->default_lang;
303 if (!empty($newlang)) {
305 $outputlangs->setDefaultLang($newlang);
309 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
312 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
317 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
318 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
323 $outputlangs = $langs;
326 $newlang =
GETPOST(
'lang_id',
'aZ09');
329 $newlang =
$object->thirdparty->default_lang;
331 if (!empty($newlang)) {
333 $outputlangs->setDefaultLang($newlang);
337 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
340 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
345 } elseif ($action ==
'classin' && $usercancreate) {
348 } elseif ($action ==
'add' && $usercancreate) {
353 if ($datecommande ==
'') {
354 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
360 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
371 $object->date_commande = $datecommande;
384 $object->delivery_date = $date_delivery;
390 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
391 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
394 $ret = $extrafields->setOptionalsFromPost(
null, $object);
400 if (!empty($origin) && !empty($originid)) {
402 $element = $subelement = $origin;
404 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
406 $subelement = $regs[2];
410 if ($element ==
'order') {
411 $element = $subelement =
'commande';
413 if ($element ==
'propal') {
414 $element =
'comm/propal';
415 $subelement =
'propal';
417 if ($element ==
'contract') {
418 $element = $subelement =
'contrat';
422 $object->origin_type = $origin;
423 $object->origin_id = $originid;
427 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
428 if (!empty($other_linked_objects)) {
429 $object->linked_objects = array_merge(
$object->linked_objects, $other_linked_objects);
433 $object_id =
$object->create($user);
435 if ($object_id > 0) {
438 $classname = ucfirst($subelement);
439 $srcobject =
new $classname($db);
440 '@phan-var-force Commande|Propal|Contrat $srcobject';
443 dol_syslog(
"Try to find source object origin=" .
$object->origin .
" originid=" .
$object->origin_id .
" to add lines");
444 $result = $srcobject->fetch(
$object->origin_id);
446 $lines = $srcobject->lines;
447 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
448 $srcobject->fetch_lines();
449 $lines = $srcobject->lines;
453 $num = count($lines);
455 for ($i = 0; $i < $num; $i++) {
456 if (!in_array($lines[$i]->
id, $selectedLines)) {
460 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
461 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
462 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
466 $date_start = $lines[$i]->date_debut_prevue;
467 if ($lines[$i]->date_debut_reel) {
468 $date_start = $lines[$i]->date_debut_reel;
470 if ($lines[$i]->date_start) {
471 $date_start = $lines[$i]->date_start;
473 $date_end = $lines[$i]->date_fin_prevue;
474 if ($lines[$i]->date_fin_reel) {
475 $date_end = $lines[$i]->date_fin_reel;
477 if ($lines[$i]->date_end) {
478 $date_end = $lines[$i]->date_end;
482 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
487 if (method_exists($lines[$i],
'fetch_optionals')) {
488 $lines[$i]->fetch_optionals();
489 $array_options = $lines[$i]->array_options;
492 $tva_tx = $lines[$i]->tva_tx;
493 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
494 $tva_tx .=
' (' . $lines[$i]->vat_src_code .
')';
499 $lines[$i]->subprice,
502 $lines[$i]->localtax1_tx,
503 $lines[$i]->localtax2_tx,
504 $lines[$i]->fk_product,
505 $lines[$i]->remise_percent,
506 $lines[$i]->info_bits,
507 $lines[$i]->fk_remise_except,
514 $lines[$i]->special_code,
516 $lines[$i]->fk_fournprice,
533 foreach (
$object->lines as $line) {
534 if ($line->id == $result) {
535 $line->extraparams = $lines[$i]->extraparams;
536 $line->setExtraParameters();
541 if ($result > 0 && $lines[$i]->product_type == 9) {
542 $fk_parent_line = $result;
576 $parameters = array(
'objFrom' => $srcobject);
578 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
593 $object_id =
$object->create($user);
598 if ($object_id > 0) {
601 $result =
$object->add_contact(
GETPOSTINT(
'contactid'), $type_contact_code,
'external');
613 $categories =
GETPOST(
'categories',
'array');
614 if (method_exists($object,
'setCategories')) {
615 $object->setCategories($categories);
620 if ($object_id > 0 && !$error) {
622 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object_id);
630 } elseif ($action ==
'classifybilled' && $usercancreate) {
631 $ret =
$object->classifyBilled($user);
636 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
637 $ret =
$object->classifyUnBilled($user);
641 } elseif ($action ==
'setref_client' && $usercancreate) {
647 } elseif ($action ==
'setremise' && $usercancreate) {
652 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
660 } elseif ($action ==
'setdate' && $usercancreate) {
663 $result =
$object->set_date($user, $date);
667 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
671 $result =
$object->setDeliveryDate($user, $date_delivery);
675 } elseif ($action ==
'setmode' && $usercancreate) {
680 } elseif ($action ==
'setposinfo' && $usercancreate) {
684 $result =
$object->update($user);
688 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
690 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
691 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
694 } elseif ($action ==
'setavailability' && $usercancreate) {
699 } elseif ($action ==
'setdemandreason' && $usercancreate) {
704 } elseif ($action ==
'setconditions' && $usercancreate) {
711 $outputlangs = $langs;
712 $newlang =
GETPOST(
'lang_id',
'alpha');
714 $newlang =
$object->thirdparty->default_lang;
716 if (!empty($newlang)) {
718 $outputlangs->setDefaultLang($newlang);
722 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
725 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
731 } elseif ($action ==
'setbankaccount' && $usercancreate) {
737 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
743 } elseif ($action ==
'setwarehouse' && $usercancreate) {
753 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
758 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
759 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
760 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
761 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
762 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
763 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
764 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
768 foreach (
$object->lines as $line) {
769 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
772 if ($line->product_type == 1) {
773 $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);
776 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
778 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
779 $vat_rate = str_replace(
'*',
'', $vat_rate);
782 foreach (
$object->lines as $line) {
783 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
786 $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);
788 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
790 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
791 $remise_percent = str_replace(
'*',
'', $remise_percent);
792 foreach (
$object->lines as $line) {
793 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
796 $tvatx = $line->tva_tx;
797 if (!empty($line->vat_src_code)) {
798 $tvatx .=
' (' . $line->vat_src_code .
')';
800 $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);
802 } elseif ($action ==
'addline' && $usercancreate && (
803 (
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines',
'alpha') !==
'') ||
804 (
GETPOST(
'submitforallmark',
'alpha') &&
GETPOST(
'markforalllines',
'alpha') !==
''))) {
807 $margin_rate = GETPOSTISSET(
'marginforalllines') ?
GETPOST(
'marginforalllines',
'int') :
'';
808 $mark_rate = GETPOSTISSET(
'markforalllines') ?
GETPOST(
'markforalllines',
'int') :
'';
809 foreach (
$object->lines as &$line)
if ($line->subprice > 0) {
810 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
813 $subprice_multicurrency = $line->subprice;
814 if (is_numeric($margin_rate) && $margin_rate > 0) {
815 $line->subprice = (float)
price2num((
float) $line->pa_ht * (1 + (float) $margin_rate / 100),
'MU');
816 } elseif (is_numeric($mark_rate) && $mark_rate > 0) {
817 $line->subprice = (float) ($line->pa_ht / (1 - ((
float) $mark_rate / 100)));
819 $line->subprice = (float) $line->pa_ht;
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');
836 $multicurrency_subprice = (float) $line->subprice * $line->multicurrency_subprice / $subprice_multicurrency;
838 $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);
841 if (is_numeric($margin_rate) && empty($mark_rate)) {
842 $line->marge_tx = $margin_rate;
843 } elseif (is_numeric($mark_rate) && empty($margin_rate)) {
844 $line->marque_tx = $mark_rate;
846 $line->total_ht = $line->qty * (float) $line->subprice;
847 $line->total_tva = $line->tva_tx * $line->qty * (float) $line->subprice;
848 $line->total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $line->subprice;
850 $line->multicurrency_total_ht = $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
851 $line->multicurrency_total_tva = $line->tva_tx * $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
852 $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
854 $line->multicurrency_subprice = $multicurrency_subprice;
859 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
862 $langs->load(
'subtotals');
864 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
865 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
867 $subtotal_options = array();
869 foreach (Commande::$TITLE_OPTIONS as $option) {
870 $value =
GETPOST($option,
'alphanohtml');
872 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
877 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
888 $outputlangs = $langs;
889 $newlang =
GETPOST(
'lang_id',
'alpha');
891 $newlang =
$object->thirdparty->default_lang;
893 if (!empty($newlang)) {
895 $outputlangs->setDefaultLang($newlang);
898 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
903 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
905 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
908 $langs->load(
'subtotals');
910 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
911 foreach (
$object->lines as $line) {
912 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
914 $depth = -$line->qty;
918 $subtotal_options = array();
920 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
921 $value =
GETPOST($option,
'alphanohtml');
923 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
928 if (isset($desc) && isset($depth)) {
929 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
931 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
934 if (isset($result) && $result >= 0) {
940 $outputlangs = $langs;
941 $newlang =
GETPOST(
'lang_id',
'alpha');
943 $newlang =
$object->thirdparty->default_lang;
945 if (!empty($newlang)) {
947 $outputlangs->setDefaultLang($newlang);
950 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
955 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
957 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && $usercancreate) {
958 $langs->load(
'errors');
963 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
966 $price_ht_devise =
'';
968 $price_ttc_devise =
'';
970 if (
GETPOST(
'price_ht') !==
'') {
973 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
976 if (
GETPOST(
'price_ttc') !==
'') {
979 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
983 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
984 if ($prod_entry_mode ==
'free') {
990 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
995 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
999 $remise_percent = (GETPOSTISSET(
'remise_percent' . $predef) ?
price2num(
GETPOST(
'remise_percent' . $predef,
'alpha'),
'', 2) : 0);
1000 if (empty($remise_percent)) {
1001 $remise_percent = 0;
1005 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1006 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1008 if (is_array($extralabelsline)) {
1010 foreach ($extralabelsline as $key => $value) {
1011 unset($_POST[
"options_" . $key]);
1015 $price_to_test_sign = ($price_ht ? $price_ht : $price_ttc);
1017 if ((empty($idprod) || $idprod < 0) && ($price_to_test_sign < 0) && ($qty < 0)) {
1018 $langs->load(
"errors");
1019 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1022 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1023 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1026 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
1027 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1031 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1036 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1040 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1041 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1045 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1046 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1050 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1051 $idprod = $res->fk_product_child;
1053 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1059 if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1067 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1078 if (!empty($idprod) && $idprod > 0) {
1080 $prod->fetch($idprod);
1082 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
1092 $pu_ht = $prod->price;
1093 $pu_ttc = $prod->price_ttc;
1094 $price_min = $prod->price_min;
1095 $price_min_ttc = $prod->price_min_ttc;
1096 $price_base_type = $prod->price_base_type;
1100 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1104 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1107 $pricebycustomerexist =
false;
1108 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1111 if (count($prodcustprice->lines) > 0) {
1112 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1113 foreach ($prodcustprice->lines as $k => $custprice_line) {
1114 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1115 $pricebycustomerexist =
true;
1116 $pu_ht =
price($custprice_line->price);
1117 $pu_ttc =
price($custprice_line->price_ttc);
1118 $price_min =
price($custprice_line->price_min);
1119 $price_min_ttc =
price($custprice_line->price_min_ttc);
1120 $price_base_type = $custprice_line->price_base_type;
1137 if (!$pricebycustomerexist && !empty(
$object->thirdparty->price_level)) {
1138 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1139 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1140 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1141 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1142 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
1144 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1145 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1147 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1148 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1153 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1154 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1155 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1156 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1157 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
1159 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1160 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1162 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1163 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1168 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1172 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1174 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1177 if (count($prodcustprice->lines) > 0) {
1178 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1179 foreach ($prodcustprice->lines as $k => $custprice_line) {
1180 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1181 $pu_ht =
price($custprice_line->price);
1182 $pu_ttc =
price($custprice_line->price_ttc);
1183 $price_min =
price($custprice_line->price_min);
1184 $price_min_ttc =
price($custprice_line->price_min_ttc);
1185 $price_base_type = $custprice_line->price_base_type;
1203 if ($prod->prices_by_qty[0]) {
1208 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1209 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1213 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1214 $pu_ht = $priceforthequantityarray[
'unitprice'];
1216 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1224 if ($prod->prices_by_qty[
$object->thirdparty->price_level]) {
1228 foreach ($prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1229 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1233 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1234 $pu_ht = $priceforthequantityarray[
'unitprice'];
1236 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1244 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1245 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
1248 if (!empty($price_ht) || (string) $price_ht ===
'0') {
1249 $pu_ht = (float)
price2num($price_ht,
'MU');
1250 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1251 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1252 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1253 $pu_ttc_devise = (float)
price2num((
float) $pu_ht_devise * (1 + ((float) $tmpvat / 100)),
'MU');
1256 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1257 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1258 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1259 } elseif (!empty($price_ttc_devise) || (
string) $price_ttc_devise ===
'0') {
1260 $pu_ttc_devise = (float)
price2num($price_ttc_devise,
'MU');
1261 $pu_ht_devise = (float)
price2num((
float) $pu_ttc_devise / (1 + ((float) $tmpvat / 100)),
'MU');
1264 } elseif ($tmpvat != $tmpprodvat) {
1266 if ($price_base_type !=
'HT') {
1267 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1269 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1277 $outputlangs = $langs;
1279 if (
GETPOST(
'lang_id',
'aZ09')) {
1280 $newlang =
GETPOST(
'lang_id',
'aZ09');
1282 if (empty($newlang)) {
1283 $newlang =
$object->thirdparty->default_lang;
1285 if (!empty($newlang)) {
1286 $outputlangs =
new Translate(
"", $conf);
1287 $outputlangs->setDefaultLang($newlang);
1290 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1292 $desc = $prod->description;
1304 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1308 $outputlangs = $langs;
1310 if (
GETPOST(
'lang_id',
'alpha')) {
1311 $newlang =
GETPOST(
'lang_id',
'alpha');
1313 if (empty($newlang)) {
1314 $newlang =
$object->thirdparty->default_lang;
1316 if (!empty($newlang)) {
1317 $outputlangs =
new Translate(
"", $conf);
1318 $outputlangs->setDefaultLang($newlang);
1319 $outputlangs->load(
'products');
1321 if (!empty($prod->customcode)) {
1322 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
1324 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1327 if (!empty($prod->country_code)) {
1328 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
1331 if (!empty($prod->customcode)) {
1332 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
1334 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1337 if (!empty($prod->country_code)) {
1338 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $langs, 0);
1345 $type = $prod->type;
1346 $fk_unit = $prod->fk_unit;
1350 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1351 $tva_tx = str_replace(
'*',
'', $tva_tx);
1352 if (empty($tva_tx)) {
1355 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1358 $fk_unit =
GETPOST(
'units',
'alpha');
1359 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1360 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1362 if ($pu_ttc && !$pu_ht) {
1363 $price_base_type =
'TTC';
1377 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1378 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1381 $pu_equivalent = $pu_ht;
1382 $pu_equivalent_ttc = $pu_ttc;
1384 $currency_tx =
$object->multicurrency_tx;
1388 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1389 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1391 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1392 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1412 if ($usermustrespectpricemin) {
1413 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1414 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1417 } 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') {
1418 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1426 $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);
1438 $outputlangs = $langs;
1439 $newlang =
GETPOST(
'lang_id',
'alpha');
1441 $newlang =
$object->thirdparty->default_lang;
1443 if (!empty($newlang)) {
1444 $outputlangs =
new Translate(
"", $conf);
1445 $outputlangs->setDefaultLang($newlang);
1448 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1451 unset($_POST[
'prod_entry_mode']);
1453 unset($_POST[
'qty']);
1454 unset($_POST[
'type']);
1455 unset($_POST[
'remise_percent']);
1456 unset($_POST[
'price_ht']);
1457 unset($_POST[
'multicurrency_price_ht']);
1458 unset($_POST[
'price_ttc']);
1459 unset($_POST[
'tva_tx']);
1460 unset($_POST[
'product_ref']);
1461 unset($_POST[
'product_label']);
1462 unset($_POST[
'product_desc']);
1463 unset($_POST[
'fournprice']);
1464 unset($_POST[
'buying_price']);
1465 unset($_POST[
'np_marginRate']);
1466 unset($_POST[
'np_markRate']);
1467 unset($_POST[
'dp_desc']);
1468 unset($_POST[
'idprod']);
1469 unset($_POST[
'units']);
1471 unset($_POST[
'date_starthour']);
1472 unset($_POST[
'date_startmin']);
1473 unset($_POST[
'date_startsec']);
1474 unset($_POST[
'date_startday']);
1475 unset($_POST[
'date_startmonth']);
1476 unset($_POST[
'date_startyear']);
1477 unset($_POST[
'date_endhour']);
1478 unset($_POST[
'date_endmin']);
1479 unset($_POST[
'date_endsec']);
1480 unset($_POST[
'date_endday']);
1481 unset($_POST[
'date_endmonth']);
1482 unset($_POST[
'date_endyear']);
1490 } elseif ($action ==
'updatetitleline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1493 $langs->load(
'subtotals');
1495 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1498 $subtotal_options = array();
1500 foreach (Commande::$TITLE_OPTIONS as $option) {
1501 $value =
GETPOST($option,
'alphanohtml');
1503 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1508 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1519 $outputlangs = $langs;
1520 $newlang =
GETPOST(
'lang_id',
'alpha');
1522 $newlang =
$object->thirdparty->default_lang;
1524 if (!empty($newlang)) {
1525 $outputlangs =
new Translate(
"", $conf);
1526 $outputlangs->setDefaultLang($newlang);
1529 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1534 } elseif ($action ==
'updatesubtotalline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1537 $langs->load(
'subtotals');
1539 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1542 $subtotal_options = array();
1544 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1545 $value =
GETPOST($option,
'alphanohtml');
1547 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1552 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1560 $outputlangs = $langs;
1561 $newlang =
GETPOST(
'lang_id',
'alpha');
1563 $newlang =
$object->thirdparty->default_lang;
1565 if (!empty($newlang)) {
1566 $outputlangs =
new Translate(
"", $conf);
1567 $outputlangs->setDefaultLang($newlang);
1570 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1575 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1588 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1593 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1594 $vat_rate = str_replace(
'*',
'', $vat_rate);
1606 $pu_equivalent = $pu_ht;
1607 $pu_equivalent_ttc = $pu_ttc;
1609 $currency_tx =
$object->multicurrency_tx;
1613 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1614 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1616 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1617 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1632 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1636 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1637 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1639 if (is_array($extralabelsline)) {
1640 foreach ($extralabelsline as $key => $value) {
1641 unset($_POST[
"options_" . $key]);
1654 $price_base_type =
'HT';
1655 if (empty($pu) && !empty($pu_ttc)) {
1657 $price_base_type =
'TTC';
1662 if (!empty($productid)) {
1664 $product->fetch($productid);
1666 $type = $product->type;
1668 $price_min = $product->price_min;
1670 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1672 $price_min_ttc = $product->price_min_ttc;
1674 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1680 if ($usermustrespectpricemin) {
1681 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1682 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1685 $action =
'editline';
1686 } 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') {
1687 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1690 $action =
'editline';
1695 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1699 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1701 $action =
'editline';
1706 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1708 $action =
'editline';
1713 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1714 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1716 $action =
'editline';
1723 if (!$user->hasRight(
'margins',
'creer')) {
1724 foreach (
$object->lines as &$line) {
1726 $fournprice = $line->fk_fournprice;
1727 $buyingprice = $line->pa_ht;
1735 $result =
$object->updateline(
GETPOSTINT(
'lineid'), $description, (
float) $pu, (
float) $qty, $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);
1742 $outputlangs = $langs;
1745 $newlang =
GETPOST(
'lang_id',
'aZ09');
1748 $newlang =
$object->thirdparty->default_lang;
1750 if (!empty($newlang)) {
1751 $outputlangs =
new Translate(
"", $conf);
1752 $outputlangs->setDefaultLang($newlang);
1756 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1759 unset($_POST[
'qty']);
1760 unset($_POST[
'type']);
1761 unset($_POST[
'productid']);
1762 unset($_POST[
'remise_percent']);
1763 unset($_POST[
'price_ht']);
1764 unset($_POST[
'multicurrency_price_ht']);
1765 unset($_POST[
'price_ttc']);
1766 unset($_POST[
'tva_tx']);
1767 unset($_POST[
'product_ref']);
1768 unset($_POST[
'product_label']);
1769 unset($_POST[
'product_desc']);
1770 unset($_POST[
'fournprice']);
1771 unset($_POST[
'buying_price']);
1773 unset($_POST[
'date_starthour']);
1774 unset($_POST[
'date_startmin']);
1775 unset($_POST[
'date_startsec']);
1776 unset($_POST[
'date_startday']);
1777 unset($_POST[
'date_startmonth']);
1778 unset($_POST[
'date_startyear']);
1779 unset($_POST[
'date_endhour']);
1780 unset($_POST[
'date_endmin']);
1781 unset($_POST[
'date_endsec']);
1782 unset($_POST[
'date_endday']);
1783 unset($_POST[
'date_endmonth']);
1784 unset($_POST[
'date_endyear']);
1791 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1792 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1794 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1797 $qualified_for_stock_change = 0;
1799 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1801 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1806 if (!$idwarehouse || $idwarehouse == -1) {
1808 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1814 $locationTarget =
'';
1818 $result =
$object->valid($user, $idwarehouse);
1823 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1826 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1827 &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1829 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1832 $forceFields = array();
1834 if (GETPOSTISSET(
'date_pointoftax')) {
1842 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1854 $outputlangs = $langs;
1857 $newlang =
GETPOST(
'lang_id',
'aZ09');
1860 $newlang =
$object->thirdparty->default_lang;
1862 if (!empty($newlang)) {
1863 $outputlangs =
new Translate(
"", $conf);
1864 $outputlangs->setDefaultLang($newlang);
1869 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1872 $deposit->fetch($deposit->id);
1873 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1877 if ($locationTarget) {
1878 header(
'Location: ' . $locationTarget);
1889 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1891 $idwarehouse =
GETPOST(
'idwarehouse');
1893 $qualified_for_stock_change = 0;
1895 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1897 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1902 if (!$idwarehouse || $idwarehouse == -1) {
1904 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1910 $result =
$object->setDraft($user, $idwarehouse);
1914 $outputlangs = $langs;
1917 $newlang =
GETPOST(
'lang_id',
'aZ09');
1920 $newlang =
$object->thirdparty->default_lang;
1922 if (!empty($newlang)) {
1923 $outputlangs =
new Translate(
"", $conf);
1924 $outputlangs->setDefaultLang($newlang);
1929 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1935 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1936 $result =
$object->cloture($user);
1940 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1943 $qualified_for_stock_change = 0;
1945 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1947 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1952 if (!$idwarehouse || $idwarehouse == -1) {
1954 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1960 $result =
$object->cancel($user, $idwarehouse);
1968 if ($action ==
'update_extras' && $permissiontoeditextra) {
1971 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1974 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1981 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
1989 $action =
'edit_extras';
1995 $fromElement =
GETPOST(
'fromelement');
1996 $fromElementid =
GETPOST(
'fromelementid');
1997 $importLines =
GETPOST(
'line_checkbox');
1999 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
2000 if ($fromElement ==
'commande') {
2001 dol_include_once(
'/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2002 $lineClassName =
'OrderLine';
2003 } elseif ($fromElement ==
'propal') {
2004 dol_include_once(
'/comm/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2005 $lineClassName =
'PropaleLigne';
2006 } elseif ($fromElement ==
'facture') {
2007 dol_include_once(
'/compta/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2008 $lineClassName =
'FactureLigne';
2010 $nextRang = count(
$object->lines) + 1;
2013 foreach ($importLines as $lineId) {
2014 $lineId = intval($lineId);
2015 $originLine =
new $lineClassName($db);
2016 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2017 $originLine->fetch_optionals();
2018 $desc = $originLine->desc;
2019 $pu_ht = $originLine->subprice;
2020 $qty = $originLine->qty;
2021 $txtva = $originLine->tva_tx;
2022 $txlocaltax1 = $originLine->localtax1_tx;
2023 $txlocaltax2 = $originLine->localtax2_tx;
2024 $fk_product = $originLine->fk_product;
2025 $remise_percent = $originLine->remise_percent;
2026 $date_start = $originLine->date_start;
2027 $date_end = $originLine->date_end;
2028 $fk_code_ventilation = 0;
2029 $info_bits = $originLine->info_bits;
2030 $fk_remise_except = $originLine->fk_remise_except;
2031 $price_base_type =
'HT';
2033 $type = $originLine->product_type;
2034 $rang = $nextRang++;
2035 $special_code = $originLine->special_code;
2036 $origin = $originLine->element;
2037 $origin_id = $originLine->id;
2038 $fk_parent_line = 0;
2039 $fk_fournprice = $originLine->fk_fournprice;
2040 $pa_ht = $originLine->pa_ht;
2041 $label = $originLine->label;
2042 $array_options = $originLine->array_options;
2043 $situation_percent = 100;
2045 $fk_unit = $originLine->fk_unit;
2046 $pu_ht_devise = $originLine->multicurrency_subprice;
2048 $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);
2067 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
2070 $upload_dir = !empty($conf->commande->multidir_output[
$object->entity ?? $conf->entity]) ? $conf->commande->multidir_output[
$object->entity ?? $conf->entity] : $conf->commande->dir_output;
2071 $permissiontoadd = $usercancreate;
2072 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
2075 $triggersendname =
'ORDER_SENTBYMAIL';
2077 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2078 $trackid =
'ord' .
$object->id;
2079 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
2083 if ($action ==
'addcontact') {
2087 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2091 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2094 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2095 $langs->load(
"errors");
2096 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2101 } elseif ($action ==
'swapstatut') {
2108 } elseif ($action ==
'deletecontact') {
2110 $result =
$object->delete_contact($lineid);
2113 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2127$title =
$object->ref .
" - " . $langs->trans(
'Card');
2128if ($action ==
'create') {
2129 $title = $langs->trans(
"NewOrder");
2131$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2133llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2135$form =
new Form($db);
2144if ($action ==
'create' && $usercancreate) {
2149 $res = $soc->fetch($socid);
2154 $currency_code = $conf->currency;
2156 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2157 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2158 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2161 if (!empty($origin) && !empty($originid)) {
2163 $element = $subelement = $origin;
2165 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2166 $element = $regs[1];
2167 $subelement = $regs[2];
2170 if ($element ==
'project') {
2171 $projectid = $originid;
2173 if (!$cond_reglement_id) {
2174 $cond_reglement_id = $soc->cond_reglement_id;
2176 if (!$deposit_percent) {
2177 $deposit_percent = $soc->deposit_percent;
2179 if (!$mode_reglement_id) {
2180 $mode_reglement_id = $soc->mode_reglement_id;
2182 if (!$remise_percent) {
2183 $remise_percent = $soc->remise_percent;
2187 if ($element ==
'order' || $element ==
'commande') {
2188 $element = $subelement =
'commande';
2189 } elseif ($element ==
'propal') {
2190 $element =
'comm/propal';
2191 $subelement =
'propal';
2192 } elseif ($element ==
'contract') {
2193 $element = $subelement =
'contrat';
2198 $classname = ucfirst($subelement);
2199 $objectsrc =
new $classname($db);
2200 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2201 $objectsrc->fetch($originid);
2202 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2203 $objectsrc->fetch_lines();
2205 $objectsrc->fetch_thirdparty();
2208 $objectsrc->fetch_optionals();
2209 $object->array_options = $objectsrc->array_options;
2211 $projectid = (int) $objectsrc->fk_project;
2212 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2214 $soc = $objectsrc->thirdparty;
2215 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2216 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2217 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2218 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2219 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2220 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2221 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2222 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2227 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2230 if (!empty($objectsrc->multicurrency_code)) {
2231 $currency_code = $objectsrc->multicurrency_code;
2233 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2234 $currency_tx = $objectsrc->multicurrency_tx;
2238 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2239 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2242 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2245 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2246 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2247 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2248 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2249 $availability_id = 0;
2250 $shipping_method_id = $soc->shipping_method_id;
2251 $warehouse_id = $soc->fk_warehouse;
2252 $demand_reason_id = $soc->demand_reason_id;
2257 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2258 $currency_code = $soc->multicurrency_code;
2261 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2262 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2266 if (!
GETPOST(
'changecompany')) {
2267 if (GETPOSTISSET(
'cond_reglement_id')) {
2268 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2270 if (GETPOSTISSET(
'deposit_percent')) {
2273 if (GETPOSTISSET(
'mode_reglement_id')) {
2274 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2276 if (GETPOSTISSET(
'cond_reglement_id')) {
2282 if ($soc->fk_warehouse > 0) {
2283 $warehouse_id = $soc->fk_warehouse;
2290 $warehouse_id = $user->fk_warehouse;
2294 print
'<form name="crea_commande" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2295 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2296 print
'<input type="hidden" name="action" value="add">';
2297 print
'<input type="hidden" name="changecompany" value="0">';
2298 print
'<input type="hidden" name="remise_percent" value="' . $soc->remise_percent .
'">';
2299 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
2300 print
'<input type="hidden" name="originid" value="' . $originid .
'">';
2301 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
2302 if (!empty($currency_tx)) {
2303 print
'<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx .
'">';
2309 $parameters = array();
2311 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters, $object, $action);
2312 if (empty($reshook)) {
2313 print
'<table class="border centpercent">';
2316 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Ref') .
'</td><td>' . $langs->trans(
"Draft") .
'</td></tr>';
2319 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td><td>';
2320 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2321 print
'<input type="text" name="ref_client" value="' . $ref_client .
'"></td>';
2323 print
'<input type="text" name="ref_client" value="' .
GETPOST(
'ref_client') .
'"></td>';
2329 print
'<td class="fieldrequired">' . $langs->trans(
'Customer') .
'</td>';
2332 print $soc->getNomUrl(1,
'customer');
2333 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
2336 print
'<td class="valuefieldcreate">';
2337 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2338 print
img_picto(
'',
'company',
'class="pictofixedwidth"') . $form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2342 $(document).ready(function() {
2343 $("#socid").change(function() {
2344 console.log("We have changed the company - Reload page");
2345 var socid = $(this).val();
2347 $("input[name=action]").val("create");
2348 $("input[name=changecompany]").val("1");
2349 $("form[name=crea_commande]").submit();
2354 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>';
2357 print
'</tr>' .
"\n";
2364 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_" . $type_contact_code));
2366 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2368 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2372 print
'<tr><td>' . $langs->trans(
'Discounts') .
'</td><td>';
2374 $absolute_discount = $soc->getAvailableDiscounts();
2378 $backtopage = $_SERVER[
"PHP_SELF"] .
'?socid=' . $thirdparty->id .
'&action=' . $action .
'&origin=' . urlencode((
string) (
GETPOST(
'origin'))) .
'&originid=' . urlencode((
string) (
GETPOSTINT(
'originid')));
2379 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
2387 print
'<tr><td class="fieldrequired">' . $langs->trans(
'Date') .
'</td><td>';
2388 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2389 print $form->selectDate($dateorder,
're', 0, 0, 0,
"crea_commande", 1, 1);
2393 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
2394 print
'<td colspan="3">';
2395 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2396 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2397 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2402 print
'<tr class="fielddeliverydelay"><td>' . $langs->trans(
'AvailabilityPeriod') .
'</td><td>';
2403 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2404 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2408 print
'<tr><td class="nowrap">' . $langs->trans(
'PaymentConditionsShort') .
'</td><td>';
2409 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2410 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2414 print
'<tr><td>' . $langs->trans(
'PaymentMode') .
'</td><td>';
2415 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2416 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2421 print
'<tr><td>' . $langs->trans(
'BankAccount') .
'</td><td>';
2422 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"') . $form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2428 print
'<tr><td>' . $langs->trans(
'SendingMethod') .
'</td><td>';
2429 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2430 $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');
2436 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
2438 print
'<tr><td>' . $langs->trans(
'Warehouse') .
'</td><td>';
2439 print
img_picto(
'',
'stock',
'class="pictofixedwidth"') . $formproduct->selectWarehouses(((GETPOSTISSET(
'warehouse_id') && !
GETPOSTINT(
'changecompany')) ?
GETPOST(
'warehouse_id') : $warehouse_id),
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2444 print
'<tr><td>' . $langs->trans(
'Source') .
'</td><td>';
2445 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2446 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2453 $langs->load(
"projects");
2455 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2456 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects((($soc->id > 0 && !
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_CUSTOMERS')) ? $soc->id : -1), (GETPOSTISSET(
'projectid') ?
GETPOST(
'projectid') : $projectid),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2457 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$soc->id.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$soc->id).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
2465 print
'<td><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? (
string) $objectsrc->fk_incoterms : (string) $soc->fk_incoterms, 1) .
'</label></td>';
2466 print
'<td class="maxwidthonsmartphone">';
2467 $incoterm_id =
GETPOST(
'incoterm_id');
2468 $location_incoterms =
GETPOST(
'location_incoterms');
2469 if (empty($incoterm_id)) {
2470 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2471 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2473 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2474 print $form->select_incoterms($incoterm_id, $location_incoterms);
2479 $parameters = array();
2480 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2481 $parameters[
'objectsrc'] = $objectsrc;
2483 $parameters[
'socid'] = $socid;
2486 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2487 print $hookmanager->resPrint;
2488 if (empty($reshook)) {
2489 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2492 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2493 if ($soc->fetch_optionals() > 0) {
2494 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2498 print
$object->showOptionals($extrafields,
'create', $parameters);
2502 print
'<tr><td>' . $langs->trans(
'DefaultModel') .
'</td>';
2504 include_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
2507 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2508 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2514 print
'<td>' . $form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0) .
'</td>';
2515 print
'<td class="maxwidthonsmartphone">';
2516 print
img_picto(
'',
'currency',
'class="pictofixedwidth"') . $form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2522 print
'<tr><td>' . $langs->trans(
"Categories") .
'</td><td colspan="3">';
2523 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
2529 print
'<td class="tdtop">' . $langs->trans(
'NotePublic') .
'</td>';
2532 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2533 print $doleditor->Create(1);
2538 if (empty($user->socid)) {
2540 print
'<td class="tdtop">' . $langs->trans(
'NotePrivate') .
'</td>';
2543 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2544 print $doleditor->Create(1);
2549 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2551 if ($origin ==
'contrat') {
2555 $objectsrc->update_price(1);
2558 print
"\n<!-- " . $classname .
" info -->\n";
2559 print
'<input type="hidden" name="amount" value="' . $objectsrc->total_ht .
'">' .
"\n";
2560 print
'<input type="hidden" name="total" value="' . $objectsrc->total_ttc .
'">' .
"\n";
2561 print
'<input type="hidden" name="tva" value="' . $objectsrc->total_tva .
'">' .
"\n";
2562 print
'<input type="hidden" name="origin" value="' . $objectsrc->element .
'">';
2563 print
'<input type="hidden" name="originid" value="' . $objectsrc->id .
'">';
2565 switch ($classname) {
2567 $newclassname =
'CommercialProposal';
2570 $newclassname =
'Order';
2573 $newclassname =
'Sending';
2576 $newclassname =
'Contract';
2579 $newclassname = $classname;
2582 print
'<tr><td>' . $langs->trans($newclassname) .
'</td><td>' . $objectsrc->getNomUrl(1) .
'</td></tr>';
2585 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td><td>' .
price($objectsrc->total_ht) .
'</td></tr>';
2586 print
'<tr><td>' . $langs->trans(
'AmountVAT') .
'</td><td>' .
price($objectsrc->total_tva) .
"</td></tr>";
2587 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2588 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax1) .
"</td></tr>";
2591 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2592 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax2) .
"</td></tr>";
2595 print
'<tr><td>' . $langs->trans(
'AmountTTC') .
'</td><td>' .
price($objectsrc->total_ttc) .
"</td></tr>";
2598 print
'<tr><td>' . $langs->trans(
'MulticurrencyAmountHT') .
'</td><td>' .
price($objectsrc->multicurrency_total_ht) .
'</td></tr>';
2599 print
'<tr><td>' . $langs->trans(
'MulticurrencyAmountVAT') .
'</td><td>' .
price($objectsrc->multicurrency_total_tva) .
"</td></tr>";
2600 print
'<tr><td>' . $langs->trans(
'MulticurrencyAmountTTC') .
'</td><td>' .
price($objectsrc->multicurrency_total_ttc) .
"</td></tr>";
2611 print $form->buttonsSaveCancel(
"CreateDraft");
2614 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2615 $title = $langs->trans(
'ProductsAndServices');
2618 print
'<div class="div-table-responsive-no-min">';
2619 print
'<table class="noborder centpercent">';
2621 $objectsrc->printOriginLinesList(
'', $selectedLines);
2633 $product_static =
new Product($db);
2638 $author =
new User($db);
2639 $author->fetch(
$object->user_author_id);
2642 $res =
$object->fetch_optionals();
2645 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2650 if ($action ==
'delete') {
2651 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2655 if ($action ==
'validate') {
2657 $ref = substr(
$object->ref, 1, 4);
2658 if ($ref ==
'PROV' || $ref ==
'') {
2659 $numref =
$object->getNextNumRef($soc);
2660 if (empty($numref)) {
2665 $numref = (string)
$object->ref;
2668 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2670 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2671 $notify =
new Notify($db);
2673 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid, $object);
2676 $qualified_for_stock_change = 0;
2678 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2680 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2683 $formquestion = array();
2685 $langs->load(
"stocks");
2686 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
2689 if ($conf->browser->name ==
'ie') {
2692 $formquestion = array(
2696 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2702 foreach (
$object->lines as $line) {
2703 $res = $line->fetch_product();
2705 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2711 if ($nbMandated > 0) {
2713 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2716 $text .=
'<div><span class="clearboth nowraponall warning">' .
img_warning() . $langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate") .
'</span></div>';
2720 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2725 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2727 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2728 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2732 $eligibleForDepositGeneration =
true;
2734 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2735 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2736 '@phan-var-force Facture $invoice';
2738 $eligibleForDepositGeneration =
false;
2744 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2745 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2746 $proposal->fetchObjectLinked();
2748 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2749 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2750 '@phan-var-force Facture $invoice';
2752 $eligibleForDepositGeneration =
false;
2760 if ($eligibleForDepositGeneration) {
2761 $formquestion[] = array(
2762 'type' =>
'checkbox',
2764 'name' =>
'generate_deposit',
2765 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2768 $formquestion[] = array(
2770 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2772 'label' => $langs->trans(
'DateInvoice'),
2778 $formquestion[] = array(
2780 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2781 'name' =>
'date_pointoftax',
2782 'label' => $langs->trans(
'DatePointOfTax'),
2788 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2790 $formquestion[] = array(
2792 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2793 'name' =>
'cond_reglement_id',
2794 'label' => $langs->trans(
'PaymentTerm'),
2795 'value' => $paymentTermsSelect
2798 $formquestion[] = array(
2799 'type' =>
'checkbox',
2800 'tdclass' =>
'showonlyifgeneratedeposit',
2801 'name' =>
'validate_generated_deposit',
2802 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2805 $formquestion[] = array(
2806 'type' =>
'onecolumn',
2809 $(document).ready(function() {
2810 $("[name=generate_deposit]").change(function () {
2811 let $self = $(this);
2812 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2814 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2831 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2836 if ($action ==
'modif') {
2837 $qualified_for_stock_change = 0;
2839 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2841 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2844 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2845 $formquestion = array();
2847 $langs->load(
"stocks");
2848 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
2851 if ($conf->browser->name ==
'ie') {
2860 'name' =>
'idwarehouse',
2861 'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
2862 'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo)
2867 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2871 if ($action ==
'shipped') {
2872 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2876 if ($action ==
'cancel') {
2877 $qualified_for_stock_change = 0;
2879 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2881 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2884 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2885 $formquestion = array();
2887 $langs->load(
"stocks");
2888 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
2891 if ($conf->browser->name ==
'ie') {
2894 $formquestion = array(
2898 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2902 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2906 if ($action ==
'ask_deleteline') {
2907 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2911 if ($action ==
'ask_subtotal_deleteline') {
2912 $langs->load(
"subtotals");
2913 $title =
"DeleteSubtotalLine";
2914 $question =
"ConfirmDeleteSubtotalLine";
2915 if (
GETPOST(
'type') ==
'title') {
2916 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2917 $title =
"DeleteTitleLine";
2918 $question =
"ConfirmDeleteTitleLine";
2920 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2924 if ($action ==
'clone') {
2925 $filter =
'(s.client:IN:1,2,3)';
2927 $formquestion = array(
2928 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2930 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2934 if ($action ==
'add_title_line') {
2935 $langs->load(
'subtotals');
2937 $depth_array =
$object->getPossibleLevels($langs);
2938 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2939 } elseif ($action ==
'add_subtotal_line') {
2940 $langs->load(
'subtotals');
2942 $titles =
$object->getPossibleTitles();
2943 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
2947 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2949 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2950 if (empty($reshook)) {
2951 $formconfirm .= $hookmanager->resPrint;
2952 } elseif ($reshook > 0) {
2953 $formconfirm = $hookmanager->resPrint;
2962 $linkback =
'<a href="' . DOL_URL_ROOT .
'/commande/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
2964 $morehtmlref =
'<div class="refidno">';
2966 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client, $object, (
int) $usercancreate,
'string',
'', 0, 1);
2967 $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);
2969 $morehtmlref .=
'<br>' . $soc->getNomUrl(1,
'customer');
2971 $morehtmlref .=
' (<a href="' . DOL_URL_ROOT .
'/commande/list.php?socid=' .
$object->thirdparty->id .
'&search_societe=' . urlencode(
$object->thirdparty->name) .
'">' . $langs->trans(
"OtherOrders") .
'</a>)';
2975 $langs->load(
"projects");
2976 $morehtmlref .=
'<br>';
2977 if ($usercancreate) {
2978 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2979 if ($action !=
'classify') {
2980 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
2982 $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');
2984 if (!empty(
$object->fk_project)) {
2986 $proj->fetch(
$object->fk_project);
2987 $morehtmlref .= $proj->getNomUrl(1);
2989 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
2994 $morehtmlref .=
'</div>';
2996 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2999 $parameters = array();
3001 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters, $object, $action);
3002 if (empty($reshook)) {
3003 print
'<div class="fichecenter">';
3004 print
'<div class="fichehalfleft">';
3005 print
'<div class="underbanner clearboth"></div>';
3007 print
'<table class="border tableforfield centpercent">';
3011 $langs->load(
"cashdesk");
3012 print
'<tr><td class="fieldname_type">';
3013 print
'<table class="nobordernopadding centpercent"><tr><td>';
3014 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3016 if ($action !=
'editposinfo' && $usercancreate) {
3017 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>';
3019 print
'</tr></table>';
3020 print
'</td><td class="valuefield fieldname_type">';
3021 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" name="formposinfo">';
3022 print
'<input type="hidden" name="action" value="setposinfo">';
3023 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3024 if ($action ==
'editposinfo') {
3025 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="' . $langs->trans(
"POSModule") .
'" value="' .
$object->module_source .
'"> ';
3026 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="' . $langs->trans(
"Terminal") .
'" value="' .
$object->pos_source .
'">';
3027 print
'<input type="submit" class="button" name="submitposinfo" value="' . $langs->trans(
"Submit") .
'">';
3030 print
'<span class="opacitymediumbycolor paddingleft">' .
dolPrintHTML(ucfirst(
$object->module_source) .
' - ' . $langs->transnoentitiesnoconv(
"Terminal") .
' ' .
$object->pos_source) .
'</span>';
3037 if ($soc->outstanding_limit) {
3039 print
'<tr><td class="titlefield">';
3040 print $langs->trans(
'OutstandingBill');
3041 print
'</td><td class="valuefield">';
3042 $arrayoutstandingbills = $soc->getOutstandingBills();
3043 print
price($arrayoutstandingbills[
'opened']) .
' / ';
3044 print
price($soc->outstanding_limit, 0,
'', 1, -1, -1, $conf->currency);
3051 $filterabsolutediscount =
"fk_facture_source IS NULL";
3052 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3054 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3055 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3058 $addrelativediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remise.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditRelativeDiscounts") .
'</a>';
3059 $addabsolutediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remx.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditGlobalDiscounts") .
'</a>';
3060 $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>';
3062 print
'<tr><td class="titlefield">' . $langs->trans(
'Discounts') .
'</td><td class="valuefield">';
3064 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3065 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3066 $absolute_discount =
price2num($absolute_discount,
'MT');
3067 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3071 $backtopage = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id;
3072 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
3079 print $form->editfieldkey(
"Date",
'date',
'', $object, (
int) $editenable);
3080 print
'</td><td class="valuefield">';
3081 if ($action ==
'editdate') {
3082 print
'<form name="setdate" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3083 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3084 print
'<input type="hidden" name="action" value="setdate">';
3085 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3086 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3087 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3092 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3100 $editenable = $usercancreate;
3101 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, (
int) $editenable);
3102 print
'</td><td class="valuefield">';
3103 if ($action ==
'editdate_livraison') {
3104 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3105 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3106 print
'<input type="hidden" name="action" value="setdate_livraison">';
3107 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3108 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3109 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3114 print
' ' .
img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3121 print
'<tr class="fielddeliverydelay"><td>';
3122 $editenable = $usercancreate;
3123 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, (
int) $editenable);
3124 print
'</td><td class="valuefield">';
3125 if ($action ==
'editavailability') {
3126 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3128 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'none', 1);
3135 $editenable = $usercancreate;
3136 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, (
int) $editenable);
3137 print
'</td><td class="valuefield">';
3138 if ($action ==
'editshippingmethod') {
3139 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3141 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'none');
3149 $langs->load(
'stocks');
3150 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
3153 $editenable = $usercancreate;
3154 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, (
int) $editenable);
3155 print
'</td><td class="valuefield">';
3156 if ($action ==
'editwarehouse') {
3157 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3159 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'none');
3167 $editenable = $usercancreate;
3168 print $form->editfieldkey(
"Source",
'demandreason',
'', $object, (
int) $editenable);
3169 print
'</td><td class="valuefield">';
3170 if ($action ==
'editdemandreason') {
3171 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3173 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'none');
3179 $editenable = $usercancreate;
3180 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, (
int) $editenable);
3181 print
'</td><td class="valuefield">';
3182 if ($action ==
'editconditions') {
3183 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3185 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3193 $editenable = $usercancreate;
3194 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, (
int) $editenable);
3195 print
'</td><td class="valuefield">';
3196 if ($action ==
'editmode') {
3197 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3199 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
3217 $tmparray =
$object->getTotalWeightVolume();
3218 $totalWeight = $tmparray[
'weight'];
3219 $totalVolume = $tmparray[
'volume'];
3221 print
'<tr><td>' . $langs->trans(
"CalculatedWeight") .
'</td>';
3222 print
'<td class="valuefield">';
3227 print
'<tr><td>' . $langs->trans(
"CalculatedVolume") .
'</td>';
3228 print
'<td class="valuefield">';
3238 $editenable = $usercancreate;
3239 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, (
int) $editenable);
3241 print
'<td class="valuefield">';
3242 if ($action !=
'editincoterm') {
3243 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3245 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3253 $editenable = $usercancreate;
3254 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, (
int) $editenable);
3255 print
'</td><td class="valuefield">';
3256 if ($action ==
'editbankaccount') {
3257 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3259 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
3268 print
'<table class="nobordernopadding centpercent"><tr><td>';
3269 print $langs->trans(
"Categories");
3270 print
'<td><td class="right">';
3271 if ($usercancreate) {
3272 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/commande/card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' .
img_edit() .
'</a>';
3276 print
'</td></tr></table>';
3279 if ($action ==
'edittags') {
3280 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
3281 print
'<input type="hidden" name="action" value="settags">';
3282 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3283 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
3284 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
3287 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3293 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3298 print
'<div class="fichehalfright">';
3299 print
'<div class="underbanner clearboth"></div>';
3301 print
'<table class="border tableforfield centpercent">';
3303 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_currency_amount.tpl.php';
3307 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3311 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3312 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3315 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3320 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3321 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3324 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3329 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3331 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
3332 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3336 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3342 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3344 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
3345 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3349 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3355 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3356 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1, $conf->currency) .
'</td>';
3359 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3361 print
'</tr>' .
"\n";
3370 $formmargin->displayMarginInfos($object);
3377 print
'<div class="clearboth"></div><br>';
3380 $blocname =
'contacts';
3381 $title = $langs->trans(
'ContactsAddresses');
3382 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3386 $blocname =
'notes';
3387 $title = $langs->trans(
'Notes');
3388 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3396 $result =
$object->getLinesArray();
3400 global $inputalsopricewithtax;
3401 $inputalsopricewithtax = 1;
3403 print
'<form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="POST">
3404 <input type="hidden" name="token" value="' .
newToken() .
'">
3405 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
3406 <input type="hidden" name="mode" value="">
3407 <input type="hidden" name="page_y" value="">
3408 <input type="hidden" name="id" value="' .
$object->id .
'">
3409 <input type="hidden" name="backtopage" value="' . $backtopage .
'">
3414 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
3416 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3420 print
'<div class="div-table-responsive-no-min">';
3421 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3425 $object->printObjectLines($action,
$mysoc, $soc, $lineid, 1);
3432 if ($action !=
'editline') {
3435 $parameters = array();
3437 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3441 if (empty($reshook)) {
3445 $parameters = array();
3446 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3460 if ($action !=
'presend' && $action !=
'editline') {
3461 print
'<div class="tabsAction">';
3463 $parameters = array();
3464 $arrayforbutaction = array();
3466 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3467 if (empty($reshook)) {
3468 $numlines = count(
$object->lines);
3472 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=reopen&token=' .
newToken() .
'&id=' .
$object->id,
'');
3476 if (empty($user->socid)) {
3479 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'');
3481 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3489 $langs->load(
'subtotals');
3491 $url_button = array();
3493 $url_button[] = array(
3494 'lang' =>
'subtotals',
3496 'perm' => (
bool) $usercancreate,
3497 'label' => $langs->trans(
'AddTitleLine'),
3498 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_title_line&token=' .
newToken()
3501 $url_button[] = array(
3502 'lang' =>
'subtotals',
3504 'perm' => (
bool) $usercancreate,
3505 'label' => $langs->trans(
'AddSubtotalLine'),
3506 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_subtotal_line&token=' .
newToken()
3508 print
dolGetButtonAction(
'', $langs->trans(
'Subtotal'),
'default', $url_button,
'',
true);
3513 if ($numlines > 0) {
3516 $langs->load(
"errors");
3517 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=validate&token=' .
newToken() .
'&id=' .
$object->id, (
string)
$object->id, -1);
3522 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=modif&token=' .
newToken() .
'&id=' .
$object->id,
'');
3528 $arrayforbutaction[] = array(
3531 'perm' => $usercancreatepurchaseorder,
3532 'label' =>
'AddPurchaseOrder',
3533 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3545 $arrayforbutaction[] = array(
3546 'lang' =>
'interventions',
3548 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3549 'label' =>
'AddIntervention',
3550 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3555 $arrayforbutaction[] = array(
3556 'lang' =>
'contracts',
3558 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3559 'label' =>
'AddContract',
3560 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3574 $numshipping =
$object->countNbOfShipments();
3577 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3579 $arrayforbutaction[] = array(
3580 'lang' =>
'sendings',
3582 'perm' => $user->hasRight(
'expedition',
'creer'),
3583 'label' =>
'CreateShipment',
3584 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3589 $arrayforbutaction[] = array(
3590 'lang' =>
'sendings',
3593 'label' =>
'CreateShipment',
3594 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3601 $arrayforbutaction[] = array(
3604 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3605 'label' =>
'CreateBill',
3606 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3615 $actionButtonsParameters = [
3616 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3619 if ($numlines > 0) {
3620 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3622 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3627 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=shipped&token=' .
newToken() .
'&id=' .
$object->id,
'');
3634 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"] .
'?action=classifybilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3639 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"] .
'?action=classifyunbilled&token=' .
newToken() .
'&id=' .
$object->id,
'');
3644 if ($usercancreate) {
3650 print
'<a class="butActionDelete" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=cancel&token=' .
newToken() .
'">' . $langs->trans(
"CancelOrder") .
'</a>';
3654 if ($usercandelete) {
3655 if ($numshipping == 0) {
3658 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3666 if (
GETPOST(
'modelselected')) {
3667 $action =
'presend';
3670 if ($action !=
'presend') {
3671 print
'<div class="fichecenter"><div class="fichehalfleft">';
3672 print
'<a name="builddoc"></a>';
3675 $relativepath = $objref .
'/' . $objref .
'.pdf';
3676 $filedir = $conf->commande->multidir_output[
$object->entity ?? $conf->entity] .
'/' . $objref;
3678 $genallowed = $usercanread;
3679 $delallowed = $usercancreate;
3680 $tooltipAfterComboOfModels =
'';
3682 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_ORDER_TERMSOFSALE'));
3685 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);
3689 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'order'), 1);
3690 $linktoelem = $tmparray[
'linktoelem'];
3691 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3692 print $htmltoenteralink;
3694 $compatibleImportElementsList =
false;
3699 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3701 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3705 include_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3706 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3707 $useonlinepayment = count($validpaymentmethod);
3710 $useonlinepayment = 0;
3713 print
'<br><!-- Link to pay -->';
3714 require_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3715 print showOnlinePaymentUrl(
'order',
$object->ref) .
'<br>';
3718 print
'</div><div class="fichehalfright">';
3723 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/messaging.php', [
'id' =>
$object->id]));
3724 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/agenda.php', [
'id' =>
$object->id]));
3727 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3729 $somethingshown = $formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3731 print
'</div></div>';
3735 $modelmail =
'order_send';
3736 $defaulttopic =
'SendOrderRef';
3738 $trackid =
'ord' .
$object->id;
3740 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.
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
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'.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
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.
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...
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.