41require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54if (isModEnabled(
"propal")) {
55 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
58if (isModEnabled(
'project')) {
59 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
63if (isModEnabled(
'variants')) {
64 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
69$langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'deliveries',
'products',
'other'));
71if (isModEnabled(
'incoterm')) {
72 $langs->load(
'incoterm');
74if (isModEnabled(
'margin')) {
75 $langs->load(
'margins');
77if (isModEnabled(
'productbatch')) {
78 $langs->load(
'productbatch');
85$action =
GETPOST(
'action',
'aZ09');
86$cancel =
GETPOST(
'cancel',
'alpha');
87$confirm =
GETPOST(
'confirm',
'alpha');
88$backtopage =
GETPOST(
'backtopage',
'alpha');
93$origin =
GETPOST(
'origin',
'alpha');
103if (!empty($user->socid)) {
104 $socid = $user->socid;
108$hookmanager->initHooks(array(
'ordercard',
'globalcard'));
116$extrafields->fetch_name_optionals_label(
$object->table_element);
119include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
122$usercanread = $user->hasRight(
"commande",
"lire");
123$usercancreate = $user->hasRight(
"commande",
"creer");
124$usercandelete = $user->hasRight(
"commande",
"supprimer");
127$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'close')));
128$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'validate')));
129$usercancancel = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'commande',
'order_advance',
'annuler')));
130$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'send'));
131$usercangeneretedoc = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
133$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
134$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
136$permissionnote = $usercancreate;
137$permissiondellink = $usercancreate;
138$permissiontoadd = $usercancreate;
150$parameters = array(
'socid' => $socid);
152$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
157if (empty($reshook)) {
158 $backurlforlist = DOL_URL_ROOT.
'/commande/list.php';
160 if (empty($backtopage) || ($cancel && empty($id))) {
161 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
162 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
163 $backtopage = $backurlforlist;
165 $backtopage = DOL_URL_ROOT.
'/commande/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
170 $selectedLines =
GETPOST(
'toselect',
'array');
173 if (!empty($backtopageforcancel)) {
174 header(
"Location: ".$backtopageforcancel);
176 } elseif (!empty($backtopage)) {
177 header(
"Location: ".$backtopage);
183 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
185 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
187 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
190 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
192 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
198 $result =
$object->createFromClone($user, $socid);
200 $warningMsgLineList = array();
202 foreach (
$object->lines as $line) {
203 if (!is_object($line->product)) {
204 $line->fetch_product();
206 if (is_object($line->product) && $line->product->id > 0) {
207 if (empty($line->product->status)) {
208 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
212 if (!empty($warningMsgLineList)) {
216 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
225 } elseif ($action ==
'reopen' && $usercancreate) {
229 $result =
$object->setDraft($user, $idwarehouse);
234 $result =
$object->set_reopen($user);
242 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
244 $result =
$object->delete($user);
246 header(
'Location: list.php?restore_lastsearch_values=1');
251 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
253 $result =
$object->deleteLine($user, $lineid);
258 $outputlangs = $langs;
261 $newlang =
GETPOST(
'lang_id',
'aZ09');
264 $newlang =
$object->thirdparty->default_lang;
266 if (!empty($newlang)) {
268 $outputlangs->setDefaultLang($newlang);
272 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
275 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
280 } elseif ($action ==
'classin' && $usercancreate) {
283 } elseif ($action ==
'add' && $usercancreate) {
288 if ($datecommande ==
'') {
289 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
295 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
306 $object->date_commande = $datecommande;
319 $object->delivery_date = $date_delivery;
325 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
326 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
330 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
337 if (!empty($origin) && !empty($originid)) {
339 $element = $subelement = $origin;
341 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
342 $element = $regs [1];
343 $subelement = $regs [2];
347 if ($element ==
'order') {
348 $element = $subelement =
'commande';
350 if ($element ==
'propal') {
351 $element =
'comm/propal';
352 $subelement =
'propal';
354 if ($element ==
'contract') {
355 $element = $subelement =
'contrat';
359 $object->origin_id = $originid;
363 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
364 if (!empty($other_linked_objects)) {
365 $object->linked_objects = array_merge(
$object->linked_objects, $other_linked_objects);
369 $object_id =
$object->create($user);
371 if ($object_id > 0) {
374 $classname = ucfirst($subelement);
375 $srcobject =
new $classname($db);
378 $result = $srcobject->fetch(
$object->origin_id);
380 $lines = $srcobject->lines;
381 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
382 $srcobject->fetch_lines();
383 $lines = $srcobject->lines;
387 $num = count($lines);
389 for ($i = 0; $i < $num; $i++) {
390 if (!in_array($lines[$i]->
id, $selectedLines)) {
394 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
395 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
396 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
400 $date_start = $lines[$i]->date_debut_prevue;
401 if ($lines[$i]->date_debut_reel) {
402 $date_start = $lines[$i]->date_debut_reel;
404 if ($lines[$i]->date_start) {
405 $date_start = $lines[$i]->date_start;
407 $date_end = $lines[$i]->date_fin_prevue;
408 if ($lines[$i]->date_fin_reel) {
409 $date_end = $lines[$i]->date_fin_reel;
411 if ($lines[$i]->date_end) {
412 $date_end = $lines[$i]->date_end;
416 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
421 if (method_exists($lines[$i],
'fetch_optionals')) {
422 $lines[$i]->fetch_optionals();
423 $array_options = $lines[$i]->array_options;
426 $tva_tx = $lines[$i]->tva_tx;
427 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
428 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
433 $lines[$i]->subprice,
436 $lines[$i]->localtax1_tx,
437 $lines[$i]->localtax2_tx,
438 $lines[$i]->fk_product,
439 $lines[$i]->remise_percent,
440 $lines[$i]->info_bits,
441 $lines[$i]->fk_remise_except,
448 $lines[$i]->special_code,
450 $lines[$i]->fk_fournprice,
465 if ($result > 0 && $lines[$i]->product_type == 9) {
466 $fk_parent_line = $result;
501 $parameters = array(
'objFrom' => $srcobject);
503 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
518 $object_id =
$object->create($user);
523 if ($object_id > 0) {
537 if ($object_id > 0 && !$error) {
539 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object_id);
547 } elseif ($action ==
'classifybilled' && $usercancreate) {
548 $ret =
$object->classifyBilled($user);
553 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
554 $ret =
$object->classifyUnBilled($user);
558 } elseif ($action ==
'setref_client' && $usercancreate) {
564 } elseif ($action ==
'setremise' && $usercancreate) {
569 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
577 } elseif ($action ==
'setdate' && $usercancreate) {
580 $result =
$object->set_date($user, $date);
584 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
588 $result =
$object->setDeliveryDate($user, $date_delivery);
592 } elseif ($action ==
'setmode' && $usercancreate) {
597 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
599 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
600 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
603 } elseif ($action ==
'setavailability' && $usercancreate) {
608 } elseif ($action ==
'setdemandreason' && $usercancreate) {
613 } elseif ($action ==
'setconditions' && $usercancreate) {
620 $outputlangs = $langs;
621 $newlang =
GETPOST(
'lang_id',
'alpha');
623 $newlang =
$object->thirdparty->default_lang;
625 if (!empty($newlang)) {
627 $outputlangs->setDefaultLang($newlang);
631 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
634 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
640 } elseif ($action ==
'setbankaccount' && $usercancreate) {
646 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
652 } elseif ($action ==
'setwarehouse' && $usercancreate) {
662 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
666 foreach (
$object->lines as $line) {
667 if ($line->product_type == 1) {
668 $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);
671 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
673 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
674 $vat_rate = str_replace(
'*',
'', $vat_rate);
677 foreach (
$object->lines as $line) {
678 $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);
680 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
682 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
683 $remise_percent = str_replace(
'*',
'', $remise_percent);
684 foreach (
$object->lines as $line) {
685 $tvatx= $line->tva_tx;
686 if (!empty($line->vat_src_code)) {
687 $tvatx .=
' ('.$line->vat_src_code.
')';
689 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $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);
691 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && $usercancreate) {
692 $langs->load(
'errors');
697 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
700 $price_ht_devise =
'';
702 $price_ttc_devise =
'';
708 if (
GETPOST(
'price_ht') !==
'') {
711 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
714 if (
GETPOST(
'price_ttc') !==
'') {
717 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
721 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
722 if ($prod_entry_mode ==
'free') {
728 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
733 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
737 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
738 if (empty($remise_percent)) {
743 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
744 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
746 if (is_array($extralabelsline)) {
748 foreach ($extralabelsline as $key => $value) {
749 unset($_POST[
"options_".$key]);
753 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
754 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
757 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
758 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
761 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
762 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
766 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
770 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
773 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
774 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
778 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
779 if ($combinations =
GETPOST(
'combinations',
'array')) {
783 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
784 $idprod = $res->fk_product_child;
786 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
792 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
796 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
798 $price_min = $price_min_ttc = 0;
804 if (!empty($idprod) && $idprod > 0) {
806 $prod->fetch($idprod);
808 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
817 $pu_ht = $prod->price;
818 $pu_ttc = $prod->price_ttc;
819 $price_min = $prod->price_min;
820 $price_min_ttc = $prod->price_min_ttc;
821 $price_base_type = $prod->price_base_type;
825 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
826 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
827 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
828 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
829 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
831 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
832 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
834 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
835 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
840 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
844 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' =>
$object->thirdparty->id);
846 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
848 if (count($prodcustprice->lines) > 0) {
849 $pu_ht =
price($prodcustprice->lines[0]->price);
850 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
851 $price_min =
price($prodcustprice->lines[0]->price_min);
852 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
853 $price_base_type = $prodcustprice->lines[0]->price_base_type;
854 $tva_tx = $prodcustprice->lines[0]->tva_tx;
855 if ($prodcustprice->lines[0]->default_vat_code && !preg_match(
'/\(.*\)/', $tva_tx)) {
856 $tva_tx .=
' ('.$prodcustprice->lines[0]->default_vat_code.
')';
858 $tva_npr = $prodcustprice->lines[0]->recuperableonly;
859 if (empty($tva_tx)) {
868 if ($prod->prices_by_qty[0]) {
873 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
874 if ($priceforthequantityarray[
'rowid'] != $pqp) {
878 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
879 $pu_ht = $priceforthequantityarray[
'unitprice'];
881 $pu_ttc = $priceforthequantityarray[
'unitprice'];
889 if ($prod->prices_by_qty[
$object->thirdparty->price_level]) {
893 foreach ($prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
894 if ($priceforthequantityarray[
'rowid'] != $pqp) {
898 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
899 $pu_ht = $priceforthequantityarray[
'unitprice'];
901 $pu_ttc = $priceforthequantityarray[
'unitprice'];
909 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
910 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
913 if (!empty($price_ht) || $price_ht ===
'0') {
915 $pu_ttc =
price2num((
float) $pu_ht * (1 + ($tmpvat / 100)),
'MU');
916 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
918 $pu_ht =
price2num((
float) $pu_ttc / (1 + ($tmpvat / 100)),
'MU');
919 } elseif ($tmpvat != $tmpprodvat) {
921 if ($price_base_type !=
'HT') {
922 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
924 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
932 $outputlangs = $langs;
934 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
935 $newlang =
GETPOST(
'lang_id',
'aZ09');
937 if (empty($newlang)) {
938 $newlang =
$object->thirdparty->default_lang;
940 if (!empty($newlang)) {
942 $outputlangs->setDefaultLang($newlang);
945 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
947 $desc = $prod->description;
956 $desc = $product_desc;
962 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
966 $outputlangs = $langs;
968 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
969 $newlang =
GETPOST(
'lang_id',
'alpha');
971 if (empty($newlang)) {
972 $newlang =
$object->thirdparty->default_lang;
974 if (!empty($newlang)) {
976 $outputlangs->setDefaultLang($newlang);
977 $outputlangs->load(
'products');
979 if (!empty($prod->customcode)) {
980 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
982 if (!empty($prod->customcode) && !empty($prod->country_code)) {
985 if (!empty($prod->country_code)) {
986 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
989 if (!empty($prod->customcode)) {
990 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
992 if (!empty($prod->customcode) && !empty($prod->country_code)) {
995 if (!empty($prod->country_code)) {
996 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
1003 $type = $prod->type;
1004 $fk_unit = $prod->fk_unit;
1008 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1009 $tva_tx = str_replace(
'*',
'', $tva_tx);
1010 if (empty($tva_tx)) {
1013 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1014 $desc = $product_desc;
1016 $fk_unit =
GETPOST(
'units',
'alpha');
1017 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1018 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1020 if ($pu_ttc && !$pu_ht) {
1021 $price_base_type =
'TTC';
1039 $pu_equivalent = $pu_ht;
1040 $pu_equivalent_ttc = $pu_ttc;
1042 $currency_tx =
$object->multicurrency_tx;
1046 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1047 $pu_equivalent = (float) $pu_ht_devise * (
float) $currency_tx;
1049 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1050 $pu_equivalent_ttc = (float) $pu_ttc_devise * (
float) $currency_tx;
1067 if ($usermustrespectpricemin) {
1068 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min)) && $price_base_type ==
'HT') {
1069 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1072 } 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') {
1073 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1081 $result =
$object->addline($desc, $pu_ht, $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,
GETPOST(
'fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit,
'', 0, $pu_ht_devise);
1089 $outputlangs = $langs;
1090 $newlang =
GETPOST(
'lang_id',
'alpha');
1092 $newlang =
$object->thirdparty->default_lang;
1094 if (!empty($newlang)) {
1095 $outputlangs =
new Translate(
"", $conf);
1096 $outputlangs->setDefaultLang($newlang);
1099 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1102 unset($_POST[
'prod_entry_mode']);
1104 unset($_POST[
'qty']);
1105 unset($_POST[
'type']);
1106 unset($_POST[
'remise_percent']);
1107 unset($_POST[
'price_ht']);
1108 unset($_POST[
'multicurrency_price_ht']);
1109 unset($_POST[
'price_ttc']);
1110 unset($_POST[
'tva_tx']);
1111 unset($_POST[
'product_ref']);
1112 unset($_POST[
'product_label']);
1113 unset($_POST[
'product_desc']);
1114 unset($_POST[
'fournprice']);
1115 unset($_POST[
'buying_price']);
1116 unset($_POST[
'np_marginRate']);
1117 unset($_POST[
'np_markRate']);
1118 unset($_POST[
'dp_desc']);
1119 unset($_POST[
'idprod']);
1120 unset($_POST[
'units']);
1122 unset($_POST[
'date_starthour']);
1123 unset($_POST[
'date_startmin']);
1124 unset($_POST[
'date_startsec']);
1125 unset($_POST[
'date_startday']);
1126 unset($_POST[
'date_startmonth']);
1127 unset($_POST[
'date_startyear']);
1128 unset($_POST[
'date_endhour']);
1129 unset($_POST[
'date_endmin']);
1130 unset($_POST[
'date_endsec']);
1131 unset($_POST[
'date_endday']);
1132 unset($_POST[
'date_endmonth']);
1133 unset($_POST[
'date_endyear']);
1139 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1151 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1156 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1157 $vat_rate = str_replace(
'*',
'', $vat_rate);
1169 $pu_equivalent = $pu_ht;
1170 $pu_equivalent_ttc = $pu_ttc;
1172 $currency_tx =
$object->multicurrency_tx;
1176 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1177 $pu_equivalent = (float) $pu_ht_devise * (
float) $currency_tx;
1179 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1180 $pu_equivalent_ttc = (float) $pu_ttc_devise * (
float) $currency_tx;
1199 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1200 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1202 if (is_array($extralabelsline)) {
1203 foreach ($extralabelsline as $key => $value) {
1204 unset($_POST[
"options_".$key]);
1209 $special_code =
GETPOST(
'special_code');
1218 if (!empty($productid)) {
1220 $product->fetch($productid);
1222 $type = $product->type;
1224 $price_min = $product->price_min;
1226 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1228 $price_min_ttc = $product->price_min_ttc;
1230 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1236 if ($usermustrespectpricemin) {
1237 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1238 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1241 $action =
'editline';
1242 } 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') {
1243 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1246 $action =
'editline';
1251 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1255 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1257 $action =
'editline';
1262 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1264 $action =
'editline';
1268 if (!$user->hasRight(
'margins',
'creer')) {
1269 foreach (
$object->lines as &$line) {
1271 $fournprice = $line->fk_fournprice;
1272 $buyingprice = $line->pa_ht;
1278 $price_base_type =
'HT';
1280 if (empty($pu) && !empty($pu_ttc)) {
1282 $price_base_type =
'TTC';
1285 $result =
$object->updateline(
GETPOSTINT(
'lineid'), $description, $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type,
GETPOST(
'fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options,
GETPOST(
'units'), $pu_ht_devise);
1290 $outputlangs = $langs;
1293 $newlang =
GETPOST(
'lang_id',
'aZ09');
1296 $newlang =
$object->thirdparty->default_lang;
1298 if (!empty($newlang)) {
1299 $outputlangs =
new Translate(
"", $conf);
1300 $outputlangs->setDefaultLang($newlang);
1304 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1307 unset($_POST[
'qty']);
1308 unset($_POST[
'type']);
1309 unset($_POST[
'productid']);
1310 unset($_POST[
'remise_percent']);
1311 unset($_POST[
'price_ht']);
1312 unset($_POST[
'multicurrency_price_ht']);
1313 unset($_POST[
'price_ttc']);
1314 unset($_POST[
'tva_tx']);
1315 unset($_POST[
'product_ref']);
1316 unset($_POST[
'product_label']);
1317 unset($_POST[
'product_desc']);
1318 unset($_POST[
'fournprice']);
1319 unset($_POST[
'buying_price']);
1321 unset($_POST[
'date_starthour']);
1322 unset($_POST[
'date_startmin']);
1323 unset($_POST[
'date_startsec']);
1324 unset($_POST[
'date_startday']);
1325 unset($_POST[
'date_startmonth']);
1326 unset($_POST[
'date_startyear']);
1327 unset($_POST[
'date_endhour']);
1328 unset($_POST[
'date_endmin']);
1329 unset($_POST[
'date_endsec']);
1330 unset($_POST[
'date_endday']);
1331 unset($_POST[
'date_endmonth']);
1332 unset($_POST[
'date_endyear']);
1337 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1338 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1340 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1343 $qualified_for_stock_change = 0;
1345 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1347 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1351 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1352 if (!$idwarehouse || $idwarehouse == -1) {
1354 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1360 $locationTarget =
'';
1364 $result =
$object->valid($user, $idwarehouse);
1369 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
1372 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1373 && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
1375 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1378 $forceFields = array();
1380 if (GETPOSTISSET(
'date_pointoftax')) {
1388 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1400 $outputlangs = $langs;
1403 $newlang =
GETPOST(
'lang_id',
'aZ09');
1406 $newlang =
$object->thirdparty->default_lang;
1408 if (!empty($newlang)) {
1409 $outputlangs =
new Translate(
"", $conf);
1410 $outputlangs->setDefaultLang($newlang);
1415 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1418 $deposit->fetch($deposit->id);
1419 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1423 if ($locationTarget) {
1424 header(
'Location: ' . $locationTarget);
1435 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1437 $idwarehouse =
GETPOST(
'idwarehouse');
1439 $qualified_for_stock_change = 0;
1441 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1443 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1447 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1448 if (!$idwarehouse || $idwarehouse == -1) {
1450 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1456 $result =
$object->setDraft($user, $idwarehouse);
1460 $outputlangs = $langs;
1463 $newlang =
GETPOST(
'lang_id',
'aZ09');
1466 $newlang =
$object->thirdparty->default_lang;
1468 if (!empty($newlang)) {
1469 $outputlangs =
new Translate(
"", $conf);
1470 $outputlangs->setDefaultLang($newlang);
1475 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1481 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1482 $result =
$object->cloture($user);
1486 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1489 $qualified_for_stock_change = 0;
1491 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1493 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1497 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
1498 if (!$idwarehouse || $idwarehouse == -1) {
1500 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1506 $result =
$object->cancel($idwarehouse);
1514 if ($action ==
'update_extras' && $usercancreate) {
1518 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
1525 $result =
$object->insertExtraFields(
'ORDER_MODIFY');
1533 $action =
'edit_extras';
1538 if ($action ==
'import_lines_from_object'
1542 $fromElement =
GETPOST(
'fromelement');
1543 $fromElementid =
GETPOST(
'fromelementid');
1544 $importLines =
GETPOST(
'line_checkbox');
1546 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1547 if ($fromElement ==
'commande') {
1549 $lineClassName =
'OrderLine';
1550 } elseif ($fromElement ==
'propal') {
1551 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1552 $lineClassName =
'PropaleLigne';
1553 } elseif ($fromElement ==
'facture') {
1554 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1555 $lineClassName =
'FactureLigne';
1557 $nextRang = count(
$object->lines) + 1;
1560 foreach ($importLines as $lineId) {
1561 $lineId = intval($lineId);
1562 $originLine =
new $lineClassName($db);
1563 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
1564 $originLine->fetch_optionals();
1565 $desc = $originLine->desc;
1566 $pu_ht = $originLine->subprice;
1567 $qty = $originLine->qty;
1568 $txtva = $originLine->tva_tx;
1569 $txlocaltax1 = $originLine->localtax1_tx;
1570 $txlocaltax2 = $originLine->localtax2_tx;
1571 $fk_product = $originLine->fk_product;
1572 $remise_percent = $originLine->remise_percent;
1573 $date_start = $originLine->date_start;
1574 $date_end = $originLine->date_end;
1575 $fk_code_ventilation = 0;
1576 $info_bits = $originLine->info_bits;
1577 $fk_remise_except = $originLine->fk_remise_except;
1578 $price_base_type =
'HT';
1580 $type = $originLine->product_type;
1581 $rang = $nextRang++;
1582 $special_code = $originLine->special_code;
1583 $origin = $originLine->element;
1584 $origin_id = $originLine->id;
1585 $fk_parent_line = 0;
1586 $fk_fournprice = $originLine->fk_fournprice;
1587 $pa_ht = $originLine->pa_ht;
1588 $label = $originLine->label;
1589 $array_options = $originLine->array_options;
1590 $situation_percent = 100;
1592 $fk_unit = $originLine->fk_unit;
1593 $pu_ht_devise = $originLine->multicurrency_subprice;
1595 $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);
1614 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1617 $upload_dir = !empty($conf->commande->multidir_output[
$object->entity]) ? $conf->commande->multidir_output[
$object->entity] : $conf->commande->dir_output;
1618 $permissiontoadd = $usercancreate;
1619 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1622 $triggersendname =
'ORDER_SENTBYMAIL';
1624 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
1625 $trackid =
'ord'.$object->id;
1626 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1630 if ($action ==
'addcontact' && $usercancreate) {
1634 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1638 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1641 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1642 $langs->load(
"errors");
1643 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1648 } elseif ($action ==
'swapstatut' && $usercancreate) {
1655 } elseif ($action ==
'deletecontact' && $usercancreate) {
1657 $result =
$object->delete_contact($lineid);
1660 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1674$title =
$object->ref.
" - ".$langs->trans(
'Card');
1675if ($action ==
'create') {
1676 $title = $langs->trans(
"NewOrder");
1678$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
1680llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
1682$form =
new Form($db);
1686if (isModEnabled(
'project')) {
1691if ($action ==
'create' && $usercancreate) {
1696 $res = $soc->fetch($socid);
1701 $currency_code = $conf->currency;
1703 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
1704 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1705 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
1708 if (!empty($origin) && !empty($originid)) {
1710 $element = $subelement = $origin;
1712 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1713 $element = $regs[1];
1714 $subelement = $regs[2];
1717 if ($element ==
'project') {
1718 $projectid = $originid;
1720 if (!$cond_reglement_id) {
1721 $cond_reglement_id = $soc->cond_reglement_id;
1723 if (!$deposit_percent) {
1724 $deposit_percent = $soc->deposit_percent;
1726 if (!$mode_reglement_id) {
1727 $mode_reglement_id = $soc->mode_reglement_id;
1729 if (!$remise_percent) {
1730 $remise_percent = $soc->remise_percent;
1738 if ($element ==
'order' || $element ==
'commande') {
1739 $element = $subelement =
'commande';
1740 } elseif ($element ==
'propal') {
1741 $element =
'comm/propal';
1742 $subelement =
'propal';
1743 } elseif ($element ==
'contract') {
1744 $element = $subelement =
'contrat';
1749 $classname = ucfirst($subelement);
1750 $objectsrc =
new $classname($db);
1751 $objectsrc->fetch($originid);
1752 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1753 $objectsrc->fetch_lines();
1755 $objectsrc->fetch_thirdparty();
1758 $objectsrc->fetch_optionals();
1759 $object->array_options = $objectsrc->array_options;
1761 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1762 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1764 $soc = $objectsrc->thirdparty;
1765 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1766 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
1767 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1768 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1769 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
1770 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
1771 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1772 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
1777 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
1779 if (isModEnabled(
"multicurrency")) {
1780 if (!empty($objectsrc->multicurrency_code)) {
1781 $currency_code = $objectsrc->multicurrency_code;
1783 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1784 $currency_tx = $objectsrc->multicurrency_tx;
1788 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
1789 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
1792 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1795 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1796 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1797 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1798 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
1799 $availability_id = 0;
1800 $shipping_method_id = $soc->shipping_method_id;
1801 $warehouse_id = $soc->fk_warehouse;
1802 $demand_reason_id = $soc->demand_reason_id;
1807 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1808 $currency_code = $soc->multicurrency_code;
1811 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1812 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1816 if (!
GETPOST(
'changecompany')) {
1817 if (GETPOSTISSET(
'cond_reglement_id')) {
1818 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
1820 if (GETPOSTISSET(
'deposit_percent')) {
1823 if (GETPOSTISSET(
'mode_reglement_id')) {
1824 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
1826 if (GETPOSTISSET(
'cond_reglement_id')) {
1832 if ($soc->fk_warehouse > 0) {
1833 $warehouse_id = $soc->fk_warehouse;
1835 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1840 $warehouse_id = $user->fk_warehouse;
1844 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1845 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1846 print
'<input type="hidden" name="action" value="add">';
1847 print
'<input type="hidden" name="changecompany" value="0">';
1848 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
1849 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1850 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1851 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1852 if (!empty($currency_tx)) {
1853 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1859 $parameters = array();
1861 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters,
$object, $action);
1862 if (empty($reshook)) {
1863 print
'<table class="border centpercent">';
1866 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
1869 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
1870 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
1871 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
1873 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
1879 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1882 print $soc->getNomUrl(1,
'customer');
1883 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1886 print
'<td class="valuefieldcreate">';
1887 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1888 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1892 $(document).ready(function() {
1893 $("#socid").change(function() {
1894 console.log("We have changed the company - Reload page");
1895 var socid = $(this).val();
1897 $("input[name=action]").val("create");
1898 $("input[name=changecompany]").val("1");
1899 $("form[name=crea_commande]").submit();
1904 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1912 print
"<tr><td>".$langs->trans(
"DefaultContact").
'</td><td>';
1913 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1915 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
1919 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1921 $absolute_discount = $soc->getAvailableDiscounts();
1925 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode((
string) (
GETPOST(
'origin'))).
'&originid='.urlencode((
string) (
GETPOSTINT(
'originid')));
1926 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1932 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
1933 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1934 print $form->selectDate(
'',
're', 0, 0, 0,
"crea_commande", 1, 1);
1938 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1939 print
'<td colspan="3">';
1940 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1941 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1942 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
1947 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
1948 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1949 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1953 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1954 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1955 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', $deposit_percent);
1959 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
1960 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1961 print $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1965 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
1966 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
1967 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1972 if (isModEnabled(
'shipping')) {
1973 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
1974 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
1975 $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');
1980 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1981 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1983 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
1984 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');
1989 print
'<tr><td>'.$langs->trans(
'Source').
'</td><td>';
1990 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1991 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1997 if (isModEnabled(
'project')) {
1998 $langs->load(
"projects");
2000 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2001 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), (GETPOSTISSET(
'projectid') ?
GETPOST(
'projectid') : $projectid),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2002 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>';
2008 if (isModEnabled(
'incoterm')) {
2010 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms, 1).
'</label></td>';
2011 print
'<td class="maxwidthonsmartphone">';
2012 $incoterm_id =
GETPOST(
'incoterm_id');
2013 $location_incoterms =
GETPOST(
'location_incoterms');
2014 if (empty($incoterm_id)) {
2015 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2016 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2018 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2019 print $form->select_incoterms($incoterm_id, $location_incoterms);
2024 $parameters = array();
2025 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2026 $parameters[
'objectsrc'] = $objectsrc;
2028 $parameters[
'socid'] = $socid;
2031 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2032 print $hookmanager->resPrint;
2033 if (empty($reshook)) {
2034 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2037 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2038 if ($soc->fetch_optionals() > 0) {
2039 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2043 print
$object->showOptionals($extrafields,
'create', $parameters);
2047 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2049 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2052 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2053 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2057 if (isModEnabled(
"multicurrency")) {
2059 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'',
$object, 0).
'</td>';
2060 print
'<td class="maxwidthonsmartphone">';
2061 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2067 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2070 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2071 print $doleditor->Create(1);
2076 if (empty($user->socid)) {
2078 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2081 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2082 print $doleditor->Create(1);
2087 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2089 if ($origin ==
'contrat') {
2093 $objectsrc->update_price(1);
2096 print
"\n<!-- ".$classname.
" info -->";
2098 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2099 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2100 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2101 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2102 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2104 switch ($classname) {
2106 $newclassname =
'CommercialProposal';
2109 $newclassname =
'Order';
2112 $newclassname =
'Sending';
2115 $newclassname =
'Contract';
2118 $newclassname = $classname;
2121 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2124 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2125 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2126 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2127 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2130 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2131 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2134 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2136 if (isModEnabled(
"multicurrency")) {
2137 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2138 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2139 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2150 print $form->buttonsSaveCancel(
"CreateDraft");
2153 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2154 $title = $langs->trans(
'ProductsAndServices');
2157 print
'<div class="div-table-responsive-no-min">';
2158 print
'<table class="noborder centpercent">';
2160 $objectsrc->printOriginLinesList(
'', $selectedLines);
2172 $product_static =
new Product($db);
2177 $author =
new User($db);
2178 $author->fetch(
$object->user_author_id);
2181 $res =
$object->fetch_optionals();
2184 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order');
2189 if ($action ==
'delete') {
2190 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2194 if ($action ==
'validate') {
2196 $ref = substr(
$object->ref, 1, 4);
2197 if ($ref ==
'PROV' || $ref ==
'') {
2198 $numref =
$object->getNextNumRef($soc);
2199 if (empty($numref)) {
2207 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2208 if (isModEnabled(
'notification')) {
2209 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2210 $notify =
new Notify($db);
2212 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid,
$object);
2215 $qualified_for_stock_change = 0;
2217 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2219 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2222 $formquestion = array();
2223 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2224 $langs->load(
"stocks");
2225 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2228 if ($conf->browser->name ==
'ie') {
2231 $formquestion = array(
2235 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2241 foreach (
$object->lines as $line) {
2242 $res = $line->fetch_product();
2244 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2250 if ($nbMandated > 0) {
2252 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2255 $text .=
'<div><span class="clearboth nowraponall warning">'.img_warning().$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2259 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2264 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2266 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2267 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2271 $eligibleForDepositGeneration =
true;
2273 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2274 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2276 $eligibleForDepositGeneration =
false;
2282 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2283 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2284 $proposal->fetchObjectLinked();
2286 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2287 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2289 $eligibleForDepositGeneration =
false;
2297 if ($eligibleForDepositGeneration) {
2298 $formquestion[] = array(
2299 'type' =>
'checkbox',
2301 'name' =>
'generate_deposit',
2302 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2305 $formquestion[] = array(
2307 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2309 'label' => $langs->trans(
'DateInvoice'),
2315 $formquestion[] = array(
2317 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2318 'name' =>
'date_pointoftax',
2319 'label' => $langs->trans(
'DatePointOfTax'),
2326 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2328 $formquestion[] = array(
2330 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2331 'name' =>
'cond_reglement_id',
2332 'label' => $langs->trans(
'PaymentTerm'),
2333 'value' => $paymentTermsSelect
2336 $formquestion[] = array(
2337 'type' =>
'checkbox',
2338 'tdclass' =>
'showonlyifgeneratedeposit',
2339 'name' =>
'validate_generated_deposit',
2340 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2343 $formquestion[] = array(
2344 'type' =>
'onecolumn',
2347 $(document).ready(function() {
2348 $("[name=generate_deposit]").change(function () {
2349 let $self = $(this);
2350 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2352 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2369 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2374 if ($action ==
'modif') {
2375 $qualified_for_stock_change = 0;
2377 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2379 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2382 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2383 $formquestion = array();
2384 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2385 $langs->load(
"stocks");
2386 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2389 if ($conf->browser->name ==
'ie') {
2392 $formquestion = array(
2396 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2400 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2406 if ($action ==
'shipped') {
2407 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2413 if ($action ==
'cancel') {
2414 $qualified_for_stock_change = 0;
2416 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2418 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2421 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2422 $formquestion = array();
2423 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2424 $langs->load(
"stocks");
2425 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2428 if ($conf->browser->name ==
'ie') {
2431 $formquestion = array(
2435 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2439 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2443 if ($action ==
'ask_deleteline') {
2444 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2448 if ($action ==
'clone') {
2449 $filter =
'(s.client:IN:1,2,3)';
2451 $formquestion = array(
2452 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300'))
2454 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2458 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2460 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2461 if (empty($reshook)) {
2462 $formconfirm .= $hookmanager->resPrint;
2463 } elseif ($reshook > 0) {
2464 $formconfirm = $hookmanager->resPrint;
2473 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2475 $morehtmlref =
'<div class="refidno">';
2477 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, $usercancreate,
'string',
'', 0, 1);
2478 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, $usercancreate,
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
2480 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2482 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2485 if (isModEnabled(
'project')) {
2486 $langs->load(
"projects");
2487 $morehtmlref .=
'<br>';
2488 if ($usercancreate) {
2489 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2490 if ($action !=
'classify') {
2491 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2493 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2495 if (!empty(
$object->fk_project)) {
2497 $proj->fetch(
$object->fk_project);
2498 $morehtmlref .= $proj->getNomUrl(1);
2500 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2505 $morehtmlref .=
'</div>';
2508 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2511 $parameters = array();
2513 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters,
$object, $action);
2514 if (empty($reshook)) {
2515 print
'<div class="fichecenter">';
2516 print
'<div class="fichehalfleft">';
2517 print
'<div class="underbanner clearboth"></div>';
2519 print
'<table class="border tableforfield centpercent">';
2521 if ($soc->outstanding_limit) {
2523 print
'<tr><td class="titlefield">';
2524 print $langs->trans(
'OutstandingBill');
2525 print
'</td><td class="valuefield">';
2526 $arrayoutstandingbills = $soc->getOutstandingBills();
2527 print
price($arrayoutstandingbills[
'opened']).
' / ';
2528 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1, $conf->currency);
2535 $filterabsolutediscount =
"fk_facture_source IS NULL";
2536 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2538 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2539 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2542 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
2543 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
2544 $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>';
2546 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
2548 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2549 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2550 $absolute_discount =
price2num($absolute_discount,
'MT');
2551 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2555 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id;
2556 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2563 print $form->editfieldkey(
"Date",
'date',
'',
$object, $editenable);
2564 print
'</td><td class="valuefield">';
2565 if ($action ==
'editdate') {
2566 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2567 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2568 print
'<input type="hidden" name="action" value="setdate">';
2569 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2570 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
2571 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2576 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
2584 $editenable = $usercancreate;
2585 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'',
$object, $editenable);
2586 print
'</td><td class="valuefield">';
2587 if ($action ==
'editdate_livraison') {
2588 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2589 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2590 print
'<input type="hidden" name="action" value="setdate_livraison">';
2591 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2592 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2593 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2598 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
2605 print
'<tr class="fielddeliverydelay"><td>';
2606 $editenable = $usercancreate;
2607 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'',
$object, $editenable);
2608 print
'</td><td class="valuefield">';
2609 if ($action ==
'editavailability') {
2610 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->availability_id,
'availability_id', 1);
2612 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->availability_id,
'none', 1);
2617 if (isModEnabled(
'shipping')) {
2619 $editenable = $usercancreate;
2620 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'',
$object, $editenable);
2621 print
'</td><td class="valuefield">';
2622 if ($action ==
'editshippingmethod') {
2623 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->shipping_method_id,
'shipping_method_id', 1);
2625 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->shipping_method_id,
'none');
2632 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2633 $langs->load(
'stocks');
2634 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2637 $editenable = $usercancreate;
2638 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $editenable);
2639 print
'</td><td class="valuefield">';
2640 if ($action ==
'editwarehouse') {
2641 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
2643 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'none');
2651 $editenable = $usercancreate;
2652 print $form->editfieldkey(
"Source",
'demandreason',
'',
$object, $editenable);
2653 print
'</td><td class="valuefield">';
2654 if ($action ==
'editdemandreason') {
2655 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->demand_reason_id,
'demand_reason_id', 1);
2657 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->demand_reason_id,
'none');
2663 $editenable = $usercancreate;
2664 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'',
$object, $editenable);
2665 print
'</td><td class="valuefield">';
2666 if ($action ==
'editconditions') {
2667 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2669 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2677 $editenable = $usercancreate;
2678 print $form->editfieldkey(
"PaymentMode",
'mode',
'',
$object, $editenable);
2679 print
'</td><td class="valuefield">';
2680 if ($action ==
'editmode') {
2681 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2683 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
2688 if (isModEnabled(
"multicurrency")) {
2693 print $form->editfieldkey(
"Currency",
'multicurrencycode',
'',
$object, $editenable);
2694 print
'</td><td class="valuefield">';
2695 if ($action ==
'editmulticurrencycode') {
2696 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'multicurrency_code');
2698 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'none');
2703 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
2706 $editenable = $usercancreate &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency &&
$object->statut == $object::STATUS_DRAFT;
2707 print $form->editfieldkey(
"CurrencyRate",
'multicurrencyrate',
'',
$object, $editenable);
2708 print
'</td><td class="valuefield">';
2709 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2710 if ($action ==
'actualizemulticurrencyrate') {
2713 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'multicurrency_tx',
$object->multicurrency_code);
2715 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
2716 if (
$object->statut == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
2717 print
'<div class="inline-block"> ';
2718 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2740 $tmparray =
$object->getTotalWeightVolume();
2741 $totalWeight = $tmparray[
'weight'];
2742 $totalVolume = $tmparray[
'volume'];
2744 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2745 print
'<td class="valuefield">';
2746 print
showDimensionInBestUnit($totalWeight, 0,
"weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT :
'no');
2750 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2751 print
'<td class="valuefield">';
2752 print
showDimensionInBestUnit($totalVolume, 0,
"volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT :
'no');
2759 if (isModEnabled(
'incoterm')) {
2761 $editenable = $usercancreate;
2762 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'',
$object, $editenable);
2764 print
'<td class="valuefield">';
2765 if ($action !=
'editincoterm') {
2766 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
2768 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
2774 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
2776 $editenable = $usercancreate;
2777 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'',
$object, $editenable);
2778 print
'</td><td class="valuefield">';
2779 if ($action ==
'editbankaccount') {
2780 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
2782 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
2789 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2794 print
'<div class="fichehalfright">';
2795 print
'<div class="underbanner clearboth"></div>';
2797 print
'<table class="border tableforfield centpercent">';
2801 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
2805 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2806 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2807 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2809 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2814 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2815 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2816 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2818 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2823 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2825 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2826 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2827 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2830 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2836 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2838 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2839 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2840 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2843 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2849 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2850 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1, $conf->currency) .
'</td>';
2851 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2853 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
2863 if (isModEnabled(
'margin')) {
2864 $formmargin->displayMarginInfos(
$object);
2871 print
'<div class="clearboth"></div><br>';
2874 $blocname =
'contacts';
2875 $title = $langs->trans(
'ContactsAddresses');
2876 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2880 $blocname =
'notes';
2881 $title = $langs->trans(
'Notes');
2882 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2890 $result =
$object->getLinesArray();
2894 global $inputalsopricewithtax;
2895 $inputalsopricewithtax = 1;
2897 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">
2898 <input type="hidden" name="token" value="' .
newToken().
'">
2899 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2900 <input type="hidden" name="mode" value="">
2901 <input type="hidden" name="page_y" value="">
2902 <input type="hidden" name="id" value="' .
$object->id.
'">
2903 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2907 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2910 print
'<div class="div-table-responsive-no-min">';
2911 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2915 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
2922 if ($action !=
'editline') {
2925 $parameters = array();
2927 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
2931 if (empty($reshook)) {
2932 $object->formAddObjectLine(1, $mysoc, $soc);
2935 $parameters = array();
2936 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters,
$object, $action);
2950 if ($action !=
'presend' && $action !=
'editline') {
2951 print
'<div class="tabsAction">';
2953 $parameters = array();
2955 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2956 if (empty($reshook)) {
2957 $numlines = count(
$object->lines);
2965 if (empty($user->socid)) {
2968 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
2970 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2977 if ($numlines > 0) {
2980 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.
$object->id,
$object->id, 0);
2988 $arrayforbutaction = array();
2992 $arrayforbutaction[] = array(
'lang' =>
'orders',
'enabled' => (isModEnabled(
"supplier_order") &&
$object->statut >
Commande::STATUS_DRAFT),
'perm' => $usercancreatepurchaseorder,
'label' =>
'AddPurchaseOrder',
'url' =>
'/fourn/commande/card.php?action=create&origin='.urlencode(
$object->element).
'&originid='.((
int)
$object->id));
3002 $arrayforbutaction[] = array(
'lang' =>
'interventions',
'enabled' => (isModEnabled(
"intervention") &&
$object->statut >
Commande::STATUS_DRAFT &&
$object->statut <
Commande::STATUS_CLOSED &&
$object->getNbOfServicesLines() > 0),
'perm' => $user->hasRight(
'ficheinter',
'creer'),
'label' =>
'AddIntervention',
'url' =>
'/fichinter/card.php?action=create&origin='.$object->element.
'&originid='.
$object->id.
'&socid='.
$object->socid);
3026 if (isModEnabled(
'shipping')) {
3027 $numshipping =
$object->countNbOfShipments();
3032 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3041 $langs->load(
"errors");
3042 print
dolGetButtonAction($langs->trans(
'ErrorModuleSetupNotComplete'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3047 $arrayforbutaction[] = array(
3050 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3051 'label' =>
'CreateBill',
3052 'url' =>
'/compta/facture/card.php?action=create&token='.
newToken().
'&origin='.urlencode(
$object->element).
'&originid='.
$object->id.
'&socid='.
$object->socid
3061 $actionButtonsParameters = [
3062 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3065 if ($numlines > 0) {
3066 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
$object->id, 1, $actionButtonsParameters);
3068 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction,
$object->id, 0, $actionButtonsParameters);
3073 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.
newToken().
'&id='.
$object->id,
'');
3080 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.
$object->id,
'');
3085 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.
newToken().
'&id='.
$object->id,
'');
3090 if ($usercancreate) {
3096 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"CancelOrder").
'</a>';
3100 if ($usercandelete) {
3101 if ($numshipping == 0) {
3104 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3112 if (
GETPOST(
'modelselected')) {
3113 $action =
'presend';
3116 if ($action !=
'presend') {
3117 print
'<div class="fichecenter"><div class="fichehalfleft">';
3118 print
'<a name="builddoc"></a>';
3121 $relativepath = $objref.
'/'.$objref.
'.pdf';
3122 $filedir = $conf->commande->multidir_output[
$object->entity].
'/'.$objref;
3123 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3124 $genallowed = $usercanread;
3125 $delallowed = $usercancreate;
3126 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'',
$object);
3130 $linktoelem = $form->showLinkToObjectBlock(
$object,
null, array(
'order'));
3132 $compatibleImportElementsList =
false;
3135 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3137 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem, $compatibleImportElementsList);
3141 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3142 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3143 $useonlinepayment = count($validpaymentmethod);
3146 $useonlinepayment = 0;
3149 print
'<br><!-- Link to pay -->';
3150 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3151 print showOnlinePaymentUrl(
'order',
$object->ref).
'<br>';
3154 print
'</div><div class="fichehalfright">';
3158 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id);
3161 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3163 $somethingshown = $formactions->showactions(
$object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3165 print
'</div></div>';
3169 $modelmail =
'order_send';
3170 $defaulttopic =
'SendOrderRef';
3172 $trackid =
'ord'.$object->id;
3174 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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.
setEventMessage($mesgs, $style='mesgs', $noduplicate=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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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,...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return 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.
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.