40require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formorder.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
53if (isModEnabled(
"propal")) {
54 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
57if (isModEnabled(
'project')) {
58 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
62if (isModEnabled(
'variants')) {
63 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
68$langs->loadLangs(array(
'orders',
'sendings',
'companies',
'bills',
'propal',
'deliveries',
'products',
'other'));
70if (isModEnabled(
'incoterm')) {
71 $langs->load(
'incoterm');
73if (isModEnabled(
'margin')) {
74 $langs->load(
'margins');
76if (isModEnabled(
'productbatch')) {
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');
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));
102if (!empty($user->socid)) {
103 $socid = $user->socid;
107$hookmanager->initHooks(array(
'ordercard',
'globalcard'));
115$extrafields->fetch_name_optionals_label($object->table_element);
118include 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'));
149$parameters = array(
'socid' => $socid);
151$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
156if (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');
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');
289 $object->deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
290 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
291 $object->fk_account =
GETPOST(
'fk_account',
'int');
292 $object->availability_id =
GETPOST(
'availability_id');
293 $object->demand_reason_id =
GETPOST(
'demand_reason_id');
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');
299 $object->contact_id =
GETPOST(
'contactid');
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;
477 $parameters = array(
'objFrom' => $srcobject);
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');
660 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
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');
700 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
701 if (empty($remise_percent)) {
706 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
707 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
709 if (is_array($extralabelsline)) {
711 foreach ($extralabelsline as $key => $value) {
712 unset($_POST[
"options_".$key]);
716 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
717 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
720 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
721 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
724 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
725 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
729 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
733 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
736 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
737 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
741 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
742 if ($combinations =
GETPOST(
'combinations',
'array')) {
746 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
747 $idprod = $res->fk_product_child;
749 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
755 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
759 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
764 if (!empty($idprod) && $idprod > 0) {
766 $prod->fetch($idprod);
768 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
777 $pu_ht = $prod->price;
778 $pu_ttc = $prod->price_ttc;
779 $price_min = $prod->price_min;
780 $price_min_ttc = $prod->price_min_ttc;
781 $price_base_type = $prod->price_base_type;
784 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
785 $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
786 $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
787 $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
788 $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
789 $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
790 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
791 if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
792 $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
794 if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
795 $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
798 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
800 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
804 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' => $object->thirdparty->id);
806 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
808 if (count($prodcustprice->lines) > 0) {
809 $pu_ht =
price($prodcustprice->lines[0]->price);
810 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
811 $price_min =
price($prodcustprice->lines[0]->price_min);
812 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
813 $price_base_type = $prodcustprice->lines[0]->price_base_type;
814 $tva_tx = $prodcustprice->lines[0]->tva_tx;
815 if ($prodcustprice->lines[0]->default_vat_code && !preg_match(
'/\(.*\)/', $tva_tx)) {
816 $tva_tx .=
' ('.$prodcustprice->lines[0]->default_vat_code.
')';
818 $tva_npr = $prodcustprice->lines[0]->recuperableonly;
819 if (empty($tva_tx)) {
826 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
828 if ($prod->prices_by_qty[0]) {
833 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
834 if ($priceforthequantityarray[
'rowid'] != $pqp) {
838 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
839 $pu_ht = $priceforthequantityarray[
'unitprice'];
841 $pu_ttc = $priceforthequantityarray[
'unitprice'];
847 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
849 if ($prod->prices_by_qty[$object->thirdparty->price_level]) {
853 foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) {
854 if ($priceforthequantityarray[
'rowid'] != $pqp) {
858 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
859 $pu_ht = $priceforthequantityarray[
'unitprice'];
861 $pu_ttc = $priceforthequantityarray[
'unitprice'];
869 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
870 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
873 if (!empty($price_ht) || $price_ht ===
'0') {
875 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
876 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
878 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
879 } elseif ($tmpvat != $tmpprodvat) {
881 if ($price_base_type !=
'HT') {
882 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
884 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
891 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
892 $outputlangs = $langs;
894 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
895 $newlang =
GETPOST(
'lang_id',
'aZ09');
897 if (empty($newlang)) {
898 $newlang = $object->thirdparty->default_lang;
900 if (!empty($newlang)) {
902 $outputlangs->setDefaultLang($newlang);
905 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
907 $desc = $prod->description;
911 if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
915 if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) {
916 $desc = $product_desc;
918 $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
922 if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
925 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
926 $outputlangs = $langs;
928 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
929 $newlang =
GETPOST(
'lang_id',
'alpha');
931 if (empty($newlang)) {
932 $newlang = $object->thirdparty->default_lang;
934 if (!empty($newlang)) {
936 $outputlangs->setDefaultLang($newlang);
937 $outputlangs->load(
'products');
939 if (!empty($prod->customcode)) {
940 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
942 if (!empty($prod->customcode) && !empty($prod->country_code)) {
945 if (!empty($prod->country_code)) {
946 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
949 if (!empty($prod->customcode)) {
950 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
952 if (!empty($prod->customcode) && !empty($prod->country_code)) {
955 if (!empty($prod->country_code)) {
956 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
964 $fk_unit = $prod->fk_unit;
968 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
969 $tva_tx = str_replace(
'*',
'', $tva_tx);
970 if (empty($tva_tx)) {
973 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
974 $desc = $product_desc;
976 $fk_unit =
GETPOST(
'units',
'alpha');
977 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
978 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
980 if ($pu_ttc && !$pu_ht) {
981 $price_base_type =
'TTC';
991 $localtax1_tx =
get_localtax($tva_tx, 1, $object->thirdparty);
992 $localtax2_tx =
get_localtax($tva_tx, 2, $object->thirdparty);
999 $pu_equivalent = $pu_ht;
1000 $pu_equivalent_ttc = $pu_ttc;
1002 $currency_tx = $object->multicurrency_tx;
1006 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1007 $pu_equivalent = $pu_ht_devise * $currency_tx;
1009 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1010 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1027 if ($usermustrespectpricemin) {
1028 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min)) && $price_base_type ==
'HT') {
1029 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1032 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1033 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1041 $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);
1044 $ret = $object->fetch($object->id);
1045 $object->fetch_thirdparty();
1047 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1049 $outputlangs = $langs;
1050 $newlang =
GETPOST(
'lang_id',
'alpha');
1052 $newlang = $object->thirdparty->default_lang;
1054 if (!empty($newlang)) {
1055 $outputlangs =
new Translate(
"", $conf);
1056 $outputlangs->setDefaultLang($newlang);
1059 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1062 unset($_POST[
'prod_entry_mode']);
1064 unset($_POST[
'qty']);
1065 unset($_POST[
'type']);
1066 unset($_POST[
'remise_percent']);
1067 unset($_POST[
'price_ht']);
1068 unset($_POST[
'multicurrency_price_ht']);
1069 unset($_POST[
'price_ttc']);
1070 unset($_POST[
'tva_tx']);
1071 unset($_POST[
'product_ref']);
1072 unset($_POST[
'product_label']);
1073 unset($_POST[
'product_desc']);
1074 unset($_POST[
'fournprice']);
1075 unset($_POST[
'buying_price']);
1076 unset($_POST[
'np_marginRate']);
1077 unset($_POST[
'np_markRate']);
1078 unset($_POST[
'dp_desc']);
1079 unset($_POST[
'idprod']);
1080 unset($_POST[
'units']);
1082 unset($_POST[
'date_starthour']);
1083 unset($_POST[
'date_startmin']);
1084 unset($_POST[
'date_startsec']);
1085 unset($_POST[
'date_startday']);
1086 unset($_POST[
'date_startmonth']);
1087 unset($_POST[
'date_startyear']);
1088 unset($_POST[
'date_endhour']);
1089 unset($_POST[
'date_endmin']);
1090 unset($_POST[
'date_endsec']);
1091 unset($_POST[
'date_endday']);
1092 unset($_POST[
'date_endmonth']);
1093 unset($_POST[
'date_endyear']);
1099 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1111 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1116 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
1117 $vat_rate = str_replace(
'*',
'', $vat_rate);
1118 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
1119 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
1129 $pu_equivalent = $pu_ht;
1130 $pu_equivalent_ttc = $pu_ttc;
1132 $currency_tx = $object->multicurrency_tx;
1136 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1137 $pu_equivalent = $pu_ht_devise * $currency_tx;
1139 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1140 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1159 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1160 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
1162 if (is_array($extralabelsline)) {
1163 foreach ($extralabelsline as $key => $value) {
1164 unset($_POST[
"options_".$key]);
1169 $special_code =
GETPOST(
'special_code');
1177 $productid =
GETPOST(
'productid',
'int');
1178 if (!empty($productid)) {
1180 $product->fetch($productid);
1182 $type = $product->type;
1184 $price_min = $product->price_min;
1185 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
1186 $price_min = $product->multiprices_min[$object->thirdparty->price_level];
1188 $price_min_ttc = $product->price_min_ttc;
1189 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
1190 $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
1196 if ($usermustrespectpricemin) {
1197 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min)) && $price_base_type ==
'HT') {
1198 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1201 $action =
'editline';
1202 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1203 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1206 $action =
'editline';
1211 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1215 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1217 $action =
'editline';
1222 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1224 $action =
'editline';
1228 if (empty($user->rights->margins->creer)) {
1229 foreach ($object->lines as &$line) {
1230 if ($line->id ==
GETPOST(
'lineid',
'int')) {
1231 $fournprice = $line->fk_fournprice;
1232 $buyingprice = $line->pa_ht;
1238 $price_base_type =
'HT';
1240 if (empty($pu) && !empty($pu_ttc)) {
1242 $price_base_type =
'TTC';
1245 $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);
1248 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1250 $outputlangs = $langs;
1253 $newlang =
GETPOST(
'lang_id',
'aZ09');
1256 $newlang = $object->thirdparty->default_lang;
1258 if (!empty($newlang)) {
1259 $outputlangs =
new Translate(
"", $conf);
1260 $outputlangs->setDefaultLang($newlang);
1263 $ret = $object->fetch($object->id);
1264 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1267 unset($_POST[
'qty']);
1268 unset($_POST[
'type']);
1269 unset($_POST[
'productid']);
1270 unset($_POST[
'remise_percent']);
1271 unset($_POST[
'price_ht']);
1272 unset($_POST[
'multicurrency_price_ht']);
1273 unset($_POST[
'price_ttc']);
1274 unset($_POST[
'tva_tx']);
1275 unset($_POST[
'product_ref']);
1276 unset($_POST[
'product_label']);
1277 unset($_POST[
'product_desc']);
1278 unset($_POST[
'fournprice']);
1279 unset($_POST[
'buying_price']);
1281 unset($_POST[
'date_starthour']);
1282 unset($_POST[
'date_startmin']);
1283 unset($_POST[
'date_startsec']);
1284 unset($_POST[
'date_startday']);
1285 unset($_POST[
'date_startmonth']);
1286 unset($_POST[
'date_startyear']);
1287 unset($_POST[
'date_endhour']);
1288 unset($_POST[
'date_endmin']);
1289 unset($_POST[
'date_endsec']);
1290 unset($_POST[
'date_endday']);
1291 unset($_POST[
'date_endmonth']);
1292 unset($_POST[
'date_endyear']);
1297 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1298 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1300 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
1301 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
1303 $qualified_for_stock_change = 0;
1304 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1305 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1307 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1311 if (isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
1312 if (!$idwarehouse || $idwarehouse == -1) {
1314 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1320 $locationTarget =
'';
1324 $result = $object->valid($user, $idwarehouse);
1329 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
1332 GETPOST(
'generate_deposit',
'alpha') ==
'on' && !empty($deposit_percent_from_payment_terms)
1333 && isModEnabled(
'facture') && !empty($user->rights->facture->creer)
1335 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1338 $forceFields = array();
1340 if (GETPOSTISSET(
'date_pointoftax')) {
1341 $forceFields[
'date_pointoftax'] =
dol_mktime(0, 0, 0,
GETPOST(
'date_pointoftaxmonth',
'int'),
GETPOST(
'date_pointoftaxday',
'int'),
GETPOST(
'date_pointoftaxyear',
'int'));
1348 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
1359 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1360 $outputlangs = $langs;
1363 $newlang =
GETPOST(
'lang_id',
'aZ09');
1366 $newlang = $object->thirdparty->default_lang;
1368 if (!empty($newlang)) {
1369 $outputlangs =
new Translate(
"", $conf);
1370 $outputlangs->setDefaultLang($newlang);
1372 $model = $object->model_pdf;
1373 $ret = $object->fetch($id);
1375 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1378 $deposit->fetch($deposit->id);
1379 $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1383 if ($locationTarget) {
1384 header(
'Location: ' . $locationTarget);
1395 } elseif ($action ==
'confirm_modif' && $usercancreate) {
1397 $idwarehouse =
GETPOST(
'idwarehouse');
1399 $qualified_for_stock_change = 0;
1400 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1401 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1403 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1407 if (isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
1408 if (!$idwarehouse || $idwarehouse == -1) {
1410 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1416 $result = $object->setDraft($user, $idwarehouse);
1419 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1420 $outputlangs = $langs;
1423 $newlang =
GETPOST(
'lang_id',
'aZ09');
1426 $newlang = $object->thirdparty->default_lang;
1428 if (!empty($newlang)) {
1429 $outputlangs =
new Translate(
"", $conf);
1430 $outputlangs->setDefaultLang($newlang);
1432 $model = $object->model_pdf;
1433 $ret = $object->fetch($id);
1435 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1441 } elseif ($action ==
'confirm_shipped' && $confirm ==
'yes' && $usercanclose) {
1442 $result = $object->cloture($user);
1446 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanvalidate) {
1447 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
1449 $qualified_for_stock_change = 0;
1450 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1451 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1453 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1457 if (isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
1458 if (!$idwarehouse || $idwarehouse == -1) {
1460 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1466 $result = $object->cancel($idwarehouse);
1474 if ($action ==
'update_extras') {
1478 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
1485 $result = $object->insertExtraFields(
'ORDER_MODIFY');
1493 $action =
'edit_extras';
1498 if ($action ==
'import_lines_from_object'
1502 $fromElement =
GETPOST(
'fromelement');
1503 $fromElementid =
GETPOST(
'fromelementid');
1504 $importLines =
GETPOST(
'line_checkbox');
1506 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
1507 if ($fromElement ==
'commande') {
1509 $lineClassName =
'OrderLine';
1510 } elseif ($fromElement ==
'propal') {
1511 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1512 $lineClassName =
'PropaleLigne';
1513 } elseif ($fromElement ==
'facture') {
1514 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
1515 $lineClassName =
'FactureLigne';
1517 $nextRang = count($object->lines) + 1;
1520 foreach ($importLines as $lineId) {
1521 $lineId = intval($lineId);
1522 $originLine =
new $lineClassName($db);
1523 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
1524 $originLine->fetch_optionals();
1525 $desc = $originLine->desc;
1526 $pu_ht = $originLine->subprice;
1527 $qty = $originLine->qty;
1528 $txtva = $originLine->tva_tx;
1529 $txlocaltax1 = $originLine->localtax1_tx;
1530 $txlocaltax2 = $originLine->localtax2_tx;
1531 $fk_product = $originLine->fk_product;
1532 $remise_percent = $originLine->remise_percent;
1533 $date_start = $originLine->date_start;
1534 $date_end = $originLine->date_end;
1536 $info_bits = $originLine->info_bits;
1537 $fk_remise_except = $originLine->fk_remise_except;
1538 $price_base_type =
'HT';
1540 $type = $originLine->product_type;
1541 $rang = $nextRang++;
1542 $special_code = $originLine->special_code;
1543 $origin = $originLine->element;
1544 $origin_id = $originLine->id;
1545 $fk_parent_line = 0;
1546 $fk_fournprice = $originLine->fk_fournprice;
1547 $pa_ht = $originLine->pa_ht;
1548 $label = $originLine->label;
1549 $array_options = $originLine->array_options;
1550 $situation_percent = 100;
1552 $fk_unit = $originLine->fk_unit;
1553 $pu_ht_devise = $originLine->multicurrency_subprice;
1555 $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);
1574 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1577 $upload_dir = !empty($conf->commande->multidir_output[$object->entity])?$conf->commande->multidir_output[$object->entity]:$conf->commande->dir_output;
1578 $permissiontoadd = $usercancreate;
1579 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1582 $triggersendname =
'ORDER_SENTBYMAIL';
1584 $autocopy =
'MAIN_MAIL_AUTOCOPY_ORDER_TO';
1585 $trackid =
'ord'.$object->id;
1586 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1589 if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) {
1590 if ($action ==
'addcontact') {
1591 if ($object->id > 0) {
1594 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1598 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1601 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1602 $langs->load(
"errors");
1603 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1608 } elseif ($action ==
'swapstatut') {
1610 if ($object->id > 0) {
1611 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
1615 } elseif ($action ==
'deletecontact') {
1617 $result = $object->delete_contact($lineid);
1620 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1634$title = $object->ref.
" - ".$langs->trans(
'Card');
1635if ($action ==
'create') {
1636 $title = $langs->trans(
"NewOrder");
1638$help_url =
'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
1642$form =
new Form($db);
1646if (isModEnabled(
'project')) {
1651if ($action ==
'create' && $usercancreate) {
1656 $res = $soc->fetch($socid);
1659 $remise_absolue = 0;
1661 $currency_code = $conf->currency;
1663 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1664 $deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
1665 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1666 $fk_account =
GETPOST(
'fk_account',
'int');
1668 if (!empty($origin) && !empty($originid)) {
1670 $element = $subelement = $origin;
1672 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1673 $element = $regs[1];
1674 $subelement = $regs[2];
1677 if ($element ==
'project') {
1678 $projectid = $originid;
1680 if (!$cond_reglement_id) {
1681 $cond_reglement_id = $soc->cond_reglement_id;
1683 if (!$deposit_percent) {
1684 $deposit_percent = $soc->deposit_percent;
1686 if (!$mode_reglement_id) {
1687 $mode_reglement_id = $soc->mode_reglement_id;
1689 if (!$remise_percent) {
1690 $remise_percent = $soc->remise_percent;
1698 if ($element ==
'order' || $element ==
'commande') {
1699 $element = $subelement =
'commande';
1700 } elseif ($element ==
'propal') {
1701 $element =
'comm/propal';
1702 $subelement =
'propal';
1703 } elseif ($element ==
'contract') {
1704 $element = $subelement =
'contrat';
1709 $classname = ucfirst($subelement);
1710 $objectsrc =
new $classname($db);
1711 $objectsrc->fetch($originid);
1712 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1713 $objectsrc->fetch_lines();
1715 $objectsrc->fetch_thirdparty();
1718 $objectsrc->fetch_optionals();
1719 $object->array_options = $objectsrc->array_options;
1721 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1722 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1724 $soc = $objectsrc->thirdparty;
1725 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1726 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent :
null));
1727 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1728 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1729 $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0);
1730 $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0));
1731 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1732 $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0));
1733 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
1734 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1735 $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ? -1 :
'';
1737 $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date :
'');
1738 if (empty($date_delivery)) {
1739 $date_delivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison :
'');
1742 if (isModEnabled(
"multicurrency")) {
1743 if (!empty($objectsrc->multicurrency_code)) {
1744 $currency_code = $objectsrc->multicurrency_code;
1746 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) {
1747 $currency_tx = $objectsrc->multicurrency_tx;
1751 $note_private = $object->getDefaultCreateValueFor(
'note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null));
1752 $note_public = $object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null));
1755 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1758 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1759 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1760 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1761 $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account;
1762 $availability_id = 0;
1763 $shipping_method_id = $soc->shipping_method_id;
1764 $warehouse_id = $soc->fk_warehouse;
1765 $demand_reason_id = $soc->demand_reason_id;
1766 $remise_percent = $soc->remise_percent;
1767 $remise_absolue = 0;
1768 $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 :
'';
1770 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1771 $currency_code = $soc->multicurrency_code;
1774 $note_private = $object->getDefaultCreateValueFor(
'note_private');
1775 $note_public = $object->getDefaultCreateValueFor(
'note_public');
1779 if (!
GETPOST(
'changecompany')) {
1780 if (GETPOSTISSET(
'cond_reglement_id')) {
1781 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1783 if (GETPOSTISSET(
'deposit_percent')) {
1786 if (GETPOSTISSET(
'mode_reglement_id')) {
1787 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1789 if (GETPOSTISSET(
'cond_reglement_id')) {
1790 $fk_account =
GETPOST(
'fk_account',
'int');
1795 if ($soc->fk_warehouse > 0) {
1796 $warehouse_id = $soc->fk_warehouse;
1798 if (isModEnabled(
'stock') && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1799 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) {
1800 $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
1802 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1803 $warehouse_id = $user->fk_warehouse;
1807 print
'<form name="crea_commande" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1808 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1809 print
'<input type="hidden" name="action" value="add">';
1810 print
'<input type="hidden" name="changecompany" value="0">';
1811 print
'<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.
'">';
1812 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1813 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1814 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1815 if (!empty($currency_tx)) {
1816 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1821 print
'<table class="border centpercent">';
1824 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
"Draft").
'</td></tr>';
1827 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td><td>';
1828 if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid)) {
1829 print
'<input type="text" name="ref_client" value="'.$ref_client.
'"></td>';
1831 print
'<input type="text" name="ref_client" value="'.GETPOST(
'ref_client').
'"></td>';
1837 print
'<td class="fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1840 print $soc->getNomUrl(1,
'customer');
1841 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1844 print
'<td class="valuefieldcreate">';
1845 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1846 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1848 if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
1850 $(document).ready(function() {
1851 $("#socid").change(function() {
1852 console.log("We have changed the company - Reload page");
1853 var socid = $(this).val();
1855 $("input[name=action]").val("create");
1856 $("input[name=changecompany]").val("1");
1857 $("form[name=crea_commande]").submit();
1862 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>';
1870 print
"<tr><td>".$langs->trans(
"DefaultContact").
'</td><td>';
1871 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1872 print $form->selectcontacts($soc->id, $contactid,
'contactid', 1, !empty($srccontactslist)?$srccontactslist:
"",
'', 1,
'maxwidth200 widthcentpercentminusx');
1876 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1878 $absolute_discount = $soc->getAvailableDiscounts();
1882 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode(
GETPOST(
'origin')).
'&originid='.urlencode(
GETPOSTINT(
'originid'));
1883 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1889 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Date').
'</td><td>';
1890 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1891 print $form->selectDate(
'',
're',
'',
'',
'',
"crea_commande", 1, 1);
1895 print
'<tr><td>'.$langs->trans(
"DateDeliveryPlanned").
'</td>';
1896 print
'<td colspan="3">';
1897 $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date);
1898 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1899 print $form->selectDate($date_delivery ? $date_delivery : -1,
'liv_', 1, 1, 1);
1904 print
'<tr class="fielddeliverydelay"><td>'.$langs->trans(
'AvailabilityPeriod').
'</td><td>';
1905 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1906 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id') : $availability_id),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1910 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1911 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1912 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'maxwidth200 widthcentpercentminusx', $deposit_percent);
1916 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
1917 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1918 print $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1922 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && isModEnabled(
"banque")) {
1923 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
1924 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1929 if (isModEnabled(
'expedition')) {
1930 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td>';
1931 print
img_picto(
'',
'object_dolly',
'class="pictofixedwidth"');
1932 $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');
1937 if (isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1938 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1940 print
'<tr><td>'.$langs->trans(
'Warehouse').
'</td><td>';
1941 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');
1946 print
'<tr><td>'.$langs->trans(
'Channel').
'</td><td>';
1947 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1948 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id')?
GETPOST(
'demand_reason_id'):$demand_reason_id),
'demand_reason_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1954 if (isModEnabled(
'project')) {
1955 $langs->load(
"projects");
1957 print
'<td>'.$langs->trans(
"Project").
'</td><td>';
1958 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');
1959 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>';
1965 if (isModEnabled(
'incoterm')) {
1967 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms, 1).
'</label></td>';
1968 print
'<td class="maxwidthonsmartphone">';
1969 $incoterm_id =
GETPOST(
'incoterm_id');
1970 $incoterm_location =
GETPOST(
'location_incoterms');
1971 if (empty($incoterm_id)) {
1972 $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
1973 $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
1975 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
1976 print $form->select_incoterms($incoterm_id, $incoterm_location);
1981 $parameters = array();
1982 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1983 $parameters[
'objectsrc'] = $objectsrc;
1985 $parameters[
'socid'] = $socid;
1988 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1989 print $hookmanager->resPrint;
1990 if (empty($reshook)) {
1991 if (!empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER) && !empty($soc->id)) {
1994 $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element);
1995 if ($soc->fetch_optionals() > 0) {
1996 $object->array_options = array_merge($object->array_options, $soc->array_options);
2000 print $object->showOptionals($extrafields,
'create', $parameters);
2004 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
2006 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
2008 $preselected = $conf->global->COMMANDE_ADDON_PDF;
2009 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2010 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2014 if (isModEnabled(
"multicurrency")) {
2016 print
'<td>'.$form->editfieldkey(
"Currency",
'multicurrency_code',
'', $object, 0).
'</td>';
2017 print
'<td class="maxwidthonsmartphone">';
2018 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code')?
GETPOST(
'multicurrency_code'):$currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2024 print
'<td class="tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2027 $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%');
2028 print $doleditor->Create(1);
2033 if (empty($user->socid)) {
2035 print
'<td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2038 $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%');
2039 print $doleditor->Create(1);
2044 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2046 if ($origin ==
'contrat') {
2048 $objectsrc->remise_absolue = $remise_absolue;
2049 $objectsrc->remise_percent = $remise_percent;
2050 $objectsrc->update_price(1);
2053 print
"\n<!-- ".$classname.
" info -->";
2055 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2056 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2057 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2058 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2059 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2061 switch ($classname) {
2063 $newclassname =
'CommercialProposal';
2066 $newclassname =
'Order';
2069 $newclassname =
'Sending';
2072 $newclassname =
'Contract';
2075 $newclassname = $classname;
2078 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2081 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2082 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2083 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2084 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2087 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2088 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2091 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2093 if (isModEnabled(
"multicurrency")) {
2094 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2095 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2096 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2106 print $form->buttonsSaveCancel(
"CreateDraft");
2109 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2110 $title = $langs->trans(
'ProductsAndServices');
2113 print
'<div class="div-table-responsive-no-min">';
2114 print
'<table class="noborder centpercent">';
2116 $objectsrc->printOriginLinesList(
'', $selectedLines);
2127 if ($object->id > 0) {
2128 $product_static =
new Product($db);
2131 $soc->fetch($object->socid);
2133 $author =
new User($db);
2134 $author->fetch($object->user_author_id);
2136 $object->fetch_thirdparty();
2137 $res = $object->fetch_optionals();
2140 print
dol_get_fiche_head($head,
'order', $langs->trans(
"CustomerOrder"), -1,
'order');
2145 if ($action ==
'delete') {
2146 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteOrder'), $langs->trans(
'ConfirmDeleteOrder'),
'confirm_delete',
'', 0, 1);
2150 if ($action ==
'validate') {
2152 $ref = substr($object->ref, 1, 4);
2153 if ($ref ==
'PROV' || $ref ==
'') {
2154 $numref = $object->getNextNumRef($soc);
2155 if (empty($numref)) {
2160 $numref = $object->ref;
2163 $text = $langs->trans(
'ConfirmValidateOrder', $numref);
2164 if (isModEnabled(
'notification')) {
2165 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2166 $notify =
new Notify($db);
2168 $text .= $notify->confirmMessage(
'ORDER_VALIDATE', $object->socid, $object);
2171 $qualified_for_stock_change = 0;
2172 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2173 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2175 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2178 $formquestion = array();
2179 if (isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
2180 $langs->load(
"stocks");
2181 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2184 if ($conf->browser->name ==
'ie') {
2187 $formquestion = array(
2191 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))
2197 foreach ($object->lines as $line) {
2198 $res = $line->fetch_product();
2200 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) {
2206 if ($nbMandated > 0 ) $text .=
'<div><span class="clearboth nowraponall warning">'.$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2208 if (
getDolGlobalInt(
'SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2213 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
2215 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'facture') && !empty($user->rights->facture->creer)) {
2216 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2218 $object->fetchObjectLinked();
2220 $eligibleForDepositGeneration =
true;
2222 if (array_key_exists(
'facture', $object->linkedObjects)) {
2223 foreach ($object->linkedObjects[
'facture'] as $invoice) {
2225 $eligibleForDepositGeneration =
false;
2231 if ($eligibleForDepositGeneration && array_key_exists(
'propal', $object->linkedObjects)) {
2232 foreach ($object->linkedObjects[
'propal'] as $proposal) {
2233 $proposal->fetchObjectLinked();
2235 if (array_key_exists(
'facture', $proposal->linkedObjects)) {
2236 foreach ($proposal->linkedObjects[
'facture'] as $invoice) {
2238 $eligibleForDepositGeneration =
false;
2246 if ($eligibleForDepositGeneration) {
2247 $formquestion[] = array(
2248 'type' =>
'checkbox',
2250 'name' =>
'generate_deposit',
2251 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit', $object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2254 $formquestion[] = array(
2256 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2258 'label' => $langs->trans(
'DateInvoice'),
2263 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
2264 $formquestion[] = array(
2266 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2267 'name' =>
'date_pointoftax',
2268 'label' => $langs->trans(
'DatePointOfTax'),
2275 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 0,
'minwidth200');
2277 $formquestion[] = array(
2279 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2280 'name' =>
'cond_reglement_id',
2281 'label' => $langs->trans(
'PaymentTerm'),
2282 'value' => $paymentTermsSelect
2285 $formquestion[] = array(
2286 'type' =>
'checkbox',
2287 'tdclass' =>
'showonlyifgeneratedeposit',
2288 'name' =>
'validate_generated_deposit',
2289 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2292 $formquestion[] = array(
2293 'type' =>
'onecolumn',
2296 $(document).ready(function() {
2297 $("[name=generate_deposit]").change(function () {
2298 let $self = $(this);
2299 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2301 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2318 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateOrder'), $text,
'confirm_validate', $formquestion, 0, 1, 220);
2323 if ($action ==
'modif') {
2324 $qualified_for_stock_change = 0;
2325 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2326 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2328 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2331 $text = $langs->trans(
'ConfirmUnvalidateOrder', $object->ref);
2332 $formquestion = array();
2333 if (isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
2334 $langs->load(
"stocks");
2335 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2338 if ($conf->browser->name ==
'ie') {
2341 $formquestion = array(
2345 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2349 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'UnvalidateOrder'), $text,
'confirm_modif', $formquestion,
"yes", 1, 220);
2355 if ($action ==
'shipped') {
2356 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloseOrder'), $langs->trans(
'ConfirmCloseOrder'),
'confirm_shipped',
'', 0, 1);
2362 if ($action ==
'cancel') {
2363 $qualified_for_stock_change = 0;
2364 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2365 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2367 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2370 $text = $langs->trans(
'ConfirmCancelOrder', $object->ref);
2371 $formquestion = array();
2372 if (isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) {
2373 $langs->load(
"stocks");
2374 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2377 if ($conf->browser->name ==
'ie') {
2380 $formquestion = array(
2384 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $langs->trans(
"SelectWarehouseForStockIncrease"),
'value' => $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1, 0, 0,
'', 0, $forcecombo))
2388 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
"Cancel"), $text,
'confirm_cancel', $formquestion, 0, 1);
2392 if ($action ==
'ask_deleteline') {
2393 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2397 if ($action ==
'clone') {
2398 $filter =
'(s.client:IN:1,2,3)';
2400 $formquestion = array(
2401 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOST(
'socid',
'int'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300'))
2403 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneOrder', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2407 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2409 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2410 if (empty($reshook)) {
2411 $formconfirm .= $hookmanager->resPrint;
2412 } elseif ($reshook > 0) {
2413 $formconfirm = $hookmanager->resPrint;
2422 $linkback =
'<a href="'.DOL_URL_ROOT.
'/commande/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2424 $morehtmlref =
'<div class="refidno">';
2426 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string',
'', 0, 1);
2427 $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);
2429 $morehtmlref .=
'<br>'.$soc->getNomUrl(1,
'customer');
2430 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
2431 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
2434 if (isModEnabled(
'project')) {
2435 $langs->load(
"projects");
2436 $morehtmlref .=
'<br>';
2437 if ($usercancreate) {
2438 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2439 if ($action !=
'classify') {
2440 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2442 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2444 if (!empty($object->fk_project)) {
2446 $proj->fetch($object->fk_project);
2447 $morehtmlref .= $proj->getNomUrl(1);
2449 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2454 $morehtmlref .=
'</div>';
2457 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2460 print
'<div class="fichecenter">';
2461 print
'<div class="fichehalfleft">';
2462 print
'<div class="underbanner clearboth"></div>';
2464 print
'<table class="border tableforfield centpercent">';
2466 if ($soc->outstanding_limit) {
2468 print
'<tr><td class="titlefield">';
2469 print $langs->trans(
'OutstandingBill');
2470 print
'</td><td class="valuefield">';
2471 $arrayoutstandingbills = $soc->getOutstandingBills();
2472 print
price($arrayoutstandingbills[
'opened']).
' / ';
2473 print
price($soc->outstanding_limit, 0,
'', 1, - 1, - 1, $conf->currency);
2479 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
2480 $filterabsolutediscount =
"fk_facture_source IS NULL";
2481 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2483 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2484 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2487 $addrelativediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.$object->id.
'">'.$langs->trans(
"EditRelativeDiscounts").
'</a>';
2488 $addabsolutediscount =
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$soc->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?facid='.$object->id.
'">'.$langs->trans(
"EditGlobalDiscounts").
'</a>';
2489 $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>';
2491 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td class="valuefield">';
2493 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2494 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2495 $absolute_discount =
price2num($absolute_discount,
'MT');
2496 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2500 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.$object->id;
2501 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2508 print $form->editfieldkey(
"Date",
'date',
'', $object, $editenable);
2509 print
'</td><td class="valuefield">';
2510 if ($action ==
'editdate') {
2511 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2512 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2513 print
'<input type="hidden" name="action" value="setdate">';
2514 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2515 print $form->selectDate($object->date,
'order_',
'',
'',
'',
"setdate");
2516 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2519 print $object->date ?
dol_print_date($object->date,
'day') :
' ';
2520 if ($object->hasDelay() && empty($object->delivery_date)) {
2521 print
' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(),
"warning");
2529 $editenable = $usercancreate;
2530 print $form->editfieldkey(
"DateDeliveryPlanned",
'date_livraison',
'', $object, $editenable);
2531 print
'</td><td class="valuefield">';
2532 if ($action ==
'editdate_livraison') {
2533 print
'<form name="setdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2534 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2535 print
'<input type="hidden" name="action" value="setdate_livraison">';
2536 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2537 print $form->selectDate($object->delivery_date ? $object->delivery_date : -1,
'liv_', 1, 1,
'',
"setdate_livraison", 1, 0);
2538 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2541 print $object->delivery_date ?
dol_print_date($object->delivery_date,
'dayhour') :
' ';
2542 if ($object->hasDelay() && !empty($object->delivery_date)) {
2543 print
' '.img_picto($langs->trans(
"Late").
' : '.$object->showDelay(),
"warning");
2550 print
'<tr class="fielddeliverydelay"><td>';
2551 $editenable = $usercancreate;
2552 print $form->editfieldkey(
"AvailabilityPeriod",
'availability',
'', $object, $editenable);
2553 print
'</td><td class="valuefield">';
2554 if ($action ==
'editavailability') {
2555 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'availability_id', 1);
2557 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'none', 1);
2562 if (isModEnabled(
'expedition')) {
2564 $editenable = $usercancreate;
2565 print $form->editfieldkey(
"SendingMethod",
'shippingmethod',
'', $object, $editenable);
2566 print
'</td><td class="valuefield">';
2567 if ($action ==
'editshippingmethod') {
2568 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
2570 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'none');
2577 if (isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
2578 $langs->load(
'stocks');
2579 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2582 $editenable = $usercancreate;
2583 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
2584 print
'</td><td class="valuefield">';
2585 if ($action ==
'editwarehouse') {
2586 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'warehouse_id', 1);
2588 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'none');
2596 $editenable = $usercancreate;
2597 print $form->editfieldkey(
"Source",
'demandreason',
'', $object, $editenable);
2598 print
'</td><td class="valuefield">';
2599 if ($action ==
'editdemandreason') {
2600 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'demand_reason_id', 1);
2602 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'none');
2608 $editenable = $usercancreate;
2609 print $form->editfieldkey(
"PaymentConditionsShort",
'conditions',
'', $object, $editenable);
2610 print
'</td><td class="valuefield">';
2611 if ($action ==
'editconditions') {
2612 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1, $object->deposit_percent);
2614 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 1,
'', 1, $object->deposit_percent);
2622 $editenable = $usercancreate;
2623 print $form->editfieldkey(
"PaymentMode",
'mode',
'', $object, $editenable);
2624 print
'</td><td class="valuefield">';
2625 if ($action ==
'editmode') {
2626 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2628 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2633 if (isModEnabled(
"multicurrency")) {
2638 print $form->editfieldkey(
"Currency",
'multicurrencycode',
'', $object, $editenable);
2639 print
'</td><td class="valuefield">';
2640 if ($action ==
'editmulticurrencycode') {
2641 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2643 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2648 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
2651 $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT;
2652 print $form->editfieldkey(
"CurrencyRate",
'multicurrencyrate',
'', $object, $editenable);
2653 print
'</td><td class="valuefield">';
2654 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2655 if ($action ==
'actualizemulticurrencyrate') {
2658 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2660 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2661 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2662 print
'<div class="inline-block"> ';
2663 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2685 $tmparray = $object->getTotalWeightVolume();
2686 $totalWeight = $tmparray[
'weight'];
2687 $totalVolume = $tmparray[
'volume'];
2689 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2690 print
'<td class="valuefield">';
2691 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');
2695 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2696 print
'<td class="valuefield">';
2697 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');
2704 if (isModEnabled(
'incoterm')) {
2706 $editenable = $usercancreate;
2707 print $form->editfieldkey(
"IncotermLabel",
'incoterm',
'', $object, $editenable);
2709 print
'<td class="valuefield">';
2710 if ($action !=
'editincoterm') {
2711 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2713 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2719 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && isModEnabled(
"banque")) {
2721 $editenable = $usercancreate;
2722 print $form->editfieldkey(
"BankAccount",
'bankaccount',
'', $object, $editenable);
2723 print
'</td><td class="valuefield">';
2724 if ($action ==
'editbankaccount') {
2725 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2727 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2734 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2739 print
'<div class="fichehalfright">';
2740 print
'<div class="underbanner clearboth"></div>';
2742 print
'<table class="border tableforfield centpercent">';
2745 if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) {
2746 $alert =
' ' .
img_warning($langs->trans(
'OrderMinAmount') .
': ' .
price($object->thirdparty->order_min_amount));
2750 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2751 print
'<td class="nowrap amountcard right">' .
price($object->total_ht,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2752 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2754 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ht,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2759 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2760 print
'<td class="nowrap amountcard right">' .
price($object->total_tva,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2761 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2763 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_tva,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2768 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
2770 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2771 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2772 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2773 $object->multicurrency_total_localtax1 =
price2num($object->total_localtax1 * $object->multicurrency_tx,
'MT');
2775 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_localtax1,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2780 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
2782 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2783 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
2784 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2785 $object->multicurrency_total_localtax2 =
price2num($object->total_localtax2 * $object->multicurrency_tx,
'MT');
2787 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_localtax2,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
2794 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2795 print
'<td class="valuefield nowrap right amountcard">' .
price($object->total_ttc, 1,
'', 1, -1, -1, $conf->currency) .
'</td>';
2796 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2798 print
'<td class="valuefield nowrap right amountcard">' .
price($object->multicurrency_total_ttc, 1,
'', 1, -1, -1, $object->multicurrency_code) .
'</td>';
2808 if (isModEnabled(
'margin')) {
2809 $formmargin->displayMarginInfos($object);
2816 print
'<div class="clearboth"></div><br>';
2818 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
2819 $blocname =
'contacts';
2820 $title = $langs->trans(
'ContactsAddresses');
2821 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2824 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2825 $blocname =
'notes';
2826 $title = $langs->trans(
'Notes');
2827 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2835 $result = $object->getLinesArray();
2839 global $inputalsopricewithtax;
2840 $inputalsopricewithtax = 1;
2842 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">
2843 <input type="hidden" name="token" value="' . newToken().
'">
2844 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2845 <input type="hidden" name="mode" value="">
2846 <input type="hidden" name="page_y" value="">
2847 <input type="hidden" name="id" value="' . $object->id.
'">
2848 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2852 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2855 print
'<div class="div-table-responsive-no-min">';
2856 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2859 if (!empty($object->lines)) {
2860 $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
2863 $numlines = count($object->lines);
2869 if ($action !=
'editline') {
2872 $parameters = array();
2874 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2875 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2876 if (empty($reshook))
2877 $object->formAddObjectLine(1, $mysoc, $soc);
2890 if ($action !=
'presend' && $action !=
'editline') {
2891 print
'<div class="tabsAction">';
2893 $parameters = array();
2895 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2896 if (empty($reshook)) {
2899 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.newToken().
'&id='.$object->id,
'');
2903 if (empty($user->socid)) {
2904 if ($object->statut >
Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) {
2906 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'');
2908 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2914 if ($object->statut ==
Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) {
2915 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
"PHP_SELF"].
'?action=validate&token='.newToken().
'&id='.$object->id,
'');
2919 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=modif&token='.newToken().
'&id='.$object->id,
'');
2931 if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) {
2932 if (isModEnabled(
"supplier_order") && $object->statut >
Commande::STATUS_DRAFT && $object->getNbOfServicesLines() > 0) {
2933 if ($usercancreatepurchaseorder) {
2934 print
dolGetButtonAction(
'', $langs->trans(
'AddPurchaseOrder'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&origin='.$object->element.
'&originid='.$object->id,
'');
2940 if (isModEnabled(
'ficheinter')) {
2941 $langs->load(
"interventions");
2944 if ($user->hasRight(
'ficheinter',
'creer')) {
2945 print
dolGetButtonAction(
'', $langs->trans(
'AddIntervention'),
'default', DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2947 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddIntervention'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2954 $langs->load(
"contracts");
2956 if ($user->hasRight(
'contrat',
'creer')) {
2957 print
dolGetButtonAction(
'', $langs->trans(
'AddContract'),
'default', DOL_URL_ROOT.
'/contrat/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid,
'');
2963 if (isModEnabled(
'expedition')) {
2964 $numshipping = $object->countNbOfShipments();
2967 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'creer')) || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'creer'))) {
2968 if ($user->hasRight(
'expedition',
'creer')) {
2969 print
dolGetButtonAction(
'', $langs->trans(
'CreateShipment'),
'default', DOL_URL_ROOT.
'/expedition/shipment.php?id='.$object->id,
'');
2971 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2974 $langs->load(
"errors");
2975 print
dolGetButtonAction($langs->trans(
'ErrorModuleSetupNotComplete'), $langs->trans(
'CreateShipment'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
2982 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyShipped'),
'default', $_SERVER[
"PHP_SELF"].
'?action=shipped&token='.newToken().
'&id='.$object->id,
'');
2987 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'creer') && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
2988 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,
'');
2990 if ($usercancreate && $object->statut >=
Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2991 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifybilled&token='.newToken().
'&id='.$object->id,
'');
2995 if ($usercancreate && $object->statut >=
Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
2996 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyUnBilled'),
'default', $_SERVER[
"PHP_SELF"].
'?action=classifyunbilled&token='.newToken().
'&id='.$object->id,
'');
3000 if ($usercancreate) {
3001 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.newToken().
'&id='.$object->id.
'&socid='.$object->socid,
'');
3006 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=cancel&token='.newToken().
'">'.$langs->trans(
"Cancel").
'</a>';
3010 if ($usercandelete) {
3011 if ($numshipping == 0) {
3012 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.$object->id,
'');
3014 print
dolGetButtonAction($langs->trans(
'ShippingExist'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
3022 if (
GETPOST(
'modelselected')) {
3023 $action =
'presend';
3026 if ($action !=
'presend') {
3027 print
'<div class="fichecenter"><div class="fichehalfleft">';
3028 print
'<a name="builddoc"></a>';
3031 $relativepath = $objref.
'/'.$objref.
'.pdf';
3032 $filedir = $conf->commande->multidir_output[$object->entity].
'/'.$objref;
3033 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
3034 $genallowed = $usercanread;
3035 $delallowed = $usercancreate;
3036 print $formfile->showdocuments(
'commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang,
'', $object);
3040 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'order'));
3042 $compatibleImportElementsList =
false;
3045 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3047 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3050 $useonlinepayment = (isModEnabled(
'paypal') || isModEnabled(
'stripe') || isModEnabled(
'paybox'));
3051 if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) {
3052 $useonlinepayment = 0;
3055 print
'<br><!-- Link to pay -->';
3056 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
3057 print showOnlinePaymentUrl(
'order', $object->ref).
'<br>';
3060 print
'</div><div class="fichehalfright">';
3064 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/commande/agenda.php?id='.$object->id);
3067 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3069 $somethingshown =
$formactions->showactions($object,
'order', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3071 print
'</div></div>';
3075 $modelmail =
'order_send';
3076 $defaulttopic =
'SendOrderRef';
3078 $trackid =
'ord'.$object->id;
3080 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
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).
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)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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_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.
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.