--- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_card.php @@ -8,2 +8,2 @@ - * Copyright (C) 2011-2023 Philippe Grand - * Copyright (C) 2012-2023 Christophe Battarel + * Copyright (C) 2011-2019 Philippe Grand + * Copyright (C) 2012-2013 Christophe Battarel @@ -15,3 +15 @@ - * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2022 Gauthier VERDOL - * Copyright (C) 2023-2024 Benjamin Falière + * Copyright (C) 2018 Frédéric France @@ -34,3 +32,3 @@ - * \file htdocs/commande/card.php - * \ingroup commande - * \brief Page to show sales order + * \file htdocs/commande/card.php + * \ingroup commande + * \brief Page to show customer order @@ -39 +36,0 @@ -// Load Dolibarr environment @@ -41,2 +37,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -46,0 +42,3 @@ +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; @@ -48,6 +46,2 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; - -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - -if (isModEnabled("propal")) { +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->propal->enabled)) { @@ -56,2 +50,2 @@ - -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -59 +52,0 @@ - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -62 +55,3 @@ -if (isModEnabled('variants')) { +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + +if (!empty($conf->variants->enabled)) { @@ -66 +60,0 @@ - @@ -69,26 +63,15 @@ - -if (isModEnabled('incoterm')) { - $langs->load('incoterm'); -} -if (isModEnabled('margin')) { - $langs->load('margins'); -} -if (isModEnabled('productbatch')) { - $langs->load('productbatch'); -} - - -$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int')); -$ref = GETPOST('ref', 'alpha'); -$socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); - -$lineid = GETPOST('lineid', 'int'); -$contactid = GETPOST('contactid', 'int'); -$projectid = GETPOST('projectid', 'int'); -$origin = GETPOST('origin', 'alpha'); -$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility -$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; +if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); +if (!empty($conf->margin->enabled)) $langs->load('margins'); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); + +$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int')); +$ref = GETPOST('ref', 'alpha'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$lineid = GETPOST('lineid', 'int'); +$contactid = GETPOST('contactid', 'int'); +$projectid = GETPOST('projectid', 'int'); +$origin = GETPOST('origin', 'alpha'); +$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility @@ -97,3 +80,3 @@ -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -102 +85 @@ -if (!empty($user->socid)) { +if (!empty($user->socid)) @@ -104 +87,10 @@ -} +$result = restrictedArea($user, 'commande', $id); + +$object = new Commande($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -109,16 +101,3 @@ -$result = restrictedArea($user, 'commande', $id); - -$object = new Commande($db); -$extrafields = new ExtraFields($db); - -// fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once - -// Permissions / Rights -$usercanread = $user->hasRight("commande", "lire"); -$usercancreate = $user->hasRight("commande", "creer"); -$usercandelete = $user->hasRight("commande", "supprimer"); - +$usercanread = $user->rights->commande->lire; +$usercancreate = $user->rights->commande->creer; +$usercandelete = $user->rights->commande->supprimer; @@ -126,13 +105,15 @@ -$usercanclose = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('commande', 'order_advance', 'close'))); -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('commande', 'order_advance', 'validate'))); -$usercancancel = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('commande', 'order_advance', 'annuler'))); -$usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('commande', 'order_advance', 'send')); -$usercangeneretedoc = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('commande', 'order_advance', 'generetedoc')); - -$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); -$usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')); - -$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - +$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->close))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->validate))); +$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->annuler))); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send); + +$usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; + +$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php + +if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse; +} @@ -141,2 +121,0 @@ - -$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')); @@ -152,24 +131,8 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/commande/list.php'; - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/commande/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - - $selectedLines = GETPOST('toselect', 'array'); - - if ($cancel) { - if (!empty($backtopageforcancel)) { - header("Location: ".$backtopageforcancel); - exit; - } elseif (!empty($backtopage)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($cancel) + { + if (!empty($backtopage)) + { @@ -182,5 +145,5 @@ - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once @@ -189,2 +152,4 @@ - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { + if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) + { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) + { @@ -192,2 +157,5 @@ - } else { - if ($object->id > 0) { + } + else + { + if ($object->id > 0) + { @@ -198 +166,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -201 +170,3 @@ - } else { + } + else + { @@ -208,19 +179,22 @@ - } elseif ($action == 'reopen' && $usercancreate) { - // Reopen a closed order - if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) { - if (getDolGlobalInt('ORDER_REOPEN_TO_DRAFT')) { - $result = $object->setDraft($user, $idwarehouse); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - $result = $object->set_reopen($user); - if ($result > 0) { - setEventMessages($langs->trans('OrderReopened', $object->ref), null); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { - // Remove order + } + + // Reopen a closed order + elseif ($action == 'reopen' && $usercancreate) + { + if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) + { + $result = $object->set_reopen($user); + if ($result > 0) + { + setEventMessages($langs->trans('OrderReopened', $object->ref), null); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + // Remove order + elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) + { @@ -228 +202,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -231 +206,3 @@ - } else { + } + else + { @@ -234,2 +211,5 @@ - } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { - // Remove a product line + } + + // Remove a product line + elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) + { @@ -237,3 +217,2 @@ - if ($result > 0) { - // reorder lines - $object->line_order(true); + if ($result > 0) + { @@ -243 +222 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) @@ -245,2 +224 @@ - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) @@ -248 +225,0 @@ - } @@ -253 +230 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -255 +232 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -260 +237,3 @@ - } else { + } + else + { @@ -263,2 +242,5 @@ - } elseif ($action == 'classin' && $usercancreate) { - // Link to a project + } + + // Link to a project + elseif ($action == 'classin' && $usercancreate) + { @@ -266,2 +248,5 @@ - } elseif ($action == 'add' && $usercancreate) { - // Add order + } + + // Add order + elseif ($action == 'add' && $usercancreate) + { @@ -269 +254,2 @@ - $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')); + $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $selectedLines = GETPOST('toselect', 'array'); @@ -290,3 +276,3 @@ - $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->source = GETPOST('source_id', 'int'); + $object->note_private = GETPOST('note_private', 'none'); + $object->note_public = GETPOST('note_public', 'none'); + $object->source = GETPOST('source_id'); @@ -295,4 +281,3 @@ - $object->model_pdf = GETPOST('model'); - $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); - $object->deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha'); - $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); + $object->modelpdf = GETPOST('model'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); @@ -301,2 +286,2 @@ - $object->demand_reason_id = GETPOST('demand_reason_id', 'int'); - $object->delivery_date = $date_delivery; + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->date_livraison = $datelivraison; @@ -305,2 +290,2 @@ - $object->fk_delivery_address = GETPOST('fk_address', 'int'); - $object->contact_id = GETPOST('contactid', 'int'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->contactid = GETPOST('contactid'); @@ -312 +297,2 @@ - if (!$error) { + if (!$error) + { @@ -314,3 +300 @@ - if ($ret < 0) { - $error++; - } + if ($ret < 0) $error++; @@ -320 +304,2 @@ - if (!empty($origin) && !empty($originid)) { + if (!empty($origin) && !empty($originid)) + { @@ -323 +307,0 @@ - $regs = array(); @@ -351 +335,2 @@ - if (!$error) { + if (!$error) + { @@ -354 +339,2 @@ - if ($object_id > 0) { + if ($object_id > 0) + { @@ -362 +348,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -364 +351,2 @@ - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { @@ -372,4 +360,3 @@ - for ($i = 0; $i < $num; $i++) { - if (!in_array($lines[$i]->id, $selectedLines)) { - continue; // Skip unselected lines - } + for ($i = 0; $i < $num; $i++) + { + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines @@ -384 +371 @@ - if ($lines[$i]->date_debut_reel) { + if ($lines[$i]->date_debut_reel) @@ -386,2 +373 @@ - } - if ($lines[$i]->date_start) { + if ($lines[$i]->date_start) @@ -389 +374,0 @@ - } @@ -391 +376 @@ - if ($lines[$i]->date_fin_reel) { + if ($lines[$i]->date_fin_reel) @@ -393,2 +378 @@ - } - if ($lines[$i]->date_end) { + if ($lines[$i]->date_end) @@ -396,3 +380,2 @@ - } - - // Reset fk_parent_line for no child products and special product + + // Reset fk_parent_line for no child products and special product @@ -404 +387,2 @@ - if (method_exists($lines[$i], 'fetch_optionals')) { // For avoid conflicts if trigger used + if (method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if trigger used + { @@ -410,3 +394 @@ - if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) { - $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - } + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; @@ -415,25 +397,4 @@ - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $date_start, - $date_end, - $product_type, - $lines[$i]->rang, - $lines[$i]->special_code, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $label, - $array_options, - $lines[$i]->fk_unit, - $object->origin, - $lines[$i]->rowid + $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, + $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, + $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, + $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid @@ -459 +420 @@ - if (!empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) + if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) @@ -461,20 +422,20 @@ - $originforcontact = $object->origin; - $originidforcontact = $object->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { - $originforcontact=$srcobject->origin; - $originidforcontact=$srcobject->origin_id; - } - $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$db->escape($originforcontact)."'"; - - $resqlcontact = $db->query($sqlcontact); - if ($resqlcontact) - { - while($objcontact = $db->fetch_object($resqlcontact)) - { - //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n"; - $object->add_contact($objcontact->fk_socpeople, $objcontact->code); - } - } - else dol_print_error($resqlcontact); + $originforcontact = $object->origin; + $originidforcontact = $object->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + $originforcontact=$srcobject->origin; + $originidforcontact=$srcobject->origin_id; + } + $sqlcontact = "SELECT code, fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + + $resqlcontact = $db->query($sqlcontact); + if ($resqlcontact) + { + while($objcontact = $db->fetch_object($resqlcontact)) + { + //print $objcontact->code.'-'.$objcontact->fk_socpeople."\n"; + $object->add_contact($objcontact->fk_socpeople, $objcontact->code); + } + } + else dol_print_error($resqlcontact); @@ -488 +448,0 @@ - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -500 +460,2 @@ - if (!$error) { + if (!$error) + { @@ -501,0 +463,11 @@ + + // If some invoice's lines already known + $NBLINES = 8; + for ($i = 1; $i <= $NBLINES; $i++) { + if ($_POST['idprod'.$i]) { + $xid = 'idprod'.$i; + $xqty = 'qty'.$i; + $xremise = 'remise_percent'.$i; + $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); + } + } @@ -506,3 +478,5 @@ - if ($object_id > 0) { - if (GETPOST('contactid', 'int')) { - $result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external'); + if ($object_id > 0) + { + if (GETPOST('contactid')) + { + $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); @@ -520 +494,2 @@ - if ($object_id > 0 && !$error) { + if ($object_id > 0 && !$error) + { @@ -530 +505,4 @@ - } elseif ($action == 'classifybilled' && $usercancreate) { + } + + elseif ($action == 'classifybilled' && $usercancreate) + { @@ -536,2 +514,4 @@ - } elseif ($action == 'classifyunbilled' && $usercancreate) { - $ret = $object->classifyUnBilled($user); + } + elseif ($action == 'classifyunbilled' && $usercancreate) + { + $ret = $object->classifyUnBilled(); @@ -541,2 +521,4 @@ - } elseif ($action == 'setref_client' && $usercancreate) { - // Positionne ref commande client + } + + // Positionne ref commande client + elseif ($action == 'setref_client' && $usercancreate) { @@ -544 +526,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -547,3 +530,6 @@ - } elseif ($action == 'setremise' && $usercancreate) { - $result = $object->setDiscount($user, price2num(GETPOST('remise'), 2)); - if ($result < 0) { + } + + elseif ($action == 'setremise' && $usercancreate) { + $result = $object->set_remise($user, GETPOST('remise')); + if ($result < 0) + { @@ -552 +538,3 @@ - } elseif ($action == 'setabsolutediscount' && $usercancreate) { + } + + elseif ($action == 'setabsolutediscount' && $usercancreate) { @@ -560,2 +548,5 @@ - } elseif ($action == 'setdate' && $usercancreate) { - $date = dol_mktime(0, 0, 0, GETPOST('order_month', 'int'), GETPOST('order_day', 'int'), GETPOST('order_year', 'int')); + } + + elseif ($action == 'setdate' && $usercancreate) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); @@ -567,5 +558,7 @@ - } elseif ($action == 'setdate_livraison' && $usercancreate) { - $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')); - - $object->fetch($id); - $result = $object->setDeliveryDate($user, $date_delivery); + } + + elseif ($action == 'setdate_livraison' && $usercancreate) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + + $result = $object->set_date_livraison($user, $datelivraison); @@ -575 +568,3 @@ - } elseif ($action == 'setmode' && $usercancreate) { + } + + elseif ($action == 'setmode' && $usercancreate) { @@ -577 +572 @@ - if ($result < 0) { + if ($result < 0) @@ -579,3 +574,4 @@ - } - } elseif ($action == 'setmulticurrencycode' && $usercancreate) { - // Multicurrency Code + } + + // Multicurrency Code + elseif ($action == 'setmulticurrencycode' && $usercancreate) { @@ -583,4 +579,8 @@ - } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { - // Multicurrency rate - $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); - } elseif ($action == 'setavailability' && $usercancreate) { + } + + // Multicurrency rate + elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); + } + + elseif ($action == 'setavailability' && $usercancreate) { @@ -588 +588 @@ - if ($result < 0) { + if ($result < 0) @@ -590,2 +590,3 @@ - } - } elseif ($action == 'setdemandreason' && $usercancreate) { + } + + elseif ($action == 'setdemandreason' && $usercancreate) { @@ -593 +594 @@ - if ($result < 0) { + if ($result < 0) @@ -595,3 +596,4 @@ - } - } elseif ($action == 'setconditions' && $usercancreate) { - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha')); + } + + elseif ($action == 'setconditions' && $usercancreate) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); @@ -601 +603 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -605 +607 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) @@ -607 +608,0 @@ - } @@ -614,5 +615,8 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - } elseif ($action == 'set_incoterms' && isModEnabled('incoterm')) { - // Set incoterm + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } + + // Set incoterm + elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) + { @@ -623,2 +627,4 @@ - } elseif ($action == 'setbankaccount' && $usercancreate) { - // bank account + } + + // bank account + elseif ($action == 'setbankaccount' && $usercancreate) { @@ -629,2 +635,4 @@ - } elseif ($action == 'setshippingmethod' && $usercancreate) { - // shipping method + } + + // shipping method + elseif ($action == 'setshippingmethod' && $usercancreate) { @@ -635,2 +643,4 @@ - } elseif ($action == 'setwarehouse' && $usercancreate) { - // warehouse + } + + // warehouse + elseif ($action == 'setwarehouse' && $usercancreate) { @@ -641,21 +651,13 @@ - //} elseif ($action == 'setremisepercent' && $usercancreate) { - // $result = $object->setDiscount($user, price2num(GETPOST('remise_percent'), '', 2)); - //} elseif ($action == 'setremiseabsolue' && $usercancreate) { - // $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') { - // Define vat_rate - $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); - $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); - foreach ($object->lines as $line) { - $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); - } - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { - // Define remise_percent - $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); - $remise_percent = str_replace('*', '', $remise_percent); - foreach ($object->lines as $line) { - $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); - } - } elseif ($action == 'addline' && $usercancreate) { // Add a new line + } + + elseif ($action == 'setremisepercent' && $usercancreate) { + $result = $object->set_remise($user, GETPOST('remise_percent')); + } + + elseif ($action == 'setremiseabsolue' && $usercancreate) { + $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); + } + + // Add a new line + elseif ($action == 'addline' && $usercancreate) + { @@ -667,26 +669,6 @@ - $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); - - $price_ht = ''; - $price_ht_devise = ''; - $price_ttc = ''; - $price_ttc_devise = ''; - $pu_ht = ''; - $pu_ttc = ''; - $pu_ht_devise = ''; - $pu_ttc_devise = ''; - - if (GETPOST('price_ht') !== '') { - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - } - if (GETPOST('multicurrency_price_ht') !== '') { - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); - } - if (GETPOST('price_ttc') !== '') { - $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2); - } - if (GETPOST('multicurrency_price_ttc') !== '') { - $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2); - } - - $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); - if ($prod_entry_mode == 'free') { + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $price_ht = GETPOST('price_ht'); + $price_ht_devise = GETPOST('multicurrency_price_ht'); + $prod_entry_mode = GETPOST('prod_entry_mode'); + if ($prod_entry_mode == 'free') + { @@ -694 +676,4 @@ - } else { + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { @@ -696,15 +681,5 @@ - - if (getDolGlobalString('MAIN_DISABLE_FREE_LINES') && $idprod <= 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")), null, 'errors'); - $error++; - } - } - - $tva_tx = GETPOST('tva_tx', 'alpha'); - - $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); - - $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); - if (empty($remise_percent)) { - $remise_percent = 0; - } + $tva_tx = ''; + } + + $qty = GETPOST('qty'.$predef); + $remise_percent = (GETPOST('remise_percent'.$predef) != '' ? GETPOST('remise_percent'.$predef) : 0); @@ -723 +698 @@ - if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) { + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { @@ -727 +702 @@ - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { @@ -731 +706,2 @@ - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '' && $price_ttc === '' && $price_ttc_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for order. + if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for order. + { @@ -739,5 +715 @@ - if ($qty < 0) { - setEventMessages($langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; - } - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { @@ -748 +720 @@ - if (!$error && isModEnabled('variants') && $prod_entry_mode != 'free') { + if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') { @@ -755 +727,3 @@ - } else { + } + else + { @@ -762 +736 @@ - if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { @@ -766,3 +740 @@ - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - - $price_min = $price_min_ttc = 0; + $price_base_type = (GETPOST('price_base_type', 'alpha') ?GETPOST('price_base_type', 'alpha') : 'HT'); @@ -771,0 +744 @@ + // Ecrase $tva_tx par celui du produit @@ -773 +746 @@ - if (!empty($idprod) && $idprod > 0) { + if (!empty($idprod)) { @@ -780 +753 @@ - /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); @@ -782,3 +755 @@ - if (empty($tva_tx)) { - $tva_npr = 0; - }*/ + if (empty($tva_tx)) $tva_npr = 0; @@ -789 +759,0 @@ - $price_min_ttc = $prod->price_min_ttc; @@ -793 +763,2 @@ - if (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) { + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) + { @@ -797 +767,0 @@ - $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level]; @@ -799,6 +769,27 @@ - if (getDolGlobalString('PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL')) { // using this option is a bug. kept for backward compatibility - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) { - $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; - } - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) { - $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + } + } + // If price per customer + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr = 0; @@ -807,26 +798,2 @@ - } elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { - // If price per customer - require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; - - $prodcustprice = new ProductCustomerPrice($db); - - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetchAll('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_min = price($prodcustprice->lines[0]->price_min); - $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { - $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; - } - $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) { - $tva_npr = 0; - } - } - } else { + else + { @@ -835,3 +802,6 @@ - } elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY')) { - // If price per quantity - if ($prod->prices_by_qty[0]) { // yes, this product has some prices per quantity + } + // If price per quantity + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { + if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity + { @@ -842,3 +812,7 @@ - foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) { - if ($priceforthequantityarray['rowid'] != $pqp) { - continue; + foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) + { + if ($priceforthequantityarray['rowid'] != $pqp) continue; + // We found the price + if ($priceforthequantityarray['price_base_type'] == 'HT') + { + $pu_ht = $priceforthequantityarray['unitprice']; @@ -846,4 +820,2 @@ - // We found the price - if ($priceforthequantityarray['price_base_type'] == 'HT') { - $pu_ht = $priceforthequantityarray['unitprice']; - } else { + else + { @@ -856,3 +828,6 @@ - } elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) { - // If price per quantity and customer - if ($prod->prices_by_qty[$object->thirdparty->price_level]) { // yes, this product has some prices per quantity + } + // If price per quantity and customer + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + { + if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity + { @@ -862,3 +837,7 @@ - foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) { - if ($priceforthequantityarray['rowid'] != $pqp) { - continue; + foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) + { + if ($priceforthequantityarray['rowid'] != $pqp) continue; + // We found the price + if ($priceforthequantityarray['price_base_type'] == 'HT') + { + $pu_ht = $priceforthequantityarray['unitprice']; @@ -866,4 +845,2 @@ - // We found the price - if ($priceforthequantityarray['price_base_type'] == 'HT') { - $pu_ht = $priceforthequantityarray['unitprice']; - } else { + else + { @@ -878,5 +855,5 @@ - $tmpvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); - $tmpprodvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - - // Set unit price to use - if (!empty($price_ht) || $price_ht === '0') { + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); + $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); + + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? + if (!empty($price_ht)) { @@ -885,5 +862,4 @@ - } elseif (!empty($price_ttc) || $price_ttc === '0') { - $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } elseif ($tmpvat != $tmpprodvat) { - // Is this still used ? + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tmpvat != $tmpprodvat) { @@ -900 +876 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { @@ -903 +879 @@ - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) @@ -905,2 +881 @@ - } - if (empty($newlang)) { + if (empty($newlang)) @@ -908 +882,0 @@ - } @@ -914 +888 @@ - $desc = (!empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; @@ -919,10 +893,2 @@ - //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if ($product_desc==$desc && getDolGlobalString('PRODUIT_AUTOFILL_DESC')) { - $product_desc=''; - } - - if (!empty($product_desc) && getDolGlobalString('MAIN_NO_CONCAT_DESCRIPTION')) { - $desc = $product_desc; - } else { - $desc = dol_concatdesc($desc, $product_desc, '', getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION')); - } + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; + else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); @@ -931 +897 @@ - if (!getDolGlobalString('MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) { + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { @@ -934 +900 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { @@ -937 +903 @@ - if (empty($newlang) && GETPOST('lang_id', 'alpha')) { + if (empty($newlang) && GETPOST('lang_id', 'alpha')) @@ -939,2 +905 @@ - } - if (empty($newlang)) { + if (empty($newlang)) @@ -942 +906,0 @@ - } @@ -948 +912 @@ - if (!empty($prod->customcode)) { + if (!empty($prod->customcode)) @@ -950,2 +914 @@ - } - if (!empty($prod->customcode) && !empty($prod->country_code)) { + if (!empty($prod->customcode) && !empty($prod->country_code)) @@ -953,2 +916 @@ - } - if (!empty($prod->country_code)) { + if (!empty($prod->country_code)) @@ -956 +917,0 @@ - } @@ -958 +919 @@ - if (!empty($prod->customcode)) { + if (!empty($prod->customcode)) @@ -960,2 +921 @@ - } - if (!empty($prod->customcode) && !empty($prod->country_code)) { + if (!empty($prod->customcode) && !empty($prod->country_code)) @@ -963,2 +923 @@ - } - if (!empty($prod->country_code)) { + if (!empty($prod->country_code)) @@ -966 +924,0 @@ - } @@ -976 +934 @@ - $pu_ttc = price2num($price_ttc, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -979,3 +936,0 @@ - if (empty($tva_tx)) { - $tva_npr = 0; - } @@ -987,11 +942,5 @@ - $pu_ttc_devise = price2num($price_ttc_devise, 'MU'); - - if ($pu_ttc && !$pu_ht) { - $price_base_type = 'TTC'; - } - } - - $info_bits = 0; - if ($tva_npr) { - $info_bits |= 0x01; - } + } + + // Margin + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value @@ -1003,24 +952,9 @@ - // Margin - $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); - $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value - - // Prepare a price equivalent for minimum price check - $pu_equivalent = $pu_ht; - $pu_equivalent_ttc = $pu_ttc; - - $currency_tx = $object->multicurrency_tx; - - // Check if we have a foreign currency - // If so, we update the pu_equiv as the equivalent price in base currency - if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; - } - if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; - } - - // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one defined - /* - if ($pu_equivalent) { - $tmp = calcul_price_total(1, $pu_equivalent, 0, $tva_tx, -1, -1, 0, 'HT', $info_bits, $type); - $pu_equivalent_ttc = ... + $desc = dol_htmlcleanlastbr($desc); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessages($mesg, null, 'errors'); @@ -1028,21 +961,0 @@ - $tmp = calcul_price_total(1, $pu_equivalent_ttc, 0, $tva_tx, -1, -1, 0, 'TTC', $info_bits, $type); - $pu_equivalent_ht = ... - } - */ - - $desc = dol_htmlcleanlastbr($desc); - - // Check price is not lower than minimum - if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - $error++; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { - $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - $error++; - } - } - - if (!$error) { @@ -1050 +963 @@ - $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); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise); @@ -1054,3 +967,2 @@ - $object->fetch_thirdparty(); - - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -1060 +972 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) @@ -1062 +973,0 @@ - } @@ -1068 +979 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1108,2 +1019,7 @@ - } elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { - // Update a line + } + + /* + * Update a line + */ + elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) + { @@ -1115,2 +1031,4 @@ - - $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); + $pu_ht_devise = GETPOST('multicurrency_subprice'); @@ -1120 +1038 @@ - if (preg_match('/\*/', GETPOST('tva_tx'))) { + if (preg_match('/\*/', $vat_rate)) @@ -1122 +1039,0 @@ - } @@ -1125 +1041,0 @@ - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0); @@ -1129,33 +1044,0 @@ - $pu_ht = price2num(GETPOST('price_ht'), '', 2); - $pu_ttc = price2num(GETPOST('price_ttc'), '', 2); - - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); - $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); - - $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); - - // Prepare a price equivalent for minimum price check - $pu_equivalent = $pu_ht; - $pu_equivalent_ttc = $pu_ttc; - - $currency_tx = $object->multicurrency_tx; - - // Check if we have a foreign currency - // If so, we update the pu_equiv as the equivalent price in base currency - if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { - $pu_equivalent = $pu_ht_devise * $currency_tx; - } - if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { - $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; - } - - // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes - /* - if ($pu_equivalent) { - $tmp = calcul_price_total(1, $pu_equivalent, 0, $vat_rate, -1, -1, 0, 'HT', $info_bits, $type); - $pu_equivalent_ttc = ... - } else { - $tmp = calcul_price_total(1, $pu_equivalent_ttc, 0, $vat_rate, -1, -1, 0, 'TTC', $info_bits, $type); - $pu_equivalent_ht = ... - } - */ @@ -1179,5 +1062 @@ - if (!GETPOST('qty')) { - $special_code = 3; - } - - $remise_percent = GETPOST('remise_percent') != '' ? price2num(GETPOST('remise_percent'), '', 2) : 0; + if (!GETPOST('qty')) $special_code = 3; @@ -1194 +1073 @@ - if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !empty($object->thirdparty->price_level)) { + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) @@ -1196,5 +1074,0 @@ - } - $price_min_ttc = $product->price_min_ttc; - if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !empty($object->thirdparty->price_level)) { - $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level]; - } @@ -1204,13 +1078,3 @@ - // Check price is not lower than minimum - if ($usermustrespectpricemin) { - if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - $error++; - $action = 'editline'; - } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') { - $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - $error++; - $action = 'editline'; - } + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); + $error++; @@ -1226,8 +1090 @@ - $action = 'editline'; - } - } - - if ($qty < 0) { - setEventMessages($langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; - $action = 'editline'; + } @@ -1237,3 +1094,6 @@ - if (!$user->hasRight('margins', 'creer')) { - foreach ($object->lines as &$line) { - if ($line->id == GETPOST('lineid', 'int')) { + if (empty($user->rights->margins->creer)) + { + foreach ($object->lines as &$line) + { + if ($line->id == GETPOST('lineid')) + { @@ -1246,9 +1106 @@ - - $price_base_type = 'HT'; - $pu = $pu_ht; - if (empty($pu) && !empty($pu_ttc)) { - $pu = $pu_ttc; - $price_base_type = 'TTC'; - } - - $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); + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise); @@ -1257 +1109 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -1261 +1113 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) @@ -1263,2 +1115 @@ - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) @@ -1266 +1116,0 @@ - } @@ -1273 +1123 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1306 +1156 @@ - } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha')) { + } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { @@ -1309 +1159,4 @@ - } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { + } + + elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) + { @@ -1313,4 +1166,7 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -1320,2 +1176,4 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) { - if (!$idwarehouse || $idwarehouse == -1) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (!$idwarehouse || $idwarehouse == -1) + { @@ -1329,4 +1186,0 @@ - $locationTarget = ''; - - $db->begin(); - @@ -1334,30 +1188,2 @@ - if ($result >= 0) { - $error = 0; - $deposit = null; - - $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); - - if ( - GETPOST('generate_deposit', 'alpha') == 'on' && !empty($deposit_percent_from_payment_terms) - && isModEnabled('facture') && $user->hasRight('facture', 'creer') - ) { - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - - $date = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int')); - $forceFields = array(); - - if (GETPOSTISSET('date_pointoftax')) { - $forceFields['date_pointoftax'] = dol_mktime(0, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int')); - } - - $deposit = Facture::createDepositFromOrigin($object, $date, GETPOST('cond_reglement_id', 'int'), $user, 0, GETPOST('validate_generated_deposit', 'alpha') == 'on', $forceFields); - - if ($deposit) { - setEventMessage('DepositGenerated'); - $locationTarget = DOL_URL_ROOT . '/compta/facture/card.php?id=' . $deposit->id; - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - + if ($result >= 0) + { @@ -1365,64 +1191,2 @@ - if (! $error) { - $db->commit(); - - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($deposit) { - $deposit->fetch($deposit->id); // Reload to get new records - $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($locationTarget) { - header('Location: ' . $locationTarget); - exit; - } - } else { - $db->rollback(); - } - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } elseif ($action == 'confirm_modif' && $usercancreate) { - // Go back to draft status - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change = 0; - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); - } - - // Check parameters - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) { - if (!$idwarehouse || $idwarehouse == -1) { - $error++; - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action = ''; - } - } - - if (!$error) { - $result = $object->setDraft($user, $idwarehouse); - if ($result >= 0) { - // Define output language - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -1431,6 +1195,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; @@ -1441 +1201 @@ - $model = $object->model_pdf; + $model = $object->modelpdf; @@ -1446 +1206,3 @@ - } else { + } + else + { @@ -1450 +1212,52 @@ - } elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) { + } + + // Go back to draft status + elseif ($action == 'confirm_modif' && $usercancreate) { + $idwarehouse = GETPOST('idwarehouse'); + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + // Check parameters + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (!$idwarehouse || $idwarehouse == -1) + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); + $action = ''; + } + } + + if (!$error) { + $result = $object->setDraft($user, $idwarehouse); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } + } + + elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) { @@ -1455 +1268,4 @@ - } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) { + } + + elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) + { @@ -1459,4 +1275,7 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -1466,2 +1285,4 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) { - if (!$idwarehouse || $idwarehouse == -1) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (!$idwarehouse || $idwarehouse == -1) + { @@ -1483,2 +1304,3 @@ - if ($action == 'update_extras') { - $object->oldcopy = dol_clone($object, 2); + if ($action == 'update_extras') + { + $object->oldcopy = dol_clone($object); @@ -1487,6 +1309,5 @@ - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - - if (!$error) { + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + + if (!$error) + { @@ -1495 +1316,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -1501,3 +1323,10 @@ - if ($error) { - $action = 'edit_extras'; - } + if ($error) $action = 'edit_extras'; + } + + if ($action == 'set_thirdparty' && $usercancreate) + { + $object->fetch($id); + $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit(); @@ -1508,72 +1337,78 @@ - && $usercancreate - && $object->statut == Commande::STATUS_DRAFT - ) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); - - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { - if ($fromElement == 'commande') { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } elseif ($fromElement == 'facture') { - dol_include_once('/compta/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'FactureLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - $situation_percent = 100; - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; - - $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); - - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } - - if ($error) { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + && $usercancreate + && $object->statut == Commande::STATUS_DRAFT + ) + { + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); + + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } + elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + $situation_percent = 100; + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; + + $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); + + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } + else { + $error++; + } + } + + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } @@ -1586 +1421 @@ - $upload_dir = !empty($conf->commande->multidir_output[$object->entity]) ? $conf->commande->multidir_output[$object->entity] : $conf->commande->dir_output; + $upload_dir = $conf->commande->multidir_output[$object->entity]; @@ -1598,2 +1433,4 @@ - if (!$error && getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && $usercancreate) { - if ($action == 'addcontact') { + if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) + { + if ($action == 'addcontact') + { @@ -1602,2 +1439 @@ - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); + $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); @@ -1617,2 +1453,5 @@ - } elseif ($action == 'swapstatut') { - // bascule du statut d'un contact + } + + // bascule du statut d'un contact + elseif ($action == 'swapstatut') + { @@ -1620 +1459 @@ - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); + $result = $object->swapContactStatus(GETPOST('ligne')); @@ -1624,2 +1463,5 @@ - } elseif ($action == 'deletecontact') { - // Efface un contact + } + + // Efface un contact + elseif ($action == 'deletecontact') + { @@ -1643,7 +1485 @@ -$title = $object->ref." - ".$langs->trans('Card'); -if ($action == 'create') { - $title = $langs->trans("NewOrder"); -} -$help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; - -llxHeader('', $title, $help_url); +llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); @@ -1655,3 +1491 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } @@ -1660 +1494,2 @@ -if ($action == 'create' && $usercancreate) { +if ($action == 'create' && $usercancreate) +{ @@ -1664 +1499 @@ - if ($socid > 0) { + if ($socid > 0) @@ -1666,3 +1501,2 @@ - } - - //$remise_absolue = 0; + + $remise_absolue = 0; @@ -1671,5 +1504,0 @@ - - $cond_reglement_id = GETPOST('cond_reglement_id', 'int'); - $deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha'); - $mode_reglement_id = GETPOST('mode_reglement_id', 'int'); - $fk_account = GETPOST('fk_account', 'int'); @@ -1692,3 +1520,0 @@ - if (!$deposit_percent) { - $deposit_percent = $soc->deposit_percent; - } @@ -1701 +1527 @@ - /*if (!$dateorder) { + if (!$dateorder) { @@ -1703,2 +1529,2 @@ - $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : '') : $dateorder); - }*/ + $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ODER) ?-1 : '') : $dateorder); + } @@ -1709 +1535,2 @@ - } elseif ($element == 'propal') { + } + elseif ($element == 'propal') { @@ -1712 +1539,2 @@ - } elseif ($element == 'contract') { + } + elseif ($element == 'contract') { @@ -1721 +1549 @@ - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) @@ -1723 +1550,0 @@ - } @@ -1734,2 +1561 @@ - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); - $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : null)); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option @@ -1738 +1564 @@ - $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : 0); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); @@ -1742,13 +1568,10 @@ - //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); - //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - $dateorder = !getDolGlobalString('MAIN_AUTOFILL_DATE_ORDER') ? -1 : ''; - - $date_delivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : ''); - - if (isModEnabled("multicurrency")) { - if (!empty($objectsrc->multicurrency_code)) { - $currency_code = $objectsrc->multicurrency_code; - } - if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) { - $currency_tx = $objectsrc->multicurrency_tx; - } + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; + + $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; @@ -1763,6 +1586,7 @@ - } else { - $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id; - $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent; - $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id; - $fk_account = empty($soc->mode_reglement_id) ? $fk_account : $soc->fk_account; - $availability_id = 0; + } + else + { + $cond_reglement_id = $soc->cond_reglement_id; + $mode_reglement_id = $soc->mode_reglement_id; + $fk_account = $soc->fk_account; + $availability_id = $soc->availability_id; @@ -1770 +1594 @@ - $warehouse_id = $soc->fk_warehouse; + $warehouse_id = $soc->warehouse_id; @@ -1772,7 +1596,5 @@ - //$remise_percent = $soc->remise_percent; - //$remise_absolue = 0; - $dateorder = !getDolGlobalString('MAIN_AUTOFILL_DATE_ORDER') ? -1 : ''; - - if (isModEnabled("multicurrency") && !empty($soc->multicurrency_code)) { - $currency_code = $soc->multicurrency_code; - } + $remise_percent = $soc->remise_percent; + $remise_absolue = 0; + $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; + + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1782,29 +1603,0 @@ - } - - // If form was posted (but error returned), we must reuse the value posted in priority (standard Dolibarr behaviour) - if (!GETPOST('changecompany')) { - if (GETPOSTISSET('cond_reglement_id')) { - $cond_reglement_id = GETPOST('cond_reglement_id', 'int'); - } - if (GETPOSTISSET('deposit_percent')) { - $deposit_percent = price2num(GETPOST('deposit_percent', 'alpha')); - } - if (GETPOSTISSET('mode_reglement_id')) { - $mode_reglement_id = GETPOST('mode_reglement_id', 'int'); - } - if (GETPOSTISSET('cond_reglement_id')) { - $fk_account = GETPOST('fk_account', 'int'); - } - } - - // Warehouse default if null - if ($soc->fk_warehouse > 0) { - $warehouse_id = $soc->fk_warehouse; - } - if (isModEnabled('stock') && empty($warehouse_id) && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) { - if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE')) { - $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; - } - if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER')) { - $warehouse_id = $user->fk_warehouse; - } @@ -1816 +1609 @@ - print ''; // will be set to 1 by javascript so we know post is done after a company change + print ''."\n"; @@ -1820,9 +1613,158 @@ - print ''; - if (!empty($currency_tx)) { - print ''; - } - - print dol_get_fiche_head(''); - - // Call Hook tabContentCreateOrder - $parameters = array(); + if (!empty($currency_tx)) print ''; + + dol_fiche_head(''); + + print ''; + + // Reference + print ''; + + // Reference client + print ''; + else + print ''; + print ''; + + // Thirdparty + print ''; + print ''; + if ($socid > 0) { + print ''; + } else { + print ''; + } + print ''."\n"; + + // Contact of order + if ($socid > 0) { + // Contacts (ask contact only if thirdparty already defined). + print "'; + + // Ligne info remises tiers + print ''; + } + + // Date + print ''; + + // Delivery date planed + print ""; + + // terms of the settlement + print ''; + + // Mode de reglement + print ''; + + // Bank Account + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) + { + print ''; + } + + // Delivery delay + print ''; + + // Shipping Method + if (!empty($conf->expedition->enabled)) { + print ''; + } + + // Warehouse + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + print ''; + } + + // What trigger creation + print ''; + + // TODO How record was recorded OrderMode (llx_c_input_method) + + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + print ''; + print ''; + print ''; + } + + // Incoterms + if (!empty($conf->incoterm->enabled)) + { + print ''; + print ''; + print ''; + } + + // Other attributes + $parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid); @@ -1830 +1772,2 @@ - $reshook = $hookmanager->executeHooks('tabContentCreateOrder', $parameters, $object, $action); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); + print $hookmanager->resPrint; @@ -1832,15 +1775,23 @@ - print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; + if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && !empty($origin) && !empty($originid)) + print '
'.$langs->trans('Customer').''; + print $soc->getNomUrl(1); + print ''; + print ''; + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + // reload page to retrieve customer informations + if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) + { + print ''; + } + print ' '; + print '
".$langs->trans("DefaultContact").''; + $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); + print '
'.$langs->trans('Discounts').''; + + $absolute_discount = $soc->getAvailableDiscounts(); + + $thirdparty = $soc; + $discount_type = 0; + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; + + print '
'.$langs->trans('Date').''; + print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date + print '
".$langs->trans("DateDeliveryPlanned").''; + if (empty($datedelivery)) + { + if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + else $datedelivery = empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY) ?-1 : ''; + } + print $form->selectDate($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1); + print "
'.$langs->trans('PaymentConditionsShort').''; + $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); + print '
'.$langs->trans('PaymentMode').''; + $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); + print '
'.$langs->trans('BankAccount').''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print '
'.$langs->trans('AvailabilityPeriod').''; + $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); + print '
'.$langs->trans('SendingMethod').''; + print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); + print '
'.$langs->trans('Warehouse').''; + print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1); + print '
'.$langs->trans('Channel').''; + $form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1); + print '
'.$langs->trans("Project").''; + $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print ' id).'">'; + print '
'; + $incoterm_id = GETPOST('incoterm_id'); + $incoterm_location = GETPOST('location_incoterms'); + if (empty($incoterm_id)) + { + $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms); + $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); + } + print $form->select_incoterms($incoterm_id, $incoterm_location); + print '
'; - - // Reference - print ''; - - // Reference client - print ''; - } else { - print ''; - } - print ''; - - // Thirdparty + if (!empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) { + // copy from thirdparty + $tpExtrafields = new Extrafields($db); + $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); + if ($soc->fetch_optionals() > 0) { + $object->array_options = array_merge($object->array_options, $soc->array_options); + } + }; + + print $object->showOptionals($extrafields, 'edit', $parameters); + } + + // Template to use by default + print ''; + print '"; + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { @@ -1848,55 +1799,3 @@ - print ''; - if ($socid > 0) { - print ''; - } else { - print ''; - } - print ''."\n"; - - // Contact of order - if ($socid > 0) { - // Contacts (ask contact only if thirdparty already defined). - print "'; - - // Ligne info remises tiers - print ''; - } - - // Date - print ''; + print ''; - print '\n"; - print ''; - - // Delivery delay - print ''; + print ''; + print ''; + + // Note private + if (empty($user->socid)) { + print ''; + print ''; + print ''; - - // Payment mode - print ''; - - // Bank Account - if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled("banque")) { - print ''; - } - - // Shipping Method - if (isModEnabled('expedition')) { - print ''; - } - - // Warehouse - if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) { - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - print ''; - } - - // Source / Channel - What trigger creation - print ''; - - // TODO How record was recorded OrderMode (llx_c_input_method) - - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - print ''; - print ''; - print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; - print ''; - } - - // Other attributes - $parameters = array(); - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { - $parameters['objectsrc'] = $objectsrc; - } - $parameters['socid'] = $socid; - - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); - print $hookmanager->resPrint; - if (empty($reshook)) { - if (getDolGlobalString('THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER') && !empty($soc->id)) { - // copy from thirdparty - $tpExtrafields = new ExtraFields($db); - $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); - if ($soc->fetch_optionals() > 0) { - $object->array_options = array_merge($object->array_options, $soc->array_options); - } - } - - print $object->showOptionals($extrafields, 'create', $parameters); - } - - // Template to use by default - print ''; - print '"; - - // Multicurrency - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - - // Note public - print ''; - print ''; - print ''; - - // Note private - if (empty($user->socid)) { - print ''; - print ''; - print ''; - } - - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { - // TODO for compatibility - if ($origin == 'contrat') { - // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva - //$objectsrc->remise_absolue = $remise_absolue; - //$objectsrc->remise_percent = $remise_percent; - $objectsrc->update_price(1); - } - - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - - switch ($classname) { - case 'Propal': - $newclassname = 'CommercialProposal'; - break; - case 'Commande': - $newclassname = 'Order'; - break; - case 'Expedition': - $newclassname = 'Sending'; - break; - case 'Contrat': - $newclassname = 'Contract'; - break; - default: - $newclassname = $classname; - } - - print ''; - - // Amount - print ''; - print '"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1 RE - print '"; - } - - if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2 IRPF - print '"; - } - - print '"; - - if (isModEnabled("multicurrency")) { - print ''; - print '"; - print '"; - } - } - + } + + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) + { + // TODO for compatibility + if ($origin == 'contrat') { + // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva + $objectsrc->remise_absolue = $remise_absolue; + $objectsrc->remise_percent = $remise_percent; + $objectsrc->update_price(1); + } + + print "\n"; @@ -2112,7 +1839,58 @@ - - print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; - if (getDolGlobalString('MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER') && !empty($origin) && !empty($originid)) { - print '
'.$langs->trans('DefaultModel').''; + include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; + $liste = ModelePDFCommandes::liste_modeles($db); + print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); + print "
'.$langs->trans('Customer').''; - print $soc->getNomUrl(1, 'customer'); - print ''; - print ''; - $filter = '((s.client:IN:1,2,3) AND (s.status:=:1))'; - print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); - // reload page to retrieve customer informations - if (!getDolGlobalString('RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED')) { - print ''; - } - print ' '; - print '
".$langs->trans("DefaultContact").''; - print img_picto('', 'contact', 'class="pictofixedwidth"'); - print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, !empty($srccontactslist) ? $srccontactslist : "", '', 1, 'maxwidth200 widthcentpercentminusx'); - print '
'.$langs->trans('Discounts').''; - - $absolute_discount = $soc->getAvailableDiscounts(); - - $thirdparty = $soc; - $discount_type = 0; - $backtopage = $_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.urlencode(GETPOST('origin')).'&originid='.urlencode(GETPOSTINT('originid')); - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - - print '
'.$langs->trans('Date').''; - print img_picto('', 'action', 'class="pictofixedwidth"'); - print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date + print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); @@ -1904,14 +1803,21 @@ - - // Date delivery planned - print '
'.$langs->trans("DateDeliveryPlanned").''; - $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date); - print img_picto('', 'action', 'class="pictofixedwidth"'); - print $form->selectDate($date_delivery ? $date_delivery : -1, 'liv_', 1, 1, 1); - print "
'.$langs->trans('AvailabilityPeriod').''; - print img_picto('', 'clock', 'class="pictofixedwidth"'); - $form->selectAvailabilityDelay((GETPOSTISSET('availability_id') ? GETPOST('availability_id') : $availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); + } + + // Note public + print '
'.$langs->trans('NotePublic').''; + + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // print ''; + print '
'.$langs->trans('NotePrivate').''; + + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + // print ''; @@ -1919,192 +1825,13 @@ - - // Terms of payment - print '
'.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'payment', 'class="pictofixedwidth"'); - print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); - print '
'.$langs->trans('PaymentMode').''; - print img_picto('', 'bank', 'class="pictofixedwidth"'); - print $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); - print '
'.$langs->trans('BankAccount').''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); - print '
'.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); - $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'); - print '
'.$langs->trans('Warehouse').''; - 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'); - print '
'.$langs->trans('Source').''; - print img_picto('', 'question', 'class="pictofixedwidth"'); - $form->selectInputReason((GETPOSTISSET('demand_reason_id') ? GETPOST('demand_reason_id') : $demand_reason_id), 'demand_reason_id', '', 1, 'maxwidth200 widthcentpercentminusx'); - print '
'.$langs->trans("Project").''; - 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'); - print ' id).'">'; - print '
'; - $incoterm_id = GETPOST('incoterm_id'); - $location_incoterms = GETPOST('location_incoterms'); - if (empty($incoterm_id)) { - $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms); - $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); - } - print img_picto('', 'incoterm', 'class="pictofixedwidth"'); - print $form->select_incoterms($incoterm_id, $location_incoterms); - print '
'.$langs->trans('DefaultModel').''; - include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $liste = ModelePDFCommandes::liste_modeles($db); - $preselected = $conf->global->COMMANDE_ADDON_PDF; - print img_picto('', 'pdf', 'class="pictofixedwidth"'); - print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); - print "
'.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; - print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET('multicurrency_code') && !GETPOST('changecompany')) ? GETPOST('multicurrency_code') : $currency_code), 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); - print '
'.$langs->trans('NotePublic').''; - - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%'); - print $doleditor->Create(1); - // print ''; - print '
'.$langs->trans('NotePrivate').''; - - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%'); - print $doleditor->Create(1); - // print ''; - print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc)."
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'; - } - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("CreateDraft"); + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + + switch ($classname) { + case 'Propal': + $newclassname = 'CommercialProposal'; + break; + case 'Commande': + $newclassname = 'Order'; + break; + case 'Expedition': + $newclassname = 'Sending'; + break; + case 'Contrat': + $newclassname = 'Contract'; + break; + default: + $newclassname = $classname; + } + + print ''.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).''; + + // Amount + print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht).''; + print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva).""; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE + { + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1).""; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF + { + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2).""; + } + + print ''.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc).""; + + if (!empty($conf->multicurrency->enabled)) + { + print ''.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).''; + print ''.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).""; + print ''.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).""; + } + } + + print ''; + + dol_fiche_end(); + + // Button "Create Draft" + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -2125 +1902,0 @@ - print '
'; @@ -2131,4 +1908,3 @@ - print '
'; - } - - print ''; + } + + print ''; @@ -2148 +1923,0 @@ - $object->fetch_thirdparty(); @@ -2152 +1927 @@ - print dol_get_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); + dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); @@ -2162 +1937,2 @@ - if ($action == 'validate') { + if ($action == 'validate') + { @@ -2165 +1941 @@ - if ($ref == 'PROV' || $ref == '') { + if ($ref == 'PROV') { @@ -2167,4 +1942,0 @@ - if (empty($numref)) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } @@ -2176 +1948,2 @@ - if (isModEnabled('notification')) { + if (!empty($conf->notification->enabled)) + { @@ -2184,4 +1957,7 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -2191 +1967,2 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { @@ -2196,3 +1973 @@ - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -2203 +1978 @@ - 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)) + 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)) @@ -2207,127 +1982 @@ - // mandatoryPeriod - $nbMandated = 0; - foreach ($object->lines as $line) { - $res = $line->fetch_product(); - if ($res > 0) { - if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) { - $nbMandated++; - break; - } - } - } - if ($nbMandated > 0) { - $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; - } - - if (getDolGlobalInt('SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) { - // This is a hidden option: - // Suggestion to create invoice during order validation is not enabled by default. - // Such choice should be managed by the workflow module and trigger. This option generates conflicts with some setup. - // It may also break step of creating an order when invoicing must be done from proposals and not from orders - $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); - - if (!empty($deposit_percent_from_payment_terms) && isModEnabled('facture') && $user->hasRight('facture', 'creer')) { - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - - $object->fetchObjectLinked(); - - $eligibleForDepositGeneration = true; - - if (array_key_exists('facture', $object->linkedObjects)) { - foreach ($object->linkedObjects['facture'] as $invoice) { - if ($invoice->type == Facture::TYPE_DEPOSIT) { - $eligibleForDepositGeneration = false; - break; - } - } - } - - if ($eligibleForDepositGeneration && array_key_exists('propal', $object->linkedObjects)) { - foreach ($object->linkedObjects['propal'] as $proposal) { - $proposal->fetchObjectLinked(); - - if (array_key_exists('facture', $proposal->linkedObjects)) { - foreach ($proposal->linkedObjects['facture'] as $invoice) { - if ($invoice->type == Facture::TYPE_DEPOSIT) { - $eligibleForDepositGeneration = false; - break 2; - } - } - } - } - } - - if ($eligibleForDepositGeneration) { - $formquestion[] = array( - 'type' => 'checkbox', - 'tdclass' => '', - 'name' => 'generate_deposit', - 'label' => $form->textwithpicto($langs->trans('GenerateDeposit', $object->deposit_percent), $langs->trans('DepositGenerationPermittedByThePaymentTermsSelected')) - ); - - $formquestion[] = array( - 'type' => 'date', - 'tdclass' => 'fieldrequired showonlyifgeneratedeposit', - 'name' => 'datef', - 'label' => $langs->trans('DateInvoice'), - 'value' => dol_now(), - 'datenow' => true - ); - - if (getDolGlobalString('INVOICE_POINTOFTAX_DATE')) { - $formquestion[] = array( - 'type' => 'date', - 'tdclass' => 'fieldrequired showonlyifgeneratedeposit', - 'name' => 'date_pointoftax', - 'label' => $langs->trans('DatePointOfTax'), - 'value' => dol_now(), - 'datenow' => true - ); - } - - - $paymentTermsSelect = $form->getSelectConditionsPaiements(0, 'cond_reglement_id', -1, 0, 0, 'minwidth200'); - - $formquestion[] = array( - 'type' => 'other', - 'tdclass' => 'fieldrequired showonlyifgeneratedeposit', - 'name' => 'cond_reglement_id', - 'label' => $langs->trans('PaymentTerm'), - 'value' => $paymentTermsSelect - ); - - $formquestion[] = array( - 'type' => 'checkbox', - 'tdclass' => 'showonlyifgeneratedeposit', - 'name' => 'validate_generated_deposit', - 'label' => $langs->trans('ValidateGeneratedDeposit') - ); - - $formquestion[] = array( - 'type' => 'onecolumn', - 'value' => ' - - ' - ); - } - } - } - - if (!$error) { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); - } + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); @@ -2337 +1986,2 @@ - if ($action == 'modif') { + if ($action == 'modif') + { @@ -2339,4 +1989,7 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -2347 +2000,2 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { @@ -2352,3 +2006 @@ - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -2359 +2011 @@ - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ? GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) @@ -2376 +2028,2 @@ - if ($action == 'cancel') { + if ($action == 'cancel') + { @@ -2378,4 +2031,7 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -2386 +2042,2 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER') && $qualified_for_stock_change) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { @@ -2391,3 +2048 @@ - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -2398 +2053 @@ - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ? GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) @@ -2402 +2057 @@ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("Cancel"), $text, 'confirm_cancel', $formquestion, 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); @@ -2406 +2061,2 @@ - if ($action == 'ask_deleteline') { + if ($action == 'ask_deleteline') + { @@ -2412 +2067,0 @@ - $filter = '(s.client:IN:1,2,3)'; @@ -2415 +2070 @@ - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', $filter, '', 0, 0, null, 0, 'maxwidth300')) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) @@ -2424,5 +2079,2 @@ - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; @@ -2436,0 +2089 @@ + @@ -2441 +2094 @@ - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); @@ -2443,4 +2096,2 @@ - $morehtmlref .= '
'.$soc->getNomUrl(1, 'customer'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; @@ -2448 +2099,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -2450,7 +2102,16 @@ - $morehtmlref .= '
'; - if ($usercancreate) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($usercancreate) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } @@ -2461,4 +2122,5 @@ - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; @@ -2473,69 +2135,16 @@ - // Call Hook tabContentViewOrder - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentViewOrder', $parameters, $object, $action); - if (empty($reshook)) { - print '
'; - print '
'; - print '
'; - - print ''; - - if ($soc->outstanding_limit) { - // Outstanding Bill - print ''; - print ''; - } - - // Relative and absolute discounts - if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { - $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; - } - - $addrelativediscount = ''.$langs->trans("EditRelativeDiscounts").''; - $addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; - $addcreditnote = ''.$langs->trans("AddCreditNote").''; - - print ''; - - // Date - print ''; - - // Margin Infos - if (isModEnabled('margin')) { - $formmargin->displayMarginInfos($object); - } - - - print ''; - print ''; // Close fichecenter - - print '

'; - - if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - if (getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - /* - * Lines - */ - - // Get object lines - $result = $object->getLinesArray(); - - // Add products/services form - //$forceall = 1; - global $inputalsopricewithtax; - $inputalsopricewithtax = 1; - - print ' - - - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - print '
'; - print $langs->trans('OutstandingBill'); - print ''; - $arrayoutstandingbills = $soc->getOutstandingBills(); - print price($arrayoutstandingbills['opened']).' / '; - print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); - print '
'.$langs->trans('Discounts').''; - - $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); - $absolute_discount = price2num($absolute_discount, 'MT'); - $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - - $thirdparty = $soc; - $discount_type = 0; - $backtopage = $_SERVER["PHP_SELF"].'?id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - - print '
'; - $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; - print $form->editfieldkey("Date", 'date', '', $object, $editenable); - print ''; - if ($action == 'editdate') { - print '
'; - print ''; - print ''; - print ''; - print $form->selectDate($object->date, 'order_', '', '', '', "setdate"); - print ''; - print '
'; - } else { - print $object->date ? dol_print_date($object->date, 'day') : ' '; - if ($object->hasDelay() && empty($object->delivery_date)) { // If there is a delivery date planned, warning should be on this date - print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); - } - } + + print '
'; + print '
'; + print '
'; + + print ''; + + if ($soc->outstanding_limit) + { + // Outstanding Bill + print ''; + + // Date + print ''; + print ''; + + // Delivery date planed + print ''; + print ''; + + // Shipping Method + if (!empty($conf->expedition->enabled)) { @@ -2548,10 +2228,4 @@ - print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); - print ''; - - // Shipping Method - if (isModEnabled('expedition')) { - print ''; - print ''; - } - - // Warehouse - if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) { - $langs->load('stocks'); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - print ''; - print ''; - } - - // Source reason (why we have an order) + } + + // Warehouse + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + $langs->load('stocks'); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); @@ -2615,4 +2246,4 @@ - print $form->editfieldkey("Source", 'demandreason', '', $object, $editenable); - print ''; + print ''; + } + + // Terms of payment + print ''; + + print ''; + + // Mode of payment + print ''; + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + print ''; + } + } + + // Delivery delay + print ''; + + // Source reason (why we have an ordrer) + print ''; + + // TODO Order mode (how we receive order). Not yet implemented + /* + print ''; + */ + + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + if ($totalWeight) { + print ''; + print ''; + } + if ($totalVolume) { + print ''; + print ''; + } + + // TODO How record was recorded OrderMode (llx_c_input_method) + + // Incoterms + if (!empty($conf->incoterm->enabled)) { @@ -2627,7 +2384 @@ - print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); - print ''; - - // Mode of payment + print ''; + } + + // Bank Account + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { @@ -2641,4 +2402,4 @@ - print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); - print ''; - - // Multicurrency - if (isModEnabled("multicurrency")) { - // Multicurrency code - print ''; - print ''; - - // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { - print ''; - print ''; - } - } - - // TODO Order mode (how we receive order). Not yet implemented - /* - print ''; - */ - - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - if ($totalWeight) { - print ''; - print ''; - } - if ($totalVolume) { - print ''; - print ''; - } - - // TODO How record was recorded OrderMode (llx_c_input_method) - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; - } - - // Bank Account - if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled("banque")) { - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; + print $langs->trans('OutstandingBill'); + print ''; + $arrayoutstandingbills = $soc->getOutstandingBills(); + print price($arrayoutstandingbills['opened']).' / '; + print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); @@ -2544,2 +2153,73 @@ - - // Delivery date planed + } + + // Relative and absolute discounts + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } else { + $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; + } + + $addrelativediscount = ''.$langs->trans("EditRelativeDiscounts").''; + $addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; + $addcreditnote = ''.$langs->trans("AddCreditNote").''; + + print '
'.$langs->trans('Discounts').''; + + $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); + + $thirdparty = $soc; + $discount_type = 0; + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; + + print '
'; + $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; + print $form->editfieldkey("Date", 'date', '', $object, $editenable); + print ''; + if ($action == 'editdate') { + print '
'; + print ''; + print ''; + print $form->selectDate($object->date, 'order_', '', '', '', "setdate"); + print ''; + print '
'; + } else { + print $object->date ? dol_print_date($object->date, 'day') : ' '; + if ($object->hasDelay()) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } + } + print '
'; + $editenable = $usercancreate; + print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); + print ''; + if ($action == 'editdate_livraison') { + print '
'; + print ''; + print ''; + print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison"); + print ''; + print '
'; + } else { + print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; + if ($object->hasDelay() && !empty($object->date_livraison)) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } + } + print '
'; - if ($action == 'editdate_livraison') { - print '
'; - print ''; - print ''; - print ''; - print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); - print ''; - print '
'; + print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); + print '
'; + if ($action == 'editshippingmethod') { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); @@ -2559,4 +2233 @@ - print $object->delivery_date ? dol_print_date($object->delivery_date, 'dayhour') : ' '; - if ($object->hasDelay() && !empty($object->delivery_date)) { - print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); - } + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); @@ -2566,47 +2237,7 @@ - - // Delivery delay - print '
'; - $editenable = $usercancreate; - print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); - print ''; - if ($action == 'editavailability') { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); - } else { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); - } - print '
'; - $editenable = $usercancreate; - print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); - print ''; - if ($action == 'editshippingmethod') { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); - } else { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); - } - print '
'; - $editenable = $usercancreate; - print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); - print ''; - if ($action == 'editwarehouse') { - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); - } else { - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); - } - print '
'; - if ($action == 'editdemandreason') { - $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); + print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); + print ''; + if ($action == 'editwarehouse') { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); @@ -2620 +2251,45 @@ - $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); + } + print '
'; + $editenable = $usercancreate; + print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); + print ''; + if ($action == 'editconditions') { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); + } + print '
'; + $editenable = $usercancreate; + print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); + print ''; + if ($action == 'editmode') { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + } else { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); + } + print '
'; + $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; + print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); + print ''; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); @@ -2624 +2299,83 @@ - // Terms of payment + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print '
'; + $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT; + print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); + print ''; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } + } + print '
'; + $editenable = $usercancreate; + print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); + print ''; + if ($action == 'editavailability') { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); + } else { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); + } + print '
'; + $editenable = $usercancreate; + print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); + print ''; + if ($action == 'editdemandreason') { + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); + } else { + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); + } + print '
'; + $editenable = $usercancreate; + print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable); + print ''; + if ($action == 'editinputmode') { + $form->formInputMode($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->source, 'input_mode_id', 1); + } else { + $form->formInputMode($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->source, 'none'); + } + print '
'.$langs->trans("CalculatedWeight").''; + 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'); + print '
'.$langs->trans("CalculatedVolume").''; + 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'); + print '
'; - if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1, '', 1, $object->deposit_percent); - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1, '', 1, $object->deposit_percent); - } + print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); @@ -2635,4 +2386,14 @@ - - print '
'; + if ($action != 'editincoterm') + { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } + else + { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } + print '
'; - if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); + print ''; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); @@ -2646,128 +2407,3 @@ - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); - } - print '
'; - $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; - print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); - print ''; - if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); - } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); - } - print '
'; - $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT; - print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); - print ''; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if ($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; - } - } - print '
'; - $editenable = $usercancreate; - print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable); - print ''; - if ($action == 'editinputmode') { - $form->formInputMode($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->source, 'input_mode_id', 1); - } else { - $form->formInputMode($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->source, 'none'); - } - print '
'.$langs->trans("CalculatedWeight").''; - 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'); - print '
'.$langs->trans("CalculatedVolume").''; - 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'); - print '
'; - $editenable = $usercancreate; - print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); - print ''; - if ($action != 'editincoterm') { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } - print '
'; - $editenable = $usercancreate; - print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); - print ''; - if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); - } - print '
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - $alert = ''; - if (getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT') && $object->total_ht < $object->thirdparty->order_min_amount) { - $alert = ' ' . img_warning($langs->trans('OrderMinAmount') . ': ' . price($object->thirdparty->order_min_amount)); - } - - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - } + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ''; @@ -2775,8 +2411,19 @@ - - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount VAT - print ''; - } + } + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) + { + // Multicurrency Amount HT + print ''; + print ''; @@ -2785,124 +2432,111 @@ - // Amount Local Taxes - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); - - print ''; - } - print ''; - } - - // Amount Local Taxes - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); - - print ''; - } - print ''; - } - - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount TTC - print ''; - } - print ''."\n"; - - print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ttc, 1, '', 1, -1, -1, $object->multicurrency_code) . '
'; - - // Statut - //print '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
'; - - // Show object lines - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); - } - - /* - * Form to add new line - */ - if ($object->statut == Commande::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { - if ($action != 'editline') { - // Add free products/services - - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - if (empty($reshook)) { - $object->formAddObjectLine(1, $mysoc, $soc); - } - } else { - $parameters = array(); - $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); - } - } - print '
'; - print '
'; - - print "\n"; - } - - print dol_get_fiche_end(); + // Multicurrency Amount VAT + print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; + + // Multicurrency Amount TTC + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; + } + + // Total HT + $alert = ''; + if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { + $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); + } + print ''.$langs->trans('AmountHT').''; + print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.''; + + // Total VAT + print ''.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).''; + + // Amount Local Taxes + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 + { + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; + print ''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).''; + } + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF + { + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; + print ''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).''; + } + + // Total TTC + print ''.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; + + // Statut + //print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; + + print ''; + + // Margin Infos + if (!empty($conf->margin->enabled)) { + $formmargin->displayMarginInfos($object); + } + + + print '
'; + print ''; + print ''; // Close fichecenter + + print '

'; + + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + /* + * Lines + */ + $result = $object->getLinesArray(); + + print '
+ + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + print ''; + + // Show object lines + if (!empty($object->lines)) + $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + + $numlines = count($object->lines); + + /* + * Form to add new line + */ + if ($object->statut == Commande::STATUS_DRAFT && $usercancreate && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add free products/services + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + // Note that $action and $object may be modified by hook + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); + } + } + print '
'; + print '
'; + + print "
\n"; + + dol_fiche_end(); @@ -2920,2 +2553,0 @@ - $numlines = count($object->lines); - @@ -2924 +2556 @@ - print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); + print ''; @@ -2929 +2561 @@ - if ($object->statut > Commande::STATUS_DRAFT || getDolGlobalString('COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS')) { + if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { @@ -2931,3 +2563,30 @@ - print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER["PHP_SELF"].'?action=presend&token='.newToken().'&id='.$object->id.'&mode=init#formmailbeforetitle', ''); - } else { - print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER['PHP_SELF']. '#', '', false); + print ''.$langs->trans('SendMail').''; + } else + print ''.$langs->trans('SendMail').''; + } + } + + // Valid + if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || !empty($conf->global->ORDER_ENABLE_NEGATIVE)) && $numlines > 0 && $usercanvalidate) + { + print ''.$langs->trans('Validate').''; + } + // Edit + if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { + print ''.$langs->trans('Modify').''; + } + // Create event + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) + { + // Add hidden condition because this is not a + // "workflow" action so should appears somewhere else on + // page. + print '' . $langs->trans("AddAction") . ''; + }*/ + + // Create a purchase order + if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) + { + if (!empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if ($usercancreatepurchaseorder) { + print ''.$langs->trans("AddPurchaseOrder").''; @@ -2938,24 +2596,0 @@ - // Valid - if ($object->statut == Commande::STATUS_DRAFT && ($object->total_ttc >= 0 || getDolGlobalString('ORDER_ENABLE_NEGATIVE')) && $usercanvalidate) { - if ($numlines > 0) { - print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, $object->id, 1); - } else { - print dolGetButtonAction($langs->trans("ErrorObjectMustHaveLinesToBeValidated", $object->ref), $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, $object->id, 0); - } - } - // Edit - if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { - print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=modif&token='.newToken().'&id='.$object->id, ''); - } - - $arrayforbutaction = array(); - // Create a purchase order - if (getDolGlobalInt('COMMANDE_DISABLE_ADD_PURCHASE_ORDER') == 0) { - $arrayforbutaction[] = array('lang'=>'orders', 'enabled'=>(isModEnabled("supplier_order") && $object->statut > Commande::STATUS_DRAFT ), 'perm'=>$usercancreatepurchaseorder, 'label'=>'AddPurchaseOrder', 'url'=>'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id); - } - /*if (isModEnabled("supplier_order") && $object->statut > Commande::STATUS_DRAFT && $object->getNbOfServicesLines() > 0) { - if ($usercancreatepurchaseorder) { isModEnabled("supplier_order") && $object->statut > Commande::STATUS_DRAFT && $object->getNbOfServicesLines() > 0 - print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id, ''); - } - }*/ - @@ -2963,2 +2598 @@ - $arrayforbutaction[] = array('lang'=>'interventions', 'enabled'=>(isModEnabled("ficheinter") && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0), 'perm'=>$user->hasRight('ficheinter', 'creer'), 'label'=>'AddIntervention', 'url'=>'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid); - /*if (isModEnabled('ficheinter')) { + if ($conf->ficheinter->enabled) { @@ -2968,2 +2602,2 @@ - if ($user->hasRight('ficheinter', 'creer')) { - print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); + if ($user->rights->ficheinter->creer) { + print ''.$langs->trans('AddIntervention').''; @@ -2971 +2605 @@ - print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false); + print ''.$langs->trans('AddIntervention').''; @@ -2974 +2608 @@ - }*/ + } @@ -2977,2 +2611 @@ - $arrayforbutaction[] = array('lang'=>'contracts', 'enabled'=>(isModEnabled("contrat") && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)), 'perm'=>$user->hasRight('contrat', 'creer'), 'label'=>'AddContract', 'url'=>'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid); - /*if (isModEnabled('contrat') && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { + if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { @@ -2981,2 +2614,2 @@ - if ($user->hasRight('contrat', 'creer')) { - print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); + if ($user->rights->contrat->creer) { + print ''.$langs->trans('AddContract').''; @@ -2984,2 +2617,3 @@ - }*/ - + } + + // Ship @@ -2987,11 +2621,10 @@ - if (isModEnabled('expedition')) { - $numshipping = $object->countNbOfShipments(); - } - - // Create shipment - if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))) { - if ((getDolGlobalInt('MAIN_SUBMODULE_EXPEDITION') && $user->hasRight('expedition', 'creer')) || (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->hasRight('expedition', 'delivery', 'creer'))) { - $arrayforbutaction[] = array('lang'=>'sendings', 'enabled'=>(isModEnabled("expedition") && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')))), 'perm'=>$user->hasRight('expedition', 'creer'), 'label'=>'CreateShipment', 'url'=>'/expedition/shipment.php?id='.$object->id); - /* - if ($user->hasRight('expedition', 'creer')) { - print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, ''); + if (!empty($conf->expedition->enabled)) { + $numshipping = $object->nb_expedition(); + + if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { + if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { + if ($user->rights->expedition->creer) { + print ''.$langs->trans('CreateShipment').''; + } else { + print ''.$langs->trans('CreateShipment').''; + } @@ -2999,5 +2632,3 @@ - print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false); - }*/ - } else { - $langs->load("errors"); - print dolGetButtonAction($langs->trans('ErrorModuleSetupNotComplete'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false); + $langs->load("errors"); + print 'transnoentitiesnoconv("Shipment"))).'">'.$langs->trans('CreateShipment').''; + } @@ -3005,21 +2635,0 @@ - } - - // Create bill - $arrayforbutaction[] = array( - 'lang'=>'bills', - 'enabled'=>(isModEnabled('facture') && $object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0), - 'perm'=>($user->hasRight('facture', 'creer') && !getDolGlobalInt('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')), - 'label'=>'CreateBill', - 'url'=>'/compta/facture/card.php?action=create&token='.newToken().'&origin='.urlencode($object->element).'&originid='.$object->id.'&socid='.$object->socid - ); - /* - if (isModEnabled('facture') && $object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) { - if (isModEnabled('facture') && $user->hasRight('facture', 'creer') && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { - print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&token='.newToken().'&origin='.urlencode($object->element).'&originid='.$object->id.'&socid='.$object->socid, ''); - } - }*/ - - if ($numlines > 0) { - print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayforbutaction, $object->id, 1); - } else { - print dolGetButtonAction($langs->trans("ErrorObjectMustHaveLinesToBeValidated", $object->ref), $langs->trans("Create"), 'default', $arrayforbutaction, $object->id, 0); @@ -3030,4 +2640,4 @@ - print dolGetButtonAction('', $langs->trans('ClassifyShipped'), 'default', $_SERVER["PHP_SELF"].'?action=shipped&token='.newToken().'&id='.$object->id, ''); - } - - // Set billed or unbilled + print ''; + } + + // Create bill and Classify billed @@ -3036,2 +2646,2 @@ - if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) { - print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&token='.newToken().'&id='.$object->id, ''); + if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { + print ''; @@ -3038,0 +2649,3 @@ + if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + print ''; + } @@ -3041,2 +2654,2 @@ - if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) { - print dolGetButtonAction('', $langs->trans('ClassifyUnBilled'), 'delete', $_SERVER["PHP_SELF"].'?action=classifyunbilled&token='.newToken().'&id='.$object->id, ''); + if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + print ''; @@ -3045 +2657,0 @@ - @@ -3048 +2660 @@ - print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id.'&socid='.$object->socid, ''); + print ''; @@ -3052,2 +2664,3 @@ - if ($object->statut == Commande::STATUS_VALIDATED && !empty($usercancancel)) { - print ''.$langs->trans("CancelOrder").''; + if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) + { + print ''; @@ -3059 +2672 @@ - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); + print ''; @@ -3061 +2674 @@ - print dolGetButtonAction($langs->trans('ShippingExist'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false); + print ''; @@ -3073 +2686,2 @@ - if ($action != 'presend') { + if ($action != 'presend') + { @@ -3083 +2697 @@ - print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); + print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); @@ -3091,2 +2705,3 @@ - && $object->statut == Commande::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande', 'propal', 'facture'); // import from linked elements + && $object->statut == Commande::STATUS_DRAFT) + { + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements @@ -3097,5 +2712,4 @@ - $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); - if (getDolGlobalString('ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER')) { - $useonlinepayment = 0; - } - if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) { + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; + if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) + { @@ -3107,5 +2721,8 @@ - print '
'; - - $MAXEVENT = 10; - - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/commande/agenda.php?id='.$object->id); + // Show direct download link + if ($object->statut != Commande::STATUS_DRAFT && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) + { + print '
'."\n"; + print showDirectDownloadLink($object).'
'; + } + + print '
'; @@ -3116,3 +2733,3 @@ - $somethingshown = $formactions->showactions($object, 'order', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty - - print '
'; + $somethingshown = $formactions->showactions($object, 'order', $socid, 1); + + print ''; @@ -3124 +2741 @@ - $diroutput = getMultidirOutput($object); + $diroutput = $conf->commande->multidir_output[$object->entity]; --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_contact.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_contact.php @@ -5,2 +5 @@ - * Copyright (C) 2011-2022 Philippe Grand - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2011-2015 Philippe Grand @@ -28 +26,0 @@ -// Load Dolibarr environment @@ -38 +36 @@ -$langs->loadLangs(array('orders', 'sendings', 'companies', 'bills')); +$langs->loadLangs(array('orders', 'sendings', 'companies')); @@ -42 +40 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -45,6 +43 @@ -if ($user->socid) { - $socid = $user->socid; -} -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('ordercontact', 'globalcard')); - +if ($user->socid) $socid = $user->socid; @@ -52,3 +44,0 @@ -$hookmanager->initHooks(array('ordercontactcard', 'globalcard')); - -$usercancreate = $user->hasRight("commande", "creer"); @@ -59,18 +49,24 @@ - * Actions - */ - -$parameters = array('id'=>$id); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Add new contact - if ($action == 'addcontact' && $user->hasRight('commande', 'creer')) { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); + * Ajout d'un nouveau contact + */ + +if ($action == 'addcontact' && $user->rights->commande->creer) +{ + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); @@ -78,28 +74,2 @@ - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } elseif ($action == 'swapstatut' && $user->hasRight('commande', 'creer')) { - // Toggle the status of a contact - if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } else { - dol_print_error($db); - } - } elseif ($action == 'deletecontact' && $user->hasRight('commande', 'creer')) { - // Delete contact - $object->fetch($id); - $result = $object->delete_contact(GETPOST("lineid", 'int')); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { + else + { @@ -110,0 +81,37 @@ +// bascule du statut d'un contact +elseif ($action == 'swapstatut' && $user->rights->commande->creer) +{ + if ($object->fetch($id)) + { + $result = $object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } +} + +// Efface un contact +elseif ($action == 'deletecontact' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } +} +/* +elseif ($action == 'setaddress' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); +}*/ + + @@ -113,0 +121,3 @@ + +llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); + @@ -127,7 +137,7 @@ -if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - $object->fetch_thirdparty(); - - $title = $object->ref." - ".$langs->trans('ContactsAddresses'); - $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; - llxHeader('', $title, $help_url); +if ($id > 0 || !empty($ref)) +{ + $langs->trans("OrderCard"); + + if ($object->fetch($id, $ref) > 0) + { + $object->fetch_thirdparty(); @@ -136 +146,2 @@ - print dol_get_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order'); + dol_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order'); + @@ -140,0 +152 @@ + @@ -147,22 +159,35 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } - } + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } @@ -173 +198 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -179,5 +204,4 @@ - foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) { - break; - } + foreach ($dirtpls as $reldir) + { + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; @@ -185 +209,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_customer.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_customer.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -37 +36,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -42,3 +42,2 @@ -if (!$user->hasRight('facture', 'creer')) { - accessforbidden(); -} +if (!$user->rights->facture->creer) +accessforbidden(); @@ -49,3 +48,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -53,3 +52 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,6 +56,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "nom"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "nom"; @@ -81,3 +74 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", sc.fk_soc, sc.fk_user "; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -85,3 +76 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -90,2 +79,4 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if (dol_strlen($stcomm)) +{ + $sql .= " AND s.fk_stcomm=".$stcomm; @@ -93,10 +84,5 @@ -if (GETPOST("search_nom")) { - $sql .= natural_search("s.nom", GETPOST("search_nom")); -} -if (GETPOST("search_compta")) { - $sql .= natural_search("s.code_compta", GETPOST("search_compta")); -} -if (GETPOST("search_code_client")) { - $sql .= natural_search("s.code_client", GETPOST("search_code_client")); -} -if (dol_strlen($begin)) { +if (GETPOST("search_nom")) $sql .= natural_search("s.nom", GETPOST("search_nom")); +if (GETPOST("search_compta")) $sql .= natural_search("s.code_compta", GETPOST("search_compta")); +if (GETPOST("search_code_client")) $sql .= natural_search("s.code_client", GETPOST("search_code_client")); +if (dol_strlen($begin)) +{ @@ -105,2 +91,3 @@ -if ($socid > 0) { - $sql .= " AND s.rowid = ".((int) $socid); +if ($socid > 0) +{ + $sql .= " AND s.rowid = ".$socid; @@ -114 +101,2 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ @@ -118 +106,2 @@ - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -128 +117,2 @@ -if ($resql) { +if ($resql) +{ @@ -168 +158,2 @@ - while ($i < min($num, $limit)) { + while ($i < min($num, $limit)) + { @@ -176 +167 @@ - $link = ''; + $link = ''; @@ -196 +187,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_document.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_document.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -36 +35 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -41 +40 @@ -$langs->loadLangs(array('companies', 'other', 'bills', 'orders')); +$langs->loadLangs(array('companies', 'other')); @@ -47,0 +47,7 @@ +// Security check +if ($user->socid) +{ + $socid = $user->socid; +} +$result = restrictedArea($user, 'commande', $id, ''); + @@ -50,2 +56,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -53,3 +59 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -60,13 +64,5 @@ -if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) { - $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; -} -if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) { - $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; -} - -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} +if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; } +if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; } + +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; @@ -75,13 +70,0 @@ - -$usercancreate = $user->hasRight("commande", "creer"); -$permissiontoadd = $usercancreate; - -// Security check -if ($user->socid) { - $socid = $user->socid; -} - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('orderdocument', 'globalcard')); - -$result = restrictedArea($user, 'commande', $id, ''); @@ -94 +77,2 @@ -if ($object->fetch($id)) { +if ($object->fetch($id)) +{ @@ -99 +83 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -105,3 +89,2 @@ -$title = $object->ref." - ".$langs->trans('Documents'); -$help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; -llxHeader('', $title, $help_url); + +llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); @@ -111,2 +94,4 @@ -if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref)) { +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref)) + { @@ -118 +103 @@ - print dol_get_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order'); + dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order'); @@ -121 +106 @@ - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -123,2 +108,3 @@ - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; @@ -137 +123 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -139,7 +125,9 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= '
'.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; @@ -147,11 +135,22 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -179 +178 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -182 +181 @@ - $permissiontoadd = $user->rights->commande->creer; + $permission = $user->rights->commande->creer; @@ -184,3 +183,5 @@ - $param = '&id='.$object->id.'&entity='.(empty($object->entity) ? $conf->entity : $object->entity); - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } else { + $param = '&id='.$object->id.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity); + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + } + else + { @@ -189 +190,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_index.php @@ -25,5 +25,3 @@ - * \brief Home page of sales order module - */ - - -// Load Dolibarr environment + * \brief Home page of customer order module + */ + @@ -35,2 +33,7 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; - + +if (!$user->rights->commande->lire) accessforbidden(); + +$hookmanager = new HookManager($db); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('ordersindex')); @@ -41,11 +43,0 @@ - -if (!$user->hasRight('commande', 'lire')) { - accessforbidden(); -} - -$hookmanager = new HookManager($db); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('ordersindex')); - - @@ -54 +46,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -59,6 +51,0 @@ -$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); - -// Maximum elements of the tables -$maxDraftCount = !getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; -$maxLatestEditCount = 5; -$maxOpenCount = !getDolGlobalString('MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; @@ -85,4 +72,108 @@ -$tmp = getCustomerOrderPieChart($socid); -if ($tmp) { - print $tmp; - print '
'; +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +{ + // Search customer orders + print '
'; + print ''; + print '
'; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'; + print $langs->trans("CustomerOrder").':

\n"; +} + + +/* + * Statistics + */ + +$sql = "SELECT count(c.rowid) as nb, c.fk_statut as status"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."commande as c"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('societe').")"; +if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " GROUP BY c.fk_statut"; + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $colorseries = array(); + $vals = array(); + // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + if (!isset($vals[$row[1]])) $vals[$row[1]] = 0; + $vals[$row[1]] += $row[0]; + $totalinprocess += $row[0]; + } + $total += $row[0]; + } + $i++; + } + $db->free($resql); + + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + print '
'; + print ''; + print ''."\n"; + $listofstatus = array(0, 1, 2, 3, -1); + foreach ($listofstatus as $status) + { + $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; + if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; + } + + //if ($totalinprocess != $total) + print ''; + print "
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; + print $commandestatic->LibStatut($status, 0, 3, 1); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); + + print '
'.$langs->trans("Total").''.$total.'

