40 require
'../main.inc.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
50 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
68 $langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'deliveries',
'products',
'other'));
71 $langs->load(
'incoterm');
74 $langs->load(
'margins');
77 $langs->load(
'productbatch');
83 $socid =
GETPOST(
'socid',
'int');
84 $action =
GETPOST(
'action',
'aZ09');
85 $cancel =
GETPOST(
'cancel',
'alpha');
86 $confirm =
GETPOST(
'confirm',
'alpha');
87 $backtopage =
GETPOST(
'backtopage',
'alpha');
89 $lineid =
GETPOST(
'lineid',
'int');
90 $contactid =
GETPOST(
'contactid',
'int');
91 $projectid =
GETPOST(
'projectid',
'int');
92 $origin =
GETPOST(
'origin',
'alpha');
94 $rank = (
GETPOST(
'rank',
'int') > 0) ?
GETPOST(
'rank',
'int') : -1;
97 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
98 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
99 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
102 if (!empty($user->socid)) {
103 $socid = $user->socid;
107 $hookmanager->initHooks(array(
'ordercard',
'globalcard'));
115 $extrafields->fetch_name_optionals_label($object->table_element);
118 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
121 $usercanread = $user->hasRight(
"commande",
"lire");
122 $usercancreate = $user->hasRight(
"commande",
"creer");
123 $usercandelete = $user->hasRight(
"commande",
"supprimer");
126 $usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'commande',
'order_advance',
'close')));
127 $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'commande',
'order_advance',
'validate')));
128 $usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
'commande',
'order_advance',
'annuler')));
129 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight(
'commande',
'order_advance',
'send'));
130 $usercangeneretedoc = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight(
'commande',
'order_advance',
'generetedoc'));
132 $usermustrespectpricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
133 $usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
135 $permissionnote = $usercancreate;
136 $permissiondellink = $usercancreate;
137 $permissiontoadd = $usercancreate;
142 $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'));
151 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
156 if (empty($reshook)) {
157 $backurlforlist = DOL_URL_ROOT.
'/commande/list.php';
159 if (empty($backtopage) || ($cancel && empty($id))) {
160 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
161 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
162 $backtopage = $backurlforlist;
164 $backtopage = DOL_URL_ROOT.
'/commande/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
170 if (!empty($backtopageforcancel)) {
171 header(
"Location: ".$backtopageforcancel);
173 } elseif (!empty($backtopage)) {
174 header(
"Location: ".$backtopage);
180 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
182 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
184 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
187 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
188 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
191 if ($object->id > 0) {
193 $orig = clone $object;
195 $result = $object->createFromClone($user, $socid);
197 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
206 } elseif ($action ==
'reopen' && $usercancreate) {
209 $result = $object->set_reopen($user);
216 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
218 $result = $object->delete($user);
220 header(
'Location: list.php?restore_lastsearch_values=1');
225 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
227 $result = $object->deleteline($user, $lineid);
230 $object->line_order(
true);
232 $outputlangs = $langs;
235 $newlang =
GETPOST(
'lang_id',
'aZ09');
238 $newlang = $object->thirdparty->default_lang;
240 if (!empty($newlang)) {
242 $outputlangs->setDefaultLang($newlang);
244 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
245 $ret = $object->fetch($object->id);
246 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
249 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
254 } elseif ($action ==
'classin' && $usercancreate) {
256 $object->setProject(
GETPOST(
'projectid',
'int'));
257 } elseif ($action ==
'add' && $usercancreate) {
260 $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'));
261 $selectedLines =
GETPOST(
'toselect',
'array');
263 if ($datecommande ==
'') {
264 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
270 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
276 $object->socid = $socid;
277 $object->fetch_thirdparty();
281 $object->date_commande = $datecommande;
282 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
283 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
284 $object->source =
GETPOST(
'source_id',
'int');
285 $object->fk_project =
GETPOST(
'projectid',
'int');
286 $object->ref_client =
GETPOST(
'ref_client',
'alpha');
287 $object->model_pdf =
GETPOST(
'model');
288 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
289 $object->deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
290 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
291 $object->fk_account =
GETPOST(
'fk_account',
'int');
292 $object->availability_id =
GETPOST(
'availability_id');
293 $object->demand_reason_id =
GETPOST(
'demand_reason_id',
'int');
294 $object->date_livraison = $date_delivery;
295 $object->delivery_date = $date_delivery;
296 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
297 $object->warehouse_id =
GETPOST(
'warehouse_id',
'int');
298 $object->fk_delivery_address =
GETPOST(
'fk_address',
'int');
299 $object->contact_id =
GETPOST(
'contactid',
'int');
300 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
301 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
302 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
303 $object->multicurrency_tx =
GETPOST(
'originmulticurrency_tx',
'int');
306 $ret = $extrafields->setOptionalsFromPost(
null, $object);
313 if (!empty($origin) && !empty($originid)) {
315 $element = $subelement = $origin;
317 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
318 $element = $regs [1];
319 $subelement = $regs [2];
323 if ($element ==
'order') {
324 $element = $subelement =
'commande';
326 if ($element ==
'propal') {
327 $element =
'comm/propal';
328 $subelement =
'propal';
330 if ($element ==
'contract') {
331 $element = $subelement =
'contrat';
334 $object->origin = $origin;
335 $object->origin_id = $originid;
338 $object->linked_objects [$object->origin] = $object->origin_id;
339 $other_linked_objects =
GETPOST(
'other_linked_objects',
'array');
340 if (!empty($other_linked_objects)) {
341 $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
345 $object_id = $object->create($user);
347 if ($object_id > 0) {
350 $classname = ucfirst($subelement);
351 $srcobject =
new $classname($db);
353 dol_syslog(
"Try to find source object origin=".$object->origin.
" originid=".$object->origin_id.
" to add lines");
354 $result = $srcobject->fetch($object->origin_id);
356 $lines = $srcobject->lines;
357 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
358 $srcobject->fetch_lines();
359 $lines = $srcobject->lines;
363 $num = count($lines);
365 for ($i = 0; $i < $num; $i++) {
366 if (!in_array($lines[$i]->
id, $selectedLines)) {
370 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
371 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
372 $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0);
376 $date_start = $lines[$i]->date_debut_prevue;
377 if ($lines[$i]->date_debut_reel) {
378 $date_start = $lines[$i]->date_debut_reel;
380 if ($lines[$i]->date_start) {
381 $date_start = $lines[$i]->date_start;
383 $date_end = $lines[$i]->date_fin_prevue;
384 if ($lines[$i]->date_fin_reel) {
385 $date_end = $lines[$i]->date_fin_reel;
387 if ($lines[$i]->date_end) {
388 $date_end = $lines[$i]->date_end;
392 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
397 if (method_exists($lines[$i],
'fetch_optionals')) {
398 $lines[$i]->fetch_optionals();
399 $array_options = $lines[$i]->array_options;
402 $tva_tx = $lines[$i]->tva_tx;
403 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
404 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
407 $result = $object->addline(
409 $lines[$i]->subprice,
412 $lines[$i]->localtax1_tx,
413 $lines[$i]->localtax2_tx,
414 $lines[$i]->fk_product,
415 $lines[$i]->remise_percent,
416 $lines[$i]->info_bits,
417 $lines[$i]->fk_remise_except,
424 $lines[$i]->special_code,
426 $lines[$i]->fk_fournprice,
441 if ($result > 0 && $lines[$i]->product_type == 9) {
442 $fk_parent_line = $result;
479 $reshook = $hookmanager->executeHooks(
'createFrom',
$parameters, $object, $action);
494 $object_id = $object->create($user);
499 if ($object_id > 0) {
500 if (
GETPOST(
'contactid',
'int')) {
501 $result = $object->add_contact(
GETPOST(
'contactid',
'int'),
'CUSTOMER',
'external');
513 if ($object_id > 0 && !$error) {
515 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object_id);
523 } elseif ($action ==
'classifybilled' && $usercancreate) {
524 $ret = $object->classifyBilled($user);
529 } elseif ($action ==
'classifyunbilled' && $usercancreate) {
530 $ret = $object->classifyUnBilled($user);
534 } elseif ($action ==
'setref_client' && $usercancreate) {
536 $result = $object->set_ref_client($user,
GETPOST(
'ref_client'));
540 } elseif ($action ==
'setremise' && $usercancreate) {
545 } elseif ($action ==
'setabsolutediscount' && $usercancreate) {
547 if ($object->id > 0) {
548 $object->insert_discount(
GETPOST(
'remise_id'));
553 } elseif ($action ==
'setdate' && $usercancreate) {
556 $result = $object->set_date($user, $date);
560 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
561 $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'));
564 $result = $object->setDeliveryDate($user, $date_delivery);
568 } elseif ($action ==
'setmode' && $usercancreate) {
569 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
573 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
575 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
576 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
578 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')),
GETPOST(
'calculation_mode',
'int'));
579 } elseif ($action ==
'setavailability' && $usercancreate) {
580 $result = $object->availability(
GETPOST(
'availability_id'));
584 } elseif ($action ==
'setdemandreason' && $usercancreate) {
585 $result = $object->demand_reason(
GETPOST(
'demand_reason_id'));
589 } elseif ($action ==
'setconditions' && $usercancreate) {
590 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'),
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha'));
594 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
596 $outputlangs = $langs;
597 $newlang =
GETPOST(
'lang_id',
'alpha');
599 $newlang = $object->thirdparty->default_lang;
601 if (!empty($newlang)) {
603 $outputlangs->setDefaultLang($newlang);
606 $ret = $object->fetch($object->id);
607 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
610 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm')) {
612 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
616 } elseif ($action ==
'setbankaccount' && $usercancreate) {
618 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
622 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
624 $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id',
'int'));
628 } elseif ($action ==
'setwarehouse' && $usercancreate) {
630 $result = $object->setWarehouse(
GETPOST(
'warehouse_id',
'int'));
634 } elseif ($action ==
'setremisepercent' && $usercancreate) {
635 $result = $object->setDiscount($user,
price2num(
GETPOST(
'remise_percent'),
'', 2));
636 } elseif ($action ==
'setremiseabsolue' && $usercancreate) {
637 $result = $object->set_remise_absolue($user,
price2num(
GETPOST(
'remise_absolue'),
'MU', 2));
638 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'') {
640 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
641 $vat_rate = str_replace(
'*',
'', $vat_rate);
642 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
643 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
644 foreach ($object->lines as $line) {
645 $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);
647 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
649 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
650 $remise_percent = str_replace(
'*',
'', $remise_percent);
651 foreach ($object->lines as $line) {
652 $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
654 } elseif ($action ==
'addline' && $usercancreate) {
655 $langs->load(
'errors');
663 $price_ht_devise =
'';
665 $price_ttc_devise =
'';
671 if (
GETPOST(
'price_ht') !==
'') {
674 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
677 if (
GETPOST(
'price_ttc') !==
'') {
680 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
684 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
685 if ($prod_entry_mode ==
'free') {
688 $idprod =
GETPOST(
'idprod',
'int');
690 if (!empty($conf->global->MAIN_DISABLE_FREE_LINES) && $idprod <= 0) {
691 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
696 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
699 $pu_equivalent = $pu_ht;
700 $pu_equivalent_ttc = $pu_ttc;
701 $currency_tx = $object->multicurrency_tx;
705 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
706 $pu_equivalent = $pu_ht_devise * $currency_tx;
708 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
709 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
715 if (empty($remise_percent)) {
720 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
721 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
723 if (is_array($extralabelsline)) {
725 foreach ($extralabelsline as $key => $value) {
726 unset($_POST[
"options_".$key]);
730 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
731 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
734 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
735 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
738 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
739 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
743 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
747 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
750 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
751 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
755 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
756 if ($combinations =
GETPOST(
'combinations',
'array')) {
760 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
761 $idprod = $res->fk_product_child;
763 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
769 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
773 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
778 if (!empty($idprod) && $idprod > 0) {
780 $prod->fetch($idprod);
782 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
791 $pu_ht = $prod->price;
792 $pu_ttc = $prod->price_ttc;
793 $price_min = $prod->price_min;
794 $price_min_ttc = $prod->price_min_ttc;
795 $price_base_type = $prod->price_base_type;
798 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
799 $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
800 $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
801 $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
802 $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
803 $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
804 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
805 if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
806 $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
808 if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
809 $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
812 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
814 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
818 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' => $object->thirdparty->id);
820 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
822 if (count($prodcustprice->lines) > 0) {
823 $pu_ht =
price($prodcustprice->lines[0]->price);
824 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
825 $price_min =
price($prodcustprice->lines[0]->price_min);
826 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
827 $price_base_type = $prodcustprice->lines[0]->price_base_type;
828 $tva_tx = $prodcustprice->lines[0]->tva_tx;
829 if ($prodcustprice->lines[0]->default_vat_code && !preg_match(
'/\(.*\)/', $tva_tx)) {
830 $tva_tx .=
' ('.$prodcustprice->lines[0]->default_vat_code.
')';
832 $tva_npr = $prodcustprice->lines[0]->recuperableonly;
833 if (empty($tva_tx)) {
840 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
842 if ($prod->prices_by_qty[0]) {
847 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
848 if ($priceforthequantityarray[
'rowid'] != $pqp) {
852 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
853 $pu_ht = $priceforthequantityarray[
'unitprice'];
855 $pu_ttc = $priceforthequantityarray[
'unitprice'];
861 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
863 if ($prod->prices_by_qty[$object->thirdparty->price_level]) {
867 foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) {
868 if ($priceforthequantityarray[
'rowid'] != $pqp) {
872 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
873 $pu_ht = $priceforthequantityarray[
'unitprice'];
875 $pu_ttc = $priceforthequantityarray[
'unitprice'];
883 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
884 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
887 if (!empty($price_ht) || $price_ht ===
'0') {
889 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
890 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
892 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
893 } elseif ($tmpvat != $tmpprodvat) {
895 if ($price_base_type !=
'HT') {
896 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
898 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
905 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
906 $outputlangs = $langs;
908 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
909 $newlang =
GETPOST(
'lang_id',
'aZ09');
911 if (empty($newlang)) {
912 $newlang = $object->thirdparty->default_lang;
914 if (!empty($newlang)) {
916 $outputlangs->setDefaultLang($newlang);
919 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->description;
921 $desc = $prod->description;
925 if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
929 if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) {
930 $desc = $product_desc;
932 $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
936 if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
939 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
940 $outputlangs = $langs;
942 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
943 $newlang =
GETPOST(
'lang_id',
'alpha');
945 if (empty($newlang)) {
946 $newlang = $object->thirdparty->default_lang;
948 if (!empty($newlang)) {
950 $outputlangs->setDefaultLang($newlang);
951 $outputlangs->load(
'products');
953 if (!empty($prod->customcode)) {
954 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
956 if (!empty($prod->customcode) && !empty($prod->country_code)) {
959 if (!empty($prod->country_code)) {
960 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
963 if (!empty($prod->customcode)) {
964 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
966 if (!empty($prod->customcode) && !empty($prod->country_code)) {
969 if (!empty($prod->country_code)) {
970 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
978 $fk_unit = $prod->fk_unit;
982 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
983 $tva_tx = str_replace(
'*',
'', $tva_tx);
984 if (empty($tva_tx)) {
987 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
988 $desc = $product_desc;
990 $fk_unit =
GETPOST(
'units',
'alpha');
991 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
992 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
994 if ($pu_ttc && !$pu_ht) {
995 $price_base_type =
'TTC';
1004 $localtax1_tx =
get_localtax($tva_tx, 1, $object->thirdparty);
1005 $localtax2_tx =
get_localtax($tva_tx, 2, $object->thirdparty);
1014 if ($usermustrespectpricemin) {
1015 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min))) {
1016 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1019 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc))) {
1020 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1028 $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);
1031 $ret = $object->fetch($object->id);
1032 $object->fetch_thirdparty();
1034 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1036 $outputlangs = $langs;
1037 $newlang =
GETPOST(
'lang_id',
'alpha');
1039 $newlang = $object->thirdparty->default_lang;
1041 if (!empty($newlang)) {
1042 $outputlangs =
new Translate(
"", $conf);
1043 $outputlangs->setDefaultLang($newlang);
1046 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1049 unset($_POST[
'prod_entry_mode']);
1051 unset($_POST[
'qty']);
1052 unset($_POST[
'type']);
1053 unset($_POST[
'remise_percent']);
1054 unset($_POST[
'price_ht']);
1055 unset($_POST[
'multicurrency_price_ht']);
1056 unset($_POST[
'price_ttc']);
1057 unset($_POST[
'tva_tx']);
1058 unset($_POST[
'product_ref']);
1059 unset($_POST[
'product_label']);
1060 unset($_POST[
'product_desc']);
1061 unset($_POST[
'fournprice']);
1062 unset($_POST[
'buying_price']);
1063 unset($_POST[
'np_marginRate']);
1064 unset($_POST[
'np_markRate']);
1065 unset($_POST[
'dp_desc']);
1066 unset($_POST[
'idprod']);
1067 unset($_POST[
'units']);
1069 unset($_POST[
'date_starthour']);
1070 unset($_POST[
'date_startmin']);
1071 unset($_POST[
'date_startsec']);
1072 unset($_POST[
'date_startday']);
1073 unset($_POST[
'date_startmonth']);
1074 unset($_POST[
'date_startyear']);
1075 unset($_POST[
'date_endhour']);
1076 unset($_POST[
'date_endmin']);
1077 unset($_POST[
'date_endsec']);
1078 unset($_POST[
'date_endday']);
1079 unset($_POST[
'date_endmonth']);
1080 unset($_POST[
'date_endyear']);
1086 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1094 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1095 $vat_rate = str_replace(
'*',
'', $vat_rate);
1106 $pu_equivalent = $pu_ht;
1107 $pu_equivalent_ttc = $pu_ttc;
1108 $currency_tx = $object->multicurrency_tx;
1112 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1113 $pu_equivalent = $pu_ht_devise * $currency_tx;
1115 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1116 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1121 if (preg_match(
'/\*/', $vat_rate)) {
1126 $vat_rate = str_replace(
'*',
'', $vat_rate);
1127 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
1128 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
1135 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1136 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
1138 if (is_array($extralabelsline)) {
1139 foreach ($extralabelsline as $key => $value) {
1140 unset($_POST[
"options_".$key]);
1145 $special_code =
GETPOST(
'special_code');
1153 $productid =
GETPOST(
'productid',
'int');
1154 if (!empty($productid)) {
1156 $product->fetch($productid);
1158 $type = $product->type;
1160 $price_min = $product->price_min;
1161 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
1162 $price_min = $product->multiprices_min[$object->thirdparty->price_level];
1164 $price_min_ttc = $product->price_min_ttc;
1165 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
1166 $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
1171 if ($usermustrespectpricemin) {
1172 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min))) {
1173 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1176 $action =
'editline';
1177 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc))) {
1178 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1181 $action =
'editline';
1186 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1190 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1192 $action =
'editline';
1197 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1199 $action =
'editline';
1203 if (empty($user->rights->margins->creer)) {
1204 foreach ($object->lines as &$line) {
1205 if ($line->id ==
GETPOST(
'lineid',
'int')) {
1206 $fournprice = $line->fk_fournprice;
1207 $buyingprice = $line->pa_ht;
1213 $price_base_type =
'HT';
1215 if (empty($pu) && !empty($pu_ttc)) {
1217 $price_base_type =
'TTC';
1220 $result = $object->updateline(
GETPOST(
'lineid',
'int'), $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);
1223 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1225 $outputlangs = $langs;
1228 $newlang =
GETPOST(
'lang_id',
'aZ09');
1231 $newlang = $object->thirdparty->default_lang;
1233 if (!empty($newlang)) {
1234 $outputlangs =
new Translate(
"", $conf);
1235 $outputlangs->setDefaultLang($newlang);
1238 $ret = $object->fetch($object->id);
1239 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1242 unset($_POST[
'qty']);
1243 unset($_POST[
'type']);
1244 unset($_POST[
'productid']);
1245 unset($_POST[
'remise_percent']);
1246 unset($_POST[
'price_ht']);
1247 unset($_POST[
'multicurrency_price_ht']);
1248 unset($_POST[
'price_ttc']);
1249 unset($_POST[
'tva_tx']);
1250 unset($_POST[
'product_ref']);
1251 unset($_POST[
'product_label']);
1252 unset($_POST[
'product_desc']);
1253 unset($_POST[
'fournprice']);
1254 unset($_POST[
'buying_price']);
1256 unset($_POST[
'date_starthour']);
1257 unset($_POST[
'date_startmin']);
1258 unset($_POST[
'date_startsec']);
1259 unset($_POST[
'date_startday']);
1260 unset($_POST[
'date_startmonth']);
1261 unset($_POST[
'date_startyear']);
1262 unset($_POST[
'date_endhour']);
1263 unset($_POST[
'date_endmin']);
1264 unset($_POST[
'date_endsec']);
1265 unset($_POST[
'date_endday']);
1266 unset($_POST[
'date_endmonth']);
1267 unset($_POST[
'date_endyear']);
1272 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1273 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1275 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1276 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
1278 $qualified_for_stock_change = 0;
1279 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1280 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1282 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1286 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
1287 if (!$idwarehouse || $idwarehouse == -1) {
1289 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1295 $locationTarget =
'';
1297 $result = $object->valid($user, $idwarehouse);
1302 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
1305 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1306 &&
isModEnabled(
'facture') && !empty($user->rights->facture->creer)
1308 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1311 $forceFields = array();
1314 $forceFields[
'date_pointoftax'] =
dol_mktime(0, 0, 0,
GETPOST(
'date_pointoftaxmonth',
'int'),
GETPOST(
'date_pointoftaxday',
'int'),
GETPOST(
'date_pointoftaxyear',
'int'));
1321 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1332 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1333 $outputlangs = $langs;
1336 $newlang =
GETPOST(
'lang_id',
'aZ09');
1339 $newlang = $object->thirdparty->default_lang;
1341 if (!empty($newlang)) {
1342 $outputlangs =
new Translate(
"", $conf);
1343 $outputlangs->setDefaultLang($newlang);
1345 $model = $object->model_pdf;
1346 $ret = $object->fetch($id);
1348 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1351 $deposit->fetch($deposit->id);
1352 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1356 if ($locationTarget) {
1357 header(
'Location: ' . $locationTarget);
1368 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1370 $idwarehouse =
GETPOST(
'idwarehouse');
1372 $qualified_for_stock_change = 0;
1373 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1374 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1376 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1380 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
1381 if (!$idwarehouse || $idwarehouse == -1) {
1383 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1389 $result = $object->setDraft($user, $idwarehouse);
1392 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1393 $outputlangs = $langs;
1396 $newlang =
GETPOST(
'lang_id',
'aZ09');
1399 $newlang = $object->thirdparty->default_lang;
1401 if (!empty($newlang)) {
1402 $outputlangs =
new Translate(
"", $conf);
1403 $outputlangs->setDefaultLang($newlang);
1405 $model = $object->model_pdf;
1406 $ret = $object->fetch($id);
1408 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1414 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1415 $result = $object->cloture($user);
1419 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1420 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
1422 $qualified_for_stock_change = 0;
1423 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1424 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1426 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1430 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
1431 if (!$idwarehouse || $idwarehouse == -1) {
1433 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1439 $result = $object->cancel($idwarehouse);
1447 if ($action ==
'update_extras') {
1451 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
1458 $result = $object->insertExtraFields(
'ORDER_MODIFY');
1466 $action =
'edit_extras';
1471 if ($action ==
'import_lines_from_object'
1475 $fromElement =
GETPOST(
'fromelement');
1476 $fromElementid =
GETPOST(
'fromelementid');
1477 $importLines =
GETPOST(
'line_checkbox');
1479 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1480 if ($fromElement ==
'commande') {
1482 $lineClassName =
'OrderLine';
1483 } elseif ($fromElement ==
'propal') {
1484 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1485 $lineClassName =
'PropaleLigne';
1486 } elseif ($fromElement ==
'facture') {
1487 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1488 $lineClassName =
'FactureLigne';
1490 $nextRang = count($object->lines) + 1;
1493 foreach ($importLines as $lineId) {
1494 $lineId = intval($lineId);
1495 $originLine =
new $lineClassName($db);
1496 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
1497 $originLine->fetch_optionals();
1498 $desc = $originLine->desc;
1499 $pu_ht = $originLine->subprice;
1500 $qty = $originLine->qty;
1501 $txtva = $originLine->tva_tx;
1502 $txlocaltax1 = $originLine->localtax1_tx;
1503 $txlocaltax2 = $originLine->localtax2_tx;
1504 $fk_product = $originLine->fk_product;
1505 $remise_percent = $originLine->remise_percent;
1506 $date_start = $originLine->date_start;
1507 $date_end = $originLine->date_end;
1509 $info_bits = $originLine->info_bits;
1510 $fk_remise_except = $originLine->fk_remise_except;
1511 $price_base_type =
'HT';
1513 $type = $originLine->product_type;
1514 $rang = $nextRang++;
1515 $special_code = $originLine->special_code;
1516 $origin = $originLine->element;
1517 $origin_id = $originLine->id;
1518 $fk_parent_line = 0;
1519 $fk_fournprice = $originLine->fk_fournprice;
1520 $pa_ht = $originLine->pa_ht;
1521 $label = $originLine->label;
1522 $array_options = $originLine->array_options;
1523 $situation_percent = 100;
1525 $fk_unit = $originLine->fk_unit;
1526 $pu_ht_devise = $originLine->multicurrency_subprice;
1528 $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);
1547 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1550 $upload_dir = !empty($conf->commande->multidir_output[$object->entity])?$conf->commande->multidir_output[$object->entity]:$conf->commande->dir_output;
1551 $permissiontoadd = $usercancreate;
1552 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1555 $triggersendname =
'ORDER_SENTBYMAIL';
1557 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
1558 $trackid =
'ord'.$object->id;
1559 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1562 if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) {
1563 if ($action ==
'addcontact') {
1564 if ($object->id > 0) {
1567 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1571 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1574 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1575 $langs->load(
"errors");
1576 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1581 } elseif ($action ==
'swapstatut') {
1583 if ($object->id > 0) {
1584 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
1588 } elseif ($action ==
'deletecontact') {
1590 $result = $object->delete_contact($lineid);
1593 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1607 $title = $object->ref.
" - ".$langs->trans(
'Card');
1608 if ($action ==
'create') {
1609 $title = $langs->trans(
"NewOrder");
1611 $help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
1624 if ($action ==
'create' && $usercancreate) {
1629 $res = $soc->fetch($socid);
1632 $remise_absolue = 0;
1634 $currency_code = $conf->currency;
1636 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1637 $deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
1638 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1639 $fk_account =
GETPOST(
'fk_account',
'int');
1641 if (!empty($origin) && !empty($originid)) {
1643 $element = $subelement = $origin;
1645 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1646 $element = $regs[1];
1647 $subelement = $regs[2];
1650 if ($element ==
'project') {
1651 $projectid = $originid;
1653 if (!$cond_reglement_id) {
1654 $cond_reglement_id = $soc->cond_reglement_id;
1656 if (!$deposit_percent) {
1657 $deposit_percent = $soc->deposit_percent;
1659 if (!$mode_reglement_id) {
1660 $mode_reglement_id = $soc->mode_reglement_id;
1662 if (!$remise_percent) {
1663 $remise_percent = $soc->remise_percent;
1671 if ($element ==
'order' || $element ==
'commande') {
1672 $element = $subelement =
'commande';
1673 } elseif ($element ==
'propal') {
1674 $element =
'comm/propal';
1675 $subelement =
'propal';
1676 } elseif ($element ==
'contract') {
1677 $element = $subelement =
'contrat';
1682 $classname = ucfirst($subelement);
1683 $objectsrc =
new $classname($db);
1684 $objectsrc->fetch($originid);
1685 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1686 $objectsrc->fetch_lines();
1688 $objectsrc->fetch_thirdparty();
1691 $objectsrc->fetch_optionals();
1692 $object->array_options = $objectsrc->array_options;
1694 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1695 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1697 $soc = $objectsrc->thirdparty;
1698 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1699 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
1700 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1701 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1702 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
1703 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
1704 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1705 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
1706 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
1707 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1708 $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ? -1 :
'';
1710 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
1711 if (empty($date_delivery)) {
1712 $date_delivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison :
'');
1716 if (!empty($objectsrc->multicurrency_code)) {
1717 $currency_code = $objectsrc->multicurrency_code;
1719 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) {
1720 $currency_tx = $objectsrc->multicurrency_tx;
1724 $note_private = $object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private :
null));
1725 $note_public = $object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public :
null));
1728 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1731 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1732 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1733 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1734 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
1735 $availability_id = 0;
1736 $shipping_method_id = $soc->shipping_method_id;
1737 $warehouse_id = $soc->fk_warehouse;
1738 $demand_reason_id = $soc->demand_reason_id;
1739 $remise_percent = $soc->remise_percent;
1740 $remise_absolue = 0;
1741 $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 :
'';
1743 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1744 $currency_code = $soc->multicurrency_code;
1747 $note_private = $object->getDefaultCreateValueFor(
'note_private');
1748 $note_public = $object->getDefaultCreateValueFor(
'note_public');
1752 if (!
GETPOST(
'changecompany')) {
1754 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1760 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1763 $fk_account =
GETPOST(
'fk_account',
'int');
1768 if ($soc->fk_warehouse > 0) {
1769 $warehouse_id = $soc->fk_warehouse;
1771 if (
isModEnabled(
'stock') && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1772 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) {
1773 $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
1775 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1776 $warehouse_id = $user->fk_warehouse;
1780 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1781 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1782 print
'<input type="hidden" name="action" value="add">';
1783 print
'<input type="hidden" name="changecompany" value="0">';
1784 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
1785 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1786 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1787 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1788 if (!empty($currency_tx)) {
1789 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1794 print
'<table class="border centpercent">';
1797 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
1800 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
1801 if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid)) {
1802 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
1804 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
1810 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1813 print $soc->getNomUrl(1,
'customer');
1814 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1817 print
'<td class="valuefieldcreate">';
1818 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1819 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1821 if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
1823 $(document).ready(function() {
1824 $("#socid").change(function() {
1825 console.log("We have changed the company - Reload page");
1826 var socid = $(this).val();
1828 $("input[name=action]").val("create");
1829 $("input[name=changecompany]").val("1");
1830 $("form[name=crea_commande]").submit();
1835 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>';
1843 print
"<tr><td>".$langs->trans(
"DefaultContact").
'</td><td>';
1844 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1845 print
$form->selectcontacts($soc->id, $contactid,
'contactid', 1, !empty($srccontactslist)?$srccontactslist:
"",
'', 1,
'maxwidth200 widthcentpercentminusx');
1849 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1851 $absolute_discount = $soc->getAvailableDiscounts();
1855 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1856 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1862 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
1863 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1864 print
$form->selectDate(
'',
're',
'',
'',
'',
"crea_commande", 1, 1);
1868 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1869 print
'<td colspan="3">';
1870 $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date);
1871 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1872 print
$form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
1877 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
1878 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1879 $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1883 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1884 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1885 print
$form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', $deposit_percent);
1889 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
1890 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1891 print
$form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1895 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) &&
isModEnabled(
"banque")) {
1896 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
1897 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1903 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
1904 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
1905 $form->selectShippingMethod(((
GETPOSTISSET(
'shipping_method_id') &&
GETPOST(
'shipping_method_id',
'int') != 0) ?
GETPOST(
'shipping_method_id') : $shipping_method_id),
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
1910 if (
isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1911 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1913 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
1914 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');
1919 print
'<tr><td>'.$langs->trans(
'Channel').
'</td><td>';
1920 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1921 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id')?
GETPOST(
'demand_reason_id'):$demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1928 $langs->load(
"projects");
1930 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
1931 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');
1932 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>';
1940 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms, 1).
'</label></td>';
1941 print
'<td class="maxwidthonsmartphone">';
1942 $incoterm_id =
GETPOST(
'incoterm_id');
1943 $incoterm_location =
GETPOST(
'location_incoterms');
1944 if (empty($incoterm_id)) {
1945 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
1946 $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
1948 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1949 print
$form->select_incoterms($incoterm_id, $incoterm_location);
1955 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1961 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1962 print $hookmanager->resPrint;
1963 if (empty($reshook)) {
1964 if (!empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER) && !empty($soc->id)) {
1967 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
1968 if ($soc->fetch_optionals() > 0) {
1969 $object->array_options = array_merge($object->array_options, $soc->array_options);
1973 print $object->showOptionals($extrafields,
'create',
$parameters);
1977 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
1979 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
1981 $preselected = $conf->global->COMMANDE_ADDON_PDF;
1982 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1983 print
$form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
1989 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0).
'</td>';
1990 print
'<td class="maxwidthonsmartphone">';
1991 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code')?
GETPOST(
'multicurrency_code'):$currency_code),
'multicurrency_code', 0,
'',
false,
'maxwidth200 widthcentpercentminusx');
1997 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2000 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3,
'90%');
2001 print $doleditor->Create(1);
2006 if (empty($user->socid)) {
2008 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2011 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3,
'90%');
2012 print $doleditor->Create(1);
2017 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2019 if ($origin ==
'contrat') {
2021 $objectsrc->remise_absolue = $remise_absolue;
2022 $objectsrc->remise_percent = $remise_percent;
2023 $objectsrc->update_price(1);
2026 print
"\n<!-- ".$classname.
" info -->";
2028 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2029 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2030 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2031 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2032 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2034 switch ($classname) {
2036 $newclassname =
'CommercialProposal';
2039 $newclassname =
'Order';
2042 $newclassname =
'Sending';
2045 $newclassname =
'Contract';
2048 $newclassname = $classname;
2051 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2054 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2055 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2056 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2057 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2060 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2061 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2064 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2067 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2068 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2069 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2079 print
$form->buttonsSaveCancel(
"CreateDraft");
2082 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2083 $title = $langs->trans(
'ProductsAndServices');
2086 print
'<div class="div-table-responsive-no-min">';
2087 print
'<table class="noborder centpercent">';
2089 $objectsrc->printOriginLinesList(
'', $selectedLines);
2100 if ($object->id > 0) {
2101 $product_static =
new Product($db);
2104 $soc->fetch($object->socid);
2106 $author =
new User($db);
2107 $author->fetch($object->user_author_id);
2109 $object->fetch_thirdparty();
2110 $res = $object->fetch_optionals();
2113 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order');
2118 if ($action ==
'delete') {
2119 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2123 if ($action ==
'validate') {
2125 $ref = substr($object->ref, 1, 4);
2126 if ($ref ==
'PROV' || $ref ==
'') {
2127 $numref = $object->getNextNumRef($soc);
2128 if (empty($numref)) {
2133 $numref = $object->ref;
2136 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2138 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2139 $notify =
new Notify($db);
2141 $text .= $notify->confirmMessage(
'ORDER_VALIDATE', $object->socid, $object);
2144 $qualified_for_stock_change = 0;
2145 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2146 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2148 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2151 $formquestion = array();
2152 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
2153 $langs->load(
"stocks");
2154 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2157 if ($conf->browser->name ==
'ie') {
2160 $formquestion = array(
2164 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))
2170 foreach ($object->lines as $line) {
2171 $res = $line->fetch_product();
2173 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) {
2179 if ($nbMandated > 0 ) $text .=
'<div><span class="clearboth nowraponall warning">'.$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2181 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2186 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
2188 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'facture') && !empty($user->rights->facture->creer)) {
2189 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2191 $object->fetchObjectLinked();
2193 $eligibleForDepositGeneration =
true;
2195 if (array_key_exists(
'facture', $object->linkedObjects)) {
2196 foreach ($object->linkedObjects[
'facture'] as $invoice) {
2198 $eligibleForDepositGeneration =
false;
2204 if ($eligibleForDepositGeneration && array_key_exists(
'propal', $object->linkedObjects)) {
2205 foreach ($object->linkedObjects[
'propal'] as $proposal) {
2206 $proposal->fetchObjectLinked();
2208 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2209 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2211 $eligibleForDepositGeneration =
false;
2219 if ($eligibleForDepositGeneration) {
2220 $formquestion[] = array(
2221 'type' =>
'checkbox',
2223 'name' =>
'generate_deposit',
2224 'label' =>
$form->textwithpicto($langs->trans(
'GenerateDeposit', $object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2227 $formquestion[] = array(
2229 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2231 'label' => $langs->trans(
'DateInvoice'),
2236 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
2237 $formquestion[] = array(
2239 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2240 'name' =>
'date_pointoftax',
2241 'label' => $langs->trans(
'DatePointOfTax'),
2248 $paymentTermsSelect =
$form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2250 $formquestion[] = array(
2252 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2253 'name' =>
'cond_reglement_id',
2254 'label' => $langs->trans(
'PaymentTerm'),
2255 'value' => $paymentTermsSelect
2258 $formquestion[] = array(
2259 'type' =>
'checkbox',
2260 'tdclass' =>
'showonlyifgeneratedeposit',
2261 'name' =>
'validate_generated_deposit',
2262 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2265 $formquestion[] = array(
2266 'type' =>
'onecolumn',
2269 $(document).ready(function() {
2270 $("[name=generate_deposit]").change(function () {
2271 let $self = $(this);
2272 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2274 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2291 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
2296 if ($action ==
'modif') {
2297 $qualified_for_stock_change = 0;
2298 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2299 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2301 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2304 $text = $langs->trans(
'ConfirmUnvalidateOrder', $object->ref);
2305 $formquestion = array();
2306 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
2307 $langs->load(
"stocks");
2308 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2311 if ($conf->browser->name ==
'ie') {
2314 $formquestion = array(
2318 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2322 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2328 if ($action ==
'shipped') {
2329 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2335 if ($action ==
'cancel') {
2336 $qualified_for_stock_change = 0;
2337 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2338 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2340 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2343 $text = $langs->trans(
'ConfirmCancelOrder', $object->ref);
2344 $formquestion = array();
2345 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
2346 $langs->load(
"stocks");
2347 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2350 if ($conf->browser->name ==
'ie') {
2353 $formquestion = array(
2357 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2361 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2365 if ($action ==
'ask_deleteline') {
2366 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2370 if ($action ==
'clone') {
2371 $filter =
'(s.client:IN:1,2,3)';
2373 $formquestion = array(
2374 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' =>
$form->select_company(
GETPOST(
'socid',
'int'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300'))
2376 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2382 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2383 if (empty($reshook)) {
2385 } elseif ($reshook > 0) {
2395 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2397 $morehtmlref =
'<div class="refidno">';
2399 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string',
'', 0, 1);
2400 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE :
''),
'',
null,
null,
'', 1);
2402 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2403 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
2404 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2408 $langs->load(
"projects");
2409 $morehtmlref .=
'<br>';
2410 if ($usercancreate) {
2411 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2412 if ($action !=
'classify') {
2413 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2415 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2417 if (!empty($object->fk_project)) {
2419 $proj->fetch($object->fk_project);
2420 $morehtmlref .= $proj->getNomUrl(1);
2422 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2427 $morehtmlref .=
'</div>';
2430 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2433 print
'<div class="fichecenter">';
2434 print
'<div class="fichehalfleft">';
2435 print
'<div class="underbanner clearboth"></div>';
2437 print
'<table class="border tableforfield centpercent">';
2439 if ($soc->outstanding_limit) {
2441 print
'<tr><td class="titlefield">';
2442 print $langs->trans(
'OutstandingBill');
2443 print
'</td><td class="valuefield">';
2444 $arrayoutstandingbills = $soc->getOutstandingBills();
2445 print
price($arrayoutstandingbills[
'opened']).
' / ';
2446 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1, $conf->currency);
2452 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
2453 $filterabsolutediscount =
"fk_facture_source IS NULL";
2454 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2456 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2457 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2460 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
2461 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
2462 $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>';
2464 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
2466 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2467 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2468 $absolute_discount =
price2num($absolute_discount,
'MT');
2469 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2473 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id);
2474 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2481 print
$form->editfieldkey(
"Date",
'date',
'', $object, $editenable);
2482 print
'</td><td class="valuefield">';
2483 if ($action ==
'editdate') {
2484 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2485 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2486 print
'<input type="hidden" name="action" value="setdate">';
2487 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2488 print
$form->selectDate($object->date,
'order_',
'',
'',
'',
"setdate");
2489 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2492 print $object->date ?
dol_print_date($object->date,
'day') :
' ';
2493 if ($object->hasDelay() && empty($object->delivery_date)) {
2494 print
' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(),
"warning");
2502 $editenable = $usercancreate;
2503 print
$form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, $editenable);
2504 print
'</td><td class="valuefield">';
2505 if ($action ==
'editdate_livraison') {
2506 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2507 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2508 print
'<input type="hidden" name="action" value="setdate_livraison">';
2509 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2510 print
$form->selectDate($object->delivery_date ? $object->delivery_date : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
2511 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2514 print $object->delivery_date ?
dol_print_date($object->delivery_date,
'dayhour') :
' ';
2515 if ($object->hasDelay() && !empty($object->delivery_date)) {
2516 print
' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(),
"warning");
2523 print
'<tr class="fielddeliverydelay"><td>';
2524 $editenable = $usercancreate;
2525 print
$form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, $editenable);
2526 print
'</td><td class="valuefield">';
2527 if ($action ==
'editavailability') {
2528 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'availability_id', 1);
2530 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'none', 1);
2537 $editenable = $usercancreate;
2538 print
$form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, $editenable);
2539 print
'</td><td class="valuefield">';
2540 if ($action ==
'editshippingmethod') {
2541 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
2543 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'none');
2550 if (
isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
2551 $langs->load(
'stocks');
2552 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2555 $editenable = $usercancreate;
2556 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
2557 print
'</td><td class="valuefield">';
2558 if ($action ==
'editwarehouse') {
2559 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'warehouse_id', 1);
2561 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'none');
2569 $editenable = $usercancreate;
2570 print
$form->editfieldkey(
"Source",
'demandreason',
'', $object, $editenable);
2571 print
'</td><td class="valuefield">';
2572 if ($action ==
'editdemandreason') {
2573 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'demand_reason_id', 1);
2575 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'none');
2581 $editenable = $usercancreate;
2582 print
$form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, $editenable);
2583 print
'</td><td class="valuefield">';
2584 if ($action ==
'editconditions') {
2585 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1, $object->deposit_percent);
2587 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 1,
'', 1, $object->deposit_percent);
2595 $editenable = $usercancreate;
2596 print
$form->editfieldkey(
"PaymentMode",
'mode',
'', $object, $editenable);
2597 print
'</td><td class="valuefield">';
2598 if ($action ==
'editmode') {
2599 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2601 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2611 print
$form->editfieldkey(
"Currency",
'multicurrencycode',
'', $object, $editenable);
2612 print
'</td><td class="valuefield">';
2613 if ($action ==
'editmulticurrencycode') {
2614 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2616 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2621 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
2624 $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT;
2625 print
$form->editfieldkey(
"CurrencyRate",
'multicurrencyrate',
'', $object, $editenable);
2626 print
'</td><td class="valuefield">';
2627 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2628 if ($action ==
'actualizemulticurrencyrate') {
2631 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2633 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2634 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2635 print
'<div class="inline-block"> ';
2636 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2658 $tmparray = $object->getTotalWeightVolume();
2659 $totalWeight = $tmparray[
'weight'];
2660 $totalVolume = $tmparray[
'volume'];
2662 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2663 print
'<td class="valuefield">';
2664 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');
2668 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2669 print
'<td class="valuefield">';
2670 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');
2679 $editenable = $usercancreate;
2680 print
$form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, $editenable);
2682 print
'<td class="valuefield">';
2683 if ($action !=
'editincoterm') {
2684 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2686 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2692 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) &&
isModEnabled(
"banque")) {
2694 $editenable = $usercancreate;
2695 print
$form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, $editenable);
2696 print
'</td><td class="valuefield">';
2697 if ($action ==
'editbankaccount') {
2698 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2700 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2707 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2712 print
'<div class="fichehalfright">';
2713 print
'<div class="underbanner clearboth"></div>';
2715 print
'<table class="border tableforfield centpercent">';
2718 if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) {
2719 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price($object->thirdparty->order_min_amount));
2723 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2724 print
'<td class="nowrap amountcard right">' .
price($object->total_ht,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2725 if (
isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2727 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ht,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2732 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2733 print
'<td class="nowrap amountcard right">' .
price($object->total_tva,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2734 if (
isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2736 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_tva,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2741 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
2743 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2744 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2745 if (
isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2746 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2752 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
2753 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2754 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2755 if (
isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2756 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2763 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2764 print
'<td class="valuefield nowrap right amountcard">' .
price($object->total_ttc, 1,
'', 1, -1, -1, $conf->currency) .
'</td>';
2765 if (
isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2767 print
'<td class="valuefield nowrap right amountcard">' .
price($object->multicurrency_total_ttc, 1,
'', 1, -1, -1, $object->multicurrency_code) .
'</td>';
2778 $formmargin->displayMarginInfos($object);
2785 print
'<div class="clearboth"></div><br>';
2787 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
2788 $blocname =
'contacts';
2789 $title = $langs->trans(
'ContactsAddresses');
2790 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2793 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2794 $blocname =
'notes';
2795 $title = $langs->trans(
'Notes');
2796 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2804 $result = $object->getLinesArray();
2808 global $inputalsopricewithtax;
2809 $inputalsopricewithtax = 1;
2811 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">
2812 <input type="hidden" name="token" value="' .
newToken().
'">
2813 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2814 <input type="hidden" name="mode" value="">
2815 <input type="hidden" name="page_y" value="">
2816 <input type="hidden" name="id" value="' . $object->id.
'">
2817 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2821 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2824 print
'<div class="div-table-responsive-no-min">';
2825 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2828 if (!empty($object->lines)) {
2829 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
2832 $numlines = count($object->lines);
2838 if ($action !=
'editline') {
2843 $reshook = $hookmanager->executeHooks(
'formAddObjectLine',
$parameters, $object, $action);
2844 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2845 if (empty($reshook))
2846 $object->formAddObjectLine(1, $mysoc, $soc);
2859 if ($action !=
'presend' && $action !=
'editline') {
2860 print
'<div class="tabsAction">';
2864 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2865 if (empty($reshook)) {
2868 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
2872 if (empty($user->socid)) {
2873 if ($object->statut >
Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) {
2875 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2877 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2883 if ($object->statut ==
Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) {
2884 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.$object->id,
'');
2888 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=modif&token='.
newToken().
'&id='.$object->id,
'');
2900 if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) {
2902 if ($usercancreatepurchaseorder) {
2903 print
dolGetButtonAction(
'', $langs->trans(
'AddPurchaseOrder'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2910 $langs->load(
"interventions");
2913 if ($user->hasRight(
'ficheinter',
'creer')) {
2914 print
dolGetButtonAction(
'', $langs->trans(
'AddIntervention'),
'default', DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2916 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddIntervention'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2923 $langs->load(
"contracts");
2925 if ($user->hasRight(
'contrat',
'creer')) {
2926 print
dolGetButtonAction(
'', $langs->trans(
'AddContract'),
'default', DOL_URL_ROOT.
'/contrat/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2933 $numshipping = $object->countNbOfShipments();
2936 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
2937 if ($user->hasRight(
'expedition',
'creer')) {
2938 print
dolGetButtonAction(
'', $langs->trans(
'CreateShipment'),
'default', DOL_URL_ROOT.
'/expedition/shipment.php?id='.$object->id,
'');
2940 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2943 $langs->load(
"errors");
2944 print
dolGetButtonAction($langs->trans(
'ErrorModuleSetupNotComplete'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2951 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.
newToken().
'&id='.$object->id,
'');
2956 if (
isModEnabled(
'facture') && $user->hasRight(
'facture',
'creer') && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
2957 print
dolGetButtonAction(
'', $langs->trans(
'CreateBill'),
'default', DOL_URL_ROOT.
'/compta/facture/card.php?action=create&token='.
newToken().
'&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2959 if ($usercancreate && $object->statut >=
Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2960 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.
newToken().
'&id='.$object->id,
'');
2964 if ($usercancreate && $object->statut >=
Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2965 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.
newToken().
'&id='.$object->id,
'');
2969 if ($usercancreate) {
2970 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken().
'&id='.$object->id.
'&socid='.$object->socid,
'');
2975 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=cancel&token='.
newToken().
'">'.$langs->trans(
"Cancel").
'</a>';
2979 if ($usercandelete) {
2980 if ($numshipping == 0) {
2981 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
2983 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2991 if (
GETPOST(
'modelselected')) {
2992 $action =
'presend';
2995 if ($action !=
'presend') {
2996 print
'<div class="fichecenter"><div class="fichehalfleft">';
2997 print
'<a name="builddoc"></a>';
3000 $relativepath = $objref.
'/'.$objref.
'.pdf';
3001 $filedir = $conf->commande->multidir_output[$object->entity].
'/'.$objref;
3002 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
3003 $genallowed = $usercanread;
3004 $delallowed = $usercancreate;
3005 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'', $object);
3009 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'order'));
3011 $compatibleImportElementsList =
false;
3014 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3016 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3020 if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) {
3021 $useonlinepayment = 0;
3024 print
'<br><!-- Link to pay -->';
3025 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3026 print showOnlinePaymentUrl(
'order', $object->ref).
'<br>';
3029 print
'</div><div class="fichehalfright">';
3033 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.$object->id);
3036 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3038 $somethingshown =
$formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3040 print
'</div></div>';
3044 $modelmail =
'order_send';
3045 $defaulttopic =
'SendOrderRef';
3047 $trackid =
'ord'.$object->id;
3049 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage a WYSIWYG editor.
static createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger=0, $autoValidateDeposit=false, $overrideFields=array())
Creates a deposit from a proposal or an order by grouping lines by VAT rates.
const TYPE_DEPOSIT
Deposit invoice.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
Class to manage notifications.
Class ProductCombination Used to represent a product combination.
Class to manage products or services.
File of class to manage predefined price products or services by customer.
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=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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='')
Return the full path of the directory where a module (or an object of a module) stores its files.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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 '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.