42require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
56if (isModEnabled(
"propal")) {
57 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
60if (isModEnabled(
'project')) {
61 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
65if (isModEnabled(
'variants')) {
66 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
80$langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'deliveries',
'products',
'other'));
82if (isModEnabled(
'incoterm')) {
83 $langs->load(
'incoterm');
85if (isModEnabled(
'margin')) {
86 $langs->load(
'margins');
88if (isModEnabled(
'productbatch')) {
89 $langs->load(
'productbatch');
96$action =
GETPOST(
'action',
'aZ09');
97$cancel =
GETPOST(
'cancel',
'alpha');
98$confirm =
GETPOST(
'confirm',
'alpha');
99$backtopage =
GETPOST(
'backtopage',
'alpha');
104$origin =
GETPOST(
'origin',
'alpha');
117if (!empty($user->socid)) {
118 $socid = $user->socid;
123$price_base_type =
null;
124$lineClassName =
null;
125$remise_percent =
null;
127$availability_id =
null;
128$shipping_method_id =
null;
130$demand_reason_id =
null;
137$hookmanager->initHooks(array(
'ordercard',
'globalcard'));
143$extrafields->fetch_name_optionals_label(
$object->table_element);
146include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
151$usercanread = $user->hasRight(
"commande",
"lire");
152$usercancreate = $user->hasRight(
"commande",
"creer");
153$usercandelete = $user->hasRight(
"commande",
"supprimer");
156$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'close')));
157$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'validate')));
158$usercancancel = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'annuler')));
159$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'send'));
160$usercangeneretedoc = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
162$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
163$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
165$permissionnote = $usercancreate;
166$permissiondellink = $usercancreate;
167$permissiontoadd = $usercancreate;
168$permissiontoeditextra = $usercancreate;
169if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
171 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
178$selectedLines = array();
185$parameters = array(
'socid' => $socid);
187$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
192if (empty($reshook)) {
193 $backurlforlist = DOL_URL_ROOT.
'/commande/list.php';
195 if (empty($backtopage) || ($cancel && empty($id))) {
196 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
197 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
198 $backtopage = $backurlforlist;
200 $backtopage = DOL_URL_ROOT.
'/commande/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
205 $selectedLines =
GETPOST(
'toselect',
'array');
208 if (!empty($backtopageforcancel)) {
209 header(
"Location: ".$backtopageforcancel);
211 } elseif (!empty($backtopage)) {
212 header(
"Location: ".$backtopage);
218 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
220 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
222 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
225 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
227 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
233 $result = $objectutil->createFromClone($user, $socid);
235 $warningMsgLineList = array();
237 foreach (
$object->lines as $line) {
238 if (!is_object($line->product)) {
239 $line->fetch_product();
241 if (is_object($line->product) && $line->product->id > 0) {
242 if (empty($line->product->status)) {
243 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
247 if (!empty($warningMsgLineList)) {
251 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
259 } elseif ($action ==
'reopen' && $usercancreate) {
264 $result =
$object->setDraft($user, $idwarehouse);
269 $result =
$object->set_reopen($user);
277 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
279 $result =
$object->delete($user);
281 header(
'Location: list.php?restore_lastsearch_values=1');
286 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
288 $result =
$object->deleteLine($user, $lineid);
293 $outputlangs = $langs;
296 $newlang =
GETPOST(
'lang_id',
'aZ09');
299 $newlang =
$object->thirdparty->default_lang;
301 if (!empty($newlang)) {
303 $outputlangs->setDefaultLang($newlang);
307 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
310 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
315 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
316 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
321 $outputlangs = $langs;
324 $newlang =
GETPOST(
'lang_id',
'aZ09');
327 $newlang =
$object->thirdparty->default_lang;
329 if (!empty($newlang)) {
331 $outputlangs->setDefaultLang($newlang);
335 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
338 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
343 } elseif ($action ==
'classin' && $usercancreate) {
346 } elseif ($action ==
'add' && $usercancreate) {
351 if ($datecommande ==
'') {
352 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
358 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
369 $object->date_commande = $datecommande;
382 $object->delivery_date = $date_delivery;
388 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
389 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
393 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
400 if (!empty($origin) && !empty($originid)) {
402 $element = $subelement = $origin;
404 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
405 $element = $regs [1];
406 $subelement = $regs [2];
410 if ($element ==
'order') {
411 $element = $subelement =
'commande';
413 if ($element ==
'propal') {
414 $element =
'comm/propal';
415 $subelement =
'propal';
417 if ($element ==
'contract') {
418 $element = $subelement =
'contrat';
422 $object->origin_type = $origin;
423 $object->origin_id = $originid;
427 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
428 if (!empty($other_linked_objects)) {
429 $object->linked_objects = array_merge(
$object->linked_objects, $other_linked_objects);
433 $object_id =
$object->create($user);
435 if ($object_id > 0) {
438 $classname = ucfirst($subelement);
439 $srcobject =
new $classname($db);
440 '@phan-var-force Commande|Propal|Contrat $srcobject';
443 $result = $srcobject->fetch(
$object->origin_id);
445 $lines = $srcobject->lines;
446 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
447 $srcobject->fetch_lines();
448 $lines = $srcobject->lines;
452 $num = count($lines);
454 for ($i = 0; $i < $num; $i++) {
455 if (!in_array($lines[$i]->
id, $selectedLines)) {
459 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
460 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
461 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
465 $date_start = $lines[$i]->date_debut_prevue;
466 if ($lines[$i]->date_debut_reel) {
467 $date_start = $lines[$i]->date_debut_reel;
469 if ($lines[$i]->date_start) {
470 $date_start = $lines[$i]->date_start;
472 $date_end = $lines[$i]->date_fin_prevue;
473 if ($lines[$i]->date_fin_reel) {
474 $date_end = $lines[$i]->date_fin_reel;
476 if ($lines[$i]->date_end) {
477 $date_end = $lines[$i]->date_end;
481 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
486 if (method_exists($lines[$i],
'fetch_optionals')) {
487 $lines[$i]->fetch_optionals();
488 $array_options = $lines[$i]->array_options;
491 $tva_tx = $lines[$i]->tva_tx;
492 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
493 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
498 $lines[$i]->subprice,
501 $lines[$i]->localtax1_tx,
502 $lines[$i]->localtax2_tx,
503 $lines[$i]->fk_product,
504 $lines[$i]->remise_percent,
505 $lines[$i]->info_bits,
506 $lines[$i]->fk_remise_except,
513 $lines[$i]->special_code,
515 $lines[$i]->fk_fournprice,
532 foreach (
$object->lines as $line) {
533 if ($line->id == $result) {
534 $line->extraparams = $lines[$i]->extraparams;
535 $line->setExtraParameters();
540 if ($result > 0 && $lines[$i]->product_type == 9) {
541 $fk_parent_line = $result;
575 $parameters = array(
'objFrom' => $srcobject);
577 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
592 $object_id =
$object->create($user);
597 if ($object_id > 0) {
600 $result =
$object->add_contact(
GETPOSTINT(
'contactid'), $type_contact_code,
'external');
611 if (isModEnabled(
'category')) {
612 $categories =
GETPOST(
'categories',
'array');
613 if (method_exists(
$object,
'setCategories')) {
614 $object->setCategories($categories);
619 if ($object_id > 0 && !$error) {
621 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object_id);
629 } elseif ($action ==
'classifybilled' && $usercancreate) {
630 $ret =
$object->classifyBilled($user);
635 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
636 $ret =
$object->classifyUnBilled($user);
640 } elseif ($action ==
'setref_client' && $usercancreate) {
646 } elseif ($action ==
'setremise' && $usercancreate) {
651 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
659 } elseif ($action ==
'setdate' && $usercancreate) {
662 $result =
$object->set_date($user, $date);
666 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
670 $result =
$object->setDeliveryDate($user, $date_delivery);
674 } elseif ($action ==
'setmode' && $usercancreate) {
679 } elseif ($action ==
'setposinfo' && $usercancreate) {
683 $result =
$object->update($user);
687 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
689 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
690 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
693 } elseif ($action ==
'setavailability' && $usercancreate) {
698 } elseif ($action ==
'setdemandreason' && $usercancreate) {
703 } elseif ($action ==
'setconditions' && $usercancreate) {
710 $outputlangs = $langs;
711 $newlang =
GETPOST(
'lang_id',
'alpha');
713 $newlang =
$object->thirdparty->default_lang;
715 if (!empty($newlang)) {
717 $outputlangs->setDefaultLang($newlang);
721 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
724 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
730 } elseif ($action ==
'setbankaccount' && $usercancreate) {
736 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
742 } elseif ($action ==
'setwarehouse' && $usercancreate) {
752 } elseif ($action ==
'settags' && isModEnabled(
'category') && $usercancreate) {
757 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
758 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
759 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
760 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
761 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
762 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
763 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
767 foreach (
$object->lines as $line) {
768 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
771 if ($line->product_type == 1) {
772 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
'HT', $line->info_bits, $alldate_start, $alldate_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
775 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
777 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
778 $vat_rate = str_replace(
'*',
'', $vat_rate);
781 foreach (
$object->lines as $line) {
782 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
785 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate,
'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
787 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
789 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
790 $remise_percent = str_replace(
'*',
'', $remise_percent);
791 foreach (
$object->lines as $line) {
792 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
795 $tvatx = $line->tva_tx;
796 if (!empty($line->vat_src_code)) {
797 $tvatx .=
' ('.$line->vat_src_code.
')';
799 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, (
float) $remise_percent, $tvatx, $line->localtax1_tx, $line->localtax2_tx,
'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
801 } elseif ($action ==
'addline' && $usercancreate && (
802 (
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines',
'alpha') !==
'') ||
803 (
GETPOST(
'submitforallmark',
'alpha') &&
GETPOST(
'markforalllines',
'alpha') !==
''))) {
806 $margin_rate = GETPOSTISSET(
'marginforalllines') ?
GETPOST(
'marginforalllines',
'int') :
'';
807 $mark_rate = GETPOSTISSET(
'markforalllines') ?
GETPOST(
'markforalllines',
'int') :
'';
808 foreach (
$object->lines as &$line)
if ($line->subprice > 0) {
809 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
812 $subprice_multicurrency = $line->subprice;
813 if (is_numeric($margin_rate) && $margin_rate > 0) {
814 $line->subprice = floatval(
price2num(floatval($line->pa_ht) * (1 + floatval($margin_rate) / 100),
'MU'));
815 } elseif (is_numeric($mark_rate) && $mark_rate > 0) {
816 $line->subprice = floatval($line->pa_ht / (1 - (floatval($mark_rate) / 100)));
818 $line->subprice = floatval($line->pa_ht);
822 $res = $prod->fetch($line->fk_product);
824 if ($prod->price_min > $line->subprice) {
825 $price_subprice =
price($line->subprice, 0, $outlangs, 1, -1, -1,
'auto');
826 $price_price_min =
price($prod->price_min, 0, $outlangs, 1, -1, -1,
'auto');
827 setEventMessages($prod->ref .
' - ' . $prod->label .
' (' . $price_subprice .
' < ' . $price_price_min .
' ' . strtolower($langs->trans(
"MinPrice")) .
')' .
"\n",
null,
'warnings');
831 } elseif ($line->fk_product) {
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;
858 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
861 $langs->load(
'subtotals');
863 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
864 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
866 $subtotal_options = array();
868 foreach (Commande::$TITLE_OPTIONS as $option) {
869 $value =
GETPOST($option,
'alphanohtml');
871 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
876 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
887 $outputlangs = $langs;
888 $newlang =
GETPOST(
'lang_id',
'alpha');
890 $newlang =
$object->thirdparty->default_lang;
892 if (!empty($newlang)) {
894 $outputlangs->setDefaultLang($newlang);
897 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
902 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
904 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
907 $langs->load(
'subtotals');
909 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
910 foreach (
$object->lines as $line) {
911 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
913 $depth = -$line->qty;
917 $subtotal_options = array();
919 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
920 $value =
GETPOST($option,
'alphanohtml');
922 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
927 if (isset($desc) && isset($depth)) {
928 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
930 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
933 if (isset($result) && $result >= 0) {
939 $outputlangs = $langs;
940 $newlang =
GETPOST(
'lang_id',
'alpha');
942 $newlang =
$object->thirdparty->default_lang;
944 if (!empty($newlang)) {
946 $outputlangs->setDefaultLang($newlang);
949 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
954 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
956 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && $usercancreate) {
957 $langs->load(
'errors');
962 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
965 $price_ht_devise =
'';
967 $price_ttc_devise =
'';
969 if (
GETPOST(
'price_ht') !==
'') {
972 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
975 if (
GETPOST(
'price_ttc') !==
'') {
978 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
982 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
983 if ($prod_entry_mode ==
'free') {
989 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
994 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
998 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
999 if (empty($remise_percent)) {
1000 $remise_percent = 0;
1004 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1005 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1007 if (is_array($extralabelsline)) {
1009 foreach ($extralabelsline as $key => $value) {
1010 unset($_POST[
"options_".$key]);
1014 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
1015 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1018 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1019 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1022 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
1023 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1027 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1031 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1034 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1035 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1039 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1040 if ($combinations =
GETPOST(
'combinations',
'array')) {
1044 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1045 $idprod = $res->fk_product_child;
1047 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1053 if (!$error && ($qty >= 0) && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1061 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1072 if (!empty($idprod) && $idprod > 0) {
1074 $prod->fetch($idprod);
1076 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
1086 $pu_ht = $prod->price;
1087 $pu_ttc = $prod->price_ttc;
1088 $price_min = $prod->price_min;
1089 $price_min_ttc = $prod->price_min_ttc;
1090 $price_base_type = $prod->price_base_type;
1094 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1098 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1101 $pricebycustomerexist =
false;
1102 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1105 if (count($prodcustprice->lines) > 0) {
1106 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1107 foreach ($prodcustprice->lines as $k => $custprice_line) {
1108 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1109 $pricebycustomerexist =
true;
1110 $pu_ht =
price($custprice_line->price);
1111 $pu_ttc =
price($custprice_line->price_ttc);
1112 $price_min =
price($custprice_line->price_min);
1113 $price_min_ttc =
price($custprice_line->price_min_ttc);
1114 $price_base_type = $custprice_line->price_base_type;
1131 if (!$pricebycustomerexist && !empty(
$object->thirdparty->price_level)) {
1132 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1133 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1134 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1135 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1138 $price_base_type = (empty($prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' : $prod->multiprices_base_type[
$object->thirdparty->price_level]);
1140 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1141 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1143 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1144 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1149 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1150 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1151 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1152 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1155 $price_base_type = (empty($prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' : $prod->multiprices_base_type[
$object->thirdparty->price_level]);
1157 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1158 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1160 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1161 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1166 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1170 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1172 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1175 if (count($prodcustprice->lines) > 0) {
1176 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1177 foreach ($prodcustprice->lines as $k => $custprice_line) {
1178 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1179 $pu_ht =
price($custprice_line->price);
1180 $pu_ttc =
price($custprice_line->price_ttc);
1181 $price_min =
price($custprice_line->price_min);
1182 $price_min_ttc =
price($custprice_line->price_min_ttc);
1183 $price_base_type = $custprice_line->price_base_type;
1201 if ($prod->prices_by_qty[0]) {
1206 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1207 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1211 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1212 $pu_ht = $priceforthequantityarray[
'unitprice'];
1214 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1222 if ($prod->prices_by_qty[
$object->thirdparty->price_level]) {
1226 foreach ($prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1227 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1231 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1232 $pu_ht = $priceforthequantityarray[
'unitprice'];
1234 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1242 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1243 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
1246 if (!empty($price_ht) || (string) $price_ht ===
'0') {
1247 $pu_ht = (float)
price2num($price_ht,
'MU');
1248 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1249 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1250 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1253 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1254 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1255 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1256 } elseif ($tmpvat != $tmpprodvat) {
1258 if ($price_base_type !=
'HT') {
1259 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1261 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1269 $outputlangs = $langs;
1271 if (
GETPOST(
'lang_id',
'aZ09')) {
1272 $newlang =
GETPOST(
'lang_id',
'aZ09');
1274 if (empty($newlang)) {
1275 $newlang =
$object->thirdparty->default_lang;
1277 if (!empty($newlang)) {
1279 $outputlangs->setDefaultLang($newlang);
1282 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1284 $desc = $prod->description;
1296 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1300 $outputlangs = $langs;
1302 if (
GETPOST(
'lang_id',
'alpha')) {
1303 $newlang =
GETPOST(
'lang_id',
'alpha');
1305 if (empty($newlang)) {
1306 $newlang =
$object->thirdparty->default_lang;
1308 if (!empty($newlang)) {
1310 $outputlangs->setDefaultLang($newlang);
1311 $outputlangs->load(
'products');
1313 if (!empty($prod->customcode)) {
1314 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1316 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1319 if (!empty($prod->country_code)) {
1320 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
1323 if (!empty($prod->customcode)) {
1324 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1326 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1329 if (!empty($prod->country_code)) {
1330 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $langs, 0);
1337 $type = $prod->type;
1338 $fk_unit = $prod->fk_unit;
1342 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1343 $tva_tx = str_replace(
'*',
'', $tva_tx);
1344 if (empty($tva_tx)) {
1347 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1350 $fk_unit =
GETPOST(
'units',
'alpha');
1351 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1352 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1354 if ($pu_ttc && !$pu_ht) {
1355 $price_base_type =
'TTC';
1369 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1370 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1373 $pu_equivalent = $pu_ht;
1374 $pu_equivalent_ttc = $pu_ttc;
1376 $currency_tx =
$object->multicurrency_tx;
1383 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1384 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1386 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1387 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1407 if ($usermustrespectpricemin) {
1408 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1409 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1412 } 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') {
1413 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1421 $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);
1433 $outputlangs = $langs;
1434 $newlang =
GETPOST(
'lang_id',
'alpha');
1436 $newlang =
$object->thirdparty->default_lang;
1438 if (!empty($newlang)) {
1440 $outputlangs->setDefaultLang($newlang);
1443 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1446 unset($_POST[
'prod_entry_mode']);
1448 unset($_POST[
'qty']);
1449 unset($_POST[
'type']);
1450 unset($_POST[
'remise_percent']);
1451 unset($_POST[
'price_ht']);
1452 unset($_POST[
'multicurrency_price_ht']);
1453 unset($_POST[
'price_ttc']);
1454 unset($_POST[
'tva_tx']);
1455 unset($_POST[
'product_ref']);
1456 unset($_POST[
'product_label']);
1457 unset($_POST[
'product_desc']);
1458 unset($_POST[
'fournprice']);
1459 unset($_POST[
'buying_price']);
1460 unset($_POST[
'np_marginRate']);
1461 unset($_POST[
'np_markRate']);
1462 unset($_POST[
'dp_desc']);
1463 unset($_POST[
'idprod']);
1464 unset($_POST[
'units']);
1466 unset($_POST[
'date_starthour']);
1467 unset($_POST[
'date_startmin']);
1468 unset($_POST[
'date_startsec']);
1469 unset($_POST[
'date_startday']);
1470 unset($_POST[
'date_startmonth']);
1471 unset($_POST[
'date_startyear']);
1472 unset($_POST[
'date_endhour']);
1473 unset($_POST[
'date_endmin']);
1474 unset($_POST[
'date_endsec']);
1475 unset($_POST[
'date_endday']);
1476 unset($_POST[
'date_endmonth']);
1477 unset($_POST[
'date_endyear']);
1485 } elseif ($action ==
'updatetitleline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1488 $langs->load(
'subtotals');
1490 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1493 $subtotal_options = array();
1495 foreach (Commande::$TITLE_OPTIONS as $option) {
1496 $value =
GETPOST($option,
'alphanohtml');
1498 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1503 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1514 $outputlangs = $langs;
1515 $newlang =
GETPOST(
'lang_id',
'alpha');
1517 $newlang =
$object->thirdparty->default_lang;
1519 if (!empty($newlang)) {
1521 $outputlangs->setDefaultLang($newlang);
1524 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1529 } elseif ($action ==
'updatesubtotalline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1532 $langs->load(
'subtotals');
1534 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1537 $subtotal_options = array();
1539 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1540 $value =
GETPOST($option,
'alphanohtml');
1542 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1547 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1555 $outputlangs = $langs;
1556 $newlang =
GETPOST(
'lang_id',
'alpha');
1558 $newlang =
$object->thirdparty->default_lang;
1560 if (!empty($newlang)) {
1562 $outputlangs->setDefaultLang($newlang);
1565 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1570 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1583 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1588 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1589 $vat_rate = str_replace(
'*',
'', $vat_rate);
1601 $pu_equivalent = $pu_ht;
1602 $pu_equivalent_ttc = $pu_ttc;
1604 $currency_tx =
$object->multicurrency_tx;
1611 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1612 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1614 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1615 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1630 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1634 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1635 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1637 if (is_array($extralabelsline)) {
1638 foreach ($extralabelsline as $key => $value) {
1639 unset($_POST[
"options_".$key]);
1652 $price_base_type =
'HT';
1653 if (empty($pu) && !empty($pu_ttc)) {
1655 $price_base_type =
'TTC';
1660 if (!empty($productid)) {
1662 $product->fetch($productid);
1664 $type = $product->type;
1666 $price_min = $product->price_min;
1668 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1670 $price_min_ttc = $product->price_min_ttc;
1672 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1678 if ($usermustrespectpricemin) {
1679 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1680 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1683 $action =
'editline';
1684 } 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') {
1685 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1688 $action =
'editline';
1693 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1697 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1699 $action =
'editline';
1704 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1706 $action =
'editline';
1711 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1712 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1714 $action =
'editline';
1721 if (!$user->hasRight(
'margins',
'creer')) {
1722 foreach (
$object->lines as &$line) {
1724 $fournprice = $line->fk_fournprice;
1725 $buyingprice = $line->pa_ht;
1733 $result =
$object->updateline(
GETPOSTINT(
'lineid'), $description, (
float) $pu, (
float) $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type,
GETPOSTINT(
'fk_parent_line'), 0, (
int) $fournprice, $buyingprice, $label, $special_code, $array_options,
GETPOSTINT(
'units'), (
float) $pu_ht_devise);
1740 $outputlangs = $langs;
1743 $newlang =
GETPOST(
'lang_id',
'aZ09');
1746 $newlang =
$object->thirdparty->default_lang;
1748 if (!empty($newlang)) {
1750 $outputlangs->setDefaultLang($newlang);
1754 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1757 unset($_POST[
'qty']);
1758 unset($_POST[
'type']);
1759 unset($_POST[
'productid']);
1760 unset($_POST[
'remise_percent']);
1761 unset($_POST[
'price_ht']);
1762 unset($_POST[
'multicurrency_price_ht']);
1763 unset($_POST[
'price_ttc']);
1764 unset($_POST[
'tva_tx']);
1765 unset($_POST[
'product_ref']);
1766 unset($_POST[
'product_label']);
1767 unset($_POST[
'product_desc']);
1768 unset($_POST[
'fournprice']);
1769 unset($_POST[
'buying_price']);
1771 unset($_POST[
'date_starthour']);
1772 unset($_POST[
'date_startmin']);
1773 unset($_POST[
'date_startsec']);
1774 unset($_POST[
'date_startday']);
1775 unset($_POST[
'date_startmonth']);
1776 unset($_POST[
'date_startyear']);
1777 unset($_POST[
'date_endhour']);
1778 unset($_POST[
'date_endmin']);
1779 unset($_POST[
'date_endsec']);
1780 unset($_POST[
'date_endday']);
1781 unset($_POST[
'date_endmonth']);
1782 unset($_POST[
'date_endyear']);
1789 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1790 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1792 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1795 $qualified_for_stock_change = 0;
1797 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1799 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1803 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1804 if (!$idwarehouse || $idwarehouse == -1) {
1806 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1812 $locationTarget =
'';
1816 $result =
$object->valid($user, $idwarehouse);
1821 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1824 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1825 && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1827 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1830 $forceFields = array();
1832 if (GETPOSTISSET(
'date_pointoftax')) {
1840 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1852 $outputlangs = $langs;
1855 $newlang =
GETPOST(
'lang_id',
'aZ09');
1858 $newlang =
$object->thirdparty->default_lang;
1860 if (!empty($newlang)) {
1862 $outputlangs->setDefaultLang($newlang);
1867 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1870 $deposit->fetch($deposit->id);
1871 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1875 if ($locationTarget) {
1876 header(
'Location: ' . $locationTarget);
1887 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1889 $idwarehouse =
GETPOST(
'idwarehouse');
1891 $qualified_for_stock_change = 0;
1893 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1895 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1899 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1900 if (!$idwarehouse || $idwarehouse == -1) {
1902 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1908 $result =
$object->setDraft($user, $idwarehouse);
1912 $outputlangs = $langs;
1915 $newlang =
GETPOST(
'lang_id',
'aZ09');
1918 $newlang =
$object->thirdparty->default_lang;
1920 if (!empty($newlang)) {
1922 $outputlangs->setDefaultLang($newlang);
1927 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1933 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1934 $result =
$object->cloture($user);
1938 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercancancel) {
1941 $qualified_for_stock_change = 0;
1943 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1945 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1949 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1950 if (!$idwarehouse || $idwarehouse == -1) {
1952 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1958 $result =
$object->cancel($idwarehouse);
1966 if ($action ==
'update_extras' && $permissiontoeditextra) {
1969 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1972 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1979 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
1987 $action =
'edit_extras';
1993 $fromElement =
GETPOST(
'fromelement');
1994 $fromElementid =
GETPOST(
'fromelementid');
1995 $importLines =
GETPOST(
'line_checkbox');
1997 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && preg_match(
'/^[a-zA-Z]+$/', $fromElement) && !empty($fromElementid)) {
1998 if ($fromElement ==
'commande') {
2000 $lineClassName =
'OrderLine';
2001 } elseif ($fromElement ==
'propal') {
2002 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
2003 $lineClassName =
'PropaleLigne';
2004 } elseif ($fromElement ==
'facture') {
2005 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
2006 $lineClassName =
'FactureLigne';
2008 $nextRang = count(
$object->lines) + 1;
2011 foreach ($importLines as $lineId) {
2012 $lineId = intval($lineId);
2013 $originLine =
new $lineClassName($db);
2014 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2015 $originLine->fetch_optionals();
2016 $desc = $originLine->desc;
2017 $pu_ht = $originLine->subprice;
2018 $qty = $originLine->qty;
2019 $txtva = $originLine->tva_tx;
2020 $txlocaltax1 = $originLine->localtax1_tx;
2021 $txlocaltax2 = $originLine->localtax2_tx;
2022 $fk_product = $originLine->fk_product;
2023 $remise_percent = $originLine->remise_percent;
2024 $date_start = $originLine->date_start;
2025 $date_end = $originLine->date_end;
2026 $fk_code_ventilation = 0;
2027 $info_bits = $originLine->info_bits;
2028 $fk_remise_except = $originLine->fk_remise_except;
2029 $price_base_type =
'HT';
2031 $type = $originLine->product_type;
2032 $rang = $nextRang++;
2033 $special_code = $originLine->special_code;
2034 $origin = $originLine->element;
2035 $origin_id = $originLine->id;
2036 $fk_parent_line = 0;
2037 $fk_fournprice = $originLine->fk_fournprice;
2038 $pa_ht = $originLine->pa_ht;
2039 $label = $originLine->label;
2040 $array_options = $originLine->array_options;
2041 $situation_percent = 100;
2043 $fk_unit = $originLine->fk_unit;
2044 $pu_ht_devise = $originLine->multicurrency_subprice;
2046 $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);
2065 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2068 $upload_dir = !empty(
$conf->commande->multidir_output[
$object->entity]) ?
$conf->commande->multidir_output[
$object->entity] :
$conf->commande->dir_output;
2069 $permissiontoadd = $usercancreate;
2070 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2073 $triggersendname =
'ORDER_SENTBYMAIL';
2075 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2076 $trackid =
'ord'.$object->id;
2077 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2081 if ($action ==
'addcontact' && $usercancreate) {
2085 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2089 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2092 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2093 $langs->load(
"errors");
2094 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2099 } elseif ($action ==
'swapstatut' && $usercancreate) {
2106 } elseif ($action ==
'deletecontact' && $usercancreate) {
2108 $result =
$object->delete_contact($lineid);
2111 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2125$title =
$object->ref.
" - ".$langs->trans(
'Card');
2126if ($action ==
'create') {
2127 $title = $langs->trans(
"NewOrder");
2129$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2131llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2133$form =
new Form($db);
2137if (isModEnabled(
'project')) {
2142if ($action ==
'create' && $usercancreate) {
2147 $res = $soc->fetch($socid);
2152 $currency_code =
$conf->currency;
2154 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2155 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2156 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2159 if (!empty($origin) && !empty($originid)) {
2161 $element = $subelement = $origin;
2163 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2164 $element = $regs[1];
2165 $subelement = $regs[2];
2168 if ($element ==
'project') {
2169 $projectid = $originid;
2171 if (!$cond_reglement_id) {
2172 $cond_reglement_id = $soc->cond_reglement_id;
2174 if (!$deposit_percent) {
2175 $deposit_percent = $soc->deposit_percent;
2177 if (!$mode_reglement_id) {
2178 $mode_reglement_id = $soc->mode_reglement_id;
2180 if (!$remise_percent) {
2181 $remise_percent = $soc->remise_percent;
2189 if ($element ==
'order' || $element ==
'commande') {
2190 $element = $subelement =
'commande';
2191 } elseif ($element ==
'propal') {
2192 $element =
'comm/propal';
2193 $subelement =
'propal';
2194 } elseif ($element ==
'contract') {
2195 $element = $subelement =
'contrat';
2200 $classname = ucfirst($subelement);
2201 $objectsrc =
new $classname($db);
2202 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2203 $objectsrc->fetch($originid);
2204 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2205 $objectsrc->fetch_lines();
2207 $objectsrc->fetch_thirdparty();
2210 $objectsrc->fetch_optionals();
2211 $object->array_options = $objectsrc->array_options;
2213 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2214 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2216 $soc = $objectsrc->thirdparty;
2217 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2218 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2219 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2220 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2221 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2222 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2223 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2224 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2229 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2231 if (isModEnabled(
"multicurrency")) {
2232 if (!empty($objectsrc->multicurrency_code)) {
2233 $currency_code = $objectsrc->multicurrency_code;
2235 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2236 $currency_tx = $objectsrc->multicurrency_tx;
2240 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2241 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2244 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2247 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2248 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2249 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2250 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2251 $availability_id = 0;
2252 $shipping_method_id = empty($soc->shipping_method_id) ? $shipping_method_id : $soc->shipping_method_id;
2253 $warehouse_id = $soc->fk_warehouse;
2254 $demand_reason_id = $soc->demand_reason_id;
2259 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2260 $currency_code = $soc->multicurrency_code;
2263 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2264 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2268 if (!
GETPOST(
'changecompany')) {
2269 if (GETPOSTISSET(
'cond_reglement_id')) {
2270 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2272 if (GETPOSTISSET(
'deposit_percent')) {
2275 if (GETPOSTISSET(
'mode_reglement_id')) {
2276 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2278 if (GETPOSTISSET(
'cond_reglement_id')) {
2284 if ($soc->fk_warehouse > 0) {
2285 $warehouse_id = $soc->fk_warehouse;
2287 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2292 $warehouse_id = $user->fk_warehouse;
2296 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2297 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2298 print
'<input type="hidden" name="action" value="add">';
2299 print
'<input type="hidden" name="changecompany" value="0">';
2300 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
2301 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2302 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2303 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2304 if (!empty($currency_tx)) {
2305 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2311 $parameters = array();
2313 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters,
$object, $action);
2314 if (empty($reshook)) {
2315 print
'<table class="border centpercent">';
2318 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
2321 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
2322 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2323 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
2325 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
2331 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
2334 print $soc->getNomUrl(1,
'customer');
2335 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
2338 print
'<td class="valuefieldcreate">';
2339 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2340 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2344 $(document).ready(function() {
2345 $("#socid").change(function() {
2346 console.log("We have changed the company - Reload page");
2347 var socid = $(this).val();
2349 $("input[name=action]").val("create");
2350 $("input[name=changecompany]").val("1");
2351 $("form[name=crea_commande]").submit();
2356 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>';
2366 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_".$type_contact_code));
2368 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2370 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2374 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2376 $absolute_discount = $soc->getAvailableDiscounts();
2380 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode((
string) (
GETPOST(
'origin'))).
'&originid='.urlencode((
string) (
GETPOSTINT(
'originid')));
2381 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2387 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
2388 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2389 print $form->selectDate(
'',
're', 0, 0, 0,
"crea_commande", 1, 1);
2393 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
2394 print
'<td colspan="3">';
2395 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2396 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2397 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2402 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
2403 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2404 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2408 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2409 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2410 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2414 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2415 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2416 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2420 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
2421 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2422 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2427 if (isModEnabled(
'shipping')) {
2428 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
2429 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2430 $form->selectShippingMethod(((GETPOSTISSET(
'shipping_method_id') &&
GETPOSTINT(
'shipping_method_id') > 0) ?
GETPOST(
'shipping_method_id') : $shipping_method_id),
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
2435 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2436 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2438 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
2439 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses((GETPOSTISSET(
'warehouse_id') ?
GETPOST(
'warehouse_id') : $warehouse_id),
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2444 print
'<tr><td>'.$langs->trans(
'Source').
'</td><td>';
2445 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2446 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2452 if (isModEnabled(
'project')) {
2453 $langs->load(
"projects");
2455 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2456 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects((($soc->id > 0 && !
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_CUSTOMERS')) ? $soc->id : -1), (GETPOSTISSET(
'projectid') ?
GETPOST(
'projectid') : $projectid),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2457 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$soc->id.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$soc->id).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
2463 if (isModEnabled(
'incoterm')) {
2465 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? (
string) $objectsrc->fk_incoterms : (string) $soc->fk_incoterms, 1).
'</label></td>';
2466 print
'<td class="maxwidthonsmartphone">';
2467 $incoterm_id =
GETPOST(
'incoterm_id');
2468 $location_incoterms =
GETPOST(
'location_incoterms');
2469 if (empty($incoterm_id)) {
2470 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2471 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2473 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2474 print $form->select_incoterms($incoterm_id, $location_incoterms);
2479 $parameters = array();
2480 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2481 $parameters[
'objectsrc'] = $objectsrc;
2483 $parameters[
'socid'] = $socid;
2486 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2487 print $hookmanager->resPrint;
2488 if (empty($reshook)) {
2489 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2492 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2493 if ($soc->fetch_optionals() > 0) {
2494 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2498 print
$object->showOptionals($extrafields,
'create', $parameters);
2502 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2504 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2507 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2508 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2512 if (isModEnabled(
"multicurrency")) {
2514 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'',
$object, 0).
'</td>';
2515 print
'<td class="maxwidthonsmartphone">';
2516 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2521 if (!empty(
$conf->categorie->enabled)) {
2522 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2523 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories',
$object);
2529 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2532 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2533 print $doleditor->Create(1);
2538 if (empty($user->socid)) {
2540 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2543 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2544 print $doleditor->Create(1);
2549 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2551 if ($origin ==
'contrat') {
2555 $objectsrc->update_price(1);
2558 print
"\n<!-- ".$classname.
" info -->";
2560 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2561 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2562 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2563 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2564 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2566 switch ($classname) {
2568 $newclassname =
'CommercialProposal';
2571 $newclassname =
'Order';
2574 $newclassname =
'Sending';
2577 $newclassname =
'Contract';
2580 $newclassname = $classname;
2583 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2586 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2587 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2588 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2589 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2592 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2593 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2596 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2598 if (isModEnabled(
"multicurrency")) {
2599 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
2600 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2601 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2612 print $form->buttonsSaveCancel(
"CreateDraft");
2615 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2616 $title = $langs->trans(
'ProductsAndServices');
2619 print
'<div class="div-table-responsive-no-min">';
2620 print
'<table class="noborder centpercent">';
2622 $objectsrc->printOriginLinesList(
'', $selectedLines);
2634 $product_static =
new Product($db);
2639 $author =
new User($db);
2640 $author->fetch(
$object->user_author_id);
2643 $res =
$object->fetch_optionals();
2646 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order', 0,
'',
'', 0,
'', 1);
2651 if ($action ==
'delete') {
2652 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2656 if ($action ==
'validate') {
2658 $ref = substr(
$object->ref, 1, 4);
2659 if ($ref ==
'PROV' || $ref ==
'') {
2660 $numref =
$object->getNextNumRef($soc);
2661 if (empty($numref)) {
2669 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2670 if (isModEnabled(
'notification')) {
2671 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2672 $notify =
new Notify($db);
2674 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid,
$object);
2677 $qualified_for_stock_change = 0;
2679 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2681 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2684 $formquestion = array();
2685 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2686 $langs->load(
"stocks");
2687 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2690 if (
$conf->browser->name ==
'ie') {
2693 $formquestion = array(
2697 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2703 foreach (
$object->lines as $line) {
2704 $res = $line->fetch_product();
2706 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2712 if ($nbMandated > 0) {
2714 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2717 $text .=
'<div><span class="clearboth nowraponall warning">'.img_warning().$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2721 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2726 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2728 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2729 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2733 $eligibleForDepositGeneration =
true;
2735 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2736 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2737 '@phan-var-force Facture $invoice';
2739 $eligibleForDepositGeneration =
false;
2745 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2746 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2747 $proposal->fetchObjectLinked();
2749 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2750 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2751 '@phan-var-force Facture $invoice';
2753 $eligibleForDepositGeneration =
false;
2761 if ($eligibleForDepositGeneration) {
2762 $formquestion[] = array(
2763 'type' =>
'checkbox',
2765 'name' =>
'generate_deposit',
2766 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2769 $formquestion[] = array(
2771 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2773 'label' => $langs->trans(
'DateInvoice'),
2779 $formquestion[] = array(
2781 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2782 'name' =>
'date_pointoftax',
2783 'label' => $langs->trans(
'DatePointOfTax'),
2790 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2792 $formquestion[] = array(
2794 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2795 'name' =>
'cond_reglement_id',
2796 'label' => $langs->trans(
'PaymentTerm'),
2797 'value' => $paymentTermsSelect
2800 $formquestion[] = array(
2801 'type' =>
'checkbox',
2802 'tdclass' =>
'showonlyifgeneratedeposit',
2803 'name' =>
'validate_generated_deposit',
2804 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2807 $formquestion[] = array(
2808 'type' =>
'onecolumn',
2811 $(document).ready(function() {
2812 $("[name=generate_deposit]").change(function () {
2813 let $self = $(this);
2814 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2816 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2833 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2838 if ($action ==
'modif') {
2839 $qualified_for_stock_change = 0;
2841 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2843 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2846 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2847 $formquestion = array();
2848 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2849 $langs->load(
"stocks");
2850 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2853 if (
$conf->browser->name ==
'ie') {
2856 $formquestion = array(
2860 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2864 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2868 if ($action ==
'shipped') {
2869 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2873 if ($action ==
'cancel') {
2874 $qualified_for_stock_change = 0;
2876 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2878 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2881 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2882 $formquestion = array();
2883 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2884 $langs->load(
"stocks");
2885 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2888 if (
$conf->browser->name ==
'ie') {
2891 $formquestion = array(
2895 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2899 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2903 if ($action ==
'ask_deleteline') {
2904 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2908 if ($action ==
'ask_subtotal_deleteline') {
2909 $langs->load(
"subtotals");
2910 $title =
"DeleteSubtotalLine";
2911 $question =
"ConfirmDeleteSubtotalLine";
2912 if (
GETPOST(
'type') ==
'title') {
2913 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2914 $title =
"DeleteTitleLine";
2915 $question =
"ConfirmDeleteTitleLine";
2917 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2921 if ($action ==
'clone') {
2922 $filter =
'(s.client:IN:1,2,3)';
2924 $formquestion = array(
2925 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2927 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2931 if ($action ==
'add_title_line') {
2932 $langs->load(
'subtotals');
2934 $depth_array =
$object->getPossibleLevels($langs);
2936 } elseif ($action ==
'add_subtotal_line') {
2937 $langs->load(
'subtotals');
2939 $titles =
$object->getPossibleTitles();
2944 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2946 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2947 if (empty($reshook)) {
2948 $formconfirm .= $hookmanager->resPrint;
2949 } elseif ($reshook > 0) {
2950 $formconfirm = $hookmanager->resPrint;
2959 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2961 $morehtmlref =
'<div class="refidno">';
2963 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, (
int) $usercancreate,
'string',
'', 0, 1);
2964 $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);
2966 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2968 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2971 if (isModEnabled(
'project')) {
2972 $langs->load(
"projects");
2973 $morehtmlref .=
'<br>';
2974 if ($usercancreate) {
2975 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2976 if ($action !=
'classify') {
2977 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2979 $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');
2981 if (!empty(
$object->fk_project)) {
2983 $proj->fetch(
$object->fk_project);
2984 $morehtmlref .= $proj->getNomUrl(1);
2986 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2991 $morehtmlref .=
'</div>';
2994 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2997 $parameters = array();
2999 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters,
$object, $action);
3000 if (empty($reshook)) {
3001 print
'<div class="fichecenter">';
3002 print
'<div class="fichehalfleft">';
3003 print
'<div class="underbanner clearboth"></div>';
3005 print
'<table class="border tableforfield centpercent">';
3009 $langs->load(
"cashdesk");
3010 print
'<tr><td class="fieldname_type">';
3011 print
'<table class="nobordernopadding centpercent"><tr><td>';
3012 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3014 if ($action !=
'editposinfo' && $usercancreate) {
3015 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>';
3017 print
'</tr></table>';
3018 print
'</td><td class="valuefield fieldname_type">';
3019 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" name="formposinfo">';
3020 print
'<input type="hidden" name="action" value="setposinfo">';
3021 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3022 if ($action ==
'editposinfo') {
3023 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="'.$langs->trans(
"POSModule").
'" value="'.
$object->module_source.
'"> ';
3024 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="'.$langs->trans(
"Terminal").
'" value="'.
$object->pos_source.
'">';
3025 print
'<input type="submit" class="button" name="submitposinfo" value="'.$langs->trans(
"Submit").
'">';
3028 print
'<span class="opacitymediumbycolor paddingleft">'.dolPrintHTML(ucfirst(
$object->module_source).
' - '.$langs->transnoentitiesnoconv(
"Terminal").
' '.
$object->pos_source).
'</span>';
3035 if ($soc->outstanding_limit) {
3037 print
'<tr><td class="titlefield">';
3038 print $langs->trans(
'OutstandingBill');
3039 print
'</td><td class="valuefield">';
3040 $arrayoutstandingbills = $soc->getOutstandingBills();
3041 print
price($arrayoutstandingbills[
'opened']).
' / ';
3042 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1,
$conf->currency);
3049 $filterabsolutediscount =
"fk_facture_source IS NULL";
3050 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3052 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3053 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3056 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
3057 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
3058 $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>';
3060 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
3062 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3063 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3064 $absolute_discount =
price2num($absolute_discount,
'MT');
3065 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3069 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id;
3070 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3077 print $form->editfieldkey(
"Date",
'date',
'',
$object, (
int) $editenable);
3078 print
'</td><td class="valuefield">';
3079 if ($action ==
'editdate') {
3080 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
3081 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3082 print
'<input type="hidden" name="action" value="setdate">';
3083 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3084 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3085 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
3090 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
3098 $editenable = $usercancreate;
3099 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'',
$object, (
int) $editenable);
3100 print
'</td><td class="valuefield">';
3101 if ($action ==
'editdate_livraison') {
3102 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
3103 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3104 print
'<input type="hidden" name="action" value="setdate_livraison">';
3105 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3106 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3107 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
3112 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
3119 print
'<tr class="fielddeliverydelay"><td>';
3120 $editenable = $usercancreate;
3121 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'',
$object, (
int) $editenable);
3122 print
'</td><td class="valuefield">';
3123 if ($action ==
'editavailability') {
3124 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3126 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->availability_id,
'none', 1);
3131 if (isModEnabled(
'shipping')) {
3133 $editenable = $usercancreate;
3134 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'',
$object, (
int) $editenable);
3135 print
'</td><td class="valuefield">';
3136 if ($action ==
'editshippingmethod') {
3137 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3139 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->shipping_method_id,
'none');
3146 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
3147 $langs->load(
'stocks');
3148 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3151 $editenable = $usercancreate;
3152 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, (
int) $editenable);
3153 print
'</td><td class="valuefield">';
3154 if ($action ==
'editwarehouse') {
3155 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3157 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'none');
3165 $editenable = $usercancreate;
3166 print $form->editfieldkey(
"Source",
'demandreason',
'',
$object, (
int) $editenable);
3167 print
'</td><td class="valuefield">';
3168 if ($action ==
'editdemandreason') {
3169 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3171 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->demand_reason_id,
'none');
3177 $editenable = $usercancreate;
3178 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'',
$object, (
int) $editenable);
3179 print
'</td><td class="valuefield">';
3180 if ($action ==
'editconditions') {
3181 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3183 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3191 $editenable = $usercancreate;
3192 print $form->editfieldkey(
"PaymentMode",
'mode',
'',
$object, (
int) $editenable);
3193 print
'</td><td class="valuefield">';
3194 if ($action ==
'editmode') {
3195 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3197 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3215 $tmparray =
$object->getTotalWeightVolume();
3216 $totalWeight = $tmparray[
'weight'];
3217 $totalVolume = $tmparray[
'volume'];
3219 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
3220 print
'<td class="valuefield">';
3225 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
3226 print
'<td class="valuefield">';
3234 if (isModEnabled(
'incoterm')) {
3236 $editenable = $usercancreate;
3237 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'',
$object, (
int) $editenable);
3239 print
'<td class="valuefield">';
3240 if ($action !=
'editincoterm') {
3241 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3243 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3249 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
3251 $editenable = $usercancreate;
3252 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'',
$object, (
int) $editenable);
3253 print
'</td><td class="valuefield">';
3254 if ($action ==
'editbankaccount') {
3255 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3257 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3264 if (isModEnabled(
'category')) {
3266 print
'<table class="nobordernopadding centpercent"><tr><td>';
3267 print $langs->trans(
"Categories");
3268 print
'<td><td class="right">';
3269 if ($usercancreate) {
3270 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/commande/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3274 print
'</td></tr></table>';
3277 if ($action ==
'edittags') {
3278 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3279 print
'<input type="hidden" name="action" value="settags">';
3280 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3281 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories',
$object);
3282 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3285 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3291 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3296 print
'<div class="fichehalfright">';
3297 print
'<div class="underbanner clearboth"></div>';
3299 print
'<table class="border tableforfield centpercent">';
3301 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3305 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3309 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3310 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3311 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3313 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3318 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3319 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3320 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3322 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3327 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3329 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
3330 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3331 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3334 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3340 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3342 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
3343 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3344 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3347 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3353 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3354 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3355 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3357 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3367 if (isModEnabled(
'margin')) {
3368 $formmargin->displayMarginInfos(
$object);
3375 print
'<div class="clearboth"></div><br>';
3378 $blocname =
'contacts';
3379 $title = $langs->trans(
'ContactsAddresses');
3380 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3384 $blocname =
'notes';
3385 $title = $langs->trans(
'Notes');
3386 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3394 $result =
$object->getLinesArray();
3398 global $inputalsopricewithtax;
3399 $inputalsopricewithtax = 1;
3401 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">
3402 <input type="hidden" name="token" value="' .
newToken().
'">
3403 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3404 <input type="hidden" name="mode" value="">
3405 <input type="hidden" name="page_y" value="">
3406 <input type="hidden" name="id" value="' .
$object->id.
'">
3407 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
3411 if (isModEnabled(
'subtotals')) {
3412 include DOL_DOCUMENT_ROOT.
'/core/tpl/subtotal_ajaxrow.tpl.php';
3414 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3418 print
'<div class="div-table-responsive-no-min">';
3419 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3423 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
3430 if ($action !=
'editline') {
3433 $parameters = array();
3435 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
3439 if (empty($reshook)) {
3440 $object->formAddObjectLine(1, $mysoc, $soc);
3443 $parameters = array();
3444 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters,
$object, $action);
3458 if ($action !=
'presend' && $action !=
'editline') {
3459 print
'<div class="tabsAction">';
3461 $parameters = array();
3463 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3464 if (empty($reshook)) {
3465 $numlines = count(
$object->lines);
3473 if (empty($user->socid)) {
3476 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3478 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3486 $langs->load(
'subtotals');
3488 $url_button = array();
3490 $url_button[] = array(
3491 'lang' =>
'subtotals',
3493 'perm' => (
bool) $usercancreate,
3494 'label' => $langs->trans(
'AddTitleLine'),
3495 'url' =>
'/commande/card.php?id='.$object->id.
'&action=add_title_line&token='.
newToken()
3498 $url_button[] = array(
3499 'lang' =>
'subtotals',
3501 'perm' => (
bool) $usercancreate,
3502 'label' => $langs->trans(
'AddSubtotalLine'),
3503 'url' =>
'/commande/card.php?id='.$object->id.
'&action=add_subtotal_line&token='.
newToken()
3505 print
dolGetButtonAction(
'', $langs->trans(
'Subtotal'),
'default', $url_button,
'',
true);
3510 if ($numlines > 0) {
3513 $langs->load(
"errors");
3514 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.
$object->id, (
string)
$object->id, -1);
3522 $arrayforbutaction = array();
3526 $arrayforbutaction[] = array(
3529 'perm' => $usercancreatepurchaseorder,
3530 'label' =>
'AddPurchaseOrder',
3531 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3543 $arrayforbutaction[] = array(
3544 'lang' =>
'interventions',
3546 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3547 'label' =>
'AddIntervention',
3548 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3553 $arrayforbutaction[] = array(
3554 'lang' =>
'contracts',
3556 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3557 'label' =>
'AddContract',
3558 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3571 if (isModEnabled(
'shipping')) {
3572 $numshipping =
$object->countNbOfShipments();
3575 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3577 $arrayforbutaction[] = array(
3578 'lang' =>
'sendings',
3580 'perm' => $user->hasRight(
'expedition',
'creer'),
3581 'label' =>
'CreateShipment',
3582 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3587 $arrayforbutaction[] = array(
3588 'lang' =>
'sendings',
3591 'label' =>
'CreateShipment',
3592 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3599 $arrayforbutaction[] = array(
3602 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3603 'label' =>
'CreateBill',
3604 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3613 $actionButtonsParameters = [
3614 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3617 if ($numlines > 0) {
3618 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3620 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3625 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.
newToken().
'&id='.
$object->id,
'');
3632 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3637 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.
newToken().
'&id='.
$object->id,
'');
3642 if ($usercancreate) {
3648 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"CancelOrder").
'</a>';
3652 if ($usercandelete) {
3653 if ($numshipping == 0) {
3656 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3664 if (
GETPOST(
'modelselected')) {
3665 $action =
'presend';
3668 if ($action !=
'presend') {
3669 print
'<div class="fichecenter"><div class="fichehalfleft">';
3670 print
'<a name="builddoc"></a>';
3673 $relativepath = $objref.
'/'.$objref.
'.pdf';
3674 $filedir =
$conf->commande->multidir_output[
$object->entity].
'/'.$objref;
3675 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3676 $genallowed = $usercanread;
3677 $delallowed = $usercancreate;
3678 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, (
int) $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'',
$object);
3682 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'order'), 1);
3683 $linktoelem = $tmparray[
'linktoelem'];
3684 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3685 print $htmltoenteralink;
3687 $compatibleImportElementsList =
false;
3690 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3692 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem, $compatibleImportElementsList);
3696 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3697 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3698 $useonlinepayment = count($validpaymentmethod);
3701 $useonlinepayment = 0;
3704 print
'<br><!-- Link to pay -->';
3705 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3706 print showOnlinePaymentUrl(
'order',
$object->ref).
'<br>';
3709 print
'</div><div class="fichehalfright">';
3713 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id);
3716 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3718 $somethingshown = $formactions->showactions(
$object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3720 print
'</div></div>';
3724 $modelmail =
'order_send';
3725 $defaulttopic =
'SendOrderRef';
3727 $trackid =
'ord'.$object->id;
3729 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage a WYSIWYG editor.
static createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger=0, $autoValidateDeposit=false, $overrideFields=array())
Creates a deposit from a proposal or an order by grouping lines by VAT rates.
const TYPE_DEPOSIT
Deposit invoice.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class ProductCombination Used to represent the relation between a product and one of its variants.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.