"; +} +else +{ + dol_print_error($db); @@ -95 +186,2 @@ -if (isModEnabled('commande')) { +if (!empty($conf->commande->enabled)) +{ @@ -97,3 +189,3 @@ - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; @@ -102,3 +194 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -108,6 +198,2 @@ - if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -116,2 +202,3 @@ - if ($resql) { - print '
'; + if ($resql) + { + print '
'; @@ -123 +210,2 @@ - if ($num) { + if ($num) + { @@ -125 +213,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -128,2 +217,2 @@ - $commandestatic->id = $obj->rowid; - $commandestatic->ref = $obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; @@ -140,2 +229,2 @@ - print ""; - print ''; + print ""; + print ''; @@ -143 +232 @@ - print ''; + print ''; @@ -146 +235,3 @@ - } else { + } + else + { @@ -154 +245 @@ -print '
'; +print '
'; @@ -170,3 +261 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -176,6 +265,2 @@ -if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); -} -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} +if ($socid) $sql .= " AND c.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -186,2 +271,3 @@ -if ($resql) { - print '
'; +if ($resql) +{ + print '
'; @@ -193 +279,2 @@ - if ($num) { + if ($num) + { @@ -195 +282,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -229,2 +317,2 @@ - print $companystatic->getNomUrl(1, 'company', 16); - print ''; + print $companystatic->getNomUrl(1, 'company', 16); + print ''; @@ -238,3 +326,2 @@ -} else { - dol_print_error($db); -} +} +else dol_print_error($db); @@ -247 +334,2 @@ -if (isModEnabled('commande')) { +if (!empty($conf->commande->enabled)) +{ @@ -249,3 +337,3 @@ - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; @@ -254,3 +342 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -260,6 +346,2 @@ - if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -269 +351,2 @@ - if ($resql) { + if ($resql) + { @@ -272 +355 @@ - print '
'; + print '
'; @@ -277 +360,2 @@ - if ($num) { + if ($num) + { @@ -279 +363,2 @@ - while ($i < $num && $i < $max) { + while ($i < $num && $i < $max) + { @@ -312,4 +397,4 @@ - print $companystatic->getNomUrl(1, 'company', 24); - print ''; - - print ''.dol_print_date($db->jdate($obj->date), 'day').''."\n"; + print $companystatic->getNomUrl(1, 'company', 24); + print ''; + + print ''.dol_print_date($db->jdate($obj->date), 'day').''."\n"; @@ -328,2 +412,0 @@ - } else { - dol_print_error($db); @@ -330,0 +414 @@ + else dol_print_error($db); @@ -336 +420,2 @@ -if (isModEnabled('commande')) { +if (!empty($conf->commande->enabled)) +{ @@ -338,3 +423,3 @@ - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; @@ -343,3 +428 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -348,7 +431,3 @@ - $sql .= " AND c.fk_statut = ".((int) Commande::STATUS_ACCEPTED); - if ($socid) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } + $sql .= " AND c.fk_statut = ".Commande::STATUS_ACCEPTED; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -358 +437,2 @@ - if ($resql) { + if ($resql) + { @@ -361 +441 @@ - print '
'; + print '
'; @@ -366 +446,2 @@ - if ($num) { + if ($num) + { @@ -368 +449,2 @@ - while ($i < $num && $i < $max) { + while ($i < $num && $i < $max) + { @@ -416,2 +497,0 @@ - } else { - dol_print_error($db); @@ -419,4 +499,5 @@ -} - - -print '
'; + else dol_print_error($db); +} + + +print '
'; --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_info.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_info.php @@ -0,0 +1,134 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2017 Ferran Marcet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/commande/info.php + * \ingroup commande + * \brief Sale Order info page + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} + +if (!$user->rights->commande->lire) accessforbidden(); + +// Load translation files required by the page +$langs->loadLangs(array('orders', 'sendings')); + +$socid = 0; +$comid = GETPOST("id", 'int'); +$id = GETPOST("id", 'int'); +$ref = GETPOST('ref', 'alpha'); + +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'commande', $comid, ''); + +$object = new Commande($db); +if (!$object->fetch($id, $ref) > 0) +{ + dol_print_error($db); + exit; +} + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); + +$object->fetch_thirdparty(); +$object->info($object->id); + +$head = commande_prepare_head($object); +dol_fiche_head($head, 'info', $langs->trans("CustomerOrder"), -1, 'order'); + +// Order card + +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref = '
'; +// Ref customer +$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); +// Thirdparty +$morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); +// Project +if (!empty($conf->projet->enabled)) +{ + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } +} +$morehtmlref .= '
'; + + +dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + +print '
'; +print '
'; + +print '
'; + +print '
'; +dol_print_object_info($object); +print '
'; + +print '
'; + +dol_fiche_end(); + +// End of page +llxFooter(); +$db->close(); --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_list.php @@ -12,3 +12,2 @@ - * Copyright (C) 2016-2023 Ferran Marcet - * Copyright (C) 2018-2023 Charlene Benke - * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2018 Charlene Benke @@ -37 +35,0 @@ -// Load Dolibarr environment @@ -45,3 +42,0 @@ -if (isModEnabled('margin')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; -} @@ -54,3 +49,2 @@ -$langs->loadLangs(array('orders', 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products')); - -// Get Parameters +$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills')); + @@ -62,19 +56,6 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'orderlist'; -$mode = GETPOST('mode', 'alpha'); - -// Search Parameters -$search_datecloture_start = GETPOST('search_datecloture_start', 'int'); -if (empty($search_datecloture_start)) { - $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int')); -} -$search_datecloture_end = GETPOST('search_datecloture_end', 'int'); -if (empty($search_datecloture_end)) { - $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int')); -} -$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_month', 'int'), GETPOST('search_dateorder_start_day', 'int'), GETPOST('search_dateorder_start_year', 'int')); -$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int')); -$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int')); -$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int')); - -$socid = GETPOST('socid', 'int'); -$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist'; + +$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_startmonth', 'int'), GETPOST('search_dateorder_startday', 'int'), GETPOST('search_dateorder_startyear', 'int')); +$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_endmonth', 'int'), GETPOST('search_dateorder_endday', 'int'), GETPOST('search_dateorder_endyear', 'int')); +$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int')); +$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int')); @@ -82 +63 @@ -$search_ref = GETPOST('search_ref', 'alpha') != '' ? GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); +$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); @@ -85,2 +65,0 @@ -$search_company_alias = GETPOST('search_company_alias', 'alpha'); -$search_parent_name = trim(GETPOST('search_parent_name', 'alphanohtml')); @@ -89,3 +68,5 @@ -$search_state = GETPOST('search_state', 'alpha'); -$search_country = GETPOST('search_country', 'int'); -$search_type_thirdparty = GETPOST('search_type_thirdparty', 'int'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); @@ -94 +75 @@ -$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); @@ -98 +78,0 @@ - @@ -101 +81 @@ -$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); @@ -104 +83,0 @@ - @@ -106 +85 @@ -$search_categ_cus = GETPOST("search_categ_cus", 'int'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); @@ -108 +87 @@ -$search_billed = GETPOST('search_billed', 'int'); +$billed = GETPOST('billed', 'int'); @@ -109,0 +89,2 @@ +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); @@ -112,6 +93,5 @@ -$search_shippable = GETPOST('search_shippable', 'aZ09'); - -$search_fk_cond_reglement = GETPOST('search_fk_cond_reglement', 'int'); -$search_fk_shipping_method = GETPOST('search_fk_shipping_method', 'int'); -$search_fk_mode_reglement = GETPOST('search_fk_mode_reglement', 'int'); -$search_fk_input_reason = GETPOST('search_fk_input_reason', 'int'); + +// Security check +$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'commande', $id, ''); @@ -122,3 +102,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -126,4 +106 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 @@ -133,8 +110,2 @@ -if (!$sortfield) { - $sortfield = 'c.ref'; -} -if (!$sortorder) { - $sortorder = 'DESC'; -} - -$show_shippable_command = GETPOST('show_shippable_command', 'aZ09'); +if (!$sortfield) $sortfield = 'c.ref'; +if (!$sortorder) $sortorder = 'DESC'; @@ -148 +119 @@ -$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label('commande'); @@ -162,3 +133 @@ -if (empty($user->socid)) { - $fieldstosearchall["c.note_private"] = "NotePrivate"; -} +if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; @@ -168,41 +137,26 @@ - 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), - 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>20), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>25), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), - 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), - 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0), - 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), - 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40), - 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), - 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), - 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), - 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60, 'csslist'=>'nowraponall'), - 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>!getDolGlobalString('ORDER_DISABLE_DELIVERY_DATE'), 'position'=>65, 'csslist'=>'nowraponall'), - 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>isModEnabled("expedition")), - 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67), - 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68), - 'c.fk_input_reason'=>array('label'=>"Origin", 'checked'=>-1, 'position'=>69), - 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), - 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), - 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), - 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>90), - 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>95), - 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>100), - 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>105), - 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 0 : 1), 'position'=>110), - 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), - 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), - 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight("margins", "liretous") || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)), - 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), - 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), - 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>135), - 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>140), - 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled("expedition")), 'position'=>990), - 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(!getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')), 'position'=>995), - 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999), - 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) + 'c.ref'=>array('label'=>"Ref", 'checked'=>1), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 's.town'=>array('label'=>"Town", 'checked'=>1), + 's.zip'=>array('label'=>"Zip", 'checked'=>1), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)), + 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), + 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) @@ -210 +163,0 @@ - @@ -212,2 +165,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -215 +173,0 @@ -//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); @@ -218,12 +175,0 @@ -if (!$user->hasRight('societe', 'client', 'voir')) { - $search_sale = $user->id; -} - -// Security check -$id = (GETPOST('orderid') ? GETPOST('orderid', 'int') : GETPOST('id', 'int')); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'commande', $id, ''); - -$error = 0; @@ -236,9 +182,4 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { - $massaction = ''; -} - -$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } + +$parameters = array('socid'=>$socid); @@ -246,5 +187,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -255 +195,3 @@ - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_categ = ''; @@ -262,2 +203,0 @@ - $search_company_alias = ''; - $search_parent_name = ''; @@ -273 +212,0 @@ - $search_warehouse = ''; @@ -287,2 +226,2 @@ - $search_billed = ''; - $toselect = array(); + $billed = ''; + $toselect = ''; @@ -291,6 +229,0 @@ - $search_datecloture_start = ''; - $search_datecloture_end = ''; - $search_fk_cond_reglement = ''; - $search_fk_shipping_method = ''; - $search_fk_mode_reglement = ''; - $search_fk_input_reason = ''; @@ -299 +232,2 @@ - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { @@ -306,14 +240,2 @@ - $permissiontoread = $user->hasRight("commande", "lire"); - $permissiontoadd = $user->hasRight("commande", "creer"); - $permissiontodelete = $user->hasRight("commande", "supprimer"); - if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - $permissiontovalidate = $user->hasRight("commande", "order_advance", "validate"); - $permissiontoclose = $user->hasRight("commande", "order_advance", "close"); - $permissiontocancel = $user->hasRight("commande", "order_advance", "annuler"); - $permissiontosendbymail = $user->hasRight("commande", "order_advance", "send"); - } else { - $permissiontovalidate = $user->hasRight("commande", "creer"); - $permissiontoclose = $user->hasRight("commande", "creer"); - $permissiontocancel = $user->hasRight("commande", "creer"); - $permissiontosendbymail = $user->hasRight("commande", "creer"); - } + $permissiontoread = $user->rights->commande->lire; + $permissiontodelete = $user->rights->commande->supprimer; @@ -322,2 +243,0 @@ - $year=""; - $month=""; @@ -325,455 +244,0 @@ - - if ($massaction == 'confirm_createbills') { // Create bills from orders. - $orders = GETPOST('toselect', 'array'); - $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); - $validate_invoices = GETPOST('validate_invoices', 'int'); - - $errors = array(); - - $TFact = array(); - $TFactThird = array(); - $TFactThirdNbLines = array(); - - $nb_bills_created = 0; - $lastid= 0; - $lastref = ''; - - $db->begin(); - - $nbOrders = is_array($orders) ? count($orders) : 1; - - foreach ($orders as $id_order) { - $cmd = new Commande($db); - if ($cmd->fetch($id_order) <= 0) { - continue; - } - $cmd->fetch_thirdparty(); - - $objecttmp = new Facture($db); - if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { - // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it. - $objecttmp = $TFactThird[$cmd->socid]; - } else { - // If we want one invoice per order or if there is no first invoice yet for this thirdparty. - $objecttmp->socid = $cmd->socid; - $objecttmp->thirdparty = $cmd->thirdparty; - - $objecttmp->type = $objecttmp::TYPE_STANDARD; - $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id; - $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id; - - $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) { - $objecttmp->ref_client = $cmd->ref_client; - } - - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) { - $datefacture = dol_now(); - } - - $objecttmp->date = $datefacture; - $objecttmp->origin = 'commande'; - $objecttmp->origin_id = $id_order; - - $objecttmp->array_options = $cmd->array_options; // Copy extrafields - - $res = $objecttmp->create($user); - - if ($res > 0) { - $nb_bills_created++; - $lastref = $objecttmp->ref; - $lastid = $objecttmp->id; - - $TFactThird[$cmd->socid] = $objecttmp; - $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang - } else { - $langs->load("errors"); - $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); - $error++; - } - } - - if ($objecttmp->id > 0) { - $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order); - - if ($res == 0) { - $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); - $error++; - } - - if (!$error) { - $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) { - $cmd->fetch_lines(); - $lines = $cmd->lines; - } - - $fk_parent_line = 0; - $num = count($lines); - - for ($i = 0; $i < $num; $i++) { - $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); - // If we build one invoice for several orders, we must put the ref of order on the invoice line - if (!empty($createbills_onebythird)) { - $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); - } - - if ($lines[$i]->subprice < 0 && !getDolGlobalString('INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN')) { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc = $objecttmp->socid; - $discount->amount_ht = abs($lines[$i]->total_ht); - $discount->amount_tva = abs($lines[$i]->total_tva); - $discount->amount_ttc = abs($lines[$i]->total_ttc); - $discount->tva_tx = $lines[$i]->tva_tx; - $discount->fk_user = $user->id; - $discount->description = $desc; - $discountid = $discount->create($user); - if ($discountid > 0) { - $result = $objecttmp->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } else { - setEventMessages($discount->error, $discount->errors, 'errors'); - $error++; - break; - } - } else { - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - // Date start - $date_start = false; - if ($lines[$i]->date_debut_prevue) { - $date_start = $lines[$i]->date_debut_prevue; - } - if ($lines[$i]->date_debut_reel) { - $date_start = $lines[$i]->date_debut_reel; - } - if ($lines[$i]->date_start) { - $date_start = $lines[$i]->date_start; - } - //Date end - $date_end = false; - if ($lines[$i]->date_fin_prevue) { - $date_end = $lines[$i]->date_fin_prevue; - } - if ($lines[$i]->date_fin_reel) { - $date_end = $lines[$i]->date_fin_reel; - } - if ($lines[$i]->date_end) { - $date_end = $lines[$i]->date_end; - } - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $objecttmp->context['createfromclone'] = 'createfromclone'; - - $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang; - //there may already be rows from previous orders - if (!empty($createbills_onebythird)) { - $TFactThirdNbLines[$cmd->socid]++; - $rang = $TFactThirdNbLines[$cmd->socid]; - } - - $result = $objecttmp->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $rang, - $lines[$i]->special_code, - $objecttmp->origin, - $lines[$i]->rowid, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $lines[$i]->label, - $array_options, - 100, - 0, - $lines[$i]->fk_unit - ); - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error++; - $errors[] = $objecttmp->error; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } - } - } - - //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { - $TFactThird[$cmd->socid] = $objecttmp; - } else { - $TFact[$objecttmp->id] = $objecttmp; - } - } - - // Build doc with all invoices - $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; - $toselect = array(); - - if (!$error && $validate_invoices) { - $massaction = $action = 'builddoc'; - - foreach ($TAllFact as &$objecttmp) { - $result = $objecttmp->validate($user); - if ($result <= 0) { - $error++; - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - break; - } - - $id = $objecttmp->id; // For builddoc action - - // Builddoc - $donotredirect = 1; - $upload_dir = $conf->facture->dir_output; - $permissiontoadd = $user->hasRight('facture', 'creer'); - - // Call action to build doc - $savobject = $object; - $object = $objecttmp; - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - $object = $savobject; - } - - $massaction = $action = 'confirm_createbills'; - } - - if (!$error) { - $db->commit(); - - if ($nb_bills_created == 1) { - $texttoshow = $langs->trans('BillXCreated', '{s1}'); - $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); - setEventMessages($texttoshow, null, 'mesgs'); - } else { - setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); - } - - // Make a redirect to avoid to bill twice if we make a refresh or back - $param = ''; - if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); - } - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($search_all) { - $param .= '&search_all='.urlencode($search_all); - } - if ($show_files) { - $param .= '&show_files='.urlencode($show_files); - } - if ($socid > 0) { - $param .= '&socid='.urlencode($socid); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($search_orderday) { - $param .= '&search_orderday='.urlencode($search_orderday); - } - if ($search_ordermonth) { - $param .= '&search_ordermonth='.urlencode($search_ordermonth); - } - if ($search_orderyear) { - $param .= '&search_orderyear='.urlencode($search_orderyear); - } - if ($search_deliveryday) { - $param .= '&search_deliveryday='.urlencode($search_deliveryday); - } - if ($search_deliverymonth) { - $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); - } - if ($search_deliveryyear) { - $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_company) { - $param .= '&search_company='.urlencode($search_company); - } - if ($search_ref_customer) { - $param .= '&search_ref_customer='.urlencode($search_ref_customer); - } - if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); - } - if ($search_total_ht != '') { - $param .= '&search_total_ht='.urlencode($search_total_ht); - } - if ($search_total_vat != '') { - $param .= '&search_total_vat='.urlencode($search_total_vat); - } - if ($search_total_ttc != '') { - $param .= '&search_total_ttc='.urlencode($search_total_ttc); - } - if ($search_project_ref >= 0) { - $param .= "&search_project_ref=".urlencode($search_project_ref); - } - if ($search_billed != '') { - $param .= '&search_billed='.urlencode($search_billed); - } - - header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); - exit; - } else { - $db->rollback(); - - $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; - if (!empty($errors)) { - setEventMessages(null, $errors, 'errors'); - } else { - setEventMessages("Error", null, 'errors'); - } - $error++; - } - } -} -if ($action == 'validate' && $permissiontoadd) { - if (GETPOST('confirm') == 'yes') { - $objecttmp = new $objectclass($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 0) { - if (!empty($objecttmp->fk_warehouse)) { - $idwarehouse = $objecttmp->fk_warehouse; - } else { - $idwarehouse = 0; - } - if ($objecttmp->valid($user, $idwarehouse)) { - setEventMessages($langs->trans('hasBeenValidated', $objecttmp->ref), null, 'mesgs'); - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - } - } else { - $langs->load("errors"); - setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); - $error++; - } - } else { - dol_print_error($db); - $error++; - } - } - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } - } -} -if ($action == 'shipped' && $permissiontoadd) { - if (GETPOST('confirm') == 'yes') { - $objecttmp = new $objectclass($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { - if ($objecttmp->cloture($user)) { - setEventMessages($langs->trans('StatusOrderDelivered', $objecttmp->ref), null, 'mesgs'); - } else { - setEventMessages($langs->trans('ErrorOrderStatusCantBeSetToDelivered'), null, 'errors'); - $error++; - } - } else { - $langs->load("errors"); - setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); - $error++; - } - } else { - dol_print_error($db); - $error++; - } - } - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } - } -} - -// Closed records -if (!$error && $massaction === 'setbilled' && $permissiontoclose) { - $db->begin(); - - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) { - $result = $objecttmp->classifyBilled($user, 0); - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else { - $nbok++; - } - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } - - if (!$error) { - if ($nbok > 1) { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } else { - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - } - $db->commit(); - } else { - $db->rollback(); - } @@ -786,0 +252,2 @@ +$now = dol_now(); + @@ -790,4 +256,0 @@ -$formmargin = null; -if (isModEnabled('margin')) { - $formmargin = new FormMargin($db); -} @@ -795 +257,0 @@ -$company_url_list = array(); @@ -799,5 +260,0 @@ -$now = dol_now(); - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - @@ -806,3 +263,2 @@ - -// Build and execute select -// -------------------------------------------------------------------- +// llxHeader('',$title,$help_url); + @@ -810,6 +266,2 @@ -if ($search_all || $search_user > 0) { - $sql = 'SELECT DISTINCT'; -} -$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,'; -$sql .= " s.parent as fk_parent,"; -$sql .= " s2.nom as name2,"; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; @@ -818,2 +270 @@ -$sql .= " country.code as country_code,"; -$sql .= ' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; +$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; @@ -821 +272 @@ -$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; +$sql .= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; @@ -823,5 +274,3 @@ -$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,'; -$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,'; -$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,'; -$sql .= ' c.fk_input_reason, c.import_key'; - +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; +$sql .= " u.login"; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; @@ -829,6 +278,2 @@ -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } -} - +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -837 +282 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -839,4 +283,0 @@ -$sql = preg_replace('/,\s*$/', '', $sql); - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -844 +284,0 @@ -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s2.rowid = s.parent"; @@ -847,0 +288 @@ +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ @@ -849,6 +290,3 @@ -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; -} -if ($search_all) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; -} +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; @@ -857 +295,5 @@ -if ($search_user > 0) { + +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_user > 0) +{ @@ -861,6 +302,0 @@ - -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - @@ -869,24 +305,20 @@ -if ($socid > 0) { - $sql .= ' AND s.rowid = '.((int) $socid); -} -if ($search_ref) { - $sql .= natural_search('c.ref', $search_ref); -} -if ($search_ref_customer) { - $sql .= natural_search('c.ref_client', $search_ref_customer); -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -if ($search_billed != '' && $search_billed >= 0) { - $sql .= ' AND c.facture = '.((int) $search_billed); -} -if ($search_status != '') { - if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) - if ($search_status == 1 && !isModEnabled('expedition')) { - $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' - } else { - $sql .= ' AND c.fk_statut = '.((int) $search_status); // draft, validated, in process or canceled - } - } - if ($search_status == -2) { // "validated + in progress" +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_ref) $sql .= natural_search('c.ref', $search_ref); +if ($search_ref_customer) $sql .= natural_search('c.ref_client', $search_ref_customer); +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($billed != '' && $billed >= 0) $sql .= ' AND c.facture = '.$billed; +if ($search_status <> '') +{ + if ($search_status < 4 && $search_status > -3) + { + if ($search_status == 1 && empty($conf->expedition->enabled)) $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' + else $sql .= ' AND c.fk_statut = '.$search_status; // brouillon, validee, en cours, annulee + } + if ($search_status == 4) + { + $sql .= ' AND c.facture = 1'; // invoice created + } + if ($search_status == -2) // To process + { @@ -894,3 +326,4 @@ - $sql .= " AND (c.fk_statut IN (1,2))"; - } - if ($search_status == -3) { // "validated + in progress + shipped" + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + } + if ($search_status == -3) // To bill + { @@ -899 +332 @@ - $sql .= ' AND (c.fk_statut IN (1,2,3))'; // validated, in process or closed + $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed @@ -903,165 +336,27 @@ -if ($search_datecloture_start) { - $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'"; -} -if ($search_datecloture_end) { - $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'"; -} -if ($search_dateorder_start) { - $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; -} -if ($search_dateorder_end) { - $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; -} -if ($search_datedelivery_start) { - $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; -} -if ($search_datedelivery_end) { - $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; -} -if ($search_town) { - $sql .= natural_search('s.town', $search_town); -} -if ($search_zip) { - $sql .= natural_search("s.zip", $search_zip); -} -if ($search_state) { - $sql .= natural_search("state.nom", $search_state); -} -if ($search_country) { - $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; -} -if ($search_type_thirdparty && $search_type_thirdparty != '-1') { - $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; -} -if (empty($arrayfields['s.name_alias']['checked']) && $search_company) { - $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company); -} else { - if ($search_company) { - $sql .= natural_search('s.nom', $search_company); - } - if ($search_company_alias) { - $sql .= natural_search('s.name_alias', $search_company_alias); - } -} -if ($search_parent_name) { - $sql .= natural_search('s2.nom', $search_parent_name); -} -if ($search_user > 0) { - $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); -} -if ($search_total_ht != '') { - $sql .= natural_search('c.total_ht', $search_total_ht, 1); -} -if ($search_total_vat != '') { - $sql .= natural_search('c.total_tva', $search_total_vat, 1); -} -if ($search_total_ttc != '') { - $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); -} -if ($search_warehouse != '' && $search_warehouse > 0) { - $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); -} -if ($search_multicurrency_code != '') { - $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'"; -} -if ($search_multicurrency_tx != '') { - $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); -} -if ($search_multicurrency_montant_ht != '') { - $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); -} -if ($search_multicurrency_montant_vat != '') { - $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); -} -if ($search_multicurrency_montant_ttc != '') { - $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -} -if ($search_login) { - $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login); -} -if ($search_project_ref != '') { - $sql .= natural_search("p.ref", $search_project_ref); -} -if ($search_project != '') { - $sql .= natural_search("p.title", $search_project); -} -if ($search_fk_cond_reglement > 0) { - $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement); -} -if ($search_fk_shipping_method > 0) { - $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method); -} -if ($search_fk_mode_reglement > 0) { - $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement); -} -if ($search_fk_input_reason > 0) { - $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason); -} -// Search on sale representative -if ($search_sale && $search_sale != '-1') { - if ($search_sale == -2) { - $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)"; - } elseif ($search_sale > 0) { - $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; - } -} -// Search for tag/category ($searchCategoryCustomerList is an array of ID) -$searchCategoryCustomerOperator = -1; -$searchCategoryCustomerList = array($search_categ_cus); -if (!empty($searchCategoryCustomerList)) { - $searchCategoryCustomerSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { - if (intval($searchCategoryCustomer) == -2) { - $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc)"; - } elseif (intval($searchCategoryCustomer) > 0) { - if ($searchCategoryCustomerOperator == 0) { - $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie = ".((int) $searchCategoryCustomer).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); - } - } - } - if ($listofcategoryid) { - $searchCategoryCustomerSqlList[] = " EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as cs WHERE s.rowid = cs.fk_soc AND cs.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategoryCustomerOperator == 1) { - if (!empty($searchCategoryCustomerSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")"; - } - } else { - if (!empty($searchCategoryCustomerSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")"; - } - } -} -// Search for tag/category ($searchCategoryProductList is an array of ID) -$searchCategoryProductOperator = -1; -$searchCategoryProductList = array($search_product_category); -if (!empty($searchCategoryProductList)) { - $searchCategoryProductSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategoryProductList as $searchCategoryProduct) { - if (intval($searchCategoryProduct) == -2) { - $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product)"; - } elseif (intval($searchCategoryProduct) > 0) { - if ($searchCategoryProductOperator == 0) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); - } - } - } - if ($listofcategoryid) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategoryProductOperator == 1) { - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; - } - } else { - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; - } - } -} +if ($search_dateorder_start) $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; +if ($search_dateorder_end) $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; +if ($search_datedelivery_start) $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; +if ($search_datedelivery_end) $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); +if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1); +if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); +if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); +if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; +if ($search_multicurrency_tx != '') $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); +if ($search_multicurrency_montant_ht != '') $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +if ($search_multicurrency_montant_vat != '') $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +if ($search_login) $sql .= natural_search("u.login", $search_login); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); +if ($search_project != '') $sql .= natural_search("p.title", $search_project); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; + @@ -1072 +367 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -1075,5 +370 @@ -// Add HAVING from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -//print $sql; +$sql .= $db->order($sortfield, $sortorder); @@ -1083,13 +374,7 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -1099 +383,0 @@ - $db->free($resql); @@ -1102,4 +386 @@ -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} +$sql .= $db->plimit($limit + 1, $offset); @@ -1109,16 +390,14 @@ -if (!$resql) { - dol_print_error($db); - exit; -} - -if ($socid > 0) { - $soc = new Societe($db); - $soc->fetch($socid); - $title = $langs->trans('CustomersOrders').' - '.$soc->name; - if (empty($search_company)) { - $search_company = $soc->name; - } -} else { - $title = $langs->trans('CustomersOrders'); -} -if (strval($search_status) == '0') { +if ($resql) +{ + if ($socid > 0) + { + $soc = new Societe($db); + $soc->fetch($socid); + $title = $langs->trans('ListOfOrders').' - '.$soc->name; + if (empty($search_company)) $search_company = $soc->name; + } + else + { + $title = $langs->trans('ListOfOrders'); + } + if (strval($search_status) == '0') @@ -1126,2 +405 @@ -} -if ($search_status == 1) { + if ($search_status == 1) @@ -1129,2 +407 @@ -} -if ($search_status == 2) { + if ($search_status == 2) @@ -1132,2 +409 @@ -} -if ($search_status == 3) { + if ($search_status == 3) @@ -1135,2 +411,3 @@ -} -if ($search_status == -1) { + if ($search_status == 4) + $title .= ' - '.$langs->trans('StatusOrderProcessedShort'); + if ($search_status == -1) @@ -1138,2 +415 @@ -} -if ($search_status == -2) { + if ($search_status == -2) @@ -1141,354 +417,197 @@ -} -if ($search_status == -3) { - $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(!isModEnabled('expedition') ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); -} -if ($search_status == -4) { - $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"); -} - -$num = $db->num_rows($resql); - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id); - exit; -} - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url); - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -$param = ''; -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -if ($search_all) { - $param .= '&search_all='.urlencode($search_all); -} -if ($socid > 0) { - $param .= '&socid='.((int) $socid); -} -if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); -} -if ($search_datecloture_start) { - $param .= '&search_datecloture_startday='.dol_print_date($search_datecloture_start, '%d').'&search_datecloture_startmonth='.dol_print_date($search_datecloture_start, '%m').'&search_datecloture_startyear='.dol_print_date($search_datecloture_start, '%Y'); -} -if ($search_datecloture_end) { - $param .= '&search_datecloture_endday='.dol_print_date($search_datecloture_end, '%d').'&search_datecloture_endmonth='.dol_print_date($search_datecloture_end, '%m').'&search_datecloture_endyear='.dol_print_date($search_datecloture_end, '%Y'); -} -if ($search_dateorder_start) { - $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); -} -if ($search_dateorder_end) { - $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); -} -if ($search_datedelivery_start) { - $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); -} -if ($search_datedelivery_end) { - $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); -} -if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); -} -if ($search_company) { - $param .= '&search_company='.urlencode($search_company); -} -if ($search_company_alias) { - $param .= '&search_company_alias='.urlencode($search_company_alias); -} -if ($search_parent_name != '') { - $param .= '&search_parent_name='.urlencode($search_parent_name); -} -if ($search_ref_customer) { - $param .= '&search_ref_customer='.urlencode($search_ref_customer); -} -if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); -} -if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); -} -if ($search_total_ht != '') { - $param .= '&search_total_ht='.urlencode($search_total_ht); -} -if ($search_total_vat != '') { - $param .= '&search_total_vat='.urlencode($search_total_vat); -} -if ($search_total_ttc != '') { - $param .= '&search_total_ttc='.urlencode($search_total_ttc); -} -if ($search_warehouse != '') { - $param .= '&search_warehouse='.urlencode($search_warehouse); -} -if ($search_login) { - $param .= '&search_login='.urlencode($search_login); -} -if ($search_multicurrency_code != '') { - $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); -} -if ($search_multicurrency_tx != '') { - $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); -} -if ($search_multicurrency_montant_ht != '') { - $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); -} -if ($search_multicurrency_montant_vat != '') { - $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); -} -if ($search_multicurrency_montant_ttc != '') { - $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); -} -if ($search_project_ref >= 0) { - $param .= "&search_project_ref=".urlencode($search_project_ref); -} -if ($search_town != '') { - $param .= '&search_town='.urlencode($search_town); -} -if ($search_zip != '') { - $param .= '&search_zip='.urlencode($search_zip); -} -if ($search_state != '') { - $param .= '&search_state='.urlencode($search_state); -} -if ($search_country != '') { - $param .= '&search_country='.urlencode($search_country); -} -if ($search_type_thirdparty && $search_type_thirdparty != '-1') { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); -} -if ($search_product_category != '') { - $param .= '&search_product_category='.urlencode($search_product_category); -} -if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); -} -if ($show_files) { - $param .= '&show_files='.urlencode($show_files); -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -if ($search_billed != '') { - $param .= '&search_billed='.urlencode($search_billed); -} -if ($search_fk_cond_reglement > 0) { - $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); -} -if ($search_fk_shipping_method > 0) { - $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); -} -if ($search_fk_mode_reglement > 0) { - $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); -} -if ($search_fk_input_reason > 0) { - $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); -} - -// Add $param from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - -// Add $param from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; - -// List of mass actions available -$arrayofmassactions = array( - 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), -); -if ($permissiontovalidate) { - $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); -} -if ($permissiontoclose) { - $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').$langs->trans("ClassifyShipped"); -} -if (isModEnabled('facture') && $user->hasRight("facture", "creer")) { - $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer"); -} -if ($permissiontoclose) { - $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); -} -if ($permissiontocancel) { - $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("CancelOrder"); -} -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if ($permissiontosendbymail) { - $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); -} -if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { - $arrayofmassactions = array(); -} -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - -$url = DOL_URL_ROOT.'/commande/card.php?action=create'; -if (!empty($socid)) { - $url .= '&socid='.$socid; -} -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', ($contextpage == 'orderlist' || $contextpage == 'billableorders') && $permissiontoadd); - -// Lines of title fields -print '
'."\n"; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - - -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); - -$topicmail = "SendOrderRef"; -$modelmail = "order_send"; -$objecttmp = new Commande($db); -$trackid = 'ord'.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - -if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); -} -if ($massaction == 'preshipped') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("CloseOrder"), $langs->trans("ConfirmCloseOrder"), "shipped", null, '', 0, 200, 500, 1); -} - -if ($massaction == 'createbills') { - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans('DateInvoice'); - print ''; - print $form->selectDate('', '', '', '', '', '', 1, 1); - print '
'; - print $langs->trans('CreateOneBillByThird'); - print ''; - print $form->selectyesno('createbills_onebythird', '', 1); - print '
'; - print $langs->trans('ValidateInvoices'); - print ''; - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) { - print $form->selectyesno('validate_invoices', 0, 1, 1); - $langs->load("errors"); - print ' ('.$langs->trans("WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").')'; - } else { - print $form->selectyesno('validate_invoices', 0, 1); - } - if (!empty($conf->workflow->enabled) && getDolGlobalString('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER')) { - print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; - } else { - print '     '.$langs->trans("OptionToSetOrderBilledNotEnabled").''; - } - print '
'; - - print '
'; - print ' '; - print ''; - print '
'; - print '

