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')) {
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') {
1516 $attribute_name =
GETPOST(
'attribute',
'restricthtml');
1519 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1526 $result =
$object->updateExtraField($attribute_name,
'ORDER_MODIFY');
1534 $action =
'edit_extras';
1539 if ($action ==
'import_lines_from_object'
1543 $fromElement =
GETPOST(
'fromelement');
1544 $fromElementid =
GETPOST(
'fromelementid');
1545 $importLines =
GETPOST(
'line_checkbox');
1547 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1548 if ($fromElement ==
'commande') {
1550 $lineClassName =
'OrderLine';
1551 } elseif ($fromElement ==
'propal') {
1552 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1553 $lineClassName =
'PropaleLigne';
1554 } elseif ($fromElement ==
'facture') {
1555 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1556 $lineClassName =
'FactureLigne';
1558 $nextRang = count(
$object->lines) + 1;
1561 foreach ($importLines as $lineId) {
1562 $lineId = intval($lineId);
1563 $originLine =
new $lineClassName($db);
1564 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
1565 $originLine->fetch_optionals();
1566 $desc = $originLine->desc;
1567 $pu_ht = $originLine->subprice;
1568 $qty = $originLine->qty;
1569 $txtva = $originLine->tva_tx;
1570 $txlocaltax1 = $originLine->localtax1_tx;
1571 $txlocaltax2 = $originLine->localtax2_tx;
1572 $fk_product = $originLine->fk_product;
1573 $remise_percent = $originLine->remise_percent;
1574 $date_start = $originLine->date_start;
1575 $date_end = $originLine->date_end;
1576 $fk_code_ventilation = 0;
1577 $info_bits = $originLine->info_bits;
1578 $fk_remise_except = $originLine->fk_remise_except;
1579 $price_base_type =
'HT';
1581 $type = $originLine->product_type;
1582 $rang = $nextRang++;
1583 $special_code = $originLine->special_code;
1584 $origin = $originLine->element;
1585 $origin_id = $originLine->id;
1586 $fk_parent_line = 0;
1587 $fk_fournprice = $originLine->fk_fournprice;
1588 $pa_ht = $originLine->pa_ht;
1589 $label = $originLine->label;
1590 $array_options = $originLine->array_options;
1591 $situation_percent = 100;
1593 $fk_unit = $originLine->fk_unit;
1594 $pu_ht_devise = $originLine->multicurrency_subprice;
1596 $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);
1615 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1618 $upload_dir = !empty($conf->commande->multidir_output[
$object->entity]) ? $conf->commande->multidir_output[
$object->entity] : $conf->commande->dir_output;
1619 $permissiontoadd = $usercancreate;
1620 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1623 $triggersendname =
'ORDER_SENTBYMAIL';
1625 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
1626 $trackid =
'ord'.$object->id;
1627 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1631 if ($action ==
'addcontact') {
1635 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1639 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1642 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1643 $langs->load(
"errors");
1644 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1649 } elseif ($action ==
'swapstatut') {
1656 } elseif ($action ==
'deletecontact') {
1658 $result =
$object->delete_contact($lineid);
1661 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1675$title =
$object->ref.
" - ".$langs->trans(
'Card');
1676if ($action ==
'create') {
1677 $title = $langs->trans(
"NewOrder");
1679$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
1681llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-order page-card');
1683$form =
new Form($db);
1687if (isModEnabled(
'project')) {
1692if ($action ==
'create' && $usercancreate) {
1697 $res = $soc->fetch($socid);
1702 $currency_code = $conf->currency;
1704 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
1705 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1706 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
1709 if (!empty($origin) && !empty($originid)) {
1711 $element = $subelement = $origin;
1713 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1714 $element = $regs[1];
1715 $subelement = $regs[2];
1718 if ($element ==
'project') {
1719 $projectid = $originid;
1721 if (!$cond_reglement_id) {
1722 $cond_reglement_id = $soc->cond_reglement_id;
1724 if (!$deposit_percent) {
1725 $deposit_percent = $soc->deposit_percent;
1727 if (!$mode_reglement_id) {
1728 $mode_reglement_id = $soc->mode_reglement_id;
1730 if (!$remise_percent) {
1731 $remise_percent = $soc->remise_percent;
1739 if ($element ==
'order' || $element ==
'commande') {
1740 $element = $subelement =
'commande';
1741 } elseif ($element ==
'propal') {
1742 $element =
'comm/propal';
1743 $subelement =
'propal';
1744 } elseif ($element ==
'contract') {
1745 $element = $subelement =
'contrat';
1750 $classname = ucfirst($subelement);
1751 $objectsrc =
new $classname($db);
1752 $objectsrc->fetch($originid);
1753 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1754 $objectsrc->fetch_lines();
1756 $objectsrc->fetch_thirdparty();
1759 $objectsrc->fetch_optionals();
1760 $object->array_options = $objectsrc->array_options;
1762 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1763 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1765 $soc = $objectsrc->thirdparty;
1766 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1767 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
1768 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1769 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1770 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
1771 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
1772 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1773 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
1778 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
1780 if (isModEnabled(
"multicurrency")) {
1781 if (!empty($objectsrc->multicurrency_code)) {
1782 $currency_code = $objectsrc->multicurrency_code;
1784 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1785 $currency_tx = $objectsrc->multicurrency_tx;
1789 $note_private =
$object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
1790 $note_public =
$object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
1793 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1796 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1797 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1798 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1799 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
1800 $availability_id = 0;
1801 $shipping_method_id = $soc->shipping_method_id;
1802 $warehouse_id = $soc->fk_warehouse;
1803 $demand_reason_id = $soc->demand_reason_id;
1808 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1809 $currency_code = $soc->multicurrency_code;
1812 $note_private =
$object->getDefaultCreateValueFor(
'note_private');
1813 $note_public =
$object->getDefaultCreateValueFor(
'note_public');
1817 if (!
GETPOST(
'changecompany')) {
1818 if (GETPOSTISSET(
'cond_reglement_id')) {
1819 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
1821 if (GETPOSTISSET(
'deposit_percent')) {
1824 if (GETPOSTISSET(
'mode_reglement_id')) {
1825 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
1827 if (GETPOSTISSET(
'cond_reglement_id')) {
1833 if ($soc->fk_warehouse > 0) {
1834 $warehouse_id = $soc->fk_warehouse;
1836 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1841 $warehouse_id = $user->fk_warehouse;
1845 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1846 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1847 print
'<input type="hidden" name="action" value="add">';
1848 print
'<input type="hidden" name="changecompany" value="0">';
1849 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
1850 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1851 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1852 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1853 if (!empty($currency_tx)) {
1854 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1860 $parameters = array();
1862 $reshook = $hookmanager->executeHooks(
'tabContentCreateOrder', $parameters,
$object, $action);
1863 if (empty($reshook)) {
1864 print
'<table class="border centpercent">';
1867 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
1870 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
1871 if (
getDolGlobalString(
'MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) {
1872 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
1874 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
1880 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1883 print $soc->getNomUrl(1,
'customer');
1884 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1887 print
'<td class="valuefieldcreate">';
1888 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1889 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1893 $(document).ready(function() {
1894 $("#socid").change(function() {
1895 console.log("We have changed the company - Reload page");
1896 var socid = $(this).val();
1898 $("input[name=action]").val("create");
1899 $("input[name=changecompany]").val("1");
1900 $("form[name=crea_commande]").submit();
1905 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>';
1913 print
"<tr><td>".$langs->trans(
"DefaultContact").
'</td><td>';
1914 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1916 print $form->select_contact($soc->id, $contactid,
'contactid', 1, empty($srccontactslist) ?
"" : $srccontactslist,
'', 1,
'maxwidth300 widthcentpercentminusx', true);
1920 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1922 $absolute_discount = $soc->getAvailableDiscounts();
1926 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode((
string) (
GETPOST(
'origin'))).
'&originid='.urlencode((
string) (
GETPOSTINT(
'originid')));
1927 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1933 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
1934 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1935 print $form->selectDate(
'',
're', 0, 0, 0,
"crea_commande", 1, 1);
1939 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1940 print
'<td colspan="3">';
1941 $date_delivery = ($date_delivery ? $date_delivery :
$object->delivery_date);
1942 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1943 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
1948 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
1949 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1950 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1954 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1955 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1956 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', $deposit_percent);
1960 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
1961 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1962 print $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1966 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
1967 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
1968 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1973 if (isModEnabled(
'shipping')) {
1974 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
1975 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
1976 $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');
1981 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1982 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1984 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
1985 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');
1990 print
'<tr><td>'.$langs->trans(
'Channel').
'</td><td>';
1991 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1992 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id') : $demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1998 if (isModEnabled(
'project')) {
1999 $langs->load(
"projects");
2001 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
2002 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');
2003 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>';
2009 if (isModEnabled(
'incoterm')) {
2011 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms, 1).
'</label></td>';
2012 print
'<td class="maxwidthonsmartphone">';
2013 $incoterm_id =
GETPOST(
'incoterm_id');
2014 $location_incoterms =
GETPOST(
'location_incoterms');
2015 if (empty($incoterm_id)) {
2016 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
2017 $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
2019 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2020 print $form->select_incoterms($incoterm_id, $location_incoterms);
2025 $parameters = array();
2026 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2027 $parameters[
'objectsrc'] = $objectsrc;
2029 $parameters[
'socid'] = $socid;
2032 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2033 print $hookmanager->resPrint;
2034 if (empty($reshook)) {
2035 if (
getDolGlobalString(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) {
2038 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
2039 if ($soc->fetch_optionals() > 0) {
2040 $object->array_options = array_merge(
$object->array_options, $soc->array_options);
2044 print
$object->showOptionals($extrafields,
'create', $parameters);
2048 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2050 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2053 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2054 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2058 if (isModEnabled(
"multicurrency")) {
2060 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'',
$object, 0).
'</td>';
2061 print
'<td class="maxwidthonsmartphone">';
2062 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2068 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2071 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2072 print $doleditor->Create(1);
2077 if (empty($user->socid)) {
2079 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2082 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2083 print $doleditor->Create(1);
2088 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2090 if ($origin ==
'contrat') {
2094 $objectsrc->update_price(1);
2097 print
"\n<!-- ".$classname.
" info -->";
2099 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2100 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2101 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2102 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2103 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2105 switch ($classname) {
2107 $newclassname =
'CommercialProposal';
2110 $newclassname =
'Order';
2113 $newclassname =
'Sending';
2116 $newclassname =
'Contract';
2119 $newclassname = $classname;
2122 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2125 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2126 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2127 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2128 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2131 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2132 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2135 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2137 if (isModEnabled(
"multicurrency")) {
2138 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2139 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2140 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2151 print $form->buttonsSaveCancel(
"CreateDraft");
2154 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2155 $title = $langs->trans(
'ProductsAndServices');
2158 print
'<div class="div-table-responsive-no-min">';
2159 print
'<table class="noborder centpercent">';
2161 $objectsrc->printOriginLinesList(
'', $selectedLines);
2173 $product_static =
new Product($db);
2178 $author =
new User($db);
2179 $author->fetch(
$object->user_author_id);
2182 $res =
$object->fetch_optionals();
2185 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order');
2190 if ($action ==
'delete') {
2191 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2195 if ($action ==
'validate') {
2197 $ref = substr(
$object->ref, 1, 4);
2198 if ($ref ==
'PROV' || $ref ==
'') {
2199 $numref =
$object->getNextNumRef($soc);
2200 if (empty($numref)) {
2208 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2209 if (isModEnabled(
'notification')) {
2210 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2211 $notify =
new Notify($db);
2213 $text .= $notify->confirmMessage(
'ORDER_VALIDATE',
$object->socid,
$object);
2216 $qualified_for_stock_change = 0;
2218 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2220 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2223 $formquestion = array();
2224 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2225 $langs->load(
"stocks");
2226 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2229 if ($conf->browser->name ==
'ie') {
2232 $formquestion = array(
2236 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOSTINT(
'idwarehouse') ?
GETPOSTINT(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2242 foreach (
$object->lines as $line) {
2243 $res = $line->fetch_product();
2245 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2251 if ($nbMandated > 0) {
2253 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
2256 $text .=
'<div><span class="clearboth nowraponall warning">'.img_warning().$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2260 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2265 $deposit_percent_from_payment_terms = (float)
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2267 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2268 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2272 $eligibleForDepositGeneration =
true;
2274 if (array_key_exists(
'facture',
$object->linkedObjects)) {
2275 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
2277 $eligibleForDepositGeneration =
false;
2283 if ($eligibleForDepositGeneration && array_key_exists(
'propal',
$object->linkedObjects)) {
2284 foreach (
$object->linkedObjects[
'propal'] as $proposal) {
2285 $proposal->fetchObjectLinked();
2287 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2288 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2290 $eligibleForDepositGeneration =
false;
2298 if ($eligibleForDepositGeneration) {
2299 $formquestion[] = array(
2300 'type' =>
'checkbox',
2302 'name' =>
'generate_deposit',
2303 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2306 $formquestion[] = array(
2308 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2310 'label' => $langs->trans(
'DateInvoice'),
2316 $formquestion[] = array(
2318 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2319 'name' =>
'date_pointoftax',
2320 'label' => $langs->trans(
'DatePointOfTax'),
2327 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2329 $formquestion[] = array(
2331 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2332 'name' =>
'cond_reglement_id',
2333 'label' => $langs->trans(
'PaymentTerm'),
2334 'value' => $paymentTermsSelect
2337 $formquestion[] = array(
2338 'type' =>
'checkbox',
2339 'tdclass' =>
'showonlyifgeneratedeposit',
2340 'name' =>
'validate_generated_deposit',
2341 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2344 $formquestion[] = array(
2345 'type' =>
'onecolumn',
2348 $(document).ready(function() {
2349 $("[name=generate_deposit]").change(function () {
2350 let $self = $(this);
2351 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2353 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2370 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 240);
2375 if ($action ==
'modif') {
2376 $qualified_for_stock_change = 0;
2378 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2380 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2383 $text = $langs->trans(
'ConfirmUnvalidateOrder',
$object->ref);
2384 $formquestion = array();
2385 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2386 $langs->load(
"stocks");
2387 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2390 if ($conf->browser->name ==
'ie') {
2393 $formquestion = array(
2397 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2401 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2407 if ($action ==
'shipped') {
2408 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2414 if ($action ==
'cancel') {
2415 $qualified_for_stock_change = 0;
2417 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2419 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2422 $text = $langs->trans(
'ConfirmCancelOrder',
$object->ref);
2423 $formquestion = array();
2424 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) {
2425 $langs->load(
"stocks");
2426 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2429 if ($conf->browser->name ==
'ie') {
2432 $formquestion = array(
2436 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2440 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2444 if ($action ==
'ask_deleteline') {
2445 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2449 if ($action ==
'clone') {
2450 $filter =
'(s.client:IN:1,2,3)';
2452 $formquestion = array(
2453 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300'))
2455 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2459 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2461 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2462 if (empty($reshook)) {
2463 $formconfirm .= $hookmanager->resPrint;
2464 } elseif ($reshook > 0) {
2465 $formconfirm = $hookmanager->resPrint;
2474 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2476 $morehtmlref =
'<div class="refidno">';
2478 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client,
$object, $usercancreate,
'string',
'', 0, 1);
2479 $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);
2481 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2483 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2486 if (isModEnabled(
'project')) {
2487 $langs->load(
"projects");
2488 $morehtmlref .=
'<br>';
2489 if ($usercancreate) {
2490 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2491 if ($action !=
'classify') {
2492 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2494 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2496 if (!empty(
$object->fk_project)) {
2498 $proj->fetch(
$object->fk_project);
2499 $morehtmlref .= $proj->getNomUrl(1);
2501 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2506 $morehtmlref .=
'</div>';
2509 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2512 $parameters = array();
2514 $reshook = $hookmanager->executeHooks(
'tabContentViewOrder', $parameters,
$object, $action);
2515 if (empty($reshook)) {
2516 print
'<div class="fichecenter">';
2517 print
'<div class="fichehalfleft">';
2518 print
'<div class="underbanner clearboth"></div>';
2520 print
'<table class="border tableforfield centpercent">';
2522 if ($soc->outstanding_limit) {
2524 print
'<tr><td class="titlefield">';
2525 print $langs->trans(
'OutstandingBill');
2526 print
'</td><td class="valuefield">';
2527 $arrayoutstandingbills = $soc->getOutstandingBills();
2528 print
price($arrayoutstandingbills[
'opened']).
' / ';
2529 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1, $conf->currency);
2536 $filterabsolutediscount =
"fk_facture_source IS NULL";
2537 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2539 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2540 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2543 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
2544 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.
$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
2545 $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>';
2547 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
2549 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2550 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2551 $absolute_discount =
price2num($absolute_discount,
'MT');
2552 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2556 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id;
2557 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2564 print $form->editfieldkey(
"Date",
'date',
'',
$object, $editenable);
2565 print
'</td><td class="valuefield">';
2566 if ($action ==
'editdate') {
2567 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2568 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2569 print
'<input type="hidden" name="action" value="setdate">';
2570 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2571 print $form->selectDate(
$object->date,
'order_', 0, 0, 0,
"setdate");
2572 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2577 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
2585 $editenable = $usercancreate;
2586 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'',
$object, $editenable);
2587 print
'</td><td class="valuefield">';
2588 if ($action ==
'editdate_livraison') {
2589 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2590 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2591 print
'<input type="hidden" name="action" value="setdate_livraison">';
2592 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2593 print $form->selectDate(
$object->delivery_date ?
$object->delivery_date : -1,
'liv_', 1, 1, 0,
"setdate_livraison", 1, 0);
2594 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2599 print
' '.img_picto($langs->trans(
"Late").
' : '.
$object->showDelay(),
"warning");
2606 print
'<tr class="fielddeliverydelay"><td>';
2607 $editenable = $usercancreate;
2608 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'',
$object, $editenable);
2609 print
'</td><td class="valuefield">';
2610 if ($action ==
'editavailability') {
2611 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->availability_id,
'availability_id', 1);
2613 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->availability_id,
'none', 1);
2618 if (isModEnabled(
'shipping')) {
2620 $editenable = $usercancreate;
2621 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'',
$object, $editenable);
2622 print
'</td><td class="valuefield">';
2623 if ($action ==
'editshippingmethod') {
2624 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->shipping_method_id,
'shipping_method_id', 1);
2626 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->shipping_method_id,
'none');
2633 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
2634 $langs->load(
'stocks');
2635 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2638 $editenable = $usercancreate;
2639 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $editenable);
2640 print
'</td><td class="valuefield">';
2641 if ($action ==
'editwarehouse') {
2642 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
2644 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->warehouse_id,
'none');
2652 $editenable = $usercancreate;
2653 print $form->editfieldkey(
"Source",
'demandreason',
'',
$object, $editenable);
2654 print
'</td><td class="valuefield">';
2655 if ($action ==
'editdemandreason') {
2656 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->demand_reason_id,
'demand_reason_id', 1);
2658 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->demand_reason_id,
'none');
2664 $editenable = $usercancreate;
2665 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'',
$object, $editenable);
2666 print
'</td><td class="valuefield">';
2667 if ($action ==
'editconditions') {
2668 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2670 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2678 $editenable = $usercancreate;
2679 print $form->editfieldkey(
"PaymentMode",
'mode',
'',
$object, $editenable);
2680 print
'</td><td class="valuefield">';
2681 if ($action ==
'editmode') {
2682 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2684 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
2689 if (isModEnabled(
"multicurrency")) {
2694 print $form->editfieldkey(
"Currency",
'multicurrencycode',
'',
$object, $editenable);
2695 print
'</td><td class="valuefield">';
2696 if ($action ==
'editmulticurrencycode') {
2697 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'multicurrency_code');
2699 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'none');
2704 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
2707 $editenable = $usercancreate &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency &&
$object->statut == $object::STATUS_DRAFT;
2708 print $form->editfieldkey(
"CurrencyRate",
'multicurrencyrate',
'',
$object, $editenable);
2709 print
'</td><td class="valuefield">';
2710 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2711 if ($action ==
'actualizemulticurrencyrate') {
2714 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'multicurrency_tx',
$object->multicurrency_code);
2716 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
2717 if (
$object->statut == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
2718 print
'<div class="inline-block"> ';
2719 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2741 $tmparray =
$object->getTotalWeightVolume();
2742 $totalWeight = $tmparray[
'weight'];
2743 $totalVolume = $tmparray[
'volume'];
2745 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2746 print
'<td class="valuefield">';
2747 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');
2751 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2752 print
'<td class="valuefield">';
2753 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');
2760 if (isModEnabled(
'incoterm')) {
2762 $editenable = $usercancreate;
2763 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'',
$object, $editenable);
2765 print
'<td class="valuefield">';
2766 if ($action !=
'editincoterm') {
2767 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
2769 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
2775 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled(
"bank")) {
2777 $editenable = $usercancreate;
2778 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'',
$object, $editenable);
2779 print
'</td><td class="valuefield">';
2780 if ($action ==
'editbankaccount') {
2781 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
2783 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
2790 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2795 print
'<div class="fichehalfright">';
2796 print
'<div class="underbanner clearboth"></div>';
2798 print
'<table class="border tableforfield centpercent">';
2802 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price(
$object->thirdparty->order_min_amount));
2806 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2807 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2808 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2810 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2815 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2816 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2817 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2819 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2824 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2826 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2827 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2828 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2831 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2837 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2839 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2840 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
2841 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2844 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2850 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2851 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->total_ttc, 1,
'', 1, -1, -1, $conf->currency) .
'</td>';
2852 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
2854 print
'<td class="valuefield nowrap right amountcard">' .
price(
$object->multicurrency_total_ttc, 1,
'', 1, -1, -1,
$object->multicurrency_code) .
'</td>';
2864 if (isModEnabled(
'margin')) {
2865 $formmargin->displayMarginInfos(
$object);
2872 print
'<div class="clearboth"></div><br>';
2875 $blocname =
'contacts';
2876 $title = $langs->trans(
'ContactsAddresses');
2877 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2881 $blocname =
'notes';
2882 $title = $langs->trans(
'Notes');
2883 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2891 $result =
$object->getLinesArray();
2895 global $inputalsopricewithtax;
2896 $inputalsopricewithtax = 1;
2898 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">
2899 <input type="hidden" name="token" value="' . newToken().
'">
2900 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2901 <input type="hidden" name="mode" value="">
2902 <input type="hidden" name="page_y" value="">
2903 <input type="hidden" name="id" value="' .
$object->id.
'">
2904 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2908 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2911 print
'<div class="div-table-responsive-no-min">';
2912 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2916 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
2923 if ($action !=
'editline') {
2926 $parameters = array();
2928 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
2932 if (empty($reshook)) {
2933 $object->formAddObjectLine(1, $mysoc, $soc);
2936 $parameters = array();
2937 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters,
$object, $action);
2951 if ($action !=
'presend' && $action !=
'editline') {
2952 print
'<div class="tabsAction">';
2954 $parameters = array();
2956 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2957 if (empty($reshook)) {
2958 $numlines = count(
$object->lines);
2962 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.newToken().
'&id='.
$object->id,
'');
2966 if (empty($user->socid)) {
2969 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.newToken().
'&id='.
$object->id.
'&mode=init#formmailbeforetitle',
'');
2971 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2978 if ($numlines > 0) {
2979 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.newToken().
'&id='.
$object->id,
$object->id, 1);
2981 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.newToken().
'&id='.
$object->id,
$object->id, 0);
2986 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=modif&token='.newToken().
'&id='.
$object->id,
'');
2989 $arrayforbutaction = array();
2994 $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='.$object->element.
'&originid='.
$object->id);
3004 $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);
3028 if (isModEnabled(
'shipping')) {
3029 $numshipping =
$object->countNbOfShipments();
3034 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
3043 $langs->load(
"errors");
3044 print
dolGetButtonAction($langs->trans(
'ErrorModuleSetupNotComplete'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3049 $arrayforbutaction[] = array(
3052 'perm' => ($user->hasRight(
'facture',
'creer') && !
getDolGlobalInt(
'WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')),
3053 'label' =>
'CreateBill',
3054 'url' =>
'/compta/facture/card.php?action=create&token='.newToken().
'&origin='.urlencode(
$object->element).
'&originid='.
$object->id.
'&socid='.
$object->socid
3063 $actionButtonsParameters = [
3064 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER")
3067 if ($numlines > 0) {
3068 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction,
$object->id, 1, $actionButtonsParameters);
3070 print
dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction,
$object->id, 0, $actionButtonsParameters);
3075 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.newToken().
'&id='.
$object->id,
'');
3082 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.newToken().
'&id='.
$object->id,
'');
3087 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.newToken().
'&id='.
$object->id,
'');
3092 if ($usercancreate) {
3093 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.newToken().
'&id='.
$object->id.
'&socid='.
$object->socid,
'');
3098 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=cancel&token='.newToken().
'">'.$langs->trans(
"CancelOrder").
'</a>';
3102 if ($usercandelete) {
3103 if ($numshipping == 0) {
3104 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.
$object->id,
'');
3106 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3114 if (
GETPOST(
'modelselected')) {
3115 $action =
'presend';
3118 if ($action !=
'presend') {
3119 print
'<div class="fichecenter"><div class="fichehalfleft">';
3120 print
'<a name="builddoc"></a>';
3123 $relativepath = $objref.
'/'.$objref.
'.pdf';
3124 $filedir = $conf->commande->multidir_output[
$object->entity].
'/'.$objref;
3125 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3126 $genallowed = $usercanread;
3127 $delallowed = $usercancreate;
3128 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'',
$object);
3132 $linktoelem = $form->showLinkToObjectBlock(
$object,
null, array(
'order'));
3134 $compatibleImportElementsList =
false;
3137 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3139 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem, $compatibleImportElementsList);
3143 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3144 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
3145 $useonlinepayment = count($validpaymentmethod);
3148 $useonlinepayment = 0;
3151 print
'<br><!-- Link to pay -->';
3152 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3153 print showOnlinePaymentUrl(
'order',
$object->ref).
'<br>';
3156 print
'</div><div class="fichehalfright">';
3160 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id);
3163 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3165 $somethingshown = $formactions->showactions(
$object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3167 print
'</div></div>';
3171 $modelmail =
'order_send';
3172 $defaulttopic =
'SendOrderRef';
3174 $trackid =
'ord'.$object->id;
3176 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage a WYSIWYG editor.
static createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger=0, $autoValidateDeposit=false, $overrideFields=array())
Creates a deposit from a proposal or an order by grouping lines by VAT rates.
const TYPE_DEPOSIT
Deposit invoice.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
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.
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.