37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
42 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47 if (!empty($conf->propal->enabled)) {
48 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
50 if (!empty($conf->projet->enabled)) {
51 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
57 if (!empty($conf->variants->enabled)) {
58 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
62 $langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'deliveries',
'products',
'other'));
63 if (!empty($conf->incoterm->enabled)) $langs->load(
'incoterm');
64 if (!empty($conf->margin->enabled)) $langs->load(
'margins');
65 if (!empty($conf->productbatch->enabled)) $langs->load(
"productbatch");
69 $socid =
GETPOST(
'socid',
'int');
70 $action =
GETPOST(
'action',
'aZ09');
71 $cancel =
GETPOST(
'cancel',
'alpha');
72 $confirm =
GETPOST(
'confirm',
'alpha');
73 $lineid =
GETPOST(
'lineid',
'int');
74 $contactid =
GETPOST(
'contactid',
'int');
75 $projectid =
GETPOST(
'projectid',
'int');
76 $origin =
GETPOST(
'origin',
'alpha');
80 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
81 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
82 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
85 if (!empty($user->socid))
86 $socid = $user->socid;
93 $extrafields->fetch_name_optionals_label($object->table_element);
96 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
99 $hookmanager->initHooks(array(
'ordercard',
'globalcard'));
101 $usercanread = $user->rights->commande->lire;
102 $usercancreate = $user->rights->commande->creer;
103 $usercandelete = $user->rights->commande->supprimer;
105 $usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->close)));
106 $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->validate)));
107 $usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->annuler)));
108 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send);
110 $usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer;
112 $permissionnote = $usercancreate;
113 $permissiondellink = $usercancreate;
114 $permissiontoadd = $usercancreate;
116 if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
117 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
118 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse;
123 $date_delivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
130 $parameters = array(
'socid' => $socid);
132 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
139 if (!empty($backtopage))
141 header(
"Location: ".$backtopage);
147 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
151 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
154 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate)
156 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers'))
163 $orig = clone $object;
165 $result = $object->createFromClone($user, $socid);
168 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?id='.$result);
180 elseif ($action ==
'reopen' && $usercancreate)
184 $result = $object->set_reopen($user);
195 elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete)
197 $result = $object->delete($user);
200 header(
'Location: list.php?restore_lastsearch_values=1');
208 elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate)
210 $result = $object->deleteline($user, $lineid);
214 $outputlangs = $langs;
216 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09'))
217 $newlang =
GETPOST(
'lang_id',
'aZ09');
218 if ($conf->global->MAIN_MULTILANGS && empty($newlang))
219 $newlang = $object->thirdparty->default_lang;
220 if (!empty($newlang)) {
222 $outputlangs->setDefaultLang($newlang);
224 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
225 $ret = $object->fetch($object->id);
226 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
229 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
237 elseif ($action ==
'classin' && $usercancreate)
239 $object->setProject(
GETPOST(
'projectid',
'int'));
243 elseif ($action ==
'add' && $usercancreate)
246 $date_delivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
247 $selectedLines =
GETPOST(
'toselect',
'array');
249 if ($datecommande ==
'') {
250 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')), null,
'errors');
256 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")), null,
'errors');
262 $object->socid = $socid;
263 $object->fetch_thirdparty();
267 $object->date_commande = $datecommande;
268 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
269 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
270 $object->source =
GETPOST(
'source_id');
271 $object->fk_project =
GETPOST(
'projectid',
'int');
272 $object->ref_client =
GETPOST(
'ref_client',
'alpha');
273 $object->model_pdf =
GETPOST(
'model');
274 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
275 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
276 $object->fk_account =
GETPOST(
'fk_account',
'int');
277 $object->availability_id =
GETPOST(
'availability_id');
278 $object->demand_reason_id =
GETPOST(
'demand_reason_id');
279 $object->date_livraison = $date_delivery;
280 $object->delivery_date = $date_delivery;
281 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
282 $object->warehouse_id =
GETPOST(
'warehouse_id',
'int');
283 $object->fk_delivery_address =
GETPOST(
'fk_address');
284 $object->contact_id =
GETPOST(
'contactid');
285 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
286 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
287 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
288 $object->multicurrency_tx =
GETPOST(
'originmulticurrency_tx',
'int');
292 $ret = $extrafields->setOptionalsFromPost(null, $object);
293 if ($ret < 0) $error++;
297 if (!empty($origin) && !empty($originid))
300 $element = $subelement = $origin;
301 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
302 $element = $regs [1];
303 $subelement = $regs [2];
307 if ($element ==
'order') {
308 $element = $subelement =
'commande';
310 if ($element ==
'propal') {
311 $element =
'comm/propal';
312 $subelement =
'propal';
314 if ($element ==
'contract') {
315 $element = $subelement =
'contrat';
318 $object->origin = $origin;
319 $object->origin_id = $originid;
322 $object->linked_objects [$object->origin] = $object->origin_id;
323 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
324 if (!empty($other_linked_objects)) {
325 $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
330 $object_id = $object->create($user);
336 $classname = ucfirst($subelement);
337 $srcobject =
new $classname($db);
339 dol_syslog(
"Try to find source object origin=".$object->origin.
" originid=".$object->origin_id.
" to add lines");
340 $result = $srcobject->fetch($object->origin_id);
343 $lines = $srcobject->lines;
344 if (empty($lines) && method_exists($srcobject,
'fetch_lines'))
346 $srcobject->fetch_lines();
347 $lines = $srcobject->lines;
351 $num = count($lines);
353 for ($i = 0; $i < $num; $i++)
355 if (!in_array($lines[$i]->
id, $selectedLines))
continue;
357 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
358 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
359 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
363 $date_start = $lines[$i]->date_debut_prevue;
364 if ($lines[$i]->date_debut_reel)
365 $date_start = $lines[$i]->date_debut_reel;
366 if ($lines[$i]->date_start)
367 $date_start = $lines[$i]->date_start;
368 $date_end = $lines[$i]->date_fin_prevue;
369 if ($lines[$i]->date_fin_reel)
370 $date_end = $lines[$i]->date_fin_reel;
371 if ($lines[$i]->date_end)
372 $date_end = $lines[$i]->date_end;
375 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
380 if (method_exists($lines[$i],
'fetch_optionals'))
382 $lines[$i]->fetch_optionals();
383 $array_options = $lines[$i]->array_options;
386 $tva_tx = $lines[$i]->tva_tx;
387 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
389 $result = $object->addline(
390 $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product,
391 $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except,
'HT', 0, $date_start, $date_end, $product_type,
392 $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options,
393 $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid
402 if ($result > 0 && $lines[$i]->product_type == 9) {
403 $fk_parent_line = $result;
438 $parameters = array(
'objFrom' => $srcobject);
440 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
455 $object_id = $object->create($user);
462 if (
GETPOST(
'contactid',
'int')) {
463 $result = $object->add_contact(
GETPOST(
'contactid',
'int'),
'CUSTOMER',
'external');
475 if ($object_id > 0 && !$error)
478 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object_id);
486 } elseif ($action ==
'classifybilled' && $usercancreate)
488 $ret = $object->classifyBilled($user);
493 } elseif ($action ==
'classifyunbilled' && $usercancreate)
495 $ret = $object->classifyUnBilled();
502 elseif ($action ==
'setref_client' && $usercancreate) {
503 $result = $object->set_ref_client($user,
GETPOST(
'ref_client'));
508 } elseif ($action ==
'setremise' && $usercancreate) {
509 $result = $object->set_remise($user,
GETPOST(
'remise'));
514 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
516 if ($object->id > 0) {
517 $object->insert_discount(
GETPOST(
'remise_id'));
522 } elseif ($action ==
'setdate' && $usercancreate) {
526 $result = $object->set_date($user, $date);
530 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
532 $date_delivery =
dol_mktime(
GETPOST(
'liv_hour',
'int'),
GETPOST(
'liv_min',
'int'), 0,
GETPOST(
'liv_month',
'int'),
GETPOST(
'liv_day',
'int'),
GETPOST(
'liv_year',
'int'));
535 $result = $object->setDeliveryDate($user, $date_delivery);
539 } elseif ($action ==
'setmode' && $usercancreate) {
540 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
546 elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
547 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
551 elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
552 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')),
GETPOST(
'calculation_mode',
'int'));
553 } elseif ($action ==
'setavailability' && $usercancreate) {
554 $result = $object->availability(
GETPOST(
'availability_id'));
557 } elseif ($action ==
'setdemandreason' && $usercancreate) {
558 $result = $object->demand_reason(
GETPOST(
'demand_reason_id'));
561 } elseif ($action ==
'setconditions' && $usercancreate) {
562 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
566 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
568 $outputlangs = $langs;
569 $newlang =
GETPOST(
'lang_id',
'alpha');
570 if ($conf->global->MAIN_MULTILANGS && empty($newlang))
571 $newlang = $object->thirdparty->default_lang;
572 if (!empty($newlang)) {
574 $outputlangs->setDefaultLang($newlang);
577 $ret = $object->fetch($object->id);
578 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
584 elseif ($action ==
'set_incoterms' && !empty($conf->incoterm->enabled))
586 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
593 elseif ($action ==
'setbankaccount' && $usercancreate) {
594 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
601 elseif ($action ==
'setshippingmethod' && $usercancreate) {
602 $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id',
'int'));
609 elseif ($action ==
'setwarehouse' && $usercancreate) {
610 $result = $object->setWarehouse(
GETPOST(
'warehouse_id',
'int'));
614 } elseif ($action ==
'setremisepercent' && $usercancreate) {
615 $result = $object->set_remise($user,
GETPOST(
'remise_percent'));
616 } elseif ($action ==
'setremiseabsolue' && $usercancreate) {
617 $result = $object->set_remise_absolue($user,
GETPOST(
'remise_absolue'));
618 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'') {
620 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
621 $vat_rate = str_replace(
'*',
'', $vat_rate);
622 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
623 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
624 foreach ($object->lines as $line) {
625 $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);
627 } elseif ($action ==
'addline' && $usercancreate)
629 $langs->load(
'errors');
637 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
638 if ($prod_entry_mode ==
'free')
643 $idprod =
GETPOST(
'idprod',
'int');
649 if (empty($remise_percent)) {
654 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
655 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
657 if (is_array($extralabelsline)) {
659 foreach ($extralabelsline as $key => $value) {
660 unset($_POST[
"options_".$key]);
664 if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
665 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')), null,
'errors');
668 if ($prod_entry_mode ==
'free' && empty($idprod) &&
GETPOST(
'type') < 0) {
669 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')), null,
'errors');
672 if ($prod_entry_mode ==
'free' && empty($idprod) && $price_ht ==
'' && $price_ht_devise ==
'')
674 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")), null,
'errors');
678 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')), null,
'errors');
681 if ($prod_entry_mode ==
'free' && empty($idprod) && empty($product_desc)) {
682 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')), null,
'errors');
686 if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode !=
'free') {
687 if ($combinations =
GETPOST(
'combinations',
'array')) {
691 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
692 $idprod = $res->fk_product_child;
694 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'), null,
'errors');
700 if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) {
704 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
710 if (!empty($idprod)) {
712 $prod->fetch($idprod);
714 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
719 if (empty($tva_tx)) $tva_npr = 0;
721 $pu_ht = $prod->price;
722 $pu_ttc = $prod->price_ttc;
723 $price_min = $prod->price_min;
724 $price_base_type = $prod->price_base_type;
727 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level))
729 $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
730 $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
731 $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
732 $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
733 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))
735 if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
736 if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
740 elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
742 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
746 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' => $object->thirdparty->id);
748 $result = $prodcustprice->fetch_all(
'',
'', 0, 0, $filter);
751 if (count($prodcustprice->lines) > 0)
753 $pu_ht =
price($prodcustprice->lines[0]->price);
754 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
755 $price_min =
price($prodcustprice->lines[0]->price_min);
756 $price_base_type = $prodcustprice->lines[0]->price_base_type;
757 $tva_tx = $prodcustprice->lines[0]->tva_tx;
758 if ($prodcustprice->lines[0]->default_vat_code && !preg_match(
'/\(.*\)/', $tva_tx)) $tva_tx .=
' ('.$prodcustprice->lines[0]->default_vat_code.
')';
759 $tva_npr = $prodcustprice->lines[0]->recuperableonly;
760 if (empty($tva_tx)) $tva_npr = 0;
767 elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
769 if ($prod->prices_by_qty[0])
775 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray)
777 if ($priceforthequantityarray[
'rowid'] != $pqp)
continue;
779 if ($priceforthequantityarray[
'price_base_type'] ==
'HT')
781 $pu_ht = $priceforthequantityarray[
'unitprice'];
783 $pu_ttc = $priceforthequantityarray[
'unitprice'];
791 elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
793 if ($prod->prices_by_qty[$object->thirdparty->price_level])
798 foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray)
800 if ($priceforthequantityarray[
'rowid'] != $pqp)
continue;
802 if ($priceforthequantityarray[
'price_base_type'] ==
'HT')
804 $pu_ht = $priceforthequantityarray[
'unitprice'];
806 $pu_ttc = $priceforthequantityarray[
'unitprice'];
814 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
815 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
818 if (!empty($price_ht) || $price_ht ===
'0') {
820 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
824 elseif ($tmpvat != $tmpprodvat) {
825 if ($price_base_type !=
'HT') {
826 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
828 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
835 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
836 $outputlangs = $langs;
838 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09'))
839 $newlang =
GETPOST(
'lang_id',
'aZ09');
841 $newlang = $object->thirdparty->default_lang;
842 if (!empty($newlang)) {
844 $outputlangs->setDefaultLang($newlang);
847 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->description;
849 $desc = $prod->description;
852 if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc;
853 else $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
856 if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
859 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
860 $outputlangs = $langs;
862 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha'))
863 $newlang =
GETPOST(
'lang_id',
'alpha');
865 $newlang = $object->thirdparty->default_lang;
866 if (!empty($newlang)) {
868 $outputlangs->setDefaultLang($newlang);
869 $outputlangs->load(
'products');
871 if (!empty($prod->customcode))
872 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
873 if (!empty($prod->customcode) && !empty($prod->country_code))
875 if (!empty($prod->country_code))
876 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
878 if (!empty($prod->customcode))
879 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
880 if (!empty($prod->customcode) && !empty($prod->country_code))
882 if (!empty($prod->country_code))
883 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
890 $fk_unit = $prod->fk_unit;
894 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
895 $tva_tx = str_replace(
'*',
'', $tva_tx);
896 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
897 $desc = $product_desc;
899 $fk_unit =
GETPOST(
'units',
'alpha');
900 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
908 $localtax1_tx =
get_localtax($tva_tx, 1, $object->thirdparty);
909 $localtax2_tx =
get_localtax($tva_tx, 2, $object->thirdparty);
917 if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (
price2num($pu_ht) * (1 -
price2num($remise_percent) / 100) <
price2num($price_min)))) {
918 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
922 $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, - 1, 0,
GETPOST(
'fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit,
'', 0, $pu_ht_devise);
925 $ret = $object->fetch($object->id);
926 $object->fetch_thirdparty();
928 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
930 $outputlangs = $langs;
931 $newlang =
GETPOST(
'lang_id',
'alpha');
932 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
933 $newlang = $object->thirdparty->default_lang;
934 if (!empty($newlang)) {
936 $outputlangs->setDefaultLang($newlang);
939 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
942 unset($_POST[
'prod_entry_mode']);
944 unset($_POST[
'qty']);
945 unset($_POST[
'type']);
946 unset($_POST[
'remise_percent']);
947 unset($_POST[
'price_ht']);
948 unset($_POST[
'multicurrency_price_ht']);
949 unset($_POST[
'price_ttc']);
950 unset($_POST[
'tva_tx']);
951 unset($_POST[
'product_ref']);
952 unset($_POST[
'product_label']);
953 unset($_POST[
'product_desc']);
954 unset($_POST[
'fournprice']);
955 unset($_POST[
'buying_price']);
956 unset($_POST[
'np_marginRate']);
957 unset($_POST[
'np_markRate']);
958 unset($_POST[
'dp_desc']);
959 unset($_POST[
'idprod']);
960 unset($_POST[
'units']);
962 unset($_POST[
'date_starthour']);
963 unset($_POST[
'date_startmin']);
964 unset($_POST[
'date_startsec']);
965 unset($_POST[
'date_startday']);
966 unset($_POST[
'date_startmonth']);
967 unset($_POST[
'date_startyear']);
968 unset($_POST[
'date_endhour']);
969 unset($_POST[
'date_endmin']);
970 unset($_POST[
'date_endsec']);
971 unset($_POST[
'date_endday']);
972 unset($_POST[
'date_endmonth']);
973 unset($_POST[
'date_endyear']);
984 elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save'))
998 if (preg_match(
'/\*/', $vat_rate)) {
1003 $vat_rate = str_replace(
'*',
'', $vat_rate);
1004 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
1005 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
1012 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1013 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
1015 if (is_array($extralabelsline)) {
1016 foreach ($extralabelsline as $key => $value) {
1017 unset($_POST[
"options_".$key]);
1022 $special_code =
GETPOST(
'special_code');
1023 if (!
GETPOST(
'qty')) $special_code = 3;
1026 $productid =
GETPOST(
'productid',
'int');
1027 if (!empty($productid)) {
1029 $product->fetch($productid);
1031 $type = $product->type;
1033 $price_min = $product->price_min;
1034 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level))
1035 $price_min = $product->multiprices_min[$object->thirdparty->price_level];
1039 if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (
price2num($pu_ht) * (1 -
price2num(
GETPOST(
'remise_percent')) / 100) <
price2num($price_min)))) {
1040 setEventMessages($langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null,
'errors');
1045 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1049 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
1055 if (empty($user->rights->margins->creer))
1057 foreach ($object->lines as &$line)
1059 if ($line->id ==
GETPOST(
'lineid'))
1061 $fournprice = $line->fk_fournprice;
1062 $buyingprice = $line->pa_ht;
1067 $result = $object->updateline(
GETPOST(
'lineid'), $description, $pu_ht,
GETPOST(
'qty'),
GETPOST(
'remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate,
'HT', $info_bits, $date_start, $date_end, $type,
GETPOST(
'fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options,
GETPOST(
'units'), $pu_ht_devise);
1070 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1072 $outputlangs = $langs;
1074 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09'))
1075 $newlang =
GETPOST(
'lang_id',
'aZ09');
1076 if ($conf->global->MAIN_MULTILANGS && empty($newlang))
1077 $newlang = $object->thirdparty->default_lang;
1078 if (!empty($newlang)) {
1079 $outputlangs =
new Translate(
"", $conf);
1080 $outputlangs->setDefaultLang($newlang);
1083 $ret = $object->fetch($object->id);
1084 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1087 unset($_POST[
'qty']);
1088 unset($_POST[
'type']);
1089 unset($_POST[
'productid']);
1090 unset($_POST[
'remise_percent']);
1091 unset($_POST[
'price_ht']);
1092 unset($_POST[
'multicurrency_price_ht']);
1093 unset($_POST[
'price_ttc']);
1094 unset($_POST[
'tva_tx']);
1095 unset($_POST[
'product_ref']);
1096 unset($_POST[
'product_label']);
1097 unset($_POST[
'product_desc']);
1098 unset($_POST[
'fournprice']);
1099 unset($_POST[
'buying_price']);
1101 unset($_POST[
'date_starthour']);
1102 unset($_POST[
'date_startmin']);
1103 unset($_POST[
'date_startsec']);
1104 unset($_POST[
'date_startday']);
1105 unset($_POST[
'date_startmonth']);
1106 unset($_POST[
'date_startyear']);
1107 unset($_POST[
'date_endhour']);
1108 unset($_POST[
'date_endmin']);
1109 unset($_POST[
'date_endsec']);
1110 unset($_POST[
'date_endday']);
1111 unset($_POST[
'date_endmonth']);
1112 unset($_POST[
'date_endyear']);
1117 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1118 header(
'Location: '.
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1120 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate)
1122 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
1124 $qualified_for_stock_change = 0;
1125 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1127 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1129 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1133 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
1135 if (!$idwarehouse || $idwarehouse == -1)
1138 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
1144 $result = $object->valid($user, $idwarehouse);
1148 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
1150 $outputlangs = $langs;
1152 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
1153 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
1154 if (!empty($newlang)) {
1155 $outputlangs =
new Translate(
"", $conf);
1156 $outputlangs->setDefaultLang($newlang);
1158 $model = $object->model_pdf;
1159 $ret = $object->fetch($id);
1161 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1170 elseif ($action ==
'confirm_modif' && $usercancreate) {
1171 $idwarehouse =
GETPOST(
'idwarehouse');
1173 $qualified_for_stock_change = 0;
1174 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1176 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1178 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1182 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
1184 if (!$idwarehouse || $idwarehouse == -1)
1187 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
1193 $result = $object->setDraft($user, $idwarehouse);
1197 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
1199 $outputlangs = $langs;
1201 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
1202 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
1203 if (!empty($newlang)) {
1204 $outputlangs =
new Translate(
"", $conf);
1205 $outputlangs->setDefaultLang($newlang);
1207 $model = $object->model_pdf;
1208 $ret = $object->fetch($id);
1210 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1214 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1215 $result = $object->cloture($user);
1219 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate)
1221 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
1223 $qualified_for_stock_change = 0;
1224 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1226 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1228 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1232 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
1234 if (!$idwarehouse || $idwarehouse == -1)
1237 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
1243 $result = $object->cancel($idwarehouse);
1251 if ($action ==
'update_extras')
1256 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
1257 if ($ret < 0) $error++;
1262 $result = $object->insertExtraFields(
'ORDER_MODIFY');
1270 if ($error) $action =
'edit_extras';
1274 if ($action ==
'import_lines_from_object'
1279 $fromElement =
GETPOST(
'fromelement');
1280 $fromElementid =
GETPOST(
'fromelementid');
1281 $importLines =
GETPOST(
'line_checkbox');
1283 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid))
1285 if ($fromElement ==
'commande')
1288 $lineClassName =
'OrderLine';
1289 } elseif ($fromElement ==
'propal')
1291 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1292 $lineClassName =
'PropaleLigne';
1294 $nextRang = count($object->lines) + 1;
1297 foreach ($importLines as $lineId)
1299 $lineId = intval($lineId);
1300 $originLine =
new $lineClassName($db);
1301 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0)
1303 $originLine->fetch_optionals();
1304 $desc = $originLine->desc;
1305 $pu_ht = $originLine->subprice;
1306 $qty = $originLine->qty;
1307 $txtva = $originLine->tva_tx;
1308 $txlocaltax1 = $originLine->localtax1_tx;
1309 $txlocaltax2 = $originLine->localtax2_tx;
1310 $fk_product = $originLine->fk_product;
1311 $remise_percent = $originLine->remise_percent;
1312 $date_start = $originLine->date_start;
1313 $date_end = $originLine->date_end;
1315 $info_bits = $originLine->info_bits;
1316 $fk_remise_except = $originLine->fk_remise_except;
1317 $price_base_type =
'HT';
1319 $type = $originLine->product_type;
1320 $rang = $nextRang++;
1321 $special_code = $originLine->special_code;
1322 $origin = $originLine->element;
1323 $origin_id = $originLine->id;
1324 $fk_parent_line = 0;
1325 $fk_fournprice = $originLine->fk_fournprice;
1326 $pa_ht = $originLine->pa_ht;
1327 $label = $originLine->label;
1328 $array_options = $originLine->array_options;
1329 $situation_percent = 100;
1331 $fk_unit = $originLine->fk_unit;
1332 $pu_ht_devise = $originLine->multicurrency_subprice;
1334 $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);
1354 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1357 $upload_dir = $conf->commande->multidir_output[$object->entity];
1358 $permissiontoadd = $usercancreate;
1359 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1362 $triggersendname =
'ORDER_SENTBYMAIL';
1364 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
1365 $trackid =
'ord'.$object->id;
1366 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1369 if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate)
1371 if ($action ==
'addcontact')
1373 if ($object->id > 0) {
1376 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1380 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1383 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1384 $langs->load(
"errors");
1385 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
1393 elseif ($action ==
'swapstatut')
1395 if ($object->id > 0) {
1396 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
1403 elseif ($action ==
'deletecontact')
1405 $result = $object->delete_contact($lineid);
1408 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1422 llxHeader(
'', $langs->trans(
'Order'),
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
1424 $form =
new Form($db);
1428 if (!empty($conf->projet->enabled)) { $formproject =
new FormProjets($db); }
1431 if ($action ==
'create' && $usercancreate)
1437 $res = $soc->fetch($socid);
1439 $remise_absolue = 0;
1441 $currency_code = $conf->currency;
1443 if (!empty($origin) && !empty($originid)) {
1445 $element = $subelement = $origin;
1447 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1448 $element = $regs[1];
1449 $subelement = $regs[2];
1452 if ($element ==
'project') {
1453 $projectid = $originid;
1455 if (!$cond_reglement_id) {
1456 $cond_reglement_id = $soc->cond_reglement_id;
1458 if (!$mode_reglement_id) {
1459 $mode_reglement_id = $soc->mode_reglement_id;
1461 if (!$remise_percent) {
1462 $remise_percent = $soc->remise_percent;
1466 $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ODER) ?-1 :
'') : $dateorder);
1470 if ($element ==
'order' || $element ==
'commande') {
1471 $element = $subelement =
'commande';
1472 } elseif ($element ==
'propal') {
1473 $element =
'comm/propal';
1474 $subelement =
'propal';
1475 } elseif ($element ==
'contract') {
1476 $element = $subelement =
'contrat';
1481 $classname = ucfirst($subelement);
1482 $objectsrc =
new $classname($db);
1483 $objectsrc->fetch($originid);
1484 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines'))
1485 $objectsrc->fetch_lines();
1486 $objectsrc->fetch_thirdparty();
1489 $objectsrc->fetch_optionals();
1490 $object->array_options = $objectsrc->array_options;
1492 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1493 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1495 $soc = $objectsrc->thirdparty;
1496 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1497 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1498 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1499 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0));
1500 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
1501 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1502 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
1503 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
1504 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1505 $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 :
'';
1507 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
1508 if (empty($date_delivery)) $date_delivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison :
'');
1510 if (!empty($conf->multicurrency->enabled))
1512 if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
1513 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
1516 $note_private = $object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
1517 $note_public = $object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
1520 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1523 $cond_reglement_id = $soc->cond_reglement_id;
1524 $mode_reglement_id = $soc->mode_reglement_id;
1525 $fk_account = $soc->fk_account;
1526 $availability_id = $soc->availability_id;
1527 $shipping_method_id = $soc->shipping_method_id;
1528 $warehouse_id = $soc->warehouse_id;
1529 $demand_reason_id = $soc->demand_reason_id;
1530 $remise_percent = $soc->remise_percent;
1531 $remise_absolue = 0;
1532 $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 :
'';
1534 if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
1536 $note_private = $object->getDefaultCreateValueFor(
'note_private');
1537 $note_public = $object->getDefaultCreateValueFor(
'note_public');
1540 print '<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1541 print '<input type="hidden" name="token" value="'.newToken().
'">';
1542 print '<input type="hidden" name="action" value="add">';
1543 print '<input type="hidden" name="socid" value="'.$soc->id.
'">'.
"\n";
1544 print '<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
1545 print '<input type="hidden" name="origin" value="'.$origin.
'">';
1546 print '<input type="hidden" name="originid" value="'.$originid.
'">';
1547 if (!empty($currency_tx))
print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1551 print '<table class="border centpercent">';
1554 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
1557 print '<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
1558 if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid))
1559 print '<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
1560 else print '<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
1565 print '<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1568 print $soc->getNomUrl(1);
1569 print '<input type="hidden" name="socid" value="'.$soc->id.
'">';
1573 print img_picto(
'',
'company').$form->select_company(
'',
'socid',
'(s.client = 1 OR s.client = 2 OR s.client = 3)',
'SelectThirdParty', 0, 0, null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1575 if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
1577 print '<script type="text/javascript">
1578 $(document).ready(function() {
1579 $("#socid").change(function() {
1580 console.log("We have changed the company - Reload page");
1581 var socid = $(this).val();
1583 window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?action=create&socid="+socid+"&ref_client="+$("input[name=ref_client]").val();
1588 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>';
1596 print "<tr><td>".$langs->trans(
"DefaultContact").
'</td><td>';
1597 $form->select_contacts($soc->id, $contactid,
'contactid', 1, $srccontactslist,
'', 1);
1601 print '<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1603 $absolute_discount = $soc->getAvailableDiscounts();
1607 $backtopage = urlencode(
$_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1608 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1614 print '<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
1615 print $form->selectDate(
'',
're',
'',
'',
'',
"crea_commande", 1, 1);
1619 print '<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1620 print '<td colspan="3">';
1621 $date_delivery = ($date_delivery ? $date_delivery : $object->date_delivery);
1622 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
1627 print '<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1628 $form->select_conditions_paiements($cond_reglement_id,
'cond_reglement_id', - 1, 1);
1632 print '<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
1633 $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id');
1637 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled))
1639 print '<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
1640 $form->select_comptes($fk_account,
'fk_account', 0,
'', 1);
1645 print '<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
1646 $form->selectAvailabilityDelay($availability_id,
'availability_id',
'', 1);
1650 if (!empty($conf->expedition->enabled)) {
1651 print '<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
1652 print $form->selectShippingMethod($shipping_method_id,
'shipping_method_id',
'', 1);
1657 if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1658 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1660 print '<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
1661 print img_picto(
'',
'stock').$formproduct->selectWarehouses($warehouse_id,
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth175 maxwidth500 widthcentpercentminusxx');
1666 print '<tr><td>'.$langs->trans(
'Channel').
'</td><td>';
1667 $form->selectInputReason($demand_reason_id,
'demand_reason_id',
'', 1);
1673 if (!empty($conf->projet->enabled))
1675 $langs->load(
"projects");
1677 print '<td>'.$langs->trans(
"Project").
'</td><td>';
1679 $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth175 maxwidth500 widthcentpercentminusxx');
1680 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>';
1686 if (!empty($conf->incoterm->enabled))
1689 print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $objectsrc->label_incoterms, 1).
'</label></td>';
1690 print '<td class="maxwidthonsmartphone">';
1691 $incoterm_id =
GETPOST(
'incoterm_id');
1692 $incoterm_location =
GETPOST(
'location_incoterms');
1693 if (empty($incoterm_id))
1695 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
1696 $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
1698 print $form->select_incoterms($incoterm_id, $incoterm_location);
1703 $parameters = array(
'objectsrc' => $objectsrc,
'socid'=>$socid);
1705 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1706 print $hookmanager->resPrint;
1707 if (empty($reshook)) {
1708 if (!empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER) && !empty($soc->id)) {
1710 $tpExtrafields =
new Extrafields($db);
1711 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
1712 if ($soc->fetch_optionals() > 0) {
1713 $object->array_options = array_merge($object->array_options, $soc->array_options);
1717 print $object->showOptionals($extrafields,
'edit', $parameters);
1721 print '<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
1723 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
1725 $preselected = $conf->global->COMMANDE_ADDON_PDF;
1726 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1730 if (!empty($conf->multicurrency->enabled))
1733 print '<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0).
'</td>';
1734 print '<td class="maxwidthonsmartphone">';
1735 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1741 print '<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1744 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
1745 print $doleditor->Create(1);
1750 if (empty($user->socid)) {
1752 print '<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1755 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
1756 print $doleditor->Create(1);
1761 if (!empty($origin) && !empty($originid) && is_object($objectsrc))
1764 if ($origin ==
'contrat') {
1766 $objectsrc->remise_absolue = $remise_absolue;
1767 $objectsrc->remise_percent = $remise_percent;
1768 $objectsrc->update_price(1);
1771 print "\n<!-- ".$classname.
" info -->";
1773 print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1774 print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1775 print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1776 print '<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1777 print '<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1779 switch ($classname) {
1781 $newclassname =
'CommercialProposal';
1784 $newclassname =
'Order';
1787 $newclassname =
'Sending';
1790 $newclassname =
'Contract';
1793 $newclassname = $classname;
1796 print '<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
1799 print '<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
1800 print '<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
1801 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0)
1803 print '<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
1806 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0)
1808 print '<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
1811 print '<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
1813 if (!empty($conf->multicurrency->enabled))
1815 print '<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1816 print '<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1817 print '<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1826 print '<div class="center">';
1827 print '<input type="submit" class="button" name="bouton" value="'.$langs->trans(
'CreateDraft').
'">';
1828 print ' ';
1829 print '<input type="button" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" onclick="javascript:history.go(-1)">';
1833 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1834 $title = $langs->trans(
'ProductsAndServices');
1837 print '<table class="noborder centpercent">';
1839 $objectsrc->printOriginLinesList(
'', $selectedLines);
1849 if ($object->id > 0) {
1850 $product_static =
new Product($db);
1853 $soc->fetch($object->socid);
1855 $author =
new User($db);
1856 $author->fetch($object->user_author_id);
1858 $object->fetch_thirdparty();
1859 $res = $object->fetch_optionals();
1867 if ($action ==
'delete') {
1868 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
1872 if ($action ==
'validate')
1875 $ref = substr($object->ref, 1, 4);
1876 if ($ref ==
'PROV') {
1877 $numref = $object->getNextNumRef($soc);
1879 $numref = $object->ref;
1882 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
1883 if (!empty($conf->notification->enabled))
1885 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1886 $notify =
new Notify($db);
1888 $text .= $notify->confirmMessage(
'ORDER_VALIDATE', $object->socid, $object);
1891 $qualified_for_stock_change = 0;
1892 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1894 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1896 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1899 $formquestion = array();
1900 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
1902 $langs->load(
"stocks");
1903 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1906 if ($conf->browser->name ==
'ie') $forcecombo = 1;
1907 $formquestion = array(
1911 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockDecrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse',
'int') ?
GETPOST(
'idwarehouse',
'int') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
1915 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
1919 if ($action ==
'modif')
1921 $qualified_for_stock_change = 0;
1922 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1924 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1926 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1929 $text = $langs->trans(
'ConfirmUnvalidateOrder', $object->ref);
1930 $formquestion = array();
1931 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
1933 $langs->load(
"stocks");
1934 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1937 if ($conf->browser->name ==
'ie') $forcecombo = 1;
1938 $formquestion = array(
1942 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
1946 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
1952 if ($action ==
'shipped') {
1953 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
1959 if ($action ==
'cancel')
1961 $qualified_for_stock_change = 0;
1962 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1964 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1966 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1969 $text = $langs->trans(
'ConfirmCancelOrder', $object->ref);
1970 $formquestion = array();
1971 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
1973 $langs->load(
"stocks");
1974 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1977 if ($conf->browser->name ==
'ie') $forcecombo = 1;
1978 $formquestion = array(
1982 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
1986 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
1990 if ($action ==
'ask_deleteline')
1992 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1996 if ($action ==
'clone') {
1998 $formquestion = array(
1999 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOST(
'socid',
'int'),
'socid',
'(s.client=1 OR s.client = 2 OR s.client=3)'))
2001 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2005 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2007 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2008 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
2009 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
2017 $linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
2019 $morehtmlref = '<div class="refidno">';
2021 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, '
string', '', 0, 1);
2022 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, '
string', '', null, null, '', 1);
2024 $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1);
2025 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->
id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->
id.'&search_societe='.urlencode($object->thirdparty->
name).'">'.$langs->trans("OtherOrders").'</a>)';
2027 if (!empty($conf->projet->enabled))
2029 $langs->load(
"projects");
2030 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
2033 if ($action !=
'classify')
2034 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
2035 if ($action ==
'classify') {
2037 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
2038 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
2039 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2040 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1, 0,
'maxwidth500');
2041 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
2042 $morehtmlref .=
'</form>';
2044 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
2047 if (!empty($object->fk_project)) {
2049 $proj->fetch($object->fk_project);
2050 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
2051 $morehtmlref .= $proj->ref;
2052 $morehtmlref .=
'</a>';
2058 $morehtmlref .=
'</div>';
2061 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2064 print '<div class="fichecenter">';
2065 print '<div class="fichehalfleft">';
2066 print '<div class="underbanner clearboth"></div>';
2068 print '<table class="border tableforfield centpercent">';
2070 if ($soc->outstanding_limit)
2073 print '<tr><td class="titlefield">';
2074 print $langs->trans(
'OutstandingBill');
2076 $arrayoutstandingbills = $soc->getOutstandingBills();
2077 print price($arrayoutstandingbills[
'opened']).
' / ';
2078 print price($soc->outstanding_limit, 0,
'', 1, - 1, - 1, $conf->currency);
2084 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
2085 $filterabsolutediscount =
"fk_facture_source IS NULL";
2086 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2088 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2089 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2092 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"]).
'?facid='.$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
2093 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"]).
'?facid='.$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
2094 $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>';
2096 print '<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2098 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2099 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2100 $absolute_discount =
price2num($absolute_discount,
'MT');
2101 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2105 $backtopage = urlencode(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
2106 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2113 print $form->editfieldkey(
"Date",
'date',
'', $object, $editenable);
2115 if ($action ==
'editdate') {
2116 print '<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2117 print '<input type="hidden" name="token" value="'.newToken().
'">';
2118 print '<input type="hidden" name="action" value="setdate">';
2119 print $form->selectDate($object->date,
'order_',
'',
'',
'',
"setdate");
2120 print '<input type="submit" class="button" value="'.$langs->trans(
'Modify').
'">';
2124 if ($object->hasDelay()) {
2125 print ' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(),
"warning");
2133 $editenable = $usercancreate;
2134 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, $editenable);
2136 if ($action ==
'editdate_livraison') {
2137 print '<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2138 print '<input type="hidden" name="token" value="'.newToken().
'">';
2139 print '<input type="hidden" name="action" value="setdate_livraison">';
2140 print $form->selectDate($object->delivery_date ? $object->delivery_date : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
2141 print '<input type="submit" class="button" value="'.$langs->trans(
'Modify').
'">';
2144 print $object->delivery_date ?
dol_print_date($object->delivery_date,
'dayhour') :
' ';
2145 if ($object->hasDelay() && !empty($object->delivery_date)) {
2146 print ' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(),
"warning");
2153 if (!empty($conf->expedition->enabled)) {
2155 $editenable = $usercancreate;
2156 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, $editenable);
2158 if ($action ==
'editshippingmethod') {
2159 $form->formSelectShippingMethod(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
2161 $form->formSelectShippingMethod(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'none');
2168 if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
2169 $langs->load(
'stocks');
2170 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2173 $editenable = $usercancreate;
2174 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
2176 if ($action ==
'editwarehouse') {
2177 $formproduct->formSelectWarehouses(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'warehouse_id', 1);
2179 $formproduct->formSelectWarehouses(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'none');
2187 $editenable = $usercancreate;
2188 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, $editenable);
2190 if ($action ==
'editconditions') {
2191 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 1);
2193 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 1);
2201 $editenable = $usercancreate;
2202 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, $editenable);
2204 if ($action ==
'editmode') {
2205 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2207 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2212 if (!empty($conf->multicurrency->enabled))
2218 print $form->editfieldkey(
"Currency",
'multicurrencycode',
'', $object, $editenable);
2220 if ($action ==
'editmulticurrencycode') {
2221 $form->form_multicurrency_code(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2223 $form->form_multicurrency_code(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2228 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1)
2232 $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT;
2233 print $form->editfieldkey(
"CurrencyRate",
'multicurrencyrate',
'', $object, $editenable);
2235 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2236 if ($action ==
'actualizemulticurrencyrate') {
2239 $form->form_multicurrency_rate(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2241 $form->form_multicurrency_rate(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2242 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2243 print '<div class="inline-block"> ';
2244 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2253 print '<tr class="fielddeliverydelay"><td>';
2254 $editenable = $usercancreate;
2255 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, $editenable);
2257 if ($action ==
'editavailability') {
2258 $form->form_availability(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'availability_id', 1);
2260 $form->form_availability(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'none', 1);
2266 $editenable = $usercancreate;
2267 print $form->editfieldkey(
"Channel",
'demandreason',
'', $object, $editenable);
2269 if ($action ==
'editdemandreason') {
2270 $form->formInputReason(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'demand_reason_id', 1);
2272 $form->formInputReason(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'none');
2290 $tmparray = $object->getTotalWeightVolume();
2291 $totalWeight = $tmparray[
'weight'];
2292 $totalVolume = $tmparray[
'volume'];
2294 print '<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2296 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');
2300 print '<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2302 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');
2309 if (!empty($conf->incoterm->enabled)) {
2311 $editenable = $usercancreate;
2312 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, $editenable);
2315 if ($action !=
'editincoterm')
2317 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2319 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''),
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2325 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) {
2327 $editenable = $usercancreate;
2328 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, $editenable);
2330 if ($action ==
'editbankaccount') {
2331 $form->formSelectAccount(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2333 $form->formSelectAccount(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2340 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2345 print '<div class="fichehalfright">';
2346 print '<div class="ficheaddleft">';
2347 print '<div class="underbanner clearboth"></div>';
2349 print '<table class="border tableforfield centpercent">';
2351 if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
2354 print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
2355 print '<td class="nowrap">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2359 print '<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
2360 print '<td class="nowrap">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2364 print '<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
2365 print '<td class="nowrap">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2371 if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) {
2372 $alert =
' '.img_warning($langs->trans(
'OrderMinAmount').
': '.
price($object->thirdparty->order_min_amount));
2374 print '<tr><td class="titlefieldmiddle">'.$langs->trans(
'AmountHT').
'</td>';
2375 print '<td>'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).$alert.
'</td>';
2378 print '<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
2381 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0)
2383 print '<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
2384 print '<td>'.price($object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
2386 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0)
2388 print '<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
2389 print '<td>'.price($object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
2393 print '<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
2401 if (!empty($conf->margin->enabled)) {
2402 $formmargin->displayMarginInfos($object);
2410 print '<div class="clearboth"></div><br>';
2412 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
2413 $blocname =
'contacts';
2414 $title = $langs->trans(
'ContactsAddresses');
2415 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2418 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2419 $blocname =
'notes';
2420 $title = $langs->trans(
'Notes');
2421 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2427 $result = $object->getLinesArray();
2429 print '<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOST(
'lineid')).
'" method="POST">
2430 <input type="hidden" name="token" value="' .
newToken().
'">
2431 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2432 <input type="hidden" name="mode" value="">
2433 <input type="hidden" name="id" value="' . $object->id.
'">';
2436 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2439 print '<div class="div-table-responsive-no-min">';
2440 print '<table id="tablelines" class="noborder noshadow" width="100%">';
2443 if (!empty($object->lines))
2444 $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
2446 $numlines = count($object->lines);
2453 if ($action !=
'editline')
2456 $object->formAddObjectLine(1, $mysoc, $soc);
2458 $parameters = array();
2460 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2473 if ($action !=
'presend' && $action !=
'editline') {
2474 print '<div class="tabsAction">';
2476 $parameters = array();
2478 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2479 if (empty($reshook)) {
2482 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=reopen">'.$langs->trans(
'ReOpen').
'</a></div>';
2486 if (empty($user->socid)) {
2487 if ($object->statut >
Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) {
2489 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
2490 }
else print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a>';
2495 if ($object->statut ==
Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate)
2497 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
'Validate').
'</a>';
2501 print '<a class="butAction" href="card.php?id='.$object->id.
'&action=modif">'.$langs->trans(
'Modify').
'</a>';
2513 if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER))
2516 if ($usercancreatepurchaseorder) {
2517 print '<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"AddPurchaseOrder").
'</a>';
2523 if ($conf->ficheinter->enabled) {
2524 $langs->load(
"interventions");
2527 if ($user->rights->ficheinter->creer) {
2528 print '<a class="butAction" href="'.DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
'AddIntervention').
'</a>';
2530 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'AddIntervention').
'</a>';
2537 $langs->load(
"contracts");
2539 if ($user->rights->contrat->creer) {
2540 print '<a class="butAction" href="'.DOL_URL_ROOT.
'/contrat/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
'AddContract').
'</a>';
2546 if (!empty($conf->expedition->enabled)) {
2547 $numshipping = $object->nb_expedition();
2550 if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) {
2551 if ($user->rights->expedition->creer) {
2552 print '<a class="butAction" href="'.DOL_URL_ROOT.
'/expedition/shipment.php?id='.$object->id.
'">'.$langs->trans(
'CreateShipment').
'</a>';
2554 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'">'.$langs->trans(
'CreateShipment').
'</a>';
2557 $langs->load(
"errors");
2558 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Shipment"))).
'">'.$langs->trans(
'CreateShipment').
'</a>';
2565 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=shipped">'.$langs->trans(
'ClassifyShipped').
'</a></div>';
2570 if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
2571 print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"CreateBill").
'</a></div>';
2573 if ($usercancreate && $object->statut >=
Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2574 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=classifybilled">'.$langs->trans(
"ClassifyBilled").
'</a></div>';
2578 if ($usercancreate && $object->statut >=
Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2579 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=classifyunbilled">'.$langs->trans(
"ClassifyUnBilled").
'</a></div>';
2583 if ($usercancreate) {
2584 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object=order">'.$langs->trans(
"ToClone").
'</a></div>';
2590 print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=cancel">'.$langs->trans(
"Cancel").
'</a></div>';
2594 if ($usercandelete) {
2595 if ($numshipping == 0) {
2596 print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a></div>';
2598 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ShippingExist").
'">'.$langs->trans(
"Delete").
'</a></div>';
2606 if (
GETPOST(
'modelselected')) {
2607 $action =
'presend';
2610 if ($action !=
'presend')
2612 print '<div class="fichecenter"><div class="fichehalfleft">';
2613 print '<a name="builddoc"></a>';
2616 $relativepath = $objref.
'/'.$objref.
'.pdf';
2617 $filedir = $conf->commande->multidir_output[$object->entity].
'/'.$objref;
2618 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2619 $genallowed = $usercanread;
2620 $delallowed = $usercancreate;
2621 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'', $object);
2625 $linktoelem = $form->showLinkToObjectBlock($object, null, array(
'order'));
2627 $compatibleImportElementsList =
false;
2631 $compatibleImportElementsList = array(
'commande',
'propal');
2633 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
2636 $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
2637 if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0;
2640 print '<br><!-- Link to pay -->';
2641 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
2642 print showOnlinePaymentUrl(
'order', $object->ref).
'<br>';
2648 print '<br><!-- Link to download main doc -->'.
"\n";
2652 print '</div><div class="fichehalfright"><div class="ficheaddleft">';
2655 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2657 $somethingshown =
$formactions->showactions($object,
'order', $socid, 1);
2659 print '</div></div></div>';
2663 $modelmail =
'order_send';
2664 $defaulttopic =
'SendOrderRef';
2665 $diroutput = $conf->commande->multidir_output[$object->entity];
2666 $trackid =
'ord'.$object->id;
2668 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
File of class to manage predefined price products or services by customer.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage notifications.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
const STATUS_CLOSED
Closed (Sent, billed or not)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
static getIdAndTxFromCode($db, $code, $date_document= '')
Get id and rate of currency from code.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
const STATUS_SHIPMENTONPROCESS
Shipment on process.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
$conf db name
Only used if Module[ID]Name translation string is not found.
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...
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
showDirectDownloadLink($object)
Return string with full Url.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no')
Output a dimension with best unit.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
const STATUS_DRAFT
Draft status.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class ProductCombination Used to represent a product combination.
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
print $_SERVER["PHP_SELF"]
Edit parameters.
const STATUS_VALIDATED
Validated status.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si ...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
const STATUS_CANCELED
Canceled status.