'; -} - -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; -} - -$moreforfilter = ''; - -// If the user can view prospects? sales other than his own -if ($user->hasRight("user", "user", "lire")) { - $langs->load("commercial"); - $moreforfilter .= '
'; - $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); - $moreforfilter .= '
'; -} -// If the user can view other users -if ($user->hasRight("user", "user", "lire")) { - $moreforfilter .= '
'; - $tmptitle = $langs->trans('LinkedToSpecificUsers'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); - $moreforfilter .= '
'; -} - -// If the user can view other products/services than his own -if (isModEnabled('categorie') && $user->hasRight("categorie", "lire") && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '
'; - $tmptitle = $langs->trans('IncludingProductWithTag'); - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); - $moreforfilter .= '
'; -} -// If Categories are enabled & user has rights to see -if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '
'; - $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx'); - $moreforfilter .= '
'; -} -// If Stock is enabled -if (isModEnabled('stock') && getDolGlobalString('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) { - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - $moreforfilter .= '
'; - $tmptitle = $langs->trans('Warehouse'); - $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx'); - $moreforfilter .= '
'; -} -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; + if ($search_status == -3) + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id); + exit; + } + + llxHeader('', $title, $help_url); + + $param = ''; + + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if ($search_dateorder_start) $param .= '&search_dateorder_start='.urlencode($search_dateorder_start); + if ($search_dateorder_end) $param .= '&search_dateorder_end='.urlencode($search_dateorder_end); + if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start); + if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_warehouse != '') $param .= '&search_warehouse='.urlencode($search_warehouse); + if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($search_town != '') $param .= '&search_town='.urlencode($search_town); + if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); + if ($search_state != '') $param .= '&search_state='.urlencode($search_state); + if ($search_country != '') $param .= '&search_country='.urlencode($search_country); + if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($billed != '') $param .= '&billed='.urlencode($billed); + + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // List of mass actions available + $arrayofmassactions = array( + 'generate_doc'=>$langs->trans("ReGeneratePDF"), + 'builddoc'=>$langs->trans("PDFMerge"), + 'cancelorders'=>$langs->trans("Cancel"), + 'presend'=>$langs->trans("SendByMail"), + ); + if ($user->rights->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); + if ($user->rights->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + $newcardbutton = ''; + if ($contextpage == 'orderlist' && $user->rights->commande->creer) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/commande/card.php?action=create'); + } + + // Lines of title fields + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); + + $topicmail = "SendOrderRef"; + $modelmail = "order_send"; + $objecttmp = new Commande($db); + $trackid = 'ord'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($massaction == 'createbills') + { + //var_dump($_REQUEST); + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans('DateInvoice'); + print ''; + print $form->selectDate('', '', '', '', '', '', 1, 1); + print '
'; + print $langs->trans('CreateOneBillByThird'); + print ''; + print $form->selectyesno('createbills_onebythird', '', 1); + print '
'; + print $langs->trans('ValidateInvoices'); + print ''; + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) + { + print $form->selectyesno('validate_invoices', 0, 1, 1); + print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; + } + else + { + print $form->selectyesno('validate_invoices', 0, 1); + } + if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; + else print '     '.$langs->trans("OptionToSetOrderBilledNotEnabled").''; + print '
'; + + print '
'; + print '
'; + print ' '; + print ''; + print '
'; + print '
'; + } + + if ($sall) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + $moreforfilter = ''; + + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) + { + $langs->load("commercial"); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; + } + // If the user can view other users + if ($user->rights->user->user->lire) + { + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; + } + // If the user can view prospects other than his' + if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) + { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; + } + if (!empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '
'; + } + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Warehouse').': '; + $moreforfilter .= $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1); + $moreforfilter .= '
'; + } @@ -1496 +615,170 @@ - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + + print '
'; + print ''."\n"; + + print ''; + // Ref + if (!empty($arrayfields['c.ref']['checked'])) + { + print ''; + } + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) + { + print ''; + } + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + // Project title + if (!empty($arrayfields['p.title']['checked'])) + { + print ''; + } + // Thirpdarty + if (!empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) print ''; + // Zip + if (!empty($arrayfields['s.zip']['checked'])) print ''; + // State + if (!empty($arrayfields['state.nom']['checked'])) + { + print ''; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + } + // Company type + if (!empty($arrayfields['typent.code']['checked'])) + { + print ''; + } + // Date order + if (!empty($arrayfields['c.date_commande']['checked'])) + { + print ''; + } + if (!empty($arrayfields['c.date_delivery']['checked'])) + { + print ''; + } + if (!empty($arrayfields['c.total_ht']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['c.total_vat']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['c.total_ttc']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) + { + // Currency + print ''; + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) + { + // Currency rate + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['u.login']['checked'])) + { + // Author + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -1498,295 +786,42 @@ - print ''; -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -if (GETPOST('autoselectall', 'int')) { - $selectedfields .= ''; -} - -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ''; + print '
'; + print $langs->trans('From').' '; + print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to').' '; + print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end', 0, 0, 1); + print '
'; + print '
'; + print '
'; + print $langs->trans('From').' '; + print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to').' '; + print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end', 0, 0, 1); + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'."\n"; - -// Fields title search -// -------------------------------------------------------------------- -print ''; -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} - -// Ref -if (!empty($arrayfields['c.ref']['checked'])) { - print ''; -} -// Ref customer -if (!empty($arrayfields['c.ref_client']['checked'])) { - print ''; -} -// Project ref -if (!empty($arrayfields['p.ref']['checked'])) { - print ''; -} -// Project title -if (!empty($arrayfields['p.title']['checked'])) { - print ''; -} -// Thirpdarty -if (!empty($arrayfields['s.nom']['checked'])) { - print ''; -} -// Alias -if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; -} -// Parent company -if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; -} -// Town -if (!empty($arrayfields['s.town']['checked'])) { - print ''; -} -// Zip -if (!empty($arrayfields['s.zip']['checked'])) { - print ''; -} -// State -if (!empty($arrayfields['state.nom']['checked'])) { - print ''; -} -// Country -if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; -} -// Company type -if (!empty($arrayfields['typent.code']['checked'])) { - print ''; -} -// Date order -if (!empty($arrayfields['c.date_commande']['checked'])) { - print ''; -} -if (!empty($arrayfields['c.date_delivery']['checked'])) { - print ''; -} -// Shipping Method -if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { - print ''; -} -// Payment term -if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { - print ''; -} -// Payment mode -if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { - print ''; -} -// Channel -if (!empty($arrayfields['c.fk_input_reason']['checked'])) { - print ''; -} -// Amount HT / net -if (!empty($arrayfields['c.total_ht']['checked'])) { - print ''; -} -// Amount of VAT -if (!empty($arrayfields['c.total_vat']['checked'])) { - print ''; -} -// Total Amount (TTC / gross) -if (!empty($arrayfields['c.total_ttc']['checked'])) { - print ''; -} -// Currency -if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print ''; -} -// Currency rate -if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { - print ''; -} -// Amount HT/net in foreign currency -if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { - print ''; -} -// VAT in foreign currency -if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - print ''; -} -// Amount/Total (TTC / gross) in foreign currency -if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { - print ''; -} -// Author -if (!empty($arrayfields['u.login']['checked'])) { - print ''; -} -// Sales Representative -if (!empty($arrayfields['sale_representative']['checked'])) { - print ''; -} -if (!empty($arrayfields['total_pa']['checked'])) { - print ''; -} -if (!empty($arrayfields['total_margin']['checked'])) { - print ''; -} -if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; -} -if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; -} - -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -// Date creation -if (!empty($arrayfields['c.datec']['checked'])) { - print ''; -} -// Date modification -if (!empty($arrayfields['c.tms']['checked'])) { - print ''; -} -// Date cloture -if (!empty($arrayfields['c.date_cloture']['checked'])) { - print ''; -} -// Note public -if (!empty($arrayfields['c.note_public']['checked'])) { - print ''; -} -// Note private -if (!empty($arrayfields['c.note_private']['checked'])) { - print ''; -} -// Shippable -if (!empty($arrayfields['shippable']['checked'])) { - print ''; -} -// Status billed -if (!empty($arrayfields['c.facture']['checked'])) { - print ''; -} -// Import key -if (!empty($arrayfields['c.import_key']['checked'])) { - print ''; -} -// Status -if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) + { + print ''; + } + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) + { + print ''; + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) + { + print ''; + } + // Status billed + if (!empty($arrayfields['c.facture']['checked'])) + { + print ''; + } + // Action column + print ''."\n"; - -$totalarray = array( - 'nbfield' => 0, - 'val' => array( - 'c.total_ht' => 0, - 'c.total_tva' => 0, - 'c.total_ttc' => 0, - ), - 'pos' => array(), -); - - -// Fields title label -// -------------------------------------------------------------------- -print ''; - -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + + print "\n"; + + // Fields title + print ''; + if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); @@ -1817,207 +870,10 @@ - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.ref']['checked'])) { - print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.ref_client']['checked'])) { - print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['p.ref']['checked'])) { - print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['p.title']['checked'])) { - print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.name_alias']['checked'])) { - print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s2.nom']['checked'])) { - print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.town']['checked'])) { - print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.zip']['checked'])) { - print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['state.nom']['checked'])) { - print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['typent.code']['checked'])) { - print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.date_commande']['checked'])) { - print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.date_delivery']['checked'])) { - print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.fk_input_reason']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.total_vat']['checked'])) { - print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { - print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { - print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['u.login']['checked'])) { - print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['sale_representative']['checked'])) { - print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['total_pa']['checked'])) { - print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['total_margin']['checked'])) { - print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['total_margin_rate']['checked'])) { - print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['total_mark_rate']['checked'])) { - print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; -} - -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (!empty($arrayfields['c.datec']['checked'])) { - print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.tms']['checked'])) { - print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.date_cloture']['checked'])) { - print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.note_public']['checked'])) { - print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.note_private']['checked'])) { - print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['shippable']['checked'])) { - print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.facture']['checked'])) { - print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.import_key']['checked'])) { - print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); - $totalarray['nbfield']++; -} -print ''."\n"; - -$total = 0; -$subtotal = 0; -$productstat_cache = array(); -$productstat_cachevirtual = array(); -$getNomUrl_cache = array(); - -$generic_commande = new Commande($db); -$generic_product = new Product($db); -$userstatic = new User($db); - -$with_margin_info = false; -if (isModEnabled('margin') && ( - !empty($arrayfields['total_pa']['checked']) - || !empty($arrayfields['total_margin']['checked']) - || !empty($arrayfields['total_margin_rate']['checked']) - || !empty($arrayfields['total_mark_rate']['checked']) -) - ) { - $with_margin_info = true; -} - - $total_ht = 0; - $total_margin = 0; - - // Loop on record - // -------------------------------------------------------------------- + print ''."\n"; + + $total = 0; + $subtotal = 0; + $productstat_cache = array(); + $getNomUrl_cache = array(); + + $generic_commande = new Commande($db); + $generic_product = new Product($db); + $userstatic = new User($db); @@ -2025 +880,0 @@ - $savnbfield = $totalarray['nbfield']; @@ -2027,97 +882,37 @@ - $totalarray['nbfield'] = 0; - $imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - $notshippable = 0; - $warning = 0; - $text_info = ''; - $text_warning = ''; - $nbprod = 0; - - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->name_alias = $obj->alias; - $companystatic->client = $obj->client; - $companystatic->fournisseur = $obj->fournisseur; - $companystatic->code_client = $obj->code_client; - $companystatic->email = $obj->email; - $companystatic->phone = $obj->phone; - $companystatic->address = $obj->address; - $companystatic->zip = $obj->zip; - $companystatic->town = $obj->town; - $companystatic->country_code = $obj->country_code; - if (!isset($getNomUrl_cache[$obj->socid])) { - $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } - - $generic_commande->id = $obj->rowid; - $generic_commande->ref = $obj->ref; - $generic_commande->statut = $obj->fk_statut; - $generic_commande->billed = $obj->billed; - $generic_commande->date = $db->jdate($obj->date_commande); - $generic_commande->delivery_date = $db->jdate($obj->date_delivery); - $generic_commande->ref_client = $obj->ref_client; - $generic_commande->total_ht = $obj->total_ht; - $generic_commande->total_tva = $obj->total_tva; - $generic_commande->total_ttc = $obj->total_ttc; - $generic_commande->note_public = $obj->note_public; - $generic_commande->note_private = $obj->note_private; - - $generic_commande->thirdparty = $companystatic; - - - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_label; - - $marginInfo = array(); - if ($with_margin_info === true) { - $generic_commande->fetch_lines(); - $marginInfo = $formmargin->getMarginInfosArray($generic_commande); - $total_ht += $obj->total_ht; - $total_margin += $marginInfo['total_margin']; - } - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - } - } else { - // Show line of result - $j = 0; - print ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + $notshippable = 0; + $warning = 0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; + + $companystatic->id = $obj->socid; + $companystatic->code_client = $obj->code_client; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->email = $obj->email; + if (!isset($getNomUrl_cache[$obj->socid])) { + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + } + + $generic_commande->id = $obj->rowid; + $generic_commande->ref = $obj->ref; + $generic_commande->statut = $obj->fk_statut; + $generic_commande->billed = $obj->billed; + $generic_commande->date = $db->jdate($obj->date_commande); + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); + $generic_commande->ref_client = $obj->ref_client; + $generic_commande->total_ht = $obj->total_ht; + $generic_commande->total_tva = $obj->total_tva; + $generic_commande->total_ttc = $obj->total_ttc; + $generic_commande->note_public = $obj->note_public; + $generic_commande->note_private = $obj->note_private; + + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + + print ''; @@ -2126 +921,2 @@ - if (!empty($arrayfields['c.ref']['checked'])) { + if (!empty($arrayfields['c.ref']['checked'])) + { @@ -2127,0 +924,3 @@ + + $generic_commande->getLinesArray(); // This set ->lines + @@ -2130,490 +929,6 @@ - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['c.ref_client']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project label - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Alias name - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Order date - if (!empty($arrayfields['c.date_commande']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Plannned date of delivery - if (!empty($arrayfields['c.date_delivery']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Shipping Method - if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment terms - if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment mode - if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Channel - if (!empty($arrayfields['c.fk_input_reason']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT/net - if (!empty($arrayfields['c.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; - } - if (isset($totalarray['val']['c.total_ht'])) { - $totalarray['val']['c.total_ht'] += $obj->total_ht; - } else { - $totalarray['val']['c.total_ht'] = $obj->total_ht; - } - } - - // Amount VAT - if (!empty($arrayfields['c.total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; - } - if (isset($totalarray['val']['c.total_tva'])) { - $totalarray['val']['c.total_tva'] += $obj->total_tva; - } else { - $totalarray['val']['c.total_tva'] = $obj->total_tva; - } - } - - // Amount TTC / gross - if (!empty($arrayfields['c.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; - } - if (isset($totalarray['val']['c.total_ttc'])) { - $totalarray['val']['c.total_ttc'] += $obj->total_ttc; - } else { - $totalarray['val']['c.total_ttc'] = $obj->total_ttc; - } - } - - // Currency - if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT/net in foreign currency - if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT in foreign currency - if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC / gross in foreign currency - if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Sales representatives - if (!empty($arrayfields['sale_representative']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] += $marginInfo['total_margin']; - } - - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; - } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); - } else { - $totalarray['val']['total_mark_rate'] = ''; - } - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date cloture - if (!empty($arrayfields['c.date_cloture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Note public - if (!empty($arrayfields['c.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Note private - if (!empty($arrayfields['c.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Show shippable Icon (this creates subloops, so may be slow) - if (!empty($arrayfields['shippable']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Import key - if (!empty($arrayfields['c.import_key']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // State + if (!empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Order date + if (!empty($arrayfields['c.date_commande']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Plannned date of delivery + if (!empty($arrayfields['c.date_delivery']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['c.total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; + $totalarray['val']['c.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['c.total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; + $totalarray['val']['c.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['c.total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; + $totalarray['val']['c.total_ttc'] += $obj->total_ttc; + } + + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount VAT + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount TTC + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + + // Author + if (!empty($arrayfields['u.login']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Billed + if (!empty($arrayfields['c.facture']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; @@ -2762,3 +1284,2 @@ - } - $i++; -} + $i++; + } @@ -2769,11 +1289,0 @@ - // If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; -} - @@ -2783 +1293 @@ - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook @@ -2787 +1297 @@ - print ''."\n"; + print ''; @@ -2791 +1300,0 @@ -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { @@ -2793,3 +1302 @@ - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; @@ -2802,2 +1309,2 @@ - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; + $genallowed = $user->rights->commande->lire; + $delallowed = $user->rights->commande->creer; @@ -2807,4 +1314,8 @@ - - // End of page - llxFooter(); - $db->close(); +else +{ + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); --- /tmp/dsg/dolibarr/htdocs/commande/github_19.0.3_note.php +++ /tmp/dsg/dolibarr/htdocs/commande/client_note.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -32 +31 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -42 +41 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -46,7 +45 @@ -if ($user->socid) { - $socid = $user->socid; -} - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('ordernote')); - +if ($user->socid) $socid = $user->socid; @@ -54,4 +46,0 @@ - -$usercancreate = $user->hasRight("commande", "creer"); - -$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php @@ -61 +50,2 @@ -if (!$object->fetch($id, $ref) > 0) { +if (!$object->fetch($id, $ref) > 0) +{ @@ -64,0 +55,2 @@ + +$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php @@ -71,8 +63 @@ -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -84,3 +69,2 @@ -$title = $object->ref." - ".$langs->trans('Notes'); -$help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; -llxHeader('', $title, $help_url); + +llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); @@ -90 +74,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -95 +80 @@ - print dol_get_fiche_head($head, 'note', $langs->trans("CustomerOrder"), -1, 'order'); + dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), -1, 'order'); @@ -107 +92 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -109,19 +94,32 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -144 +142 @@ - print dol_get_fiche_end(); + dol_fiche_end();
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); - print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); - print ''; - print '
'; - print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); - print ''; - print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); - print ''; - print $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1, '', 1); - print ''; - $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print ''; - print ''; - //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); - if (getDolGlobalString('ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT')) { - print ''; - print $langs->trans('ShowShippableStatus'); - } else { - $show_shippable_command = 1; - } - print ''; - print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); - print ''; - print ''; - $liststatus = array( - Commande::STATUS_DRAFT => $langs->trans("StatusOrderDraftShort"), - Commande::STATUS_VALIDATED => $langs->trans("StatusOrderValidated"), - Commande::STATUS_SHIPMENTONPROCESS => $langs->trans("StatusOrderSentShort"), - -2 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), - -3 => $langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CLOSED => $langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED => $langs->trans("StatusOrderCanceledShort") - ); - print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); - print ''; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) + { + print ''; + print ''; + print ''; + print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); + print ''; + print $form->selectyesno('billed', $billed, 1, 0, 1); + print ''; @@ -1796,20 +831,38 @@ -} -print '
'; - print '
'; - } - - // Output Kanban - $selected = -1; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - } - print $generic_commande->getKanbanView('', array('selected' => $selected)); - if ($i == ($imaxinloop - 1)) { - print '
'; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'; - print dol_escape_htmltag($obj->ref_client); - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print $projectstatic->title; - } - print ''; - if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { - print $companystatic->getNomUrl(1, 'customer', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } else { - print $getNomUrl_cache[$obj->socid]; - } - - // If module invoices enabled and user with invoice creation permissions - if (isModEnabled('facture') && getDolGlobalString('ORDER_BILLING_ALL_CUSTOMER')) { - if ($user->hasRight('facture', 'creer')) { - if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { - print ' '; - print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; - } - } - } - print ''; - print $obj->alias; - print ''; - if ($obj->fk_parent > 0) { - if (!isset($company_url_list[$obj->fk_parent])) { - $companyparent = new Societe($db); - $res = $companyparent->fetch($obj->fk_parent); - if ($res > 0) { - $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); - } - } - if (isset($company_url_list[$obj->fk_parent])) { - print $company_url_list[$obj->fk_parent]; - } - } - print "'; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - print dol_print_date($db->jdate($obj->date_commande), 'day'); - // Warning late icon and note - if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); - } - print ''; - print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); - print ''; - $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); - print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''; - $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } else { - print ' '; - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); - } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; - } - //print '
'; - } - } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; - } - print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if (!empty($show_shippable_command) && isModEnabled('stock')) { - if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { - $generic_commande->getLinesArray(); // Load array ->lines - $generic_commande->loadExpeditions(); // Load array ->expeditions - + // Show shippable Icon (create subloop, so may be slow) + if ($conf->stock->enabled) + { + $langs->load("stocks"); + if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) + { @@ -2621,7 +936,4 @@ - for ($lig = 0; $lig < $numlines; $lig++) { - if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { - $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; - } else { - $reliquat = $generic_commande->lines[$lig]->qty; - } - if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service + for ($lig = 0; $lig < $numlines; $lig++) + { + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service + { @@ -2633 +945,2 @@ - $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock() + $generic_product->load_stock('nobatch'); + //$generic_product->load_virtual_stock(); Already included into load_stock @@ -2641,2 +954,11 @@ - if ($reliquat > $generic_product->stock_reel) { - $notshippable++; + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result + { + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique; + $text_info .= '
'; + + if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) + { + $notshippable++; + } @@ -2644,10 +966 @@ - if (!getDolGlobalString('SHIPPABLE_ORDER_ICON_IN_LIST')) { // Default code. Default should be this case. - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; - $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; - } else { // BUGGED CODE. - // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. - // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE - // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + else { // Detailed code, looks bugged @@ -2657,2 +970,4 @@ - if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { // What about other options ? - if (isModEnabled('commande')) { + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? + { + if (!empty($conf->commande->enabled)) + { @@ -2667 +982,2 @@ - if (isModEnabled("supplier_order")) { + if (!empty($conf->fournisseur->enabled)) + { @@ -2677 +993 @@ - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); @@ -2683 +999,2 @@ - if ($reliquat > $generic_product->stock_reel) { + if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { + $notshippable++; @@ -2688,2 +1005,4 @@ - if (isModEnabled("supplier_order")) { - $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; + if (!empty($conf->fournisseur->enabled)) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; + } else { + $text_info .= '
'; @@ -2691,2 +1009,0 @@ - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; @@ -2698 +1015 @@ - $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; + $text_info = $langs->trans('Shippable').'
'.$text_info; @@ -2701 +1018 @@ - $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + $text_info = $langs->trans('NonShippable').'
'.$text_info; @@ -2705 +1022,2 @@ - if ($nbprod) { + if ($nbprod) + { @@ -2711,0 +1030,11 @@ + + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); + @@ -2713,38 +1042,17 @@ - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Billed - if (!empty($arrayfields['c.facture']['checked'])) { - print '
'.yn($obj->billed).''.dol_escape_htmltag($obj->import_key).''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) + { + print ''.$obj->ref_client.''; + if ($obj->project_id > 0) + { + print $projectstatic->getNomUrl(1); @@ -2753,2 +1061,32 @@ - if (!$i) { - $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; + } + + // Project label + if (!empty($arrayfields['p.title']['checked'])) + { + print ''; + if ($obj->project_id > 0) + { + print $projectstatic->title; + } + print ''; + print $getNomUrl_cache[$obj->socid]; + + // If module invoices enabled and user with invoice creation permissions + if (!empty($conf->facture->enabled) && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) + { + if ($user->rights->facture->creer) + { + if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) + { + print ' '; + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; + } + } @@ -2756 +1094,185 @@ - } + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'day'); + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; + if ($userstatic->id) print $userstatic->getLoginUrl(1); + else print ' '; + print "'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''.yn($obj->billed).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'