43require
'../main.inc.php';
54require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
55require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
56require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
57require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formorder.class.php';
58require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmargin.class.php';
59require_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
60require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
61require_once DOL_DOCUMENT_ROOT .
'/core/lib/order.lib.php';
63require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
64require_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
65require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
68 require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
72 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
73 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
77 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductCombination.class.php';
82$langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'products',
'other'));
85 $langs->load(
'incoterm');
88 $langs->load(
'margins');
91 $langs->load(
'productbatch');
98$action =
GETPOST(
'action',
'aZ09');
99$cancel =
GETPOST(
'cancel',
'alpha');
100$confirm =
GETPOST(
'confirm',
'alpha');
101$backtopage =
GETPOST(
'backtopage',
'alpha');
102$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
107$origin =
GETPOST(
'origin',
'alpha');
120if (!empty($user->socid)) {
121 $socid = $user->socid;
126$price_base_type =
null;
127$lineClassName =
null;
128$remise_percent =
null;
130$availability_id =
null;
131$shipping_method_id =
null;
133$demand_reason_id =
null;
142$hookmanager->initHooks(array(
'ordercard',
'globalcard'));
149$extrafields->fetch_name_optionals_label(
$object->table_element);
152include DOL_DOCUMENT_ROOT .
'/core/actions_fetchobject.inc.php';
155$usercanread = $user->hasRight(
"commande",
"lire");
156$usercancreate = $user->hasRight(
"commande",
"creer");
157$usercandelete = $user->hasRight(
"commande",
"supprimer");
160$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'close')));
161$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'validate')));
162$usercancancel = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'annuler')));
163$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'send'));
164$usercangeneratedoc = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
166$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
167$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
169$permissionnote = $usercancreate;
170$permissiondellink = $usercancreate;
171$permissiontoadd = $usercancreate;
172$permissiontoeditextra = $usercancreate;
173if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
175 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
182$selectedLines = array();
189$parameters = array(
'socid' => $socid);
191$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
193 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
196if (empty($reshook)) {
197 $backurlforlist = DOL_URL_ROOT .
'/commande/list.php';
199 if (empty($backtopage) || ($cancel && empty($id))) {
200 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
201 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
202 $backtopage = $backurlforlist;
204 $backtopage = DOL_URL_ROOT .
'/commande/card.php?id=' . ((!empty($id) &&
$id > 0) ? $id :
'__ID__');
209 $selectedLines =
GETPOST(
'toselect',
'array:int');
212 if (!empty($backtopageforcancel)) {
213 header(
"Location: " . $backtopageforcancel);
215 } elseif (!empty($backtopage)) {
216 header(
"Location: " . $backtopage);
222 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
224 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
226 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
229 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
231 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
237 $result = $objectutil->createFromClone($user, $socid, (
GETPOSTISSET(
'entity') ?
GETPOSTINT(
'entity') : null));
239 $warningMsgLineList = array();
241 foreach ($objectutil->lines as $line) {
242 if (!is_object($line->product)) {
243 $line->fetch_product();
245 if (is_object($line->product) && $line->product->id > 0) {
246 if (empty($line->product->status)) {
247 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
251 if (!empty($warningMsgLineList)) {
252 setEventMessages(
'', $warningMsgLineList,
'warnings');
255 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $result);
258 setEventMessages($objectutil->error, $objectutil->errors,
'errors');
263 } elseif ($action ==
'reopen' && $usercancreate) {
268 $result =
$object->setDraft($user, $idwarehouse);
273 $result =
$object->set_reopen($user);
275 setEventMessages($langs->trans(
'OrderReopened',
$object->ref),
null);
281 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
287 header(
'Location: list.php?restore_lastsearch_values=1');
292 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
294 $result =
$object->deleteLine($user, $lineid);
299 $outputlangs = $langs;
302 $newlang =
GETPOST(
'lang_id',
'aZ09');
305 $newlang =
$object->thirdparty->default_lang;
307 if (!empty($newlang)) {
309 $outputlangs->setDefaultLang($newlang);
313 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
316 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
321 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
322 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
327 $outputlangs = $langs;
330 $newlang =
GETPOST(
'lang_id',
'aZ09');
333 $newlang =
$object->thirdparty->default_lang;
335 if (!empty($newlang)) {
337 $outputlangs->setDefaultLang($newlang);
341 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
344 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
349 } elseif ($action ==
'classin' && $usercancreate) {
352 } elseif ($action ==
'add' && $usercancreate) {
357 if ($datecommande ==
'') {
358 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
364 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
375 $object->date_commande = $datecommande;
388 $object->delivery_date = $date_delivery;
394 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
395 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
398 $ret = $extrafields->setOptionalsFromPost(
null, $object);
404 if (!empty($origin) && !empty($originid)) {
406 $object->origin_type = $origin;
407 $object->origin_id = $originid;
411 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
412 if (!empty($other_linked_objects)) {
413 $object->linked_objects = array_merge(
$object->linked_objects, $other_linked_objects);
417 $object_id =
$object->create($user);
419 if ($object_id > 0) {
420 dol_syslog(
"Try to find source object origin=" .
$object->origin .
" originid=" .
$object->origin_id .
" to add lines");
423 $srcobject = fetchObjectByElement(
$object->origin_id, $origin);
425 if (is_object($srcobject) && $srcobject->id > 0) {
426 '@phan-var-force Commande|Propal|Contrat $srcobject';
428 $lines = $srcobject->lines;
429 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
430 $srcobject->fetch_lines();
431 $lines = $srcobject->lines;
435 $num = count($lines);
437 for ($i = 0; $i < $num; $i++) {
438 if (!in_array($lines[$i]->
id, $selectedLines)) {
442 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
443 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
444 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
449 if ($lines[$i]->date_debut_reel) {
452 if ($lines[$i]->date_start) {
455 $date_end = $lines[$i]->date_fin_prevue;
456 if ($lines[$i]->date_fin_reel) {
457 $date_end = $lines[$i]->date_fin_reel;
459 if ($lines[$i]->date_end) {
460 $date_end = $lines[$i]->date_end;
464 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
469 if (method_exists($lines[$i],
'fetch_optionals')) {
470 $lines[$i]->fetch_optionals();
471 $array_options = $lines[$i]->array_options;
474 $tva_tx = $lines[$i]->tva_tx;
475 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
476 $tva_tx .=
' (' . $lines[$i]->vat_src_code .
')';
480 $line_price_base_type = $lines[$i]->getPriceBaseType();
483 $lines[$i]->subprice,
486 $lines[$i]->localtax1_tx,
487 $lines[$i]->localtax2_tx,
488 $lines[$i]->fk_product,
489 $lines[$i]->remise_percent,
490 $lines[$i]->info_bits,
491 $lines[$i]->fk_remise_except,
492 $line_price_base_type,
493 (
float) $lines[$i]->subprice_ttc,
498 $lines[$i]->special_code,
500 $lines[$i]->fk_fournprice,
517 foreach (
$object->lines as $line) {
518 if ($line->id == $result) {
519 $line->extraparams = $lines[$i]->extraparams;
520 $line->setExtraParameters();
525 if ($result > 0 && $lines[$i]->product_type == 9) {
526 $fk_parent_line = $result;
530 if (is_object($srcobject) && !empty($srcobject->error)) {
531 setEventMessages($srcobject->error, $srcobject->errors,
'errors');
533 $langs->load(
"errors");
534 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
565 $parameters = array(
'objFrom' => (is_object($srcobject) ? $srcobject : null));
567 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
569 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
582 $object_id =
$object->create($user);
587 if ($object_id > 0) {
590 $result =
$object->add_contact(
GETPOSTINT(
'contactid'), $type_contact_code,
'external');
592 setEventMessages($langs->trans(
"ErrorFailedToAddContact"),
null,
'errors');
602 $categories =
GETPOST(
'categories',
'array');
603 if (method_exists($object,
'setCategories')) {
604 $object->setCategories($categories);
609 if ($object_id > 0 && !$error) {
611 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object_id);
619 } elseif ($action ==
'classifybilled' && $usercancreate) {
620 $ret =
$object->classifyBilled($user);
625 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
626 $ret =
$object->classifyUnBilled($user);
630 } elseif ($action ==
'setref_client' && $usercancreate) {
636 } elseif ($action ==
'setremise' && $usercancreate) {
641 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
646 dol_print_error($db,
$object->error);
649 } elseif ($action ==
'setdate' && $usercancreate) {
652 $result =
$object->set_date($user, $date);
656 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
660 $result =
$object->setDeliveryDate($user, $date_delivery);
664 } elseif ($action ==
'setmode' && $usercancreate) {
669 } elseif ($action ==
'setposinfo' && $usercancreate) {
673 $result =
$object->update($user);
675 dol_print_error($db,
$object->error);
677 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
679 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
680 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
683 } elseif ($action ==
'setavailability' && $usercancreate) {
688 } elseif ($action ==
'setdemandreason' && $usercancreate) {
693 } elseif ($action ==
'setconditions' && $usercancreate) {
696 dol_print_error($db,
$object->error);
700 $outputlangs = $langs;
701 $newlang =
GETPOST(
'lang_id',
'alpha');
703 $newlang =
$object->thirdparty->default_lang;
705 if (!empty($newlang)) {
707 $outputlangs->setDefaultLang($newlang);
711 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
714 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
720 } elseif ($action ==
'setbankaccount' && $usercancreate) {
726 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
732 } elseif ($action ==
'setwarehouse' && $usercancreate) {
738 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
743 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
744 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
745 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
746 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
747 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
748 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
749 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
753 foreach (
$object->lines as $line) {
754 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
757 if ($line->product_type == 1) {
759 $line_price_base_type = $line->getPriceBaseType();
760 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
761 $result =
$object->updateline($line->id, $line->desc, $line_pu, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line_price_base_type, $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);
764 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
766 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
767 $vat_rate = str_replace(
'*',
'', $vat_rate);
770 foreach (
$object->lines as $line) {
771 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
775 $line_price_base_type = $line->getPriceBaseType();
776 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
777 $result =
$object->updateline($line->id, $line->desc, $line_pu, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line_price_base_type, $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);
779 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
781 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
782 $remise_percent = str_replace(
'*',
'', $remise_percent);
783 foreach (
$object->lines as $line) {
784 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
787 $tvatx = $line->tva_tx;
788 if (!empty($line->vat_src_code)) {
789 $tvatx .=
' (' . $line->vat_src_code .
')';
792 $line_price_base_type = $line->getPriceBaseType();
793 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
794 $result =
$object->updateline($line->id, $line->desc, $line_pu, $line->qty, (
float) $remise_percent, $tvatx, $line->localtax1_tx, $line->localtax2_tx, $line_price_base_type, $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);
796 } elseif ($action ==
'addline' && $usercancreate && (
797 (
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines',
'alpha') !==
'') ||
798 (
GETPOST(
'submitforallmark',
'alpha') &&
GETPOST(
'markforalllines',
'alpha') !==
'')
802 $margin_rate =
GETPOSTISSET(
'marginforalllines') ?
GETPOST(
'marginforalllines',
'int') :
'';
804 foreach (
$object->lines as &$line) {
805 if ($line->subprice > 0) {
806 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
809 $subprice_multicurrency = $line->subprice;
810 if (is_numeric($margin_rate) && $margin_rate > 0) {
811 $line->subprice = (float)
price2num((
float) $line->pa_ht * (1 + (float) $margin_rate / 100),
'MU');
812 } elseif (is_numeric($mark_rate) && $mark_rate > 0) {
813 $line->subprice = (float) ($line->pa_ht / (1 - ((
float) $mark_rate / 100)));
815 $line->subprice = (float) $line->pa_ht;
818 if ($line->fk_product > 0) {
820 $res =
$prod->fetch($line->fk_product);
822 if (
$prod->price_min > $line->subprice) {
823 $price_subprice =
price($line->subprice, 0, $outlangs, 1, -1, -1,
'auto');
824 $price_price_min =
price(
$prod->price_min, 0, $outlangs, 1, -1, -1,
'auto');
825 setEventMessages(
$prod->ref .
' - ' .
$prod->label .
' (' . $price_subprice .
' < ' . $price_price_min .
' ' . strtolower($langs->trans(
"MinPrice")) .
')' .
"\n",
null,
'warnings');
827 setEventMessages(
$prod->error,
$prod->errors,
'errors');
830 setEventMessages(
$prod->error,
$prod->errors,
'errors');
835 $multicurrency_subprice = (float) $line->subprice * $line->multicurrency_subprice / $subprice_multicurrency;
837 $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);
840 if (is_numeric($margin_rate) && empty($mark_rate)) {
841 $line->marge_tx = $margin_rate;
842 } elseif (is_numeric($mark_rate) && empty($margin_rate)) {
843 $line->marque_tx = $mark_rate;
845 $line->total_ht = $line->qty * (float) $line->subprice;
846 $line->total_tva = $line->tva_tx * $line->qty * (float) $line->subprice;
847 $line->total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $line->subprice;
849 $line->multicurrency_total_ht = $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
850 $line->multicurrency_total_tva = $line->tva_tx * $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
851 $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
853 $line->multicurrency_subprice = $multicurrency_subprice;
859 } elseif ($action ==
'confirm_addtextline' && $usercancreate) {
862 $langs->load(
'subtotals');
864 $desc =
GETPOST(
'subtotaltextcontent',
'restricthtml');
867 $result =
$object->addSubtotalLine($langs, $desc, 0, array());
878 $outputlangs = $langs;
879 $newlang =
GETPOST(
'lang_id',
'alpha');
881 $newlang =
$object->thirdparty->default_lang;
883 if (!empty($newlang)) {
885 $outputlangs->setDefaultLang($newlang);
888 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
893 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
895 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
898 $langs->load(
'subtotals');
900 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
901 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
903 $subtotal_options = array();
905 foreach (Commande::$TITLE_OPTIONS as $option) {
906 $value =
GETPOST($option,
'alphanohtml');
908 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
913 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
924 $outputlangs = $langs;
925 $newlang =
GETPOST(
'lang_id',
'alpha');
927 $newlang =
$object->thirdparty->default_lang;
929 if (!empty($newlang)) {
931 $outputlangs->setDefaultLang($newlang);
934 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
939 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
941 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
944 $langs->load(
'subtotals');
946 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
947 foreach (
$object->lines as $line) {
948 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
950 $depth = -$line->qty;
954 $subtotal_options = array();
956 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
957 $value =
GETPOST($option,
'alphanohtml');
959 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
964 if (isset($desc) && isset($depth)) {
965 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
968 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
977 $outputlangs = $langs;
978 $newlang =
GETPOST(
'lang_id',
'alpha');
980 $newlang =
$object->thirdparty->default_lang;
982 if (!empty($newlang)) {
984 $outputlangs->setDefaultLang($newlang);
987 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
992 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
994 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && $usercancreate) {
995 $langs->load(
'errors');
1003 $price_ht_devise =
'';
1005 $price_ttc_devise =
'';
1007 if (
GETPOST(
'price_ht') !==
'') {
1010 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1013 if (
GETPOST(
'price_ttc') !==
'') {
1016 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1017 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1020 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
1021 if ($prod_entry_mode ==
'free') {
1027 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1032 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
1037 if (empty($remise_percent)) {
1038 $remise_percent = 0;
1042 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1043 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1045 if (is_array($extralabelsline)) {
1047 foreach ($extralabelsline as $key => $value) {
1048 unset($_POST[
"options_" . $key]);
1052 $price_to_test_sign = ($price_ht ? $price_ht : $price_ttc);
1054 if ((empty($idprod) || $idprod < 0) && ($price_to_test_sign < 0) && ($qty < 0)) {
1055 $langs->load(
"errors");
1056 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1059 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1060 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1063 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
1064 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1068 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1073 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1077 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1078 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1082 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1083 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1087 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1088 $idprod = $res->fk_product_child;
1090 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1096 if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1104 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1115 if (!empty($idprod) && $idprod > 0) {
1117 $prod->fetch($idprod);
1129 $pu_ht =
$prod->price;
1130 $pu_ttc =
$prod->price_ttc;
1131 $price_min =
$prod->price_min;
1132 $price_min_ttc =
$prod->price_min_ttc;
1133 $price_base_type =
$prod->price_base_type;
1137 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1141 $filter = array(
't.fk_product' => (
string)
$prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1144 $pricebycustomerexist =
false;
1145 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1148 if (count($prodcustprice->lines) > 0) {
1149 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1150 foreach ($prodcustprice->lines as $k => $custprice_line) {
1151 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1152 $pricebycustomerexist =
true;
1153 $pu_ht =
price($custprice_line->price);
1154 $pu_ttc =
price($custprice_line->price_ttc);
1155 $price_min =
price($custprice_line->price_min);
1156 $price_min_ttc =
price($custprice_line->price_min_ttc);
1157 $price_base_type = $custprice_line->price_base_type;
1171 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
1174 if (!$pricebycustomerexist && !empty(
$object->thirdparty->price_level)) {
1175 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1176 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1177 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1178 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1179 $price_base_type =
$prod->multiprices_base_type[
$object->thirdparty->price_level];
1181 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1182 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1184 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1185 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1190 $pu_ht =
$prod->multiprices[
$object->thirdparty->price_level];
1191 $pu_ttc =
$prod->multiprices_ttc[
$object->thirdparty->price_level];
1192 $price_min =
$prod->multiprices_min[
$object->thirdparty->price_level];
1193 $price_min_ttc =
$prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1194 $price_base_type =
$prod->multiprices_base_type[
$object->thirdparty->price_level];
1196 if (isset(
$prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1197 $tva_tx =
$prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1199 if (isset(
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1200 $tva_npr =
$prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1205 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1209 $filter = array(
't.fk_product' => (
string)
$prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1211 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1214 if (count($prodcustprice->lines) > 0) {
1215 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1216 foreach ($prodcustprice->lines as $k => $custprice_line) {
1217 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1218 $pu_ht =
price($custprice_line->price);
1219 $pu_ttc =
price($custprice_line->price_ttc);
1220 $price_min =
price($custprice_line->price_min);
1221 $price_min_ttc =
price($custprice_line->price_min_ttc);
1222 $price_base_type = $custprice_line->price_base_type;
1236 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
1240 if (
$prod->prices_by_qty[0]) {
1245 foreach (
$prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1246 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1250 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1251 $pu_ht = $priceforthequantityarray[
'unitprice'];
1253 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1261 if (
$prod->prices_by_qty[
$object->thirdparty->price_level]) {
1265 foreach (
$prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1266 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1270 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1271 $pu_ht = $priceforthequantityarray[
'unitprice'];
1273 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1281 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1282 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string)
$prod->tva_tx));
1287 if (!empty($price_ht) || (string) $price_ht ===
'0') {
1288 $pu_ht = (float)
price2num($price_ht,
'MU');
1289 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1290 $price_base_type =
'HT';
1291 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1292 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1293 $pu_ttc_devise = (float)
price2num((
float) $pu_ht_devise * (1 + ((float) $tmpvat / 100)),
'MU');
1296 $price_base_type =
'HT';
1297 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1298 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1299 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1300 $price_base_type =
'TTC';
1301 } elseif (!empty($price_ttc_devise) || (
string) $price_ttc_devise ===
'0') {
1302 $pu_ttc_devise = (float)
price2num($price_ttc_devise,
'MU');
1303 $pu_ht_devise = (float)
price2num((
float) $pu_ttc_devise / (1 + ((float) $tmpvat / 100)),
'MU');
1306 $price_base_type =
'TTC';
1307 } elseif ($tmpvat != $tmpprodvat) {
1309 if ($price_base_type !=
'HT') {
1310 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1312 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1320 $outputlangs = $langs;
1322 if (
GETPOST(
'lang_id',
'aZ09')) {
1323 $newlang =
GETPOST(
'lang_id',
'aZ09');
1325 if (empty($newlang)) {
1326 $newlang =
$object->thirdparty->default_lang;
1328 if (!empty($newlang)) {
1330 $outputlangs->setDefaultLang($newlang);
1333 $desc = (!empty(
$prod->multilangs[$outputlangs->defaultlang][
"description"])) ?
$prod->multilangs[$outputlangs->defaultlang][
"description"] :
$prod->
description;
1335 $desc =
$prod->description;
1351 $outputlangs = $langs;
1353 if (
GETPOST(
'lang_id',
'alpha')) {
1354 $newlang =
GETPOST(
'lang_id',
'alpha');
1356 if (empty($newlang)) {
1357 $newlang =
$object->thirdparty->default_lang;
1359 if (!empty($newlang)) {
1361 $outputlangs->setDefaultLang($newlang);
1362 $outputlangs->load(
'products');
1364 if (!empty(
$prod->customcode)) {
1365 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1367 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1370 if (!empty(
$prod->country_code)) {
1371 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'', $db, $outputlangs, 0);
1374 if (!empty(
$prod->customcode)) {
1375 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' .
$prod->customcode;
1377 if (!empty(
$prod->customcode) && !empty(
$prod->country_code)) {
1380 if (!empty(
$prod->country_code)) {
1381 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry(
$prod->country_code,
'', $db, $langs, 0);
1388 $type =
$prod->type;
1389 $fk_unit =
$prod->fk_unit;
1393 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1394 $tva_tx = str_replace(
'*',
'', $tva_tx);
1395 if (empty($tva_tx)) {
1398 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1401 $fk_unit =
GETPOST(
'units',
'alpha');
1402 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1403 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1405 if ($pu_ttc && !$pu_ht) {
1406 $price_base_type =
'TTC';
1420 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1421 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1424 $pu_equivalent = $pu_ht;
1425 $pu_equivalent_ttc = $pu_ttc;
1427 $currency_tx =
$object->multicurrency_tx;
1431 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1432 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1434 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1435 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1452 if ($usermustrespectpricemin) {
1453 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1454 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1455 setEventMessages($mesg,
null,
'errors');
1457 } 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') {
1458 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1459 setEventMessages($mesg,
null,
'errors');
1466 $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);
1478 $outputlangs = $langs;
1479 $newlang =
GETPOST(
'lang_id',
'alpha');
1481 $newlang =
$object->thirdparty->default_lang;
1483 if (!empty($newlang)) {
1485 $outputlangs->setDefaultLang($newlang);
1488 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1491 unset($_POST[
'prod_entry_mode']);
1493 unset($_POST[
'qty']);
1494 unset($_POST[
'type']);
1495 unset($_POST[
'remise_percent']);
1496 unset($_POST[
'price_ht']);
1497 unset($_POST[
'multicurrency_price_ht']);
1498 unset($_POST[
'price_ttc']);
1499 unset($_POST[
'tva_tx']);
1500 unset($_POST[
'product_ref']);
1501 unset($_POST[
'product_label']);
1502 unset($_POST[
'product_desc']);
1503 unset($_POST[
'fournprice']);
1504 unset($_POST[
'buying_price']);
1505 unset($_POST[
'np_marginRate']);
1506 unset($_POST[
'np_markRate']);
1507 unset($_POST[
'dp_desc']);
1508 unset($_POST[
'idprod']);
1509 unset($_POST[
'units']);
1511 unset($_POST[
'date_starthour']);
1512 unset($_POST[
'date_startmin']);
1513 unset($_POST[
'date_startsec']);
1514 unset($_POST[
'date_startday']);
1515 unset($_POST[
'date_startmonth']);
1516 unset($_POST[
'date_startyear']);
1517 unset($_POST[
'date_endhour']);
1518 unset($_POST[
'date_endmin']);
1519 unset($_POST[
'date_endsec']);
1520 unset($_POST[
'date_endday']);
1521 unset($_POST[
'date_endmonth']);
1522 unset($_POST[
'date_endyear']);
1524 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
1533 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1536 $langs->load(
'subtotals');
1538 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1541 $subtotal_options = array();
1543 foreach (Commande::$TITLE_OPTIONS as $option) {
1544 $value =
GETPOST($option,
'alphanohtml');
1546 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1551 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1562 $outputlangs = $langs;
1563 $newlang =
GETPOST(
'lang_id',
'alpha');
1565 $newlang =
$object->thirdparty->default_lang;
1567 if (!empty($newlang)) {
1569 $outputlangs->setDefaultLang($newlang);
1572 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1577 } elseif ($action ==
'updatetextline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1580 $langs->load(
'subtotals');
1582 $desc =
GETPOST(
'line_desc',
'restricthtml');
1585 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, 0, array());
1596 $outputlangs = $langs;
1597 $newlang =
GETPOST(
'lang_id',
'alpha');
1599 $newlang =
$object->thirdparty->default_lang;
1601 if (!empty($newlang)) {
1603 $outputlangs->setDefaultLang($newlang);
1606 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1611 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1614 $langs->load(
'subtotals');
1616 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1619 $subtotal_options = array();
1621 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1622 $value =
GETPOST($option,
'alphanohtml');
1624 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1629 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1637 $outputlangs = $langs;
1638 $newlang =
GETPOST(
'lang_id',
'alpha');
1640 $newlang =
$object->thirdparty->default_lang;
1642 if (!empty($newlang)) {
1644 $outputlangs->setDefaultLang($newlang);
1647 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1652 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1665 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1670 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1671 $vat_rate = str_replace(
'*',
'', $vat_rate);
1683 $pu_equivalent = $pu_ht;
1684 $pu_equivalent_ttc = $pu_ttc;
1686 $currency_tx =
$object->multicurrency_tx;
1690 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1691 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1693 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1694 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1709 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1713 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1714 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1716 if (is_array($extralabelsline)) {
1717 foreach ($extralabelsline as $key => $value) {
1718 unset($_POST[
"options_" . $key]);
1734 $price_base_type =
'HT';
1735 if (empty($pu_ht) && !empty($pu_ttc)) {
1737 $price_base_type =
'TTC';
1738 } elseif (!empty($pu_ht) && !empty($pu_ttc)) {
1739 foreach (
$object->lines as $line_obj) {
1742 if ($line_obj->wasEnteredIncludingTax()) {
1744 $price_base_type =
'TTC';
1753 if (!empty($productid)) {
1755 $product->fetch($productid);
1757 $type = $product->type;
1759 $price_min = $product->price_min;
1761 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1763 $price_min_ttc = $product->price_min_ttc;
1765 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1771 if ($usermustrespectpricemin) {
1772 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1773 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1774 setEventMessages($mesg,
null,
'errors');
1776 $action =
'editline';
1777 } 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') {
1778 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1779 setEventMessages($mesg,
null,
'errors');
1781 $action =
'editline';
1786 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1790 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1792 $action =
'editline';
1797 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1799 $action =
'editline';
1804 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1805 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1807 $action =
'editline';
1814 if (!$user->hasRight(
'margins',
'creer')) {
1815 foreach (
$object->lines as &$line) {
1817 $fournprice = $line->fk_fournprice;
1818 $buyingprice = $line->pa_ht;
1824 $result =
$object->updateline(
GETPOSTINT(
'lineid'), $description, (
float) $pu, (
float) $qty, (
float) $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits,
$date_start, $date_end, $type,
GETPOSTINT(
'fk_parent_line'), 0, (
int) $fournprice, $buyingprice, $label, $special_code, $array_options,
GETPOSTINT(
'units'), (
float) $pu_ht_devise);
1832 $outputlangs = $langs;
1835 $newlang =
GETPOST(
'lang_id',
'aZ09');
1838 $newlang =
$object->thirdparty->default_lang;
1840 if (!empty($newlang)) {
1842 $outputlangs->setDefaultLang($newlang);
1846 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1849 unset($_POST[
'qty']);
1850 unset($_POST[
'type']);
1851 unset($_POST[
'productid']);
1852 unset($_POST[
'remise_percent']);
1853 unset($_POST[
'price_ht']);
1854 unset($_POST[
'multicurrency_price_ht']);
1855 unset($_POST[
'price_ttc']);
1856 unset($_POST[
'tva_tx']);
1857 unset($_POST[
'product_ref']);
1858 unset($_POST[
'product_label']);
1859 unset($_POST[
'product_desc']);
1860 unset($_POST[
'fournprice']);
1861 unset($_POST[
'buying_price']);
1863 unset($_POST[
'date_starthour']);
1864 unset($_POST[
'date_startmin']);
1865 unset($_POST[
'date_startsec']);
1866 unset($_POST[
'date_startday']);
1867 unset($_POST[
'date_startmonth']);
1868 unset($_POST[
'date_startyear']);
1869 unset($_POST[
'date_endhour']);
1870 unset($_POST[
'date_endmin']);
1871 unset($_POST[
'date_endsec']);
1872 unset($_POST[
'date_endday']);
1873 unset($_POST[
'date_endmonth']);
1874 unset($_POST[
'date_endyear']);
1881 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1882 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
1884 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1887 $qualified_for_stock_change = 0;
1889 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1891 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1896 if (!$idwarehouse || $idwarehouse == -1) {
1898 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1904 $locationTarget =
'';
1908 $result =
$object->valid($user, $idwarehouse);
1913 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1916 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1917 &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1919 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1922 $forceFields = array();
1931 setEventMessage(
'DepositGenerated');
1932 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1944 $outputlangs = $langs;
1947 $newlang =
GETPOST(
'lang_id',
'aZ09');
1950 $newlang =
$object->thirdparty->default_lang;
1952 if (!empty($newlang)) {
1954 $outputlangs->setDefaultLang($newlang);
1959 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1962 $deposit->fetch($deposit->id);
1963 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1967 if ($locationTarget) {
1968 header(
'Location: ' . $locationTarget);
1979 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1981 $idwarehouse =
GETPOST(
'idwarehouse');
1983 $qualified_for_stock_change = 0;
1985 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1987 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1992 if (!$idwarehouse || $idwarehouse == -1) {
1994 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
2000 $result =
$object->setDraft($user, $idwarehouse);
2004 $outputlangs = $langs;
2007 $newlang =
GETPOST(
'lang_id',
'aZ09');
2010 $newlang =
$object->thirdparty->default_lang;
2012 if (!empty($newlang)) {
2014 $outputlangs->setDefaultLang($newlang);
2019 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2025 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
2026 $result =
$object->cloture($user);
2030 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
2033 $qualified_for_stock_change = 0;
2035 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2037 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2042 if (!$idwarehouse || $idwarehouse == -1) {
2044 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
2050 $result =
$object->cancel($user, $idwarehouse);
2058 if ($action ==
'update_extras' && $permissiontoeditextra) {
2061 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2064 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2071 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
2079 $action =
'edit_extras';
2085 $fromElement =
GETPOST(
'fromelement');
2086 $fromElementid =
GETPOST(
'fromelementid');
2087 $importLines =
GETPOST(
'line_checkbox');
2089 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && preg_match(
'/^[a-zA-Z]+$/', $fromElement) && !empty($fromElementid)) {
2090 if ($fromElement ==
'commande') {
2091 dol_include_once(
'/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2092 $lineClassName =
'OrderLine';
2093 } elseif ($fromElement ==
'propal') {
2094 dol_include_once(
'/comm/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2095 $lineClassName =
'PropaleLigne';
2096 } elseif ($fromElement ==
'facture') {
2097 dol_include_once(
'/compta/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
2098 $lineClassName =
'FactureLigne';
2100 $nextRang = count(
$object->lines) + 1;
2103 foreach ($importLines as $lineId) {
2104 $lineId = intval($lineId);
2105 $originLine =
new $lineClassName($db);
2106 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2107 $originLine->fetch_optionals();
2108 $desc = $originLine->desc;
2109 $pu_ht = $originLine->subprice;
2110 $qty = $originLine->qty;
2111 $txtva = $originLine->tva_tx;
2112 $txlocaltax1 = $originLine->localtax1_tx;
2113 $txlocaltax2 = $originLine->localtax2_tx;
2114 $fk_product = $originLine->fk_product;
2115 $remise_percent = $originLine->remise_percent;
2117 $date_end = $originLine->date_end;
2118 $fk_code_ventilation = 0;
2119 $info_bits = $originLine->info_bits;
2120 $fk_remise_except = $originLine->fk_remise_except;
2121 $price_base_type =
'HT';
2123 $type = $originLine->product_type;
2124 $rang = $nextRang++;
2125 $special_code = $originLine->special_code;
2126 $origin = $originLine->element;
2127 $origin_id = $originLine->id;
2128 $fk_parent_line = 0;
2129 $fk_fournprice = $originLine->fk_fournprice;
2130 $pa_ht = $originLine->pa_ht;
2131 $label = $originLine->label;
2132 $array_options = $originLine->array_options;
2133 $situation_percent = 100;
2135 $fk_unit = $originLine->fk_unit;
2136 $pu_ht_devise = $originLine->multicurrency_subprice;
2138 $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);
2151 setEventMessages($langs->trans(
'ErrorsOnXLines', $error),
null,
'errors');
2157 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
2161 $permissiontoadd = $usercancreate;
2162 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
2165 $triggersendname =
'ORDER_SENTBYMAIL';
2167 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2168 $trackid =
'ord' .
$object->id;
2169 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
2173 if ($action ==
'addcontact') {
2177 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2181 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2184 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2185 $langs->load(
"errors");
2186 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2191 } elseif ($action ==
'swapstatut') {
2196 dol_print_error($db);
2198 } elseif ($action ==
'deletecontact') {
2200 $result =
$object->delete_contact($lineid);
2203 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2206 dol_print_error($db);
2217$title =
$object->ref .
" - " . $langs->trans(
'Card');
2218if ($action ==
'create') {
2219 $title = $langs->trans(
"NewOrder");
2221$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2223llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2225$form =
new Form($db);
2235if ($action ==
'create' && $usercancreate) {
2240 $res = $soc->fetch($socid);
2243 $currency_code =
$conf->currency;
2245 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2246 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2247 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2250 if (!empty($origin) && !empty($originid)) {
2254 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2255 $element = $regs[1];
2258 if ($element ==
'project') {
2259 $projectid = $originid;
2261 if (!$cond_reglement_id) {
2262 $cond_reglement_id = $soc->cond_reglement_id;
2264 if (!$deposit_percent) {
2265 $deposit_percent = $soc->deposit_percent;
2267 if (!$mode_reglement_id) {
2268 $mode_reglement_id = $soc->mode_reglement_id;
2270 if (!$remise_percent) {
2271 $remise_percent = $soc->remise_percent;
2275 $objectsrc = fetchObjectByElement($originid, $origin);
2277 if (is_object($objectsrc)) {
2278 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2279 $classname = get_class($objectsrc);
2281 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2282 $objectsrc->fetch_lines();
2284 $objectsrc->fetch_thirdparty();
2287 $objectsrc->fetch_optionals();
2288 $object->array_options = $objectsrc->array_options;
2290 $projectid = (int) $objectsrc->fk_project;
2291 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2293 $soc = $objectsrc->thirdparty;
2294 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2295 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2296 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2297 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2298 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2299 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2300 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2301 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2304 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2307 if (!empty($objectsrc->multicurrency_code)) {
2308 $currency_code = $objectsrc->multicurrency_code;
2310 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2311 $currency_tx = $objectsrc->multicurrency_tx;
2315 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2316 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2319 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2325 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2326 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2327 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2328 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2329 $availability_id = 0;
2330 $shipping_method_id = empty($soc->shipping_method_id) ? $shipping_method_id : $soc->shipping_method_id;
2331 $warehouse_id = $soc->fk_warehouse;
2332 $demand_reason_id = $soc->demand_reason_id;
2335 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2336 $currency_code = $soc->multicurrency_code;
2339 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2340 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2344 if (!
GETPOST(
'changecompany')) {
2346 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2352 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2360 if ($soc->fk_warehouse > 0) {
2361 $warehouse_id = $soc->fk_warehouse;
2368 $warehouse_id = $user->fk_warehouse;
2372 print
'<form name="crea_commande" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2373 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2374 print
'<input type="hidden" name="action" value="add">';
2375 print
'<input type="hidden" name="changecompany" value="0">';
2376 print
'<input type="hidden" name="remise_percent" value="' . $soc->remise_percent .
'">';
2377 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
2378 print
'<input type="hidden" name="originid" value="' . $originid .
'">';
2379 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
2380 if (!empty($currency_tx)) {
2381 print
'<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx .
'">';
2387 $parameters = array();
2389 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters, $object, $action);
2390 if (empty($reshook)) {
2391 print
'<table class="border centpercent">';
2398 print
'<td class="fieldrequired">' . $langs->trans(
'Customer') .
'</td>';
2401 print $soc->getNomUrl(1,
'customer');
2402 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
2405 print
'<td class="valuefieldcreate">';
2406 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2407 print img_picto(
'',
'company',
'class="pictofixedwidth"') . $form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2411 $(document).ready(function() {
2412 $("#socid").change(function() {
2413 console.log("We have changed the company - Reload page");
2414 var socid = $(this).val();
2416 $("input[name=action]").val("create");
2417 $("input[name=changecompany]").val("1");
2418 $("form[name=crea_commande]").submit();
2423 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>';
2426 print
'</tr>' .
"\n";
2431 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2432 print $langs->trans(
'RefProposal') .
'</td><td>';
2433 print
'<input type="text" name="ref_client" value="' . $ref_client .
'">';
2435 print $form->textwithpicto($langs->trans(
'RefCustomer'), $langs->trans(
'RefOfOnCustomerSide', $langs->transnoentitiesnoconv(
"Order"))) .
'</td><td>';
2436 print
'<input type="text" name="ref_client" value="' .
GETPOST(
'ref_client') .
'">';
2446 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_" . $type_contact_code));
2448 print img_picto(
'',
'contact',
'class="pictofixedwidth"');
2450 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2454 print
'<tr><td>' . $langs->trans(
'Discounts') .
'</td><td>';
2456 $absolute_discount = $soc->getAvailableDiscounts();
2460 $backtopage = $_SERVER[
"PHP_SELF"] .
'?socid=' . $thirdparty->id .
'&action=' . $action .
'&origin=' . urlencode((
string) (
GETPOST(
'origin'))) .
'&originid=' . urlencode((
string) (
GETPOSTINT(
'originid')));
2461 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
2469 print
'<tr><td class="fieldrequired">' . $langs->trans(
'Date') .
'</td><td>';
2470 print img_picto(
'',
'action',
'class="pictofixedwidth"');
2471 print $form->selectDate($dateorder,
're', 0, 0, 0,
"crea_commande", 1, 1);
2475 print
'<tr><td>' . $langs->trans(
"DateDeliveryPlanned") .
'</td>';
2476 print
'<td colspan="3">';
2477 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2478 print img_picto(
'',
'action',
'class="pictofixedwidth"');
2479 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2484 print
'<tr class="fielddeliverydelay"><td>' . $langs->trans(
'AvailabilityPeriod') .
'</td><td>';
2485 print img_picto(
'',
'clock',
'class="pictofixedwidth"');
2486 $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2490 print
'<tr><td class="nowrap">' . $langs->trans(
'PaymentConditionsShort') .
'</td><td>';
2491 print img_picto(
'',
'payment',
'class="pictofixedwidth"');
2492 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2496 print
'<tr><td>' . $langs->trans(
'PaymentMode') .
'</td><td>';
2497 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
2498 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2503 print
'<tr><td>' . $langs->trans(
'BankAccount') .
'</td><td>';
2504 print img_picto(
'',
'bank_account',
'class="pictofixedwidth"') . $form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2510 print
'<tr><td>' . $langs->trans(
'SendingMethod') .
'</td><td>';
2511 print img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2512 $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');
2518 print
'<tr><td>' . $langs->trans(
'Warehouse') .
'</td><td>';
2519 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');
2524 print
'<tr><td>' . $langs->trans(
'Source') .
'</td><td>';
2525 print img_picto(
'',
'question',
'class="pictofixedwidth"');
2526 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2533 $langs->load(
"projects");
2535 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2536 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');
2537 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>';
2545 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>';
2546 print
'<td class="maxwidthonsmartphone">';
2547 $incoterm_id =
GETPOST(
'incoterm_id');
2548 $location_incoterms =
GETPOST(
'location_incoterms');
2549 if (empty($incoterm_id)) {
2550 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2551 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2553 print img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2554 print $form->select_incoterms($incoterm_id, $location_incoterms);
2559 $parameters = array();
2560 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2561 $parameters[
'objectsrc'] = $objectsrc;
2563 $parameters[
'socid'] = $socid;
2566 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2567 print $hookmanager->resPrint;
2568 if (empty($reshook)) {
2569 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2572 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2573 if ($soc->fetch_optionals() > 0) {
2574 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2578 print
$object->showOptionals($extrafields,
'create', $parameters);
2582 include_once DOL_DOCUMENT_ROOT .
'/core/modules/commande/modules_commande.php';
2584 if (is_array($list) && count($list) > 0) {
2585 print
'<tr><td>' . $langs->trans(
'DefaultModel') .
'</td>';
2588 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2589 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2596 print
'<td>' . $form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0) .
'</td>';
2597 print
'<td class="maxwidthonsmartphone">';
2598 print img_picto(
'',
'currency',
'class="pictofixedwidth"') . $form->selectMultiCurrency(((
GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2604 print
'<tr><td>' . $langs->trans(
"Categories") .
'</td><td colspan="3">';
2605 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
2611 print
'<td class="tdtop">' . $langs->trans(
'NotePublic') .
'</td>';
2614 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2615 print $doleditor->Create(1);
2620 if (empty($user->socid)) {
2622 print
'<td class="tdtop">' . $langs->trans(
'NotePrivate') .
'</td>';
2625 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2626 print $doleditor->Create(1);
2631 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($classname)) {
2633 if ($origin ==
'contrat') {
2635 $objectsrc->update_price(1);
2638 print
"\n<!-- " . $classname .
" info -->\n";
2639 print
'<input type="hidden" name="amount" value="' . $objectsrc->total_ht .
'">' .
"\n";
2640 print
'<input type="hidden" name="total" value="' . $objectsrc->total_ttc .
'">' .
"\n";
2641 print
'<input type="hidden" name="tva" value="' . $objectsrc->total_tva .
'">' .
"\n";
2642 print
'<input type="hidden" name="origin" value="' . $objectsrc->element .
'">';
2643 print
'<input type="hidden" name="originid" value="' . $objectsrc->id .
'">';
2645 switch ($classname) {
2647 $newclassname =
'CommercialProposal';
2650 $newclassname =
'Order';
2653 $newclassname =
'Sending';
2656 $newclassname =
'Contract';
2659 $newclassname = $classname;
2662 print
'<tr><td>' . $langs->trans($newclassname) .
'</td><td>' . $objectsrc->getNomUrl(1) .
'</td></tr>';
2665 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td><td>' .
price($objectsrc->total_ht) .
'</td></tr>';
2666 print
'<tr><td>' . $langs->trans(
'AmountVAT') .
'</td><td>' .
price($objectsrc->total_tva) .
"</td></tr>";
2667 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2668 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax1) .
"</td></tr>";
2671 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2672 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax2) .
"</td></tr>";
2675 print
'<tr><td>' . $langs->trans(
'AmountTTC') .
'</td><td>' .
price($objectsrc->total_ttc) .
"</td></tr>";
2678 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
2679 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2680 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2691 print $form->buttonsSaveCancel(
"CreateDraft");
2694 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2695 $title = $langs->trans(
'ProductsAndServices');
2698 print
'<div class="div-table-responsive-no-min">';
2699 print
'<table class="noborder centpercent">';
2701 $objectsrc->printOriginLinesList(
'', $selectedLines);
2713 $product_static =
new Product($db);
2718 $author =
new User($db);
2719 $author->fetch(
$object->user_author_id);
2722 $res =
$object->fetch_optionals();
2725 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2730 if ($action ==
'delete') {
2731 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2735 if ($action ==
'validate') {
2737 $ref = substr(
$object->ref, 1, 4);
2738 if ($ref ==
'PROV' || $ref ==
'') {
2739 $numref =
$object->getNextNumRef($soc);
2740 if (empty($numref)) {
2745 $numref = (string)
$object->ref;
2748 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2750 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
2751 $notify =
new Notify($db);
2753 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid, $object);
2756 $qualified_for_stock_change = 0;
2758 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2760 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2763 $formquestion = array();
2765 $langs->load(
"stocks");
2767 if (
$conf->browser->name ==
'ie') {
2770 $formquestion = array(
2774 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0, $langs->trans(
"NoStockAction"), 0, $forcecombo))
2780 foreach (
$object->lines as $line) {
2781 $res = $line->fetch_product();
2783 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2789 if ($nbMandated > 0) {
2791 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2794 $text .=
'<div><span class="clearboth nowraponall warning">' . img_warning() . $langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate") .
'</span></div>';
2798 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2803 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2805 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2806 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2810 $eligibleForDepositGeneration =
true;
2812 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2813 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2814 '@phan-var-force Facture $invoice';
2816 $eligibleForDepositGeneration =
false;
2822 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2823 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2824 $proposal->fetchObjectLinked();
2826 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2827 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2828 '@phan-var-force Facture $invoice';
2830 $eligibleForDepositGeneration =
false;
2838 if ($eligibleForDepositGeneration) {
2839 $formquestion[] = array(
2840 'type' =>
'checkbox',
2842 'name' =>
'generate_deposit',
2843 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2846 $formquestion[] = array(
2848 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2850 'label' => $langs->trans(
'DateInvoice'),
2856 $formquestion[] = array(
2858 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2859 'name' =>
'date_pointoftax',
2860 'label' => $langs->trans(
'DatePointOfTax'),
2866 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2868 $formquestion[] = array(
2870 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2871 'name' =>
'cond_reglement_id',
2872 'label' => $langs->trans(
'PaymentTerm'),
2873 'value' => $paymentTermsSelect
2876 $formquestion[] = array(
2877 'type' =>
'checkbox',
2878 'tdclass' =>
'showonlyifgeneratedeposit',
2879 'name' =>
'validate_generated_deposit',
2880 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2883 $formquestion[] = array(
2884 'type' =>
'onecolumn',
2887 $(document).ready(function() {
2888 $("[name=generate_deposit]").change(function () {
2889 let $self = $(this);
2890 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2892 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2909 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2914 if ($action ==
'modif') {
2915 $qualified_for_stock_change = 0;
2917 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2919 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2922 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2923 $formquestion = array();
2925 $langs->load(
"stocks");
2927 if (
$conf->browser->name ==
'ie') {
2936 'name' =>
'idwarehouse',
2937 'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
2938 'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo)
2943 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2947 if ($action ==
'shipped') {
2948 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2953 if ($action ==
'cancel' || $action ==
'delete') {
2954 $qualified_for_stock_change = 0;
2956 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2958 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2961 if ($action ==
'cancel') {
2962 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2963 $title = $langs->trans(
"Cancel");
2964 $confirmaction =
'confirm_cancel';
2966 $text = $langs->trans(
'ConfirmDeleteOrder',
$object->ref);
2967 $title = $langs->trans(
'DeleteOrder');
2968 $confirmaction =
'confirm_delete';
2971 $formquestion = array();
2973 $langs->load(
"stocks");
2975 if (
$conf->browser->name ==
'ie') {
2978 $formquestion = array(
2982 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2986 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $title, $text, $confirmaction, $formquestion, 0, 1);
2990 if ($action ==
'ask_deleteline') {
2991 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2995 if ($action ==
'ask_subtotal_deleteline') {
2996 $langs->load(
"subtotals");
2997 $title =
"DeleteSubtotalLine";
2998 $question =
"ConfirmDeleteSubtotalLine";
2999 if (
GETPOST(
'type') ==
'title') {
3000 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
3001 $title =
"DeleteTitleLine";
3002 $question =
"ConfirmDeleteTitleLine";
3004 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
3008 if ($action ==
'clone') {
3009 $filter =
'(s.client:IN:1,2,3)';
3011 $formquestion = array(
3012 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
3014 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
3018 if ($action ==
'add_title_line') {
3019 $langs->load(
'subtotals');
3021 $depth_array =
$object->getPossibleLevels($langs);
3022 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
3023 } elseif ($action ==
'add_subtotal_line') {
3024 $langs->load(
'subtotals');
3026 $titles =
$object->getPossibleTitles();
3027 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
3028 } elseif ($action ==
'add_text_line') {
3029 $langs->load(
'subtotals');
3031 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
3035 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3037 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3038 if (empty($reshook)) {
3039 $formconfirm .= $hookmanager->resPrint;
3040 } elseif ($reshook > 0) {
3041 $formconfirm = $hookmanager->resPrint;
3050 $linkback =
'<a href="' . DOL_URL_ROOT .
'/commande/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
3052 $morehtmlref =
'<div class="refidno">';
3054 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client, $object, (
int) $usercancreate,
'string',
'', 0, 1);
3055 $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);
3057 $morehtmlref .=
'<br>' . $soc->getNomUrl(1,
'customer');
3059 $morehtmlref .=
' (<a href="' . DOL_URL_ROOT .
'/commande/list.php?socid=' . ((int)
$object->thirdparty->id) .
'">' . $langs->trans(
"OtherOrders") .
'</a>)';
3063 $langs->load(
"projects");
3064 $morehtmlref .=
'<br>';
3065 if ($usercancreate) {
3066 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3067 if ($action !=
'classify') {
3068 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
3070 $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');
3072 if (!empty(
$object->fk_project)) {
3074 $proj->fetch(
$object->fk_project);
3075 $morehtmlref .= $proj->getNomUrl(1);
3077 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
3082 $morehtmlref .=
'</div>';
3084 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3087 $parameters = array();
3089 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters, $object, $action);
3090 if (empty($reshook)) {
3091 print
'<div class="fichecenter">';
3092 print
'<div class="fichehalfleft">';
3093 print
'<div class="underbanner clearboth"></div>';
3095 print
'<table class="border tableforfield centpercent">';
3099 $langs->load(
"cashdesk");
3100 print
'<tr><td class="fieldname_type">';
3101 print
'<table class="nobordernopadding centpercent"><tr><td>';
3102 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3104 if ($action !=
'editposinfo' && $usercancreate) {
3105 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>';
3107 print
'</tr></table>';
3108 print
'</td><td class="valuefield fieldname_type">';
3109 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" name="formposinfo">';
3110 print
'<input type="hidden" name="action" value="setposinfo">';
3111 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3112 if ($action ==
'editposinfo') {
3113 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="' . $langs->trans(
"POSModule") .
'" value="' .
$object->module_source .
'"> ';
3114 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="' . $langs->trans(
"Terminal") .
'" value="' .
$object->pos_source .
'">';
3115 print
'<input type="submit" class="button" name="submitposinfo" value="' . $langs->trans(
"Submit") .
'">';
3118 print
'<span class="opacitymediumbycolor paddingleft">' . dolPrintHTML(ucfirst(
$object->module_source) .
' - ' . $langs->transnoentitiesnoconv(
"Terminal") .
' ' .
$object->pos_source) .
'</span>';
3125 if ($soc->outstanding_limit) {
3127 print
'<tr><td class="titlefield">';
3128 print $langs->trans(
'OutstandingBill');
3129 print
'</td><td class="valuefield">';
3130 $arrayoutstandingbills = $soc->getOutstandingBills();
3131 print
price($arrayoutstandingbills[
'opened']) .
' / ';
3132 print
price($soc->outstanding_limit, 0,
'', 1, -1, -1,
$conf->currency);
3139 $filterabsolutediscount =
"fk_facture_source IS NULL";
3140 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3142 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3143 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3146 $addrelativediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remise.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditRelativeDiscounts") .
'</a>';
3147 $addabsolutediscount =
'<a href="' . DOL_URL_ROOT .
'/comm/remx.php?id=' . $soc->id .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"]) .
'?facid=' .
$object->id .
'">' . $langs->trans(
"EditGlobalDiscounts") .
'</a>';
3148 $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>';
3150 print
'<tr><td class="titlefield">' . $langs->trans(
'Discounts') .
'</td><td class="valuefield">';
3152 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3153 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3154 $absolute_discount =
price2num($absolute_discount,
'MT');
3155 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3159 $backtopage = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id;
3160 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
3167 print $form->editfieldkey(
"Date",
'date',
'', $object, (
int) $editenable);
3168 print
'</td><td class="valuefield">';
3169 if ($action ==
'editdate') {
3170 print
'<form name="setdate" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3171 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3172 print
'<input type="hidden" name="action" value="setdate">';
3173 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3174 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3175 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3180 print
' ' . img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3188 $editenable = $usercancreate;
3189 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, (
int) $editenable);
3190 print
'</td><td class="valuefield">';
3191 if ($action ==
'editdate_livraison') {
3192 print
'<form name="setdate_livraison" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3193 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3194 print
'<input type="hidden" name="action" value="setdate_livraison">';
3195 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3196 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3197 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3202 print
' ' . img_picto($langs->trans(
"Late") .
' : ' .
$object->showDelay(),
"warning");
3207 $shippableInfos =
$object->getShippableInfos();
3209 if (!empty($shippableInfos[
'has_product'])) {
3211 print $form->textwithtooltip(
'', $shippableInfos[
'textinfo'], 2, 1, $shippableInfos[
'texticon'],
'', 2);
3213 if (!empty($shippableInfos[
'warning'])) {
3215 print $form->textwithtooltip(
'', $langs->trans(
"NotEnoughForAllOrders"), 2, 1, img_picto(
'',
'error',
'', 0, 0, 0,
'',
'2'),
'', 2);
3223 print
'<tr class="fielddeliverydelay"><td>';
3224 $editenable = $usercancreate;
3225 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, (
int) $editenable);
3226 print
'</td><td class="valuefield">';
3227 if ($action ==
'editavailability') {
3228 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3230 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'none', 1);
3237 $editenable = $usercancreate;
3238 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, (
int) $editenable);
3239 print
'</td><td class="valuefield">';
3240 if ($action ==
'editshippingmethod') {
3241 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3243 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'none');
3251 $langs->load(
'stocks');
3253 $editenable = $usercancreate;
3254 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, (
int) $editenable);
3255 print
'</td><td class="valuefield">';
3256 if ($action ==
'editwarehouse') {
3257 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3259 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'none');
3267 $editenable = $usercancreate;
3268 print $form->editfieldkey(
"Source",
'demandreason',
'', $object, (
int) $editenable);
3269 print
'</td><td class="valuefield">';
3270 if ($action ==
'editdemandreason') {
3271 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3273 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'none');
3279 $editenable = $usercancreate;
3280 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, (
int) $editenable);
3281 print
'</td><td class="valuefield">';
3282 if ($action ==
'editconditions') {
3283 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3285 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3293 $editenable = $usercancreate;
3294 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, (
int) $editenable);
3295 print
'</td><td class="valuefield">';
3296 if ($action ==
'editmode') {
3297 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3299 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
3317 $tmparray =
$object->getTotalWeightVolume();
3318 $totalWeight = $tmparray[
'weight'];
3319 $totalVolume = $tmparray[
'volume'];
3321 print
'<tr><td>' . $langs->trans(
"CalculatedWeight") .
'</td>';
3322 print
'<td class="valuefield">';
3327 print
'<tr><td>' . $langs->trans(
"CalculatedVolume") .
'</td>';
3328 print
'<td class="valuefield">';
3338 $editenable = $usercancreate;
3339 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, (
int) $editenable);
3341 print
'<td class="valuefield">';
3342 if ($action !=
'editincoterm') {
3343 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3345 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3353 $editenable = $usercancreate;
3354 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, (
int) $editenable);
3355 print
'</td><td class="valuefield">';
3356 if ($action ==
'editbankaccount') {
3357 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3359 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
3368 print
'<table class="nobordernopadding centpercent"><tr><td>';
3369 print $langs->trans(
"Categories");
3370 print
'<td><td class="right">';
3371 if ($usercancreate) {
3372 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/commande/card.php?id=' .
$object->id .
'&action=edittags&token=' .
newToken() .
'">' . img_edit() .
'</a>';
3376 print
'</td></tr></table>';
3379 if ($action ==
'edittags') {
3380 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
3381 print
'<input type="hidden" name="action" value="settags">';
3382 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3383 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories', $object);
3384 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
3387 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3393 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3398 print
'<div class="fichehalfright">';
3399 print
'<div class="underbanner clearboth"></div>';
3401 print
'<table class="border tableforfield centpercent">';
3403 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_currency_amount.tpl.php';
3407 $alert =
' ' . img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3411 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3412 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3415 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3420 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3421 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3424 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3429 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3431 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
3432 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3436 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3442 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3444 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
3445 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3449 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3455 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3456 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3459 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3461 print
'</tr>' .
"\n";
3470 $formmargin->displayMarginInfos($object);
3477 print
'<div class="clearboth"></div><br>';
3480 $blocname =
'contacts';
3481 $title = $langs->trans(
'ContactsAddresses');
3482 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3486 $blocname =
'notes';
3487 $title = $langs->trans(
'Notes');
3488 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3496 $result =
$object->getLinesArray();
3500 global $inputalsopricewithtax;
3501 $inputalsopricewithtax = 1;
3503 print
'<form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="POST">
3504 <input type="hidden" name="token" value="' .
newToken() .
'">
3505 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
3506 <input type="hidden" name="mode" value="">
3507 <input type="hidden" name="page_y" value="">
3508 <input type="hidden" name="id" value="' .
$object->id .
'">
3509 <input type="hidden" name="backtopage" value="' . $backtopage .
'">
3514 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
3516 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3520 print
'<div class="div-table-responsive-no-min">';
3521 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3525 $object->printObjectLines($action,
$mysoc, $soc, $lineid, 1);
3532 if ($action !=
'editline') {
3535 $parameters = array();
3537 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3539 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
3541 if (empty($reshook)) {
3545 $parameters = array();
3546 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3560 if ($action !=
'presend' && $action !=
'editline') {
3561 print
'<div class="tabsAction">';
3563 $parameters = array();
3564 $arrayforbutaction = array();
3566 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3567 if (empty($reshook)) {
3568 $numlines = count(
$object->lines);
3572 print dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'reopen',
'id' =>
$object->id],
true),
'');
3576 if (empty($user->socid)) {
3579 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'presend',
'id' =>
$object->id,
'mode' =>
'init'],
true) .
'#formmailbeforetitle',
'');
3581 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3589 $langs->load(
'subtotals');
3591 $url_button = array();
3593 $url_button[] = array(
3594 'lang' =>
'subtotals',
3596 'perm' => (
bool) $usercancreate,
3597 'label' => $langs->trans(
'AddTitleLine'),
3598 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_title_line&token=' .
newToken()
3601 $url_button[] = array(
3602 'lang' =>
'subtotals',
3604 'perm' => (
bool) $usercancreate,
3605 'label' => $langs->trans(
'AddSubtotalLine'),
3606 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_subtotal_line&token=' .
newToken()
3609 $url_button[] = array(
3610 'lang' =>
'subtotals',
3612 'perm' => (
bool) $usercancreate,
3613 'label' => $langs->trans(
'AddTextLine'),
3614 'url' =>
'/commande/card.php?id=' .
$object->id .
'&action=add_text_line&token=' .
newToken()
3616 print dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
3621 if ($numlines > 0) {
3622 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'validate',
'id' =>
$object->id],
true),
'action-validate', 1);
3624 $langs->load(
"errors");
3625 print dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'validate',
'id' =>
$object->id],
true),
'action-validate', -1);
3630 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'modif',
'id' =>
$object->id],
true),
'action-modif');
3636 $arrayforbutaction[] = array(
3639 'perm' => $usercancreatepurchaseorder,
3640 'label' =>
'AddPurchaseOrder',
3641 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3653 $arrayforbutaction[] = array(
3654 'lang' =>
'interventions',
3656 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3657 'label' =>
'AddIntervention',
3658 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3664 $arrayforbutaction[] = [
3665 'lang' =>
'contracts',
3667 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3668 'label' =>
'AddContract',
3669 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3684 $numshipping =
$object->countNbOfShipments();
3687 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3689 $arrayforbutaction[] = array(
3690 'lang' =>
'sendings',
3692 'perm' => $user->hasRight(
'expedition',
'creer'),
3693 'label' =>
'CreateShipment',
3694 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3699 $arrayforbutaction[] = array(
3700 'lang' =>
'sendings',
3703 'label' =>
'CreateShipment',
3704 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3711 $arrayforbutaction[] = array(
3714 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3715 'label' =>
'CreateBill',
3716 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3725 $actionButtonsParameters = [
3726 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3729 if ($numlines > 0) {
3730 print dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3732 print dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3737 print dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'shipped',
'id' =>
$object->id],
true),
'');
3744 print dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'classifybilled',
'id' =>
$object->id],
true),
'');
3749 print dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'classifyunbilled',
'id' =>
$object->id],
true),
'',
true, array(
'attr' => array(
'classOverride' =>
'butAction butActionDanger'))).
"\n";
3754 if ($usercancreate) {
3755 print dolGetButtonAction($langs->trans(
'ToClone'), $langs->trans(
'ToClone'),
'clone',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'clone',
'id' =>
$object->id,
'socid' =>
$object->socid],
true),
'',
true, array(
'attr' => array(
'class' =>
'reposition')));
3760 print
'<a class="butActionDelete" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=cancel&token=' .
newToken() .
'">' . $langs->trans(
"CancelOrder") .
'</a>';
3764 if ($usercandelete) {
3766 if ($numshipping == 0 && !$stocksent) {
3767 print dolGetButtonAction($langs->trans(
'Delete'), $langs->trans(
'Delete'),
'delete',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'delete',
'id' =>
$object->id],
true),
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
3769 print dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'] .
'#',
'',
false);
3777 if (
GETPOST(
'modelselected')) {
3778 $action =
'presend';
3781 if ($action !=
'presend') {
3782 print
'<div class="fichecenter"><div class="fichehalfleft">';
3783 print
'<a name="builddoc"></a>';
3786 $relativepath = $objref .
'/' . $objref .
'.pdf';
3787 $filedir =
$conf->commande->multidir_output[
$object->entity ??
$conf->entity] .
'/' . $objref;
3789 $genallowed = $usercanread;
3790 $delallowed = $usercancreate;
3791 $tooltipAfterComboOfModels =
'';
3793 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_ORDER_TERMSOFSALE'));
3796 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);
3800 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'order'), 1);
3801 $linktoelem = $tmparray[
'linktoelem'];
3802 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3803 print $htmltoenteralink;
3805 $compatibleImportElementsList =
false;
3810 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3812 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3816 include_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3817 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3818 $useonlinepayment = count($validpaymentmethod);
3821 $useonlinepayment = 0;
3824 print
'<br><!-- Link to pay -->';
3825 require_once DOL_DOCUMENT_ROOT .
'/core/lib/payments.lib.php';
3826 print showOnlinePaymentUrl(
'order',
$object->ref) .
'<br>';
3832 print
'<br><!-- Link to sign -->';
3833 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
3834 print showOnlineSignatureUrl(
'order',
$object->ref, $object) .
'<br>';
3837 print
'</div><div class="fichehalfright">';
3842 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/messaging.php', [
'id' =>
$object->id]));
3843 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dolBuildUrl(DOL_URL_ROOT .
'/commande/agenda.php', [
'id' =>
$object->id]));
3846 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
3848 $somethingshown = $formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3850 print
'</div></div>';
3854 $modelmail =
'order_send';
3855 $defaulttopic =
'SendOrderRef';
3857 $trackid =
'ord' .
$object->id;
3859 include DOL_DOCUMENT_ROOT .
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage a WYSIWYG editor.
static createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger=0, $autoValidateDeposit=false, $overrideFields=array())
Creates a deposit from a proposal or an order by grouping lines by VAT rates.
const TYPE_DEPOSIT
Deposit invoice.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class ProductCombination Used to represent the relation between a product and one of its variants.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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_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.
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.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.