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'));
145$extrafields->fetch_name_optionals_label(
$object->table_element);
148include 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');
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];
1136 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
1138 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1139 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1141 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1142 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1147 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1148 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1149 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1150 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1151 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
1153 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1154 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1156 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1157 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1162 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1166 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1168 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1171 if (count($prodcustprice->lines) > 0) {
1172 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1173 foreach ($prodcustprice->lines as $k => $custprice_line) {
1174 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1175 $pu_ht =
price($custprice_line->price);
1176 $pu_ttc =
price($custprice_line->price_ttc);
1177 $price_min =
price($custprice_line->price_min);
1178 $price_min_ttc =
price($custprice_line->price_min_ttc);
1179 $price_base_type = $custprice_line->price_base_type;
1197 if ($prod->prices_by_qty[0]) {
1202 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1203 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1207 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1208 $pu_ht = $priceforthequantityarray[
'unitprice'];
1210 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1218 if ($prod->prices_by_qty[
$object->thirdparty->price_level]) {
1222 foreach ($prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1223 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1227 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1228 $pu_ht = $priceforthequantityarray[
'unitprice'];
1230 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1238 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1239 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
1242 if (!empty($price_ht) || (string) $price_ht ===
'0') {
1243 $pu_ht = (float)
price2num($price_ht,
'MU');
1244 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1245 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1246 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1249 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1250 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1251 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1252 } elseif ($tmpvat != $tmpprodvat) {
1254 if ($price_base_type !=
'HT') {
1255 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1257 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1265 $outputlangs = $langs;
1267 if (
GETPOST(
'lang_id',
'aZ09')) {
1268 $newlang =
GETPOST(
'lang_id',
'aZ09');
1270 if (empty($newlang)) {
1271 $newlang =
$object->thirdparty->default_lang;
1273 if (!empty($newlang)) {
1275 $outputlangs->setDefaultLang($newlang);
1278 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1280 $desc = $prod->description;
1292 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1296 $outputlangs = $langs;
1298 if (
GETPOST(
'lang_id',
'alpha')) {
1299 $newlang =
GETPOST(
'lang_id',
'alpha');
1301 if (empty($newlang)) {
1302 $newlang =
$object->thirdparty->default_lang;
1304 if (!empty($newlang)) {
1306 $outputlangs->setDefaultLang($newlang);
1307 $outputlangs->load(
'products');
1309 if (!empty($prod->customcode)) {
1310 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1312 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1315 if (!empty($prod->country_code)) {
1316 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
1319 if (!empty($prod->customcode)) {
1320 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
1322 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1325 if (!empty($prod->country_code)) {
1326 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $langs, 0);
1333 $type = $prod->type;
1334 $fk_unit = $prod->fk_unit;
1338 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1339 $tva_tx = str_replace(
'*',
'', $tva_tx);
1340 if (empty($tva_tx)) {
1343 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1346 $fk_unit =
GETPOST(
'units',
'alpha');
1347 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1348 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1350 if ($pu_ttc && !$pu_ht) {
1351 $price_base_type =
'TTC';
1365 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) : 0);
1366 $buyingprice =
price2num((
GETPOST(
'buying_price'.$predef) !=
'' ?
GETPOST(
'buying_price'.$predef) :
''),
'', 2);
1369 $pu_equivalent = $pu_ht;
1370 $pu_equivalent_ttc = $pu_ttc;
1372 $currency_tx =
$object->multicurrency_tx;
1379 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1380 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1382 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1383 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1403 if ($usermustrespectpricemin) {
1404 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1405 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1408 } 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') {
1409 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1417 $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);
1429 $outputlangs = $langs;
1430 $newlang =
GETPOST(
'lang_id',
'alpha');
1432 $newlang =
$object->thirdparty->default_lang;
1434 if (!empty($newlang)) {
1436 $outputlangs->setDefaultLang($newlang);
1439 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1442 unset($_POST[
'prod_entry_mode']);
1444 unset($_POST[
'qty']);
1445 unset($_POST[
'type']);
1446 unset($_POST[
'remise_percent']);
1447 unset($_POST[
'price_ht']);
1448 unset($_POST[
'multicurrency_price_ht']);
1449 unset($_POST[
'price_ttc']);
1450 unset($_POST[
'tva_tx']);
1451 unset($_POST[
'product_ref']);
1452 unset($_POST[
'product_label']);
1453 unset($_POST[
'product_desc']);
1454 unset($_POST[
'fournprice']);
1455 unset($_POST[
'buying_price']);
1456 unset($_POST[
'np_marginRate']);
1457 unset($_POST[
'np_markRate']);
1458 unset($_POST[
'dp_desc']);
1459 unset($_POST[
'idprod']);
1460 unset($_POST[
'units']);
1462 unset($_POST[
'date_starthour']);
1463 unset($_POST[
'date_startmin']);
1464 unset($_POST[
'date_startsec']);
1465 unset($_POST[
'date_startday']);
1466 unset($_POST[
'date_startmonth']);
1467 unset($_POST[
'date_startyear']);
1468 unset($_POST[
'date_endhour']);
1469 unset($_POST[
'date_endmin']);
1470 unset($_POST[
'date_endsec']);
1471 unset($_POST[
'date_endday']);
1472 unset($_POST[
'date_endmonth']);
1473 unset($_POST[
'date_endyear']);
1481 } elseif ($action ==
'updatetitleline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1484 $langs->load(
'subtotals');
1486 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1489 $subtotal_options = array();
1491 foreach (Commande::$TITLE_OPTIONS as $option) {
1492 $value =
GETPOST($option,
'alphanohtml');
1494 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1499 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1510 $outputlangs = $langs;
1511 $newlang =
GETPOST(
'lang_id',
'alpha');
1513 $newlang =
$object->thirdparty->default_lang;
1515 if (!empty($newlang)) {
1517 $outputlangs->setDefaultLang($newlang);
1520 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1525 } elseif ($action ==
'updatesubtotalline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1528 $langs->load(
'subtotals');
1530 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1533 $subtotal_options = array();
1535 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1536 $value =
GETPOST($option,
'alphanohtml');
1538 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1543 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1551 $outputlangs = $langs;
1552 $newlang =
GETPOST(
'lang_id',
'alpha');
1554 $newlang =
$object->thirdparty->default_lang;
1556 if (!empty($newlang)) {
1558 $outputlangs->setDefaultLang($newlang);
1561 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1566 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1579 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1584 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1585 $vat_rate = str_replace(
'*',
'', $vat_rate);
1597 $pu_equivalent = $pu_ht;
1598 $pu_equivalent_ttc = $pu_ttc;
1600 $currency_tx =
$object->multicurrency_tx;
1607 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1608 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1610 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1611 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1626 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1630 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1631 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1633 if (is_array($extralabelsline)) {
1634 foreach ($extralabelsline as $key => $value) {
1635 unset($_POST[
"options_".$key]);
1648 $price_base_type =
'HT';
1649 if (empty($pu) && !empty($pu_ttc)) {
1651 $price_base_type =
'TTC';
1656 if (!empty($productid)) {
1658 $product->fetch($productid);
1660 $type = $product->type;
1662 $price_min = $product->price_min;
1664 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1666 $price_min_ttc = $product->price_min_ttc;
1668 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1674 if ($usermustrespectpricemin) {
1675 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1676 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1679 $action =
'editline';
1680 } 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') {
1681 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1684 $action =
'editline';
1689 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1693 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1695 $action =
'editline';
1700 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1702 $action =
'editline';
1707 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1708 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1710 $action =
'editline';
1717 if (!$user->hasRight(
'margins',
'creer')) {
1718 foreach (
$object->lines as &$line) {
1720 $fournprice = $line->fk_fournprice;
1721 $buyingprice = $line->pa_ht;
1729 $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);
1736 $outputlangs = $langs;
1739 $newlang =
GETPOST(
'lang_id',
'aZ09');
1742 $newlang =
$object->thirdparty->default_lang;
1744 if (!empty($newlang)) {
1746 $outputlangs->setDefaultLang($newlang);
1750 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1753 unset($_POST[
'qty']);
1754 unset($_POST[
'type']);
1755 unset($_POST[
'productid']);
1756 unset($_POST[
'remise_percent']);
1757 unset($_POST[
'price_ht']);
1758 unset($_POST[
'multicurrency_price_ht']);
1759 unset($_POST[
'price_ttc']);
1760 unset($_POST[
'tva_tx']);
1761 unset($_POST[
'product_ref']);
1762 unset($_POST[
'product_label']);
1763 unset($_POST[
'product_desc']);
1764 unset($_POST[
'fournprice']);
1765 unset($_POST[
'buying_price']);
1767 unset($_POST[
'date_starthour']);
1768 unset($_POST[
'date_startmin']);
1769 unset($_POST[
'date_startsec']);
1770 unset($_POST[
'date_startday']);
1771 unset($_POST[
'date_startmonth']);
1772 unset($_POST[
'date_startyear']);
1773 unset($_POST[
'date_endhour']);
1774 unset($_POST[
'date_endmin']);
1775 unset($_POST[
'date_endsec']);
1776 unset($_POST[
'date_endday']);
1777 unset($_POST[
'date_endmonth']);
1778 unset($_POST[
'date_endyear']);
1785 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1786 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1788 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1791 $qualified_for_stock_change = 0;
1793 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1795 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1799 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1800 if (!$idwarehouse || $idwarehouse == -1) {
1802 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1808 $locationTarget =
'';
1812 $result =
$object->valid($user, $idwarehouse);
1817 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1820 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1821 && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1823 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1826 $forceFields = array();
1828 if (GETPOSTISSET(
'date_pointoftax')) {
1836 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1848 $outputlangs = $langs;
1851 $newlang =
GETPOST(
'lang_id',
'aZ09');
1854 $newlang =
$object->thirdparty->default_lang;
1856 if (!empty($newlang)) {
1858 $outputlangs->setDefaultLang($newlang);
1863 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1866 $deposit->fetch($deposit->id);
1867 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1871 if ($locationTarget) {
1872 header(
'Location: ' . $locationTarget);
1883 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1885 $idwarehouse =
GETPOST(
'idwarehouse');
1887 $qualified_for_stock_change = 0;
1889 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1891 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1895 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1896 if (!$idwarehouse || $idwarehouse == -1) {
1898 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1904 $result =
$object->setDraft($user, $idwarehouse);
1908 $outputlangs = $langs;
1911 $newlang =
GETPOST(
'lang_id',
'aZ09');
1914 $newlang =
$object->thirdparty->default_lang;
1916 if (!empty($newlang)) {
1918 $outputlangs->setDefaultLang($newlang);
1923 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1929 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1930 $result =
$object->cloture($user);
1934 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1937 $qualified_for_stock_change = 0;
1939 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1941 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1945 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1946 if (!$idwarehouse || $idwarehouse == -1) {
1948 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1954 $result =
$object->cancel($idwarehouse);
1962 if ($action ==
'update_extras' && $permissiontoeditextra) {
1965 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1968 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1975 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
1983 $action =
'edit_extras';
1989 $fromElement =
GETPOST(
'fromelement');
1990 $fromElementid =
GETPOST(
'fromelementid');
1991 $importLines =
GETPOST(
'line_checkbox');
1993 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1994 if ($fromElement ==
'commande') {
1996 $lineClassName =
'OrderLine';
1997 } elseif ($fromElement ==
'propal') {
1998 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1999 $lineClassName =
'PropaleLigne';
2000 } elseif ($fromElement ==
'facture') {
2001 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
2002 $lineClassName =
'FactureLigne';
2004 $nextRang = count(
$object->lines) + 1;
2007 foreach ($importLines as $lineId) {
2008 $lineId = intval($lineId);
2009 $originLine =
new $lineClassName($db);
2010 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2011 $originLine->fetch_optionals();
2012 $desc = $originLine->desc;
2013 $pu_ht = $originLine->subprice;
2014 $qty = $originLine->qty;
2015 $txtva = $originLine->tva_tx;
2016 $txlocaltax1 = $originLine->localtax1_tx;
2017 $txlocaltax2 = $originLine->localtax2_tx;
2018 $fk_product = $originLine->fk_product;
2019 $remise_percent = $originLine->remise_percent;
2020 $date_start = $originLine->date_start;
2021 $date_end = $originLine->date_end;
2022 $fk_code_ventilation = 0;
2023 $info_bits = $originLine->info_bits;
2024 $fk_remise_except = $originLine->fk_remise_except;
2025 $price_base_type =
'HT';
2027 $type = $originLine->product_type;
2028 $rang = $nextRang++;
2029 $special_code = $originLine->special_code;
2030 $origin = $originLine->element;
2031 $origin_id = $originLine->id;
2032 $fk_parent_line = 0;
2033 $fk_fournprice = $originLine->fk_fournprice;
2034 $pa_ht = $originLine->pa_ht;
2035 $label = $originLine->label;
2036 $array_options = $originLine->array_options;
2037 $situation_percent = 100;
2039 $fk_unit = $originLine->fk_unit;
2040 $pu_ht_devise = $originLine->multicurrency_subprice;
2042 $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);
2061 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2064 $upload_dir = !empty(
$conf->commande->multidir_output[
$object->entity]) ?
$conf->commande->multidir_output[
$object->entity] :
$conf->commande->dir_output;
2065 $permissiontoadd = $usercancreate;
2066 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2069 $triggersendname =
'ORDER_SENTBYMAIL';
2071 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2072 $trackid =
'ord'.$object->id;
2073 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2077 if ($action ==
'addcontact' && $usercancreate) {
2081 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2085 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2088 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2089 $langs->load(
"errors");
2090 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2095 } elseif ($action ==
'swapstatut' && $usercancreate) {
2102 } elseif ($action ==
'deletecontact' && $usercancreate) {
2104 $result =
$object->delete_contact($lineid);
2107 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2121$title =
$object->ref.
" - ".$langs->trans(
'Card');
2122if ($action ==
'create') {
2123 $title = $langs->trans(
"NewOrder");
2125$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2127llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2129$form =
new Form($db);
2133if (isModEnabled(
'project')) {
2138if ($action ==
'create' && $usercancreate) {
2143 $res = $soc->fetch($socid);
2148 $currency_code =
$conf->currency;
2150 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2151 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2152 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2155 if (!empty($origin) && !empty($originid)) {
2157 $element = $subelement = $origin;
2159 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2160 $element = $regs[1];
2161 $subelement = $regs[2];
2164 if ($element ==
'project') {
2165 $projectid = $originid;
2167 if (!$cond_reglement_id) {
2168 $cond_reglement_id = $soc->cond_reglement_id;
2170 if (!$deposit_percent) {
2171 $deposit_percent = $soc->deposit_percent;
2173 if (!$mode_reglement_id) {
2174 $mode_reglement_id = $soc->mode_reglement_id;
2176 if (!$remise_percent) {
2177 $remise_percent = $soc->remise_percent;
2185 if ($element ==
'order' || $element ==
'commande') {
2186 $element = $subelement =
'commande';
2187 } elseif ($element ==
'propal') {
2188 $element =
'comm/propal';
2189 $subelement =
'propal';
2190 } elseif ($element ==
'contract') {
2191 $element = $subelement =
'contrat';
2196 $classname = ucfirst($subelement);
2197 $objectsrc =
new $classname($db);
2198 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2199 $objectsrc->fetch($originid);
2200 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2201 $objectsrc->fetch_lines();
2203 $objectsrc->fetch_thirdparty();
2206 $objectsrc->fetch_optionals();
2207 $object->array_options = $objectsrc->array_options;
2209 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2210 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2212 $soc = $objectsrc->thirdparty;
2213 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2214 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2215 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2216 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2217 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2218 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2219 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2220 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2225 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2227 if (isModEnabled(
"multicurrency")) {
2228 if (!empty($objectsrc->multicurrency_code)) {
2229 $currency_code = $objectsrc->multicurrency_code;
2231 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2232 $currency_tx = $objectsrc->multicurrency_tx;
2236 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2237 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2240 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2243 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2244 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2245 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2246 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2247 $availability_id = 0;
2248 $shipping_method_id = $soc->shipping_method_id;
2249 $warehouse_id = $soc->fk_warehouse;
2250 $demand_reason_id = $soc->demand_reason_id;
2255 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2256 $currency_code = $soc->multicurrency_code;
2259 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2260 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2264 if (!
GETPOST(
'changecompany')) {
2265 if (GETPOSTISSET(
'cond_reglement_id')) {
2266 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2268 if (GETPOSTISSET(
'deposit_percent')) {
2271 if (GETPOSTISSET(
'mode_reglement_id')) {
2272 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2274 if (GETPOSTISSET(
'cond_reglement_id')) {
2280 if ($soc->fk_warehouse > 0) {
2281 $warehouse_id = $soc->fk_warehouse;
2283 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2288 $warehouse_id = $user->fk_warehouse;
2292 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2293 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2294 print
'<input type="hidden" name="action" value="add">';
2295 print
'<input type="hidden" name="changecompany" value="0">';
2296 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
2297 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2298 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2299 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2300 if (!empty($currency_tx)) {
2301 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2307 $parameters = array();
2309 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters,
$object, $action);
2310 if (empty($reshook)) {
2311 print
'<table class="border centpercent">';
2314 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
2317 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
2318 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2319 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
2321 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
2327 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
2330 print $soc->getNomUrl(1,
'customer');
2331 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
2334 print
'<td class="valuefieldcreate">';
2335 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2336 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2340 $(document).ready(function() {
2341 $("#socid").change(function() {
2342 console.log("We have changed the company - Reload page");
2343 var socid = $(this).val();
2345 $("input[name=action]").val("create");
2346 $("input[name=changecompany]").val("1");
2347 $("form[name=crea_commande]").submit();
2352 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&customer=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
2362 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_".$type_contact_code));
2364 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2366 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2370 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2372 $absolute_discount = $soc->getAvailableDiscounts();
2376 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode((
string) (
GETPOST(
'origin'))).
'&originid='.urlencode((
string) (
GETPOSTINT(
'originid')));
2377 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2383 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
2384 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2385 print $form->selectDate(
'',
're', 0, 0, 0,
"crea_commande", 1, 1);
2389 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
2390 print
'<td colspan="3">';
2391 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2392 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2393 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2398 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
2399 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2400 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2404 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2405 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2406 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2410 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2411 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2412 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2416 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
2417 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2418 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2423 if (isModEnabled(
'shipping')) {
2424 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
2425 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2426 $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');
2431 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2432 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2434 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
2435 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');
2440 print
'<tr><td>'.$langs->trans(
'Source').
'</td><td>';
2441 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2442 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2448 if (isModEnabled(
'project')) {
2449 $langs->load(
"projects");
2451 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2452 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');
2453 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>';
2459 if (isModEnabled(
'incoterm')) {
2461 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>';
2462 print
'<td class="maxwidthonsmartphone">';
2463 $incoterm_id =
GETPOST(
'incoterm_id');
2464 $location_incoterms =
GETPOST(
'location_incoterms');
2465 if (empty($incoterm_id)) {
2466 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2467 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2469 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2470 print $form->select_incoterms($incoterm_id, $location_incoterms);
2475 $parameters = array();
2476 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2477 $parameters[
'objectsrc'] = $objectsrc;
2479 $parameters[
'socid'] = $socid;
2482 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2483 print $hookmanager->resPrint;
2484 if (empty($reshook)) {
2485 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2488 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2489 if ($soc->fetch_optionals() > 0) {
2490 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2494 print
$object->showOptionals($extrafields,
'create', $parameters);
2498 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2500 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2503 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2504 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2508 if (isModEnabled(
"multicurrency")) {
2510 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'',
$object, 0).
'</td>';
2511 print
'<td class="maxwidthonsmartphone">';
2512 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2517 if (!empty(
$conf->categorie->enabled)) {
2518 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2519 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories',
$object);
2525 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2528 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2529 print $doleditor->Create(1);
2534 if (empty($user->socid)) {
2536 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2539 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2540 print $doleditor->Create(1);
2545 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2547 if ($origin ==
'contrat') {
2551 $objectsrc->update_price(1);
2554 print
"\n<!-- ".$classname.
" info -->";
2556 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2557 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2558 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2559 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2560 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2562 switch ($classname) {
2564 $newclassname =
'CommercialProposal';
2567 $newclassname =
'Order';
2570 $newclassname =
'Sending';
2573 $newclassname =
'Contract';
2576 $newclassname = $classname;
2579 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2582 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2583 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2584 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2585 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2588 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2589 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2592 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2594 if (isModEnabled(
"multicurrency")) {
2595 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2596 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2597 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2608 print $form->buttonsSaveCancel(
"CreateDraft");
2611 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2612 $title = $langs->trans(
'ProductsAndServices');
2615 print
'<div class="div-table-responsive-no-min">';
2616 print
'<table class="noborder centpercent">';
2618 $objectsrc->printOriginLinesList(
'', $selectedLines);
2630 $product_static =
new Product($db);
2635 $author =
new User($db);
2636 $author->fetch(
$object->user_author_id);
2639 $res =
$object->fetch_optionals();
2642 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order', 0,
'',
'', 0,
'', 1);
2647 if ($action ==
'delete') {
2648 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2652 if ($action ==
'validate') {
2654 $ref = substr(
$object->ref, 1, 4);
2655 if ($ref ==
'PROV' || $ref ==
'') {
2656 $numref =
$object->getNextNumRef($soc);
2657 if (empty($numref)) {
2665 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2666 if (isModEnabled(
'notification')) {
2667 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2668 $notify =
new Notify($db);
2670 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid,
$object);
2673 $qualified_for_stock_change = 0;
2675 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2677 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2680 $formquestion = array();
2681 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2682 $langs->load(
"stocks");
2683 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2686 if (
$conf->browser->name ==
'ie') {
2689 $formquestion = array(
2693 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2699 foreach (
$object->lines as $line) {
2700 $res = $line->fetch_product();
2702 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2708 if ($nbMandated > 0) {
2710 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2713 $text .=
'<div><span class="clearboth nowraponall warning">'.img_warning().$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2717 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2722 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2724 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2725 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2729 $eligibleForDepositGeneration =
true;
2731 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2732 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2733 '@phan-var-force Facture $invoice';
2735 $eligibleForDepositGeneration =
false;
2741 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2742 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2743 $proposal->fetchObjectLinked();
2745 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2746 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2747 '@phan-var-force Facture $invoice';
2749 $eligibleForDepositGeneration =
false;
2757 if ($eligibleForDepositGeneration) {
2758 $formquestion[] = array(
2759 'type' =>
'checkbox',
2761 'name' =>
'generate_deposit',
2762 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2765 $formquestion[] = array(
2767 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2769 'label' => $langs->trans(
'DateInvoice'),
2775 $formquestion[] = array(
2777 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2778 'name' =>
'date_pointoftax',
2779 'label' => $langs->trans(
'DatePointOfTax'),
2786 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2788 $formquestion[] = array(
2790 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2791 'name' =>
'cond_reglement_id',
2792 'label' => $langs->trans(
'PaymentTerm'),
2793 'value' => $paymentTermsSelect
2796 $formquestion[] = array(
2797 'type' =>
'checkbox',
2798 'tdclass' =>
'showonlyifgeneratedeposit',
2799 'name' =>
'validate_generated_deposit',
2800 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2803 $formquestion[] = array(
2804 'type' =>
'onecolumn',
2807 $(document).ready(function() {
2808 $("[name=generate_deposit]").change(function () {
2809 let $self = $(this);
2810 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2812 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2829 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2834 if ($action ==
'modif') {
2835 $qualified_for_stock_change = 0;
2837 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2839 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2842 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2843 $formquestion = array();
2844 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2845 $langs->load(
"stocks");
2846 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2849 if (
$conf->browser->name ==
'ie') {
2852 $formquestion = array(
2856 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2860 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2864 if ($action ==
'shipped') {
2865 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2869 if ($action ==
'cancel') {
2870 $qualified_for_stock_change = 0;
2872 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2874 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2877 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2878 $formquestion = array();
2879 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2880 $langs->load(
"stocks");
2881 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2884 if (
$conf->browser->name ==
'ie') {
2887 $formquestion = array(
2891 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2895 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2899 if ($action ==
'ask_deleteline') {
2900 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2904 if ($action ==
'ask_subtotal_deleteline') {
2905 $langs->load(
"subtotals");
2906 $title =
"DeleteSubtotalLine";
2907 $question =
"ConfirmDeleteSubtotalLine";
2908 if (
GETPOST(
'type') ==
'title') {
2909 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2910 $title =
"DeleteTitleLine";
2911 $question =
"ConfirmDeleteTitleLine";
2913 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2917 if ($action ==
'clone') {
2918 $filter =
'(s.client:IN:1,2,3)';
2920 $formquestion = array(
2921 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2923 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2927 if ($action ==
'add_title_line') {
2928 $langs->load(
'subtotals');
2930 $depth_array =
$object->getPossibleLevels($langs);
2932 } elseif ($action ==
'add_subtotal_line') {
2933 $langs->load(
'subtotals');
2935 $titles =
$object->getPossibleTitles();
2940 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2942 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2943 if (empty($reshook)) {
2944 $formconfirm .= $hookmanager->resPrint;
2945 } elseif ($reshook > 0) {
2946 $formconfirm = $hookmanager->resPrint;
2955 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2957 $morehtmlref =
'<div class="refidno">';
2959 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, (
int) $usercancreate,
'string',
'', 0, 1);
2960 $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);
2962 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2964 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2967 if (isModEnabled(
'project')) {
2968 $langs->load(
"projects");
2969 $morehtmlref .=
'<br>';
2970 if ($usercancreate) {
2971 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2972 if ($action !=
'classify') {
2973 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2975 $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');
2977 if (!empty(
$object->fk_project)) {
2979 $proj->fetch(
$object->fk_project);
2980 $morehtmlref .= $proj->getNomUrl(1);
2982 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2987 $morehtmlref .=
'</div>';
2990 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2993 $parameters = array();
2995 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters,
$object, $action);
2996 if (empty($reshook)) {
2997 print
'<div class="fichecenter">';
2998 print
'<div class="fichehalfleft">';
2999 print
'<div class="underbanner clearboth"></div>';
3001 print
'<table class="border tableforfield centpercent">';
3005 $langs->load(
"cashdesk");
3006 print
'<tr><td class="fieldname_type">';
3007 print
'<table class="nobordernopadding centpercent"><tr><td>';
3008 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3010 if ($action !=
'editposinfo' && $usercancreate) {
3011 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>';
3013 print
'</tr></table>';
3014 print
'</td><td class="valuefield fieldname_type">';
3015 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" name="formposinfo">';
3016 print
'<input type="hidden" name="action" value="setposinfo">';
3017 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3018 if ($action ==
'editposinfo') {
3019 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="'.$langs->trans(
"POSModule").
'" value="'.
$object->module_source.
'"> ';
3020 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="'.$langs->trans(
"Terminal").
'" value="'.
$object->pos_source.
'">';
3021 print
'<input type="submit" class="button" name="submitposinfo" value="'.$langs->trans(
"Submit").
'">';
3024 print
'<span class="opacitymediumbycolor paddingleft">'.dolPrintHTML(ucfirst(
$object->module_source).
' - '.$langs->transnoentitiesnoconv(
"Terminal").
' '.
$object->pos_source).
'</span>';
3031 if ($soc->outstanding_limit) {
3033 print
'<tr><td class="titlefield">';
3034 print $langs->trans(
'OutstandingBill');
3035 print
'</td><td class="valuefield">';
3036 $arrayoutstandingbills = $soc->getOutstandingBills();
3037 print
price($arrayoutstandingbills[
'opened']).
' / ';
3038 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1,
$conf->currency);
3045 $filterabsolutediscount =
"fk_facture_source IS NULL";
3046 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3048 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3049 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3052 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
3053 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
3054 $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>';
3056 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
3058 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3059 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3060 $absolute_discount =
price2num($absolute_discount,
'MT');
3061 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3065 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id;
3066 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3073 print $form->editfieldkey(
"Date",
'date',
'',
$object, (
int) $editenable);
3074 print
'</td><td class="valuefield">';
3075 if ($action ==
'editdate') {
3076 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
3077 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3078 print
'<input type="hidden" name="action" value="setdate">';
3079 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3080 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3081 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
3086 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
3094 $editenable = $usercancreate;
3095 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'',
$object, (
int) $editenable);
3096 print
'</td><td class="valuefield">';
3097 if ($action ==
'editdate_livraison') {
3098 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
3099 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3100 print
'<input type="hidden" name="action" value="setdate_livraison">';
3101 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3102 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3103 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
3108 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
3115 print
'<tr class="fielddeliverydelay"><td>';
3116 $editenable = $usercancreate;
3117 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'',
$object, (
int) $editenable);
3118 print
'</td><td class="valuefield">';
3119 if ($action ==
'editavailability') {
3120 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3122 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->availability_id,
'none', 1);
3127 if (isModEnabled(
'shipping')) {
3129 $editenable = $usercancreate;
3130 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'',
$object, (
int) $editenable);
3131 print
'</td><td class="valuefield">';
3132 if ($action ==
'editshippingmethod') {
3133 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3135 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->shipping_method_id,
'none');
3142 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
3143 $langs->load(
'stocks');
3144 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3147 $editenable = $usercancreate;
3148 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, (
int) $editenable);
3149 print
'</td><td class="valuefield">';
3150 if ($action ==
'editwarehouse') {
3151 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3153 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'none');
3161 $editenable = $usercancreate;
3162 print $form->editfieldkey(
"Source",
'demandreason',
'',
$object, (
int) $editenable);
3163 print
'</td><td class="valuefield">';
3164 if ($action ==
'editdemandreason') {
3165 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3167 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->demand_reason_id,
'none');
3173 $editenable = $usercancreate;
3174 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'',
$object, (
int) $editenable);
3175 print
'</td><td class="valuefield">';
3176 if ($action ==
'editconditions') {
3177 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3179 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3187 $editenable = $usercancreate;
3188 print $form->editfieldkey(
"PaymentMode",
'mode',
'',
$object, (
int) $editenable);
3189 print
'</td><td class="valuefield">';
3190 if ($action ==
'editmode') {
3191 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3193 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3211 $tmparray =
$object->getTotalWeightVolume();
3212 $totalWeight = $tmparray[
'weight'];
3213 $totalVolume = $tmparray[
'volume'];
3215 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
3216 print
'<td class="valuefield">';
3221 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
3222 print
'<td class="valuefield">';
3230 if (isModEnabled(
'incoterm')) {
3232 $editenable = $usercancreate;
3233 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'',
$object, (
int) $editenable);
3235 print
'<td class="valuefield">';
3236 if ($action !=
'editincoterm') {
3237 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3239 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3245 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
3247 $editenable = $usercancreate;
3248 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'',
$object, (
int) $editenable);
3249 print
'</td><td class="valuefield">';
3250 if ($action ==
'editbankaccount') {
3251 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3253 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3260 if (isModEnabled(
'category')) {
3262 print
'<table class="nobordernopadding centpercent"><tr><td>';
3263 print $langs->trans(
"Categories");
3264 print
'<td><td class="right">';
3265 if ($usercancreate) {
3266 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/commande/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3270 print
'</td></tr></table>';
3273 if ($action ==
'edittags') {
3274 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3275 print
'<input type="hidden" name="action" value="settags">';
3276 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3277 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories',
$object);
3278 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3281 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3287 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3292 print
'<div class="fichehalfright">';
3293 print
'<div class="underbanner clearboth"></div>';
3295 print
'<table class="border tableforfield centpercent">';
3297 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3301 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3305 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3306 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3307 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3309 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3314 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3315 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3316 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3318 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3323 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3325 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
3326 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3327 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3330 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3336 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3338 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
3339 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3340 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3343 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3349 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3350 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3351 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3353 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3363 if (isModEnabled(
'margin')) {
3364 $formmargin->displayMarginInfos(
$object);
3371 print
'<div class="clearboth"></div><br>';
3374 $blocname =
'contacts';
3375 $title = $langs->trans(
'ContactsAddresses');
3376 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3380 $blocname =
'notes';
3381 $title = $langs->trans(
'Notes');
3382 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3390 $result =
$object->getLinesArray();
3394 global $inputalsopricewithtax;
3395 $inputalsopricewithtax = 1;
3397 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">
3398 <input type="hidden" name="token" value="' .
newToken().
'">
3399 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3400 <input type="hidden" name="mode" value="">
3401 <input type="hidden" name="page_y" value="">
3402 <input type="hidden" name="id" value="' .
$object->id.
'">
3403 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
3407 if (isModEnabled(
'subtotals')) {
3408 include DOL_DOCUMENT_ROOT.
'/core/tpl/subtotal_ajaxrow.tpl.php';
3410 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3414 print
'<div class="div-table-responsive-no-min">';
3415 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3419 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
3426 if ($action !=
'editline') {
3429 $parameters = array();
3431 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
3435 if (empty($reshook)) {
3436 $object->formAddObjectLine(1, $mysoc, $soc);
3439 $parameters = array();
3440 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters,
$object, $action);
3454 if ($action !=
'presend' && $action !=
'editline') {
3455 print
'<div class="tabsAction">';
3457 $parameters = array();
3459 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3460 if (empty($reshook)) {
3461 $numlines = count(
$object->lines);
3469 if (empty($user->socid)) {
3472 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3474 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3482 $langs->load(
'subtotals');
3484 $url_button = array();
3486 $url_button[] = array(
3487 'lang' =>
'subtotals',
3489 'perm' => (
bool) $usercancreate,
3490 'label' => $langs->trans(
'AddTitleLine'),
3491 'url' =>
'/commande/card.php?id='.$object->id.
'&action=add_title_line&token='.
newToken()
3494 $url_button[] = array(
3495 'lang' =>
'subtotals',
3497 'perm' => (
bool) $usercancreate,
3498 'label' => $langs->trans(
'AddSubtotalLine'),
3499 'url' =>
'/commande/card.php?id='.$object->id.
'&action=add_subtotal_line&token='.
newToken()
3501 print
dolGetButtonAction(
'', $langs->trans(
'Subtotal'),
'default', $url_button,
'',
true);
3506 if ($numlines > 0) {
3509 $langs->load(
"errors");
3510 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);
3518 $arrayforbutaction = array();
3522 $arrayforbutaction[] = array(
3525 'perm' => $usercancreatepurchaseorder,
3526 'label' =>
'AddPurchaseOrder',
3527 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3539 $arrayforbutaction[] = array(
3540 'lang' =>
'interventions',
3542 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3543 'label' =>
'AddIntervention',
3544 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3549 $arrayforbutaction[] = array(
3550 'lang' =>
'contracts',
3552 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3553 'label' =>
'AddContract',
3554 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3567 if (isModEnabled(
'shipping')) {
3568 $numshipping =
$object->countNbOfShipments();
3571 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3573 $arrayforbutaction[] = array(
3574 'lang' =>
'sendings',
3576 'perm' => $user->hasRight(
'expedition',
'creer'),
3577 'label' =>
'CreateShipment',
3578 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3583 $arrayforbutaction[] = array(
3584 'lang' =>
'sendings',
3587 'label' =>
'CreateShipment',
3588 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3595 $arrayforbutaction[] = array(
3598 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3599 'label' =>
'CreateBill',
3600 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3609 $actionButtonsParameters = [
3610 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3613 if ($numlines > 0) {
3614 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3616 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3621 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.
newToken().
'&id='.
$object->id,
'');
3628 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3633 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.
newToken().
'&id='.
$object->id,
'');
3638 if ($usercancreate) {
3644 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"CancelOrder").
'</a>';
3648 if ($usercandelete) {
3649 if ($numshipping == 0) {
3652 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3660 if (
GETPOST(
'modelselected')) {
3661 $action =
'presend';
3664 if ($action !=
'presend') {
3665 print
'<div class="fichecenter"><div class="fichehalfleft">';
3666 print
'<a name="builddoc"></a>';
3669 $relativepath = $objref.
'/'.$objref.
'.pdf';
3670 $filedir =
$conf->commande->multidir_output[
$object->entity].
'/'.$objref;
3671 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3672 $genallowed = $usercanread;
3673 $delallowed = $usercancreate;
3674 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, (
int) $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'',
$object);
3678 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'order'), 1);
3679 $linktoelem = $tmparray[
'linktoelem'];
3680 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3681 print $htmltoenteralink;
3683 $compatibleImportElementsList =
false;
3686 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3688 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem, $compatibleImportElementsList);
3692 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3693 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3694 $useonlinepayment = count($validpaymentmethod);
3697 $useonlinepayment = 0;
3700 print
'<br><!-- Link to pay -->';
3701 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3702 print showOnlinePaymentUrl(
'order',
$object->ref).
'<br>';
3705 print
'</div><div class="fichehalfright">';
3709 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id);
3712 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3714 $somethingshown = $formactions->showactions(
$object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3716 print
'</div></div>';
3720 $modelmail =
'order_send';
3721 $defaulttopic =
'SendOrderRef';
3723 $trackid =
'ord'.$object->id;
3725 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.