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;
1376 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1377 $pu_equivalent = (float) $pu_ht_devise * (
float) $currency_tx;
1379 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1380 $pu_equivalent_ttc = (float) $pu_ttc_devise * (
float) $currency_tx;
1400 if ($usermustrespectpricemin) {
1401 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1402 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1405 } 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') {
1406 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1414 $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);
1426 $outputlangs = $langs;
1427 $newlang =
GETPOST(
'lang_id',
'alpha');
1429 $newlang =
$object->thirdparty->default_lang;
1431 if (!empty($newlang)) {
1433 $outputlangs->setDefaultLang($newlang);
1436 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1439 unset($_POST[
'prod_entry_mode']);
1441 unset($_POST[
'qty']);
1442 unset($_POST[
'type']);
1443 unset($_POST[
'remise_percent']);
1444 unset($_POST[
'price_ht']);
1445 unset($_POST[
'multicurrency_price_ht']);
1446 unset($_POST[
'price_ttc']);
1447 unset($_POST[
'tva_tx']);
1448 unset($_POST[
'product_ref']);
1449 unset($_POST[
'product_label']);
1450 unset($_POST[
'product_desc']);
1451 unset($_POST[
'fournprice']);
1452 unset($_POST[
'buying_price']);
1453 unset($_POST[
'np_marginRate']);
1454 unset($_POST[
'np_markRate']);
1455 unset($_POST[
'dp_desc']);
1456 unset($_POST[
'idprod']);
1457 unset($_POST[
'units']);
1459 unset($_POST[
'date_starthour']);
1460 unset($_POST[
'date_startmin']);
1461 unset($_POST[
'date_startsec']);
1462 unset($_POST[
'date_startday']);
1463 unset($_POST[
'date_startmonth']);
1464 unset($_POST[
'date_startyear']);
1465 unset($_POST[
'date_endhour']);
1466 unset($_POST[
'date_endmin']);
1467 unset($_POST[
'date_endsec']);
1468 unset($_POST[
'date_endday']);
1469 unset($_POST[
'date_endmonth']);
1470 unset($_POST[
'date_endyear']);
1478 } elseif ($action ==
'updatetitleline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1481 $langs->load(
'subtotals');
1483 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1486 $subtotal_options = array();
1488 foreach (Commande::$TITLE_OPTIONS as $option) {
1489 $value =
GETPOST($option,
'alphanohtml');
1491 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1496 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1507 $outputlangs = $langs;
1508 $newlang =
GETPOST(
'lang_id',
'alpha');
1510 $newlang =
$object->thirdparty->default_lang;
1512 if (!empty($newlang)) {
1514 $outputlangs->setDefaultLang($newlang);
1517 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1522 } elseif ($action ==
'updatesubtotalline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1525 $langs->load(
'subtotals');
1527 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1530 $subtotal_options = array();
1532 foreach (Commande::$SUBTOTAL_OPTIONS as $option) {
1533 $value =
GETPOST($option,
'alphanohtml');
1535 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1540 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1548 $outputlangs = $langs;
1549 $newlang =
GETPOST(
'lang_id',
'alpha');
1551 $newlang =
$object->thirdparty->default_lang;
1553 if (!empty($newlang)) {
1555 $outputlangs->setDefaultLang($newlang);
1558 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1563 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1576 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1581 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1582 $vat_rate = str_replace(
'*',
'', $vat_rate);
1594 $pu_equivalent = $pu_ht;
1595 $pu_equivalent_ttc = $pu_ttc;
1597 $currency_tx =
$object->multicurrency_tx;
1601 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1602 $pu_equivalent = (float) $pu_ht_devise * (
float) $currency_tx;
1604 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1605 $pu_equivalent_ttc = (float) $pu_ttc_devise * (
float) $currency_tx;
1620 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1624 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1625 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1627 if (is_array($extralabelsline)) {
1628 foreach ($extralabelsline as $key => $value) {
1629 unset($_POST[
"options_".$key]);
1642 $price_base_type =
'HT';
1643 if (empty($pu) && !empty($pu_ttc)) {
1645 $price_base_type =
'TTC';
1650 if (!empty($productid)) {
1652 $product->fetch($productid);
1654 $type = $product->type;
1656 $price_min = $product->price_min;
1658 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1660 $price_min_ttc = $product->price_min_ttc;
1662 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1668 if ($usermustrespectpricemin) {
1669 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1670 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1673 $action =
'editline';
1674 } 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') {
1675 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1678 $action =
'editline';
1683 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1687 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1689 $action =
'editline';
1694 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1696 $action =
'editline';
1701 if ($qty < $object->expeditions[
GETPOST(
'lineid',
'int')]) {
1702 setEventMessages($langs->trans(
'ErrorQtyOrderedLessQtyShipped'),
null,
'errors');
1704 $action =
'editline';
1711 if (!$user->hasRight(
'margins',
'creer')) {
1712 foreach (
$object->lines as &$line) {
1714 $fournprice = $line->fk_fournprice;
1715 $buyingprice = $line->pa_ht;
1723 $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);
1730 $outputlangs = $langs;
1733 $newlang =
GETPOST(
'lang_id',
'aZ09');
1736 $newlang =
$object->thirdparty->default_lang;
1738 if (!empty($newlang)) {
1740 $outputlangs->setDefaultLang($newlang);
1744 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1747 unset($_POST[
'qty']);
1748 unset($_POST[
'type']);
1749 unset($_POST[
'productid']);
1750 unset($_POST[
'remise_percent']);
1751 unset($_POST[
'price_ht']);
1752 unset($_POST[
'multicurrency_price_ht']);
1753 unset($_POST[
'price_ttc']);
1754 unset($_POST[
'tva_tx']);
1755 unset($_POST[
'product_ref']);
1756 unset($_POST[
'product_label']);
1757 unset($_POST[
'product_desc']);
1758 unset($_POST[
'fournprice']);
1759 unset($_POST[
'buying_price']);
1761 unset($_POST[
'date_starthour']);
1762 unset($_POST[
'date_startmin']);
1763 unset($_POST[
'date_startsec']);
1764 unset($_POST[
'date_startday']);
1765 unset($_POST[
'date_startmonth']);
1766 unset($_POST[
'date_startyear']);
1767 unset($_POST[
'date_endhour']);
1768 unset($_POST[
'date_endmin']);
1769 unset($_POST[
'date_endsec']);
1770 unset($_POST[
'date_endday']);
1771 unset($_POST[
'date_endmonth']);
1772 unset($_POST[
'date_endyear']);
1779 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1780 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1782 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1785 $qualified_for_stock_change = 0;
1787 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1789 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1793 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1794 if (!$idwarehouse || $idwarehouse == -1) {
1796 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1802 $locationTarget =
'';
1806 $result =
$object->valid($user, $idwarehouse);
1811 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1814 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1815 && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1817 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1820 $forceFields = array();
1822 if (GETPOSTISSET(
'date_pointoftax')) {
1830 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1842 $outputlangs = $langs;
1845 $newlang =
GETPOST(
'lang_id',
'aZ09');
1848 $newlang =
$object->thirdparty->default_lang;
1850 if (!empty($newlang)) {
1852 $outputlangs->setDefaultLang($newlang);
1857 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1860 $deposit->fetch($deposit->id);
1861 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1865 if ($locationTarget) {
1866 header(
'Location: ' . $locationTarget);
1877 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1879 $idwarehouse =
GETPOST(
'idwarehouse');
1881 $qualified_for_stock_change = 0;
1883 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1885 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1889 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1890 if (!$idwarehouse || $idwarehouse == -1) {
1892 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1898 $result =
$object->setDraft($user, $idwarehouse);
1902 $outputlangs = $langs;
1905 $newlang =
GETPOST(
'lang_id',
'aZ09');
1908 $newlang =
$object->thirdparty->default_lang;
1910 if (!empty($newlang)) {
1912 $outputlangs->setDefaultLang($newlang);
1917 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1923 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1924 $result =
$object->cloture($user);
1928 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1931 $qualified_for_stock_change = 0;
1933 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1935 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1939 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1940 if (!$idwarehouse || $idwarehouse == -1) {
1942 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1948 $result =
$object->cancel($idwarehouse);
1956 if ($action ==
'update_extras' && $permissiontoeditextra) {
1959 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1962 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1969 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
1977 $action =
'edit_extras';
1983 $fromElement =
GETPOST(
'fromelement');
1984 $fromElementid =
GETPOST(
'fromelementid');
1985 $importLines =
GETPOST(
'line_checkbox');
1987 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1988 if ($fromElement ==
'commande') {
1990 $lineClassName =
'OrderLine';
1991 } elseif ($fromElement ==
'propal') {
1992 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1993 $lineClassName =
'PropaleLigne';
1994 } elseif ($fromElement ==
'facture') {
1995 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1996 $lineClassName =
'FactureLigne';
1998 $nextRang = count(
$object->lines) + 1;
2001 foreach ($importLines as $lineId) {
2002 $lineId = intval($lineId);
2003 $originLine =
new $lineClassName($db);
2004 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
2005 $originLine->fetch_optionals();
2006 $desc = $originLine->desc;
2007 $pu_ht = $originLine->subprice;
2008 $qty = $originLine->qty;
2009 $txtva = $originLine->tva_tx;
2010 $txlocaltax1 = $originLine->localtax1_tx;
2011 $txlocaltax2 = $originLine->localtax2_tx;
2012 $fk_product = $originLine->fk_product;
2013 $remise_percent = $originLine->remise_percent;
2014 $date_start = $originLine->date_start;
2015 $date_end = $originLine->date_end;
2016 $fk_code_ventilation = 0;
2017 $info_bits = $originLine->info_bits;
2018 $fk_remise_except = $originLine->fk_remise_except;
2019 $price_base_type =
'HT';
2021 $type = $originLine->product_type;
2022 $rang = $nextRang++;
2023 $special_code = $originLine->special_code;
2024 $origin = $originLine->element;
2025 $origin_id = $originLine->id;
2026 $fk_parent_line = 0;
2027 $fk_fournprice = $originLine->fk_fournprice;
2028 $pa_ht = $originLine->pa_ht;
2029 $label = $originLine->label;
2030 $array_options = $originLine->array_options;
2031 $situation_percent = 100;
2033 $fk_unit = $originLine->fk_unit;
2034 $pu_ht_devise = $originLine->multicurrency_subprice;
2036 $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);
2055 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2058 $upload_dir = !empty(
$conf->commande->multidir_output[
$object->entity]) ?
$conf->commande->multidir_output[
$object->entity] :
$conf->commande->dir_output;
2059 $permissiontoadd = $usercancreate;
2060 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2063 $triggersendname =
'ORDER_SENTBYMAIL';
2065 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
2066 $trackid =
'ord'.$object->id;
2067 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2071 if ($action ==
'addcontact' && $usercancreate) {
2075 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2079 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2082 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2083 $langs->load(
"errors");
2084 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2089 } elseif ($action ==
'swapstatut' && $usercancreate) {
2096 } elseif ($action ==
'deletecontact' && $usercancreate) {
2098 $result =
$object->delete_contact($lineid);
2101 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2115$title =
$object->ref.
" - ".$langs->trans(
'Card');
2116if ($action ==
'create') {
2117 $title = $langs->trans(
"NewOrder");
2119$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
2121llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
2123$form =
new Form($db);
2127if (isModEnabled(
'project')) {
2132if ($action ==
'create' && $usercancreate) {
2137 $res = $soc->fetch($socid);
2142 $currency_code =
$conf->currency;
2144 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2145 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2146 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2149 if (!empty($origin) && !empty($originid)) {
2151 $element = $subelement = $origin;
2153 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2154 $element = $regs[1];
2155 $subelement = $regs[2];
2158 if ($element ==
'project') {
2159 $projectid = $originid;
2161 if (!$cond_reglement_id) {
2162 $cond_reglement_id = $soc->cond_reglement_id;
2164 if (!$deposit_percent) {
2165 $deposit_percent = $soc->deposit_percent;
2167 if (!$mode_reglement_id) {
2168 $mode_reglement_id = $soc->mode_reglement_id;
2170 if (!$remise_percent) {
2171 $remise_percent = $soc->remise_percent;
2179 if ($element ==
'order' || $element ==
'commande') {
2180 $element = $subelement =
'commande';
2181 } elseif ($element ==
'propal') {
2182 $element =
'comm/propal';
2183 $subelement =
'propal';
2184 } elseif ($element ==
'contract') {
2185 $element = $subelement =
'contrat';
2190 $classname = ucfirst($subelement);
2191 $objectsrc =
new $classname($db);
2192 '@phan-var-force Commande|Propal|Contrat $objectsrc';
2193 $objectsrc->fetch($originid);
2194 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2195 $objectsrc->fetch_lines();
2197 $objectsrc->fetch_thirdparty();
2200 $objectsrc->fetch_optionals();
2201 $object->array_options = $objectsrc->array_options;
2203 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2204 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2206 $soc = $objectsrc->thirdparty;
2207 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2208 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
2209 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2210 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
2211 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
2212 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
2213 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
2214 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
2219 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
2221 if (isModEnabled(
"multicurrency")) {
2222 if (!empty($objectsrc->multicurrency_code)) {
2223 $currency_code = $objectsrc->multicurrency_code;
2225 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2226 $currency_tx = $objectsrc->multicurrency_tx;
2230 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
2231 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
2234 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
2237 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2238 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2239 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2240 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
2241 $availability_id = 0;
2242 $shipping_method_id = $soc->shipping_method_id;
2243 $warehouse_id = $soc->fk_warehouse;
2244 $demand_reason_id = $soc->demand_reason_id;
2249 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2250 $currency_code = $soc->multicurrency_code;
2253 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
2254 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
2258 if (!
GETPOST(
'changecompany')) {
2259 if (GETPOSTISSET(
'cond_reglement_id')) {
2260 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2262 if (GETPOSTISSET(
'deposit_percent')) {
2265 if (GETPOSTISSET(
'mode_reglement_id')) {
2266 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2268 if (GETPOSTISSET(
'cond_reglement_id')) {
2274 if ($soc->fk_warehouse > 0) {
2275 $warehouse_id = $soc->fk_warehouse;
2277 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2282 $warehouse_id = $user->fk_warehouse;
2286 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2287 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2288 print
'<input type="hidden" name="action" value="add">';
2289 print
'<input type="hidden" name="changecompany" value="0">';
2290 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
2291 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2292 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2293 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2294 if (!empty($currency_tx)) {
2295 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2301 $parameters = array();
2303 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters,
$object, $action);
2304 if (empty($reshook)) {
2305 print
'<table class="border centpercent">';
2308 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
2311 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
2312 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
2313 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
2315 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
2321 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
2324 print $soc->getNomUrl(1,
'customer');
2325 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
2328 print
'<td class="valuefieldcreate">';
2329 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2330 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
2334 $(document).ready(function() {
2335 $("#socid").change(function() {
2336 console.log("We have changed the company - Reload page");
2337 var socid = $(this).val();
2339 $("input[name=action]").val("create");
2340 $("input[name=changecompany]").val("1");
2341 $("form[name=crea_commande]").submit();
2346 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>';
2356 print $form->textwithpicto($langs->trans(
"DefaultContact"), $langs->trans(
"TypeContact_commande_external_".$type_contact_code));
2358 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2360 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
2364 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2366 $absolute_discount = $soc->getAvailableDiscounts();
2370 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode((
string) (
GETPOST(
'origin'))).
'&originid='.urlencode((
string) (
GETPOSTINT(
'originid')));
2371 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2377 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
2378 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2379 print $form->selectDate(
'',
're', 0, 0, 0,
"crea_commande", 1, 1);
2383 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
2384 print
'<td colspan="3">';
2385 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
2386 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2387 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
2392 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
2393 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2394 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2398 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2399 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2400 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', (
float) $deposit_percent);
2404 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2405 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2406 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2410 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
2411 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2412 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2417 if (isModEnabled(
'shipping')) {
2418 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
2419 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
2420 $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');
2425 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2426 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2428 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
2429 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');
2434 print
'<tr><td>'.$langs->trans(
'Source').
'</td><td>';
2435 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2436 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2442 if (isModEnabled(
'project')) {
2443 $langs->load(
"projects");
2445 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2446 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');
2447 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>';
2453 if (isModEnabled(
'incoterm')) {
2455 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>';
2456 print
'<td class="maxwidthonsmartphone">';
2457 $incoterm_id =
GETPOST(
'incoterm_id');
2458 $location_incoterms =
GETPOST(
'location_incoterms');
2459 if (empty($incoterm_id)) {
2460 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2461 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2463 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2464 print $form->select_incoterms($incoterm_id, $location_incoterms);
2469 $parameters = array();
2470 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2471 $parameters[
'objectsrc'] = $objectsrc;
2473 $parameters[
'socid'] = $socid;
2476 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2477 print $hookmanager->resPrint;
2478 if (empty($reshook)) {
2479 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2482 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2483 if ($soc->fetch_optionals() > 0) {
2484 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2488 print
$object->showOptionals($extrafields,
'create', $parameters);
2492 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2494 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2497 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2498 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2502 if (isModEnabled(
"multicurrency")) {
2504 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'',
$object, 0).
'</td>';
2505 print
'<td class="maxwidthonsmartphone">';
2506 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2511 if (!empty(
$conf->categorie->enabled)) {
2512 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2513 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories',
$object);
2519 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2522 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2523 print $doleditor->Create(1);
2528 if (empty($user->socid)) {
2530 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2533 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2534 print $doleditor->Create(1);
2539 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2541 if ($origin ==
'contrat') {
2545 $objectsrc->update_price(1);
2548 print
"\n<!-- ".$classname.
" info -->";
2550 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2551 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2552 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2553 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2554 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2556 switch ($classname) {
2558 $newclassname =
'CommercialProposal';
2561 $newclassname =
'Order';
2564 $newclassname =
'Sending';
2567 $newclassname =
'Contract';
2570 $newclassname = $classname;
2573 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2576 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2577 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2578 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2579 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2582 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2583 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2586 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2588 if (isModEnabled(
"multicurrency")) {
2589 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2590 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2591 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2602 print $form->buttonsSaveCancel(
"CreateDraft");
2605 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2606 $title = $langs->trans(
'ProductsAndServices');
2609 print
'<div class="div-table-responsive-no-min">';
2610 print
'<table class="noborder centpercent">';
2612 $objectsrc->printOriginLinesList(
'', $selectedLines);
2624 $product_static =
new Product($db);
2629 $author =
new User($db);
2630 $author->fetch(
$object->user_author_id);
2633 $res =
$object->fetch_optionals();
2636 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order', 0,
'',
'', 0,
'', 1);
2641 if ($action ==
'delete') {
2642 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2646 if ($action ==
'validate') {
2648 $ref = substr(
$object->ref, 1, 4);
2649 if ($ref ==
'PROV' || $ref ==
'') {
2650 $numref =
$object->getNextNumRef($soc);
2651 if (empty($numref)) {
2659 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2660 if (isModEnabled(
'notification')) {
2661 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2662 $notify =
new Notify($db);
2664 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid,
$object);
2667 $qualified_for_stock_change = 0;
2669 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2671 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2674 $formquestion = array();
2675 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2676 $langs->load(
"stocks");
2677 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2680 if (
$conf->browser->name ==
'ie') {
2683 $formquestion = array(
2687 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2693 foreach (
$object->lines as $line) {
2694 $res = $line->fetch_product();
2696 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2702 if ($nbMandated > 0) {
2704 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2707 $text .=
'<div><span class="clearboth nowraponall warning">'.img_warning().$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2711 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2716 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2718 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2719 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2723 $eligibleForDepositGeneration =
true;
2725 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2726 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2727 '@phan-var-force Facture $invoice';
2729 $eligibleForDepositGeneration =
false;
2735 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2736 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2737 $proposal->fetchObjectLinked();
2739 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2740 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2741 '@phan-var-force Facture $invoice';
2743 $eligibleForDepositGeneration =
false;
2751 if ($eligibleForDepositGeneration) {
2752 $formquestion[] = array(
2753 'type' =>
'checkbox',
2755 'name' =>
'generate_deposit',
2756 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2759 $formquestion[] = array(
2761 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2763 'label' => $langs->trans(
'DateInvoice'),
2769 $formquestion[] = array(
2771 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2772 'name' =>
'date_pointoftax',
2773 'label' => $langs->trans(
'DatePointOfTax'),
2780 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2782 $formquestion[] = array(
2784 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2785 'name' =>
'cond_reglement_id',
2786 'label' => $langs->trans(
'PaymentTerm'),
2787 'value' => $paymentTermsSelect
2790 $formquestion[] = array(
2791 'type' =>
'checkbox',
2792 'tdclass' =>
'showonlyifgeneratedeposit',
2793 'name' =>
'validate_generated_deposit',
2794 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2797 $formquestion[] = array(
2798 'type' =>
'onecolumn',
2801 $(document).ready(function() {
2802 $("[name=generate_deposit]").change(function () {
2803 let $self = $(this);
2804 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2806 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2823 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2828 if ($action ==
'modif') {
2829 $qualified_for_stock_change = 0;
2831 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2833 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2836 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2837 $formquestion = array();
2838 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2839 $langs->load(
"stocks");
2840 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2843 if (
$conf->browser->name ==
'ie') {
2846 $formquestion = array(
2850 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2854 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2858 if ($action ==
'shipped') {
2859 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2863 if ($action ==
'cancel') {
2864 $qualified_for_stock_change = 0;
2866 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2868 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2871 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2872 $formquestion = array();
2873 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2874 $langs->load(
"stocks");
2875 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2878 if (
$conf->browser->name ==
'ie') {
2881 $formquestion = array(
2885 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2889 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2893 if ($action ==
'ask_deleteline') {
2894 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2898 if ($action ==
'ask_subtotal_deleteline') {
2899 $langs->load(
"subtotals");
2900 $title =
"DeleteSubtotalLine";
2901 $question =
"ConfirmDeleteSubtotalLine";
2902 if (
GETPOST(
'type') ==
'title') {
2903 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
2904 $title =
"DeleteTitleLine";
2905 $question =
"ConfirmDeleteTitleLine";
2907 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
2911 if ($action ==
'clone') {
2912 $filter =
'(s.client:IN:1,2,3)';
2914 $formquestion = array(
2915 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300'))
2917 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2921 if ($action ==
'add_title_line') {
2922 $langs->load(
'subtotals');
2924 $depth_array =
$object->getPossibleLevels($langs);
2926 } elseif ($action ==
'add_subtotal_line') {
2927 $langs->load(
'subtotals');
2929 $titles =
$object->getPossibleTitles();
2934 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2936 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2937 if (empty($reshook)) {
2938 $formconfirm .= $hookmanager->resPrint;
2939 } elseif ($reshook > 0) {
2940 $formconfirm = $hookmanager->resPrint;
2949 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2951 $morehtmlref =
'<div class="refidno">';
2953 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, (
int) $usercancreate,
'string',
'', 0, 1);
2954 $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);
2956 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2958 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2961 if (isModEnabled(
'project')) {
2962 $langs->load(
"projects");
2963 $morehtmlref .=
'<br>';
2964 if ($usercancreate) {
2965 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2966 if ($action !=
'classify') {
2967 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2969 $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');
2971 if (!empty(
$object->fk_project)) {
2973 $proj->fetch(
$object->fk_project);
2974 $morehtmlref .= $proj->getNomUrl(1);
2976 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2981 $morehtmlref .=
'</div>';
2984 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2987 $parameters = array();
2989 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters,
$object, $action);
2990 if (empty($reshook)) {
2991 print
'<div class="fichecenter">';
2992 print
'<div class="fichehalfleft">';
2993 print
'<div class="underbanner clearboth"></div>';
2995 print
'<table class="border tableforfield centpercent">';
2999 $langs->load(
"cashdesk");
3000 print
'<tr><td class="fieldname_type">';
3001 print
'<table class="nobordernopadding centpercent"><tr><td>';
3002 print $form->textwithpicto($langs->trans(
'PointOfSale'), $langs->trans(
'POSInfo'));
3004 if ($action !=
'editposinfo' && $usercancreate) {
3005 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>';
3007 print
'</tr></table>';
3008 print
'</td><td class="valuefield fieldname_type">';
3009 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" name="formposinfo">';
3010 print
'<input type="hidden" name="action" value="setposinfo">';
3011 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3012 if ($action ==
'editposinfo') {
3013 print
'<input type="text" class="maxwidth150" name="posmodule" placeholder="'.$langs->trans(
"POSModule").
'" value="'.
$object->module_source.
'"> ';
3014 print
'<input type="text" class="maxwidth100" name="posterminal" placeholder="'.$langs->trans(
"Terminal").
'" value="'.
$object->pos_source.
'">';
3015 print
'<input type="submit" class="button" name="submitposinfo" value="'.$langs->trans(
"Submit").
'">';
3018 print
'<span class="opacitymediumbycolor paddingleft">'.dolPrintHTML(ucfirst(
$object->module_source).
' - '.$langs->transnoentitiesnoconv(
"Terminal").
' '.
$object->pos_source).
'</span>';
3025 if ($soc->outstanding_limit) {
3027 print
'<tr><td class="titlefield">';
3028 print $langs->trans(
'OutstandingBill');
3029 print
'</td><td class="valuefield">';
3030 $arrayoutstandingbills = $soc->getOutstandingBills();
3031 print
price($arrayoutstandingbills[
'opened']).
' / ';
3032 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1,
$conf->currency);
3039 $filterabsolutediscount =
"fk_facture_source IS NULL";
3040 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3042 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3043 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3046 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
3047 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
3048 $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>';
3050 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
3052 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3053 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3054 $absolute_discount =
price2num($absolute_discount,
'MT');
3055 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3059 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id;
3060 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3067 print $form->editfieldkey(
"Date",
'date',
'',
$object, (
int) $editenable);
3068 print
'</td><td class="valuefield">';
3069 if ($action ==
'editdate') {
3070 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
3071 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3072 print
'<input type="hidden" name="action" value="setdate">';
3073 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3074 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
3075 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
3080 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
3088 $editenable = $usercancreate;
3089 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'',
$object, (
int) $editenable);
3090 print
'</td><td class="valuefield">';
3091 if ($action ==
'editdate_livraison') {
3092 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
3093 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3094 print
'<input type="hidden" name="action" value="setdate_livraison">';
3095 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3096 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
3097 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
3102 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
3109 print
'<tr class="fielddeliverydelay"><td>';
3110 $editenable = $usercancreate;
3111 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'',
$object, (
int) $editenable);
3112 print
'</td><td class="valuefield">';
3113 if ($action ==
'editavailability') {
3114 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->availability_id,
'availability_id', 1);
3116 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->availability_id,
'none', 1);
3121 if (isModEnabled(
'shipping')) {
3123 $editenable = $usercancreate;
3124 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'',
$object, (
int) $editenable);
3125 print
'</td><td class="valuefield">';
3126 if ($action ==
'editshippingmethod') {
3127 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3129 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->shipping_method_id,
'none');
3136 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
3137 $langs->load(
'stocks');
3138 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3141 $editenable = $usercancreate;
3142 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, (
int) $editenable);
3143 print
'</td><td class="valuefield">';
3144 if ($action ==
'editwarehouse') {
3145 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3147 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'none');
3155 $editenable = $usercancreate;
3156 print $form->editfieldkey(
"Source",
'demandreason',
'',
$object, (
int) $editenable);
3157 print
'</td><td class="valuefield">';
3158 if ($action ==
'editdemandreason') {
3159 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3161 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->demand_reason_id,
'none');
3167 $editenable = $usercancreate;
3168 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'',
$object, (
int) $editenable);
3169 print
'</td><td class="valuefield">';
3170 if ($action ==
'editconditions') {
3171 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
3173 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
3181 $editenable = $usercancreate;
3182 print $form->editfieldkey(
"PaymentMode",
'mode',
'',
$object, (
int) $editenable);
3183 print
'</td><td class="valuefield">';
3184 if ($action ==
'editmode') {
3185 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3187 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3205 $tmparray =
$object->getTotalWeightVolume();
3206 $totalWeight = $tmparray[
'weight'];
3207 $totalVolume = $tmparray[
'volume'];
3209 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
3210 print
'<td class="valuefield">';
3215 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
3216 print
'<td class="valuefield">';
3224 if (isModEnabled(
'incoterm')) {
3226 $editenable = $usercancreate;
3227 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'',
$object, (
int) $editenable);
3229 print
'<td class="valuefield">';
3230 if ($action !=
'editincoterm') {
3231 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3233 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3239 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
3241 $editenable = $usercancreate;
3242 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'',
$object, (
int) $editenable);
3243 print
'</td><td class="valuefield">';
3244 if ($action ==
'editbankaccount') {
3245 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3247 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3254 if (isModEnabled(
'category')) {
3256 print
'<table class="nobordernopadding centpercent"><tr><td>';
3257 print $langs->trans(
"Categories");
3258 print
'<td><td class="right">';
3259 if ($usercancreate) {
3260 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/commande/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3264 print
'</td></tr></table>';
3267 if ($action ==
'edittags') {
3268 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3269 print
'<input type="hidden" name="action" value="settags">';
3270 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3271 print $form->selectCategories(Categorie::TYPE_ORDER,
'categories',
$object);
3272 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3275 print $form->showCategories(
$object->id, Categorie::TYPE_ORDER, 1);
3281 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3286 print
'<div class="fichehalfright">';
3287 print
'<div class="underbanner clearboth"></div>';
3289 print
'<table class="border tableforfield centpercent">';
3291 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3295 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
3299 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3300 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3301 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3303 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3308 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
3309 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3310 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3312 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3317 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3319 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
3320 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3321 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3324 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3330 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3332 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
3333 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3334 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3337 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3343 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3344 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1,
$conf->currency) .
'</td>';
3345 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3347 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3357 if (isModEnabled(
'margin')) {
3358 $formmargin->displayMarginInfos(
$object);
3365 print
'<div class="clearboth"></div><br>';
3368 $blocname =
'contacts';
3369 $title = $langs->trans(
'ContactsAddresses');
3370 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3374 $blocname =
'notes';
3375 $title = $langs->trans(
'Notes');
3376 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3384 $result =
$object->getLinesArray();
3388 global $inputalsopricewithtax;
3389 $inputalsopricewithtax = 1;
3391 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">
3392 <input type="hidden" name="token" value="' .
newToken().
'">
3393 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
3394 <input type="hidden" name="mode" value="">
3395 <input type="hidden" name="page_y" value="">
3396 <input type="hidden" name="id" value="' .
$object->id.
'">
3397 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
3401 if (isModEnabled(
'subtotals')) {
3402 include DOL_DOCUMENT_ROOT.
'/core/tpl/subtotal_ajaxrow.tpl.php';
3404 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3408 print
'<div class="div-table-responsive-no-min">';
3409 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3413 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
3420 if ($action !=
'editline') {
3423 $parameters = array();
3425 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
3429 if (empty($reshook)) {
3430 $object->formAddObjectLine(1, $mysoc, $soc);
3433 $parameters = array();
3434 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters,
$object, $action);
3448 if ($action !=
'presend' && $action !=
'editline') {
3449 print
'<div class="tabsAction">';
3451 $parameters = array();
3453 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3454 if (empty($reshook)) {
3455 $numlines = count(
$object->lines);
3463 if (empty($user->socid)) {
3466 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
3468 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3476 $langs->load(
'subtotals');
3478 $url_button = array();
3480 $url_button[] = array(
3481 'lang' =>
'subtotals',
3483 'perm' => (
bool) $usercancreate,
3484 'label' => $langs->trans(
'AddTitleLine'),
3485 'url' =>
'/commande/card.php?id='.$object->id.
'&action=add_title_line&token='.
newToken()
3488 $url_button[] = array(
3489 'lang' =>
'subtotals',
3491 'perm' => (
bool) $usercancreate,
3492 'label' => $langs->trans(
'AddSubtotalLine'),
3493 'url' =>
'/commande/card.php?id='.$object->id.
'&action=add_subtotal_line&token='.
newToken()
3495 print
dolGetButtonAction(
'', $langs->trans(
'Subtotal'),
'default', $url_button,
'',
true);
3500 if ($numlines > 0) {
3503 $langs->load(
"errors");
3504 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);
3512 $arrayforbutaction = array();
3516 $arrayforbutaction[] = array(
3519 'perm' => $usercancreatepurchaseorder,
3520 'label' =>
'AddPurchaseOrder',
3521 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3533 $arrayforbutaction[] = array(
3534 'lang' =>
'interventions',
3536 'perm' => ($user->hasRight(
'ficheinter',
'creer') == 1),
3537 'label' =>
'AddIntervention',
3538 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid),
3543 $arrayforbutaction[] = array(
3544 'lang' =>
'contracts',
3546 'perm' => ($user->hasRight(
'contrat',
'creer') == 1),
3547 'label' =>
'AddContract',
3548 'url' =>
'/contrat/card.php?action=create&origin=' .
$object->element .
'&originid=' .
$object->id .
'&socid=' .
$object->socid,
3561 if (isModEnabled(
'shipping')) {
3562 $numshipping =
$object->countNbOfShipments();
3565 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3567 $arrayforbutaction[] = array(
3568 'lang' =>
'sendings',
3570 'perm' => $user->hasRight(
'expedition',
'creer'),
3571 'label' =>
'CreateShipment',
3572 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3577 $arrayforbutaction[] = array(
3578 'lang' =>
'sendings',
3581 'label' =>
'CreateShipment',
3582 'url' =>
'/expedition/shipment.php?id=' .
$object->id
3589 $arrayforbutaction[] = array(
3592 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3593 'label' =>
'CreateBill',
3594 'url' =>
'/compta/facture/card.php?action=create&token=' .
newToken() .
'&origin=' . urlencode(
$object->element) .
'&originid=' .
$object->id .
'&socid=' .
$object->socid
3603 $actionButtonsParameters = [
3604 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3607 if ($numlines > 0) {
3608 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3610 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3615 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.
newToken().
'&id='.
$object->id,
'');
3622 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3627 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.
newToken().
'&id='.
$object->id,
'');
3632 if ($usercancreate) {
3638 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"CancelOrder").
'</a>';
3642 if ($usercandelete) {
3643 if ($numshipping == 0) {
3646 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3654 if (
GETPOST(
'modelselected')) {
3655 $action =
'presend';
3658 if ($action !=
'presend') {
3659 print
'<div class="fichecenter"><div class="fichehalfleft">';
3660 print
'<a name="builddoc"></a>';
3663 $relativepath = $objref.
'/'.$objref.
'.pdf';
3664 $filedir =
$conf->commande->multidir_output[
$object->entity].
'/'.$objref;
3665 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3666 $genallowed = $usercanread;
3667 $delallowed = $usercancreate;
3668 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, (
int) $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'',
$object);
3672 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'order'), 1);
3673 $linktoelem = $tmparray[
'linktoelem'];
3674 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3675 print $htmltoenteralink;
3677 $compatibleImportElementsList =
false;
3680 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3682 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem, $compatibleImportElementsList);
3686 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3687 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3688 $useonlinepayment = count($validpaymentmethod);
3691 $useonlinepayment = 0;
3694 print
'<br><!-- Link to pay -->';
3695 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3696 print showOnlinePaymentUrl(
'order',
$object->ref).
'<br>';
3699 print
'</div><div class="fichehalfright">';
3703 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id);
3706 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3708 $somethingshown = $formactions->showactions(
$object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3710 print
'</div></div>';
3714 $modelmail =
'order_send';
3715 $defaulttopic =
'SendOrderRef';
3717 $trackid =
'ord'.$object->id;
3719 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.