39require
'../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
65 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
69$langs->loadLangs(array(
"categories",
"orders",
'sendings',
'companies',
'compta',
'bills',
'stocks',
'products'));
71$action =
GETPOST(
'action',
'aZ09');
72$massaction =
GETPOST(
'massaction',
'alpha');
74$confirm =
GETPOST(
'confirm',
'alpha');
75$toselect =
GETPOST(
'toselect',
'array:int');
76$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'orderlistdet';
77$optioncss =
GETPOST(
'optioncss',
'alpha');
79$productobuy =
GETPOST(
'productobuy',
'alpha');
80$productonly =
GETPOST(
'productonly',
'alpha');
81$disablelinefree =
GETPOST(
'disablelinefree',
'alpha');
83$search_datecloture_start =
GETPOSTINT(
'search_datecloture_start');
84if (empty($search_datecloture_start)) {
87$search_datecloture_end =
GETPOSTINT(
'search_datecloture_end');
88if (empty($search_datecloture_end)) {
96$search_product_category_array = array();
97$searchCategoryProductOperator = 0;
99 $search_product_category_array =
GETPOST(
"search_category_".Categorie::TYPE_PRODUCT.
"_list",
"array");
101 $searchCategoryProductOperator =
GETPOSTINT(
'search_category_product_operator');
110$search_id =
GETPOST(
'search_id',
'alpha');
111$search_refProduct =
GETPOST(
'search_refProduct',
'alpha');
112$search_descProduct =
GETPOST(
'search_descProduct',
'alpha');
114$search_ref =
GETPOST(
'search_ref',
'alpha') !=
'' ?
GETPOST(
'search_ref',
'alpha') :
GETPOST(
'sref',
'alpha');
115$search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
116$search_company =
GETPOST(
'search_company',
'alpha');
117$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
118$search_town =
GETPOST(
'search_town',
'alpha');
119$search_zip =
GETPOST(
'search_zip',
'alpha');
120$search_state =
GETPOST(
"search_state",
'alpha');
121$search_country =
GETPOST(
"search_country",
'aZ09');
122$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
123$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
124$search_user =
GETPOST(
'search_user',
'intcomma');
125$search_sale =
GETPOST(
'search_sale',
'intcomma');
126$search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
127$search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
128$search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
129$search_warehouse =
GETPOST(
'search_warehouse',
'intcomma');
130$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
131$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
132$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
133$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
134$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
135$search_login =
GETPOST(
'search_login',
'alpha');
136$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma');
137$search_billed =
GETPOST(
'search_billed',
'intcomma');
138$search_status =
GETPOST(
'search_status',
'intcomma');
139$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
140$search_project =
GETPOST(
'search_project',
'alpha');
141$search_shippable =
GETPOST(
'search_shippable',
'aZ09');
142$search_fk_cond_reglement =
GETPOSTINT(
"search_fk_cond_reglement");
143$search_fk_shipping_method =
GETPOSTINT(
"search_fk_shipping_method");
144$search_fk_mode_reglement =
GETPOSTINT(
"search_fk_mode_reglement");
145$search_fk_input_reason =
GETPOSTINT(
"search_fk_input_reason");
147$diroutputmassaction =
$conf->commande->multidir_output[
$conf->entity].
'/temp/massgeneration/'.$user->id;
151$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
152$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
154if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
157$offset = $limit * $page;
158$pageprev = $page - 1;
159$pagenext = $page + 1;
161 $sortfield =
'c.ref';
167$show_shippable_command =
GETPOST(
'show_shippable_command',
'aZ09');
171$hookmanager->initHooks(array(
'orderlistdetail'));
174$extrafields->fetch_name_optionals_label(
$object->table_element);
175$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
178$fieldstosearchall = array(
180 'c.ref_client' =>
'RefCustomerOrder',
181 'cdet.description' =>
'Description',
182 's.nom' =>
"ThirdParty",
183 's.name_alias' =>
"AliasNameShort",
186 'c.note_public' =>
'NotePublic',
188if (empty($user->socid)) {
189 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
192$checkedtypetiers = 0;
195 'rowid' => array(
'label' =>
'LineID',
'checked' =>
'-1',
'position' => 1,
'enabled' =>
'1'),
196 'c.ref' => array(
'label' =>
"RefOrder",
'checked' =>
'1',
'position' => 5),
197 'pr.ref' => array(
'label' =>
'ProductRef',
'checked' =>
'1',
'position' => 6),
198 'pr.label' => array(
'label' =>
'ProductLabel',
'checked' =>
'-1',
'position' => 7),
199 'cdet.qty' => array(
'label' =>
'QtyOrdered',
'checked' =>
'1',
'position' => 8),
200 'c.ref_client' => array(
'label' =>
"RefCustomerOrder",
'checked' =>
'-1',
'position' => 10),
201 'p.ref' => array(
'label' =>
"ProjectRef",
'checked' =>
'-1',
'enabled' => (
string) (
int)
isModEnabled(
'project'),
'position' => 20),
202 'p.title' => array(
'label' =>
"ProjectLabel",
'checked' =>
'0',
'enabled' => (
string) (
int)
isModEnabled(
'project'),
'position' => 25),
203 's.nom' => array(
'label' =>
"ThirdParty",
'checked' =>
'1',
'position' => 30),
204 's.name_alias' => array(
'label' =>
"AliasNameShort",
'checked' =>
'-1',
'position' => 31),
205 's.town' => array(
'label' =>
"Town",
'checked' =>
'-1',
'position' => 35),
206 's.zip' => array(
'label' =>
"Zip",
'checked' =>
'-1',
'position' => 40),
207 'state.nom' => array(
'label' =>
"StateShort",
'checked' =>
'0',
'position' => 45),
208 'country.code_iso' => array(
'label' =>
"Country",
'checked' =>
'0',
'position' => 50),
209 'typent.code' => array(
'label' =>
"ThirdPartyType",
'checked' => (
string) $checkedtypetiers,
'position' => 55),
210 'c.date_commande' => array(
'label' =>
"OrderDateShort",
'checked' =>
'1',
'position' => 60),
211 'c.delivery_date' => array(
'label' =>
"DateDeliveryPlanned",
'checked' =>
'1',
'enabled' => (
string) (
int) !
getDolGlobalString(
'ORDER_DISABLE_DELIVERY_DATE'),
'position' => 65),
212 'c.fk_shipping_method' => array(
'label' =>
"SendingMethod",
'checked' =>
'-1',
'position' => 66 ,
'enabled' => (
string) (
int)
isModEnabled(
'shipping')),
213 'c.fk_cond_reglement' => array(
'label' =>
"PaymentConditionsShort",
'checked' =>
'-1',
'position' => 67),
214 'c.fk_mode_reglement' => array(
'label' =>
"PaymentMode",
'checked' =>
'-1',
'position' => 68),
215 'c.fk_input_reason' => array(
'label' =>
"Channel",
'checked' =>
'-1',
'position' => 69),
216 'cdet.total_ht' => array(
'label' =>
"AmountHT",
'checked' =>
'1',
'position' => 75),
217 'c.total_vat' => array(
'label' =>
"AmountVAT",
'checked' =>
'0',
'position' => 80),
218 'cdet.total_ttc' => array(
'label' =>
"AmountTTC",
'checked' =>
'0',
'position' => 85),
219 'c.multicurrency_code' => array(
'label' =>
'Currency',
'checked' =>
'0',
'enabled' => (empty(
$conf->multicurrency->enabled) ?
'0' :
'1'),
'position' => 90),
220 'c.multicurrency_tx' => array(
'label' =>
'CurrencyRate',
'checked' =>
'0',
'enabled' => (empty(
$conf->multicurrency->enabled) ?
'0' :
'1'),
'position' => 95),
221 'c.multicurrency_total_ht' => array(
'label' =>
'MulticurrencyAmountHT',
'checked' =>
'0',
'enabled' => (empty(
$conf->multicurrency->enabled) ?
'0' :
'1'),
'position' => 100),
222 'c.multicurrency_total_vat' => array(
'label' =>
'MulticurrencyAmountVAT',
'checked' =>
'0',
'enabled' => (empty(
$conf->multicurrency->enabled) ?
'0' :
'1'),
'position' => 105),
223 'c.multicurrency_total_ttc' => array(
'label' =>
'MulticurrencyAmountTTC',
'checked' =>
'0',
'enabled' => (empty(
$conf->multicurrency->enabled) ?
'0' :
'1'),
'position' => 110),
224 'c.fk_warehouse' => array(
'label' =>
'Warehouse',
'checked' =>
'0',
'enabled' => (string) (int) (!
isModEnabled(
'stock') && !
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') ?
'0' :
'1'),
'position' => 110),
225 'u.login' => array(
'label' =>
"Author",
'checked' =>
'1',
'position' => 115),
226 'sale_representative' => array(
'label' =>
"SaleRepresentativesOfThirdParty",
'checked' =>
'0',
'position' => 116),
227 'total_pa' => array(
'label' => (
getDolGlobalString(
'MARGIN_TYPE') ==
'1' ?
'BuyingPrice' :
'CostPrice'),
'checked' =>
'0',
'position' => 300,
'enabled' => (string) (int) (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') ?
'0' :
'1')),
228 'total_margin' => array(
'label' =>
'Margin',
'checked' =>
'0',
'position' => 301,
'enabled' => (string) (int) (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') ?
'0' :
'1')),
229 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' =>
'0',
'position' => 302,
'enabled' => (string) (int) (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') || !
getDolGlobalString(
'DISPLAY_MARGIN_RATES') ?
'0' :
'1')),
230 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' =>
'0',
'position' => 303,
'enabled' => (string) (int) (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') || !
getDolGlobalString(
'DISPLAY_MARK_RATES') ?
'0' :
'1')),
231 'c.datec' => array(
'label' =>
"DateCreation",
'checked' =>
'0',
'position' => 120),
232 'c.tms' => array(
'label' =>
"DateModificationShort",
'checked' =>
'0',
'position' => 125),
233 'c.date_cloture' => array(
'label' =>
"DateClosing",
'checked' =>
'0',
'position' => 130),
234 'c.note_public' => array(
'label' =>
'NotePublic',
'checked' =>
'0',
'enabled' => (string) (int) (!
getDolGlobalString(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position' => 135),
235 'c.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'enabled' => (string) (int) (!
getDolGlobalString(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position' => 140),
236 'shippable' => array(
'label' =>
"Shippable",
'checked' =>
'1',
'enabled' => (string) (int) (
isModEnabled(
'shipping')),
'position' => 990),
237 'c.facture' => array(
'label' =>
"Billed",
'checked' =>
'1',
'enabled' => (string) (int) (!
getDolGlobalString(
'WORKFLOW_BILL_ON_SHIPMENT')),
'position' => 995),
238 'c.import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' =>
'1',
'visible' => -2,
'position' => 999),
239 'c.fk_statut' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 1000)
243include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
245$parameters = array(
'arrayfields' => &$arrayfields);
246$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
251if (!$user->hasRight(
'societe',
'client',
'voir')) {
252 $search_sale = $user->id;
258 $socid = $user->socid;
262$permissiontoread = $user->hasRight(
"commande",
"lire");
263$permissiontoadd = $user->hasRight(
"commande",
"creer");
264$permissiontodelete = $user->hasRight(
"commande",
"supprimer");
265$permissiontoexport = $user->hasRight(
"commande",
"commande",
"export");
267 $permissiontovalidate = $user->hasRight(
"commande",
"order_advance",
"validate");
268 $permissiontoclose = $user->hasRight(
"commande",
"order_advance",
"close");
269 $permissiontocancel = $user->hasRight(
"commande",
"order_advance",
"annuler");
270 $permissiontosendbymail = $user->hasRight(
"commande",
"order_advance",
"send");
272 $permissiontovalidate = $user->hasRight(
"commande",
"creer");
273 $permissiontoclose = $user->hasRight(
"commande",
"creer");
274 $permissiontocancel = $user->hasRight(
"commande",
"creer");
275 $permissiontosendbymail = $user->hasRight(
"commande",
"creer");
283if (
GETPOST(
'cancel',
'alpha')) {
287if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
291$parameters = array(
'socid' => $socid);
292$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
294 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
297if (empty($reshook)) {
299 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
302 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
305 $disablelinefree =
'';
309 $search_product_category_array = array();
310 $searchCategoryProductOperator = 0;
312 $search_refProduct =
'';
313 $search_descProduct =
'';
315 $search_ref_customer =
'';
316 $search_company =
'';
317 $search_company_alias =
'';
322 $search_country =
'';
323 $search_type_thirdparty =
'';
324 $search_total_ht =
'';
325 $search_total_vat =
'';
326 $search_total_ttc =
'';
327 $search_warehouse =
'';
328 $search_multicurrency_code =
'';
329 $search_multicurrency_tx =
'';
330 $search_multicurrency_montant_ht =
'';
331 $search_multicurrency_montant_vat =
'';
332 $search_multicurrency_montant_ttc =
'';
334 $search_dateorder_start =
'';
335 $search_dateorder_end =
'';
336 $search_datedelivery_start =
'';
337 $search_datedelivery_end =
'';
338 $search_project_ref =
'';
339 $search_project =
'';
343 $search_array_options = array();
344 $search_categ_cus =
'';
345 $search_datecloture_start =
'';
346 $search_datecloture_end =
'';
347 $search_fk_cond_reglement =
'';
348 $search_fk_shipping_method =
'';
349 $search_fk_mode_reglement =
'';
350 $search_fk_input_reason =
'';
352 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
353 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
358 $objectclass =
'Commande';
359 $objectlabel =
'Orders';
360 $uploaddir =
$conf->commande->multidir_output[
$conf->entity];
361 $triggersendname =
'ORDER_SENTBYMAIL';
362 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
372$form =
new Form($db);
380$companystatic =
new Societe($db);
382$projectstatic =
new Project($db);
384$title = $langs->trans(
"Orders");
385$help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
389$sqlSelect =
'SELECT';
391if ($search_all || !empty($search_product_category_array) || $search_user > 0) {
392 $sqlSelect =
'SELECT DISTINCT';
394$sqlSelect .=
' 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.code_client,';
395$sqlSelect .=
" typent.code as typent_code,";
396$sqlSelect .=
" state.code_departement as state_code, state.nom as state_name,";
397$sqlSelect .=
" country.code as country_code,";
398$sqlSelect .=
' c.rowid as c_rowid, c.ref, c.ref_client, c.fk_user_author,';
399$sqlSelect .=
' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,';
400$sqlSelect .=
' c.total_ht as c_total_ht, c.total_tva as c_total_tva, c.total_ttc as c_total_ttc, c.fk_warehouse as warehouse,';
401$sqlSelect .=
' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as delivery_date, c.fk_statut, c.facture as billed,';
402$sqlSelect .=
' c.date_creation as date_creation, c.tms as date_modification, c.date_cloture as date_cloture,';
403$sqlSelect .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
404$sqlSelect .=
' 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,';
405$sqlSelect .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
406$sqlSelect .=
' c.fk_input_reason, c.import_key,';
408$sqlSelect .=
' cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc,';
409$sqlSelect .=
' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy';
411if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
412 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
413 $sqlSelect .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
418$parameters = array();
419$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
420$sqlSelect .= $hookmanager->resPrint;
422$sql =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
423$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
424$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
425$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
427$sql .=
', '.MAIN_DB_PREFIX.
'commandedet as cdet';
428$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande as c ON cdet.fk_commande = c.rowid';
429$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as pr ON pr.rowid = cdet.fk_product';
430if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
431 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
433$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
434$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
436if ($search_user > 0) {
437 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
438 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
441$parameters = array();
442$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
443$sql .= $hookmanager->resPrint;
445$sql .=
' WHERE c.fk_soc = s.rowid';
446$sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
447$sql .=
' AND cdet.product_type <> 9';
449if (!empty($productobuy)) {
450 $sql .=
" AND pr.tobuy = 1";
452if (!empty($productonly)) {
453 $sql .=
" AND (cdet.product_type = 0 OR cdet.product_type = 1)";
455if (!empty($disablelinefree)) {
456 $sql .=
" AND cdet.fk_product IS NOT NULL";
459 $sql .=
' AND s.rowid = '.((int) $socid);
464if ($search_refProduct) {
467if ($search_descProduct) {
468 $sql .=
natural_search(array(
'pr.label',
'cdet.description'), $search_descProduct);
473if ($search_ref_customer) {
477 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
479if ($search_billed !=
'' && $search_billed >= 0) {
480 $sql .=
' AND c.facture = '.((int) $search_billed);
482if ($search_status !=
'') {
483 if ($search_status <= 3 && $search_status >= -1) {
485 $sql .=
' AND c.fk_statut IN (1,2)';
487 $sql .=
' AND c.fk_statut = '.((int) $search_status);
490 if ($search_status == -2) {
492 $sql .=
" AND c.fk_statut IN (1,2)";
494 if ($search_status == -3) {
497 $sql .=
' AND c.fk_statut IN (1,2,3)';
501if ($search_datecloture_start) {
502 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
504if ($search_datecloture_end) {
505 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
507if ($search_dateorder_start) {
508 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
510if ($search_dateorder_end) {
511 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
513if ($search_datedelivery_start) {
514 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
516if ($search_datedelivery_end) {
517 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
528if ($search_country) {
529 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
531if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
532 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
534if ($search_company) {
537if ($search_company_alias) {
540if ($search_user > 0) {
541 $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);
543if ($search_total_ht !=
'') {
546if ($search_total_vat !=
'') {
549if ($search_total_ttc !=
'') {
552if ($search_warehouse !=
'' && $search_warehouse > 0) {
555if ($search_multicurrency_code !=
'') {
556 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
558if ($search_multicurrency_tx !=
'') {
559 $sql .=
natural_search(
'c.multicurrency_tx', $search_multicurrency_tx, 1);
561if ($search_multicurrency_montant_ht !=
'') {
562 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
564if ($search_multicurrency_montant_vat !=
'') {
565 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
567if ($search_multicurrency_montant_ttc !=
'') {
568 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
571 $sql .=
natural_search(array(
"u.login",
"u.firstname",
"u.lastname"), $search_login);
573if ($search_project_ref !=
'') {
576if ($search_project !=
'') {
579if ($search_fk_cond_reglement > 0) {
580 $sql .=
" AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
582if ($search_fk_shipping_method > 0) {
583 $sql .=
" AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
585if ($search_fk_mode_reglement > 0) {
586 $sql .=
" AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
588if ($search_fk_input_reason > 0) {
589 $sql .=
" AND c.fk_input_reason = ".((int) $search_fk_input_reason);
592if ($search_sale && $search_sale !=
'-1') {
593 if ($search_sale == -2) {
594 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'c.fk_soc', 0, 1);
595 } elseif ($search_sale > 0) {
596 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'c.fk_soc', (
int) $search_sale);
600$searchCategoryCustomerOperator =
GETPOSTINT(
'search_category_customer_operator');
601$searchCategoryCustomerList = ($search_categ_cus !==
'-1' ? explode(
',', $search_categ_cus) : array());
602if (!empty($searchCategoryCustomerList)) {
603 $searchCategoryCustomerSqlList = array();
604 $listofcategoryid =
'';
605 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
606 if (intval($searchCategoryCustomer) == -2) {
607 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT cs.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs WHERE s.rowid = cs.fk_soc)";
608 } elseif (intval($searchCategoryCustomer) > 0) {
609 if ($searchCategoryCustomerOperator == 0) {
610 $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).
")";
612 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
616 if ($listofcategoryid) {
617 $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).
"))";
619 if ($searchCategoryCustomerOperator == 1) {
620 if (!empty($searchCategoryCustomerSqlList)) {
621 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
624 if (!empty($searchCategoryCustomerSqlList)) {
625 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
630$searchCategoryProductList = $search_product_category_array;
631if (!empty($searchCategoryProductList)) {
632 $searchCategoryProjectSqlList = array();
633 $listofcategoryid =
'';
634 foreach ($searchCategoryProductList as $searchCategoryProject) {
635 if (intval($searchCategoryProject) == -2) {
636 $searchCategoryProjectSqlList[] =
"NOT EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as cp WHERE cdet.fk_product = cp.fk_product)";
637 } elseif (intval($searchCategoryProject) > 0) {
638 if ($searchCategoryProductOperator == 0) {
639 $searchCategoryProjectSqlList[] =
" EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as cp WHERE cdet.fk_product = cp.fk_product AND cp.fk_categorie = ".((int) $searchCategoryProject).
")";
641 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProject);
645 if ($listofcategoryid) {
646 $searchCategoryProjectSqlList[] =
" EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as cp WHERE cdet.fk_product = cp.fk_product AND cp.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
648 if ($searchCategoryProductOperator == 1) {
649 if (!empty($searchCategoryProjectSqlList)) {
650 $sql .=
" AND (".implode(
' OR ', $searchCategoryProjectSqlList).
")";
653 if (!empty($searchCategoryProjectSqlList)) {
654 $sql .=
" AND (".implode(
' AND ', $searchCategoryProjectSqlList).
")";
660include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
663$parameters = array();
664$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
665$sql .= $hookmanager->resPrint;
668$parameters = array();
669$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
670if (empty($reshook)) {
671 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
673 $sql = $hookmanager->resPrint;
676$sql .= $db->order($sortfield, $sortorder);
679$nbtotalofrecords =
'';
681 $result = $db->query(
'SELECT COUNT(*) as numrows ' . $sql);
682 $obj = $db->fetch_object($result);
684 $nbtotalofrecords = 0;
686 $nbtotalofrecords = $obj->numrows;
689 if (($page * $limit) > (
int) $nbtotalofrecords) {
695$sql .= $db->plimit($limit + 1, $offset);
697$resql = $db->query($sqlSelect . $sql);
702 $title = $langs->trans(
'ListOrderLigne').
' - '.$soc->name;
703 if (empty($search_company)) {
704 $search_company = $soc->name;
707 $title = $langs->trans(
'ListOrderLigne');
709 if (strval($search_status) ==
'0') {
710 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
712 if ($search_status == 1) {
713 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
715 if ($search_status == 2) {
716 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
718 if ($search_status == 3) {
719 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
721 if ($search_status == -1) {
722 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
724 if ($search_status == -2) {
725 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
727 if ($search_status == -3) {
728 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(!
isModEnabled(
'shipping') ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
731 $num = $db->num_rows($resql);
733 $arrayofselected = is_array($toselect) ? $toselect : array();
735 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
736 $obj = $db->fetch_object($resql);
738 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.$id);
742 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-commande page-list_det');
746 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
747 $param .=
'&contextpage='.urlencode($contextpage);
749 if ($limit > 0 && $limit !=
$conf->liste_limit) {
750 $param .=
'&limit='.((int) $limit);
753 $param .=
'&search_all='.urlencode($search_all);
756 $param .=
'&socid='.urlencode((
string) ($socid));
759 $param .=
'&search_id='.urlencode($search_id);
762 if ($search_refProduct) {
763 $param .=
'&search_refProduct='.urlencode($search_refProduct);
765 if ($search_descProduct) {
766 $param .=
'&search_descProduct='.urlencode($search_descProduct);
768 if ($search_status !=
'') {
769 $param .=
'&search_status='.urlencode($search_status);
771 if ($search_datecloture_start) {
772 $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');
774 if ($search_datecloture_end) {
775 $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');
777 if ($search_dateorder_start) {
778 $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');
780 if ($search_dateorder_end) {
781 $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');
783 if ($search_datedelivery_start) {
784 $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');
786 if ($search_datedelivery_end) {
787 $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');
790 $param .=
'&search_ref='.urlencode($search_ref);
792 if ($search_company) {
793 $param .=
'&search_company='.urlencode($search_company);
795 if ($search_company_alias) {
796 $param .=
'&search_company_alias='.urlencode($search_company_alias);
798 if ($search_ref_customer) {
799 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
801 if ($search_user > 0) {
802 $param .=
'&search_user='.urlencode((
string) ($search_user));
804 if ($search_sale > 0) {
805 $param .=
'&search_sale='.urlencode($search_sale);
807 if ($search_total_ht !=
'') {
808 $param .=
'&search_total_ht='.urlencode($search_total_ht);
810 if ($search_total_vat !=
'') {
811 $param .=
'&search_total_vat='.urlencode($search_total_vat);
813 if ($search_total_ttc !=
'') {
814 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
816 if ($search_warehouse !=
'') {
817 $param .=
'&search_warehouse='.urlencode((
string) ($search_warehouse));
820 $param .=
'&search_login='.urlencode($search_login);
822 if ($search_multicurrency_code !=
'') {
823 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
825 if ($search_multicurrency_tx !=
'') {
826 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
828 if ($search_multicurrency_montant_ht !=
'') {
829 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
831 if ($search_multicurrency_montant_vat !=
'') {
832 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
834 if ($search_multicurrency_montant_ttc !=
'') {
835 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
837 if ($search_project_ref >= 0) {
838 $param .=
"&search_project_ref=".urlencode($search_project_ref);
840 if ($search_town !=
'') {
841 $param .=
'&search_town='.urlencode($search_town);
843 if ($search_zip !=
'') {
844 $param .=
'&search_zip='.urlencode($search_zip);
846 if ($search_state !=
'') {
847 $param .=
'&search_state='.urlencode($search_state);
849 if ($search_country !=
'') {
850 $param .=
'&search_country='.urlencode((
string) ($search_country));
852 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
853 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
855 if (!empty($search_product_category_array)) {
856 foreach ($search_product_category_array as $tmpval) {
857 $param .=
'&search_categegory_product_list[]='.urlencode($tmpval);
860 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
861 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
864 $param .=
'&show_files='.urlencode((
string) ($show_files));
866 if ($optioncss !=
'') {
867 $param .=
'&optioncss='.urlencode($optioncss);
869 if ($search_billed !=
'') {
870 $param .=
'&search_billed='.urlencode($search_billed);
872 if ($search_fk_cond_reglement > 0) {
873 $param .=
'&search_fk_cond_reglement='.urlencode((
string) ($search_fk_cond_reglement));
875 if ($search_fk_shipping_method > 0) {
876 $param .=
'&search_fk_shipping_method='.urlencode((
string) ($search_fk_shipping_method));
878 if ($search_fk_mode_reglement > 0) {
879 $param .=
'&search_fk_mode_reglement='.urlencode((
string) ($search_fk_mode_reglement));
881 if ($search_fk_input_reason > 0) {
882 $param .=
'&search_fk_input_reason='.urlencode((
string) ($search_fk_input_reason));
884 if (!empty($productobuy)) {
885 $param .=
'&productobuy='.urlencode($productobuy);
887 if (!empty($productonly)) {
888 $param .=
'&productonly='.urlencode($productonly);
890 if (!empty($disablelinefree)) {
891 $param .=
'&disablelinefree='.urlencode($disablelinefree);
895 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
898 $parameters = array(
'param' => &$param);
899 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
900 $param .= $hookmanager->resPrint;
903 $arrayofmassactions = array(
907 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
909 $url = DOL_URL_ROOT.
'/commande/card.php?action=create';
910 if (!empty($socid)) {
911 $url .=
'&socid='.$socid;
916 print
'<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
917 if ($optioncss !=
'') {
918 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
920 print
'<input type="hidden" name="token" value="'.newToken().
'">';
921 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
922 print
'<input type="hidden" name="action" value="list">';
923 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
924 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
925 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
926 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
927 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
929 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
931 $topicmail =
"SendOrderRef";
932 $modelmail =
"order_send";
934 $trackid =
'ord'.$object->id;
935 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
938 foreach ($fieldstosearchall as $key => $val) {
939 $fieldstosearchall[$key] = $langs->trans($val);
941 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
946 $moreforfilter .=
'<div class="divsearchfield">';
947 $moreforfilter .=
'<input type="checkbox" id="productobuy" name="productobuy"'.(!empty($productobuy) ?
'value="productobuychecked" checked' :
'').
'><label for="productobuy">'.$langs->trans(
"productobuy").
'</label>';
948 $moreforfilter .=
'</div>';
949 $moreforfilter .=
'<div class="divsearchfield">';
950 $moreforfilter .=
'<input type="checkbox" id="productonly" name="productonly"'.(!empty($productonly) ?
'value="productonlychecked" checked' :
'').
'><label for="productonly">'.$langs->trans(
"productonly").
'</label>';
951 $moreforfilter .=
'</div>';
952 $moreforfilter .=
'<div class="divsearchfield">';
953 $moreforfilter .=
'<input type="checkbox" id="disablelinefree" name="disablelinefree"'.(!empty($disablelinefree) ?
'value="disablelinefreechecked" checked' :
'').
'><label for="disablelinefree">'.$langs->trans(
"disablelinefree").
'</label>';
954 $moreforfilter .=
'</div><br>';
957 if ($user->hasRight(
'user',
'user',
'lire')) {
958 $langs->load(
"commercial");
959 $moreforfilter .=
'<div class="divsearchfield">';
960 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
961 $moreforfilter .= img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
962 $moreforfilter .=
'</div>';
965 if ($user->hasRight(
'user',
'user',
'lire')) {
966 $moreforfilter .=
'<div class="divsearchfield">';
967 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
968 $moreforfilter .= img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
969 $moreforfilter .=
'</div>';
972 if (
isModEnabled(
"category") && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
974 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $search_product_category_array,
'minwidth300imp minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0, 1, 1, $langs->transnoentitiesnoconv(
"ProductsCategoryShort"));
976 if (
isModEnabled(
"category") && $user->hasRight(
'categorie',
'lire')) {
977 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
978 $moreforfilter .=
'<div class="divsearchfield">';
979 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
980 $moreforfilter .= img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'minwidth300imp maxwidth300 widthcentpercentminusx');
981 $moreforfilter .=
'</div>';
984 $moreforfilter .=
'<div class="divsearchfield">';
985 $tmptitle = $langs->trans(
'Warehouse');
986 $moreforfilter .= img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'minwidth300imp maxwidth300 widthcentpercentminusx');
987 $moreforfilter .=
'</div>';
991 $parameters = array();
992 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
993 if (empty($reshook)) {
994 $moreforfilter .= $hookmanager->resPrint;
996 $moreforfilter = $hookmanager->resPrint;
999 if (!empty($moreforfilter)) {
1000 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1001 print $moreforfilter;
1005 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1006 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1007 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1010 $selectedfields .=
'<script>';
1011 $selectedfields .=
' $(document).ready(function() {';
1012 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1013 $selectedfields .=
' $("#checkforselects").click();';
1014 $selectedfields .=
' $("#massaction").val("createbills").change();';
1015 $selectedfields .=
' });';
1016 $selectedfields .=
'</script>';
1019 print
'<div class="div-table-responsive">';
1020 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1022 print
'<tr class="liste_titre_filter">';
1025 if (
$conf->main_checkbox_left_column) {
1026 print
'<td class="liste_titre center">';
1027 $searchpicto = $form->showFilterButtons(
'left');
1032 if (!empty($arrayfields[
'rowid'][
'checked'])) {
1033 print
'<td class="liste_titre right" data-key="id">';
1034 print
'<input class="flat searchstring width50" type="text" name="search_id" value="'.dol_escape_htmltag($search_id).
'">';
1038 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1039 print
'<td class="liste_titre">';
1040 print
'<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1044 if (!empty($arrayfields[
'pr.ref'][
'checked'])) {
1045 print
'<td class="liste_titre">';
1046 print
'<input class="flat" size="6" type="text" name="search_refProduct" value="'.dol_escape_htmltag($search_refProduct).
'">';
1050 if (!empty($arrayfields[
'pr.label'][
'checked'])) {
1051 print
'<td class="liste_titre">';
1052 print
'<input class="flat" size="6" type="text" name="search_descProduct" value="'.dol_escape_htmltag($search_descProduct).
'">';
1056 if (!empty($arrayfields[
'cdet.qty'][
'checked'])) {
1057 print
'<td class="liste_titre"></td>';
1061 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1062 print
'<td class="liste_titre" align="left">';
1063 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1067 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1068 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1071 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1072 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1075 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1076 print
'<td class="liste_titre" align="left">';
1077 print
'<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag((
string) $search_company).
'">';
1081 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1082 print
'<td class="liste_titre" align="left">';
1083 print
'<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1087 if (!empty($arrayfields[
's.town'][
'checked'])) {
1088 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1091 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1092 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1095 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1096 print
'<td class="liste_titre">';
1097 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1101 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1102 print
'<td class="liste_titre" align="center">';
1103 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1107 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1108 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1109 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'),
'', 1);
1113 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1114 print
'<td class="liste_titre center">';
1115 print
'<div class="nowrapfordate">';
1116 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1118 print
'<div class="nowrapfordate">';
1119 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1123 if (!empty($arrayfields[
'c.delivery_date'][
'checked'])) {
1124 print
'<td class="liste_titre center">';
1125 print
'<div class="nowrapfordate">';
1126 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1128 print
'<div class="nowrapfordate">';
1129 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1134 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1135 print
'<td class="liste_titre">';
1136 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1140 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1141 print
'<td class="liste_titre">';
1142 print $form->getSelectConditionsPaiements($search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1146 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1147 print
'<td class="liste_titre">';
1148 $form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1);
1152 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1153 print
'<td class="liste_titre">';
1154 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1157 if (!empty($arrayfields[
'cdet.total_ht'][
'checked'])) {
1159 print
'<td class="liste_titre right">';
1160 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1163 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1165 print
'<td class="liste_titre right">';
1166 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1169 if (!empty($arrayfields[
'cdet.total_ttc'][
'checked'])) {
1171 print
'<td class="liste_titre right">';
1172 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1175 if (!empty($arrayfields[
'c.fk_warehouse'][
'checked'])) {
1177 print
'<td class="liste_titre right"></td>';
1179 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1181 print
'<td class="liste_titre">';
1182 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1185 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1187 print
'<td class="liste_titre">';
1188 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1191 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1193 print
'<td class="liste_titre right">';
1194 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1197 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1199 print
'<td class="liste_titre right">';
1200 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1203 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1205 print
'<td class="liste_titre right">';
1206 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1209 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1211 print
'<td class="liste_titre" align="center">';
1212 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1215 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1216 print
'<td class="liste_titre"></td>';
1218 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1219 print
'<td class="liste_titre right">';
1222 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1223 print
'<td class="liste_titre right">';
1226 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1227 print
'<td class="liste_titre right">';
1230 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1231 print
'<td class="liste_titre right">';
1235 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1237 $parameters = array(
'arrayfields' => $arrayfields);
1238 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1239 print $hookmanager->resPrint;
1241 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1242 print
'<td class="liste_titre">';
1246 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1247 print
'<td class="liste_titre">';
1251 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1252 print
'<td class="liste_titre center">';
1253 print
'<div class="nowrapfordate">';
1254 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1256 print
'<div class="nowrapfordate">';
1257 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1262 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1263 print
'<td class="liste_titre">';
1267 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1268 print
'<td class="liste_titre">';
1272 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1273 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1276 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
1277 print $langs->trans(
'ShowShippableStatus');
1279 $show_shippable_command = 1;
1284 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1285 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1286 print $form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1290 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1291 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1295 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1296 print
'<td class="liste_titre maxwidthonsmartphone center">';
1297 $liststatus = array(
1301 -2 => $langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
1302 -3 => $langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
1307 print $form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'maxwidth125', 1);
1311 if (!
$conf->main_checkbox_left_column) {
1312 print
'<td class="liste_titre" align="middle">';
1313 $searchpicto = $form->showFilterButtons();
1320 print
'<tr class="liste_titre">';
1322 if (
$conf->main_checkbox_left_column) {
1323 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1327 if (!empty($arrayfields[
'rowid'][
'checked'])) {
1329 print_liste_field_titre($arrayfields[
'rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'rowid',
'', $param,
'', $sortfield, $sortorder);
1331 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1332 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
1334 if (!empty($arrayfields[
'pr.ref'][
'checked'])) {
1335 print_liste_field_titre($arrayfields[
'pr.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'pr.ref',
'', $param,
'', $sortfield, $sortorder);
1337 if (!empty($arrayfields[
'pr.label'][
'checked'])) {
1338 print_liste_field_titre($arrayfields[
'pr.label'][
'label'], $_SERVER[
"PHP_SELF"],
'pr.label',
'', $param,
'', $sortfield, $sortorder);
1340 if (!empty($arrayfields[
'cdet.qty'][
'checked'])) {
1341 print_liste_field_titre($arrayfields[
'cdet.qty'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.qty',
'', $param,
'', $sortfield, $sortorder);
1344 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1345 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
1347 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1348 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1350 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1351 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
1353 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1354 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1356 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1357 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1359 if (!empty($arrayfields[
's.town'][
'checked'])) {
1360 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1362 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1363 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1365 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1366 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1368 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1369 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1371 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1372 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1374 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1375 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
1377 if (!empty($arrayfields[
'c.delivery_date'][
'checked'])) {
1378 print_liste_field_titre($arrayfields[
'c.delivery_date'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1380 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1381 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
1383 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1384 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
1386 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1387 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
1389 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1390 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
1392 if (!empty($arrayfields[
'cdet.total_ht'][
'checked'])) {
1393 print_liste_field_titre($arrayfields[
'cdet.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1395 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1396 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1398 if (!empty($arrayfields[
'cdet.total_ttc'][
'checked'])) {
1399 print_liste_field_titre($arrayfields[
'cdet.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1401 if (!empty($arrayfields[
'c.fk_warehouse'][
'checked'])) {
1402 print_liste_field_titre($arrayfields[
'c.fk_warehouse'][
'label'],
"",
'',
'', $param,
'', $sortfield, $sortorder);
1404 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1405 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1407 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1408 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1410 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1411 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1413 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1414 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1416 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1417 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1419 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1420 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1422 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1423 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1425 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1426 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1428 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1429 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1431 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1432 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1434 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1435 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1438 $totalarray = array(
1441 'cdet.total_ht' => 0,
1442 'cdet.total_tva' => 0,
1443 'cdet.total_ttc' => 0,
1448 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1450 $parameters = array(
1451 'arrayfields' => $arrayfields,
1453 'sortfield' => $sortfield,
1454 'sortorder' => $sortorder,
1455 'totalarray' => &$totalarray,
1457 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1458 print $hookmanager->resPrint;
1459 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1460 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1462 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1463 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1465 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1466 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1468 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1469 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'right ');
1471 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1472 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'right ');
1474 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1475 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1477 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1478 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
1480 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1481 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1483 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1484 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1486 if (!
$conf->main_checkbox_left_column) {
1487 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1493 $productstat_cache = array();
1494 '@phan-var-force array<int,array{stock_reel:float|int,stats_order_customer?:float|int,stats_order_supplier?:float|int}> $productstat_cache';
1495 $productstat_cachevirtual = array();
1496 '@phan-var-force array<int,array{stock_reel:float|int}> $productstat_cachevirtual';
1497 $getNomUrl_cache = array();
1499 $generic_commande =
new Commande($db);
1500 $generic_product =
new Product($db);
1501 $userstatic =
new User($db);
1504 $with_margin_info =
false;
1506 !empty($arrayfields[
'total_pa'][
'checked'])
1507 || !empty($arrayfields[
'total_margin'][
'checked'])
1508 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1509 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1512 $with_margin_info =
true;
1522 $totalarray = array();
1523 $totalarray[
'nbfield'] = 0;
1524 $subtotalarray = array();
1525 $subtotalarray[
'nbfield'] = 0;
1526 $totalarray[
'val'][
'cdet.total_tva'] = 0;
1527 $totalarray[
'val'][
'cdet.total_ttc'] = 0;
1528 $imaxinloop = ($limit ? min($num, $limit) : $num);
1529 while ($i < $imaxinloop) {
1530 $obj = $db->fetch_object($resql);
1540 $oldref = $obj->product_ref;
1542 if ($oldref != $obj->product_ref && $sortfield ==
'pr.ref') {
1543 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_subtotal.tpl.php';
1544 $oldref = $obj->product_ref;
1547 $companystatic->id = $obj->socid;
1548 $companystatic->name = $obj->name;
1549 $companystatic->name_alias = $obj->alias;
1550 $companystatic->client = $obj->client;
1551 $companystatic->code_client = $obj->code_client;
1552 $companystatic->email = $obj->email;
1553 $companystatic->phone = $obj->phone;
1554 $companystatic->address = $obj->address;
1555 $companystatic->zip = $obj->zip;
1556 $companystatic->town = $obj->town;
1557 $companystatic->country_code = $obj->country_code;
1558 if (!isset($getNomUrl_cache[$obj->socid])) {
1559 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer');
1562 $generic_commande->id = $obj->c_rowid;
1563 $generic_commande->ref = $obj->ref;
1564 $generic_commande->statut = $obj->fk_statut;
1565 $generic_commande->status = $obj->fk_statut;
1566 $generic_commande->billed = $obj->billed;
1567 $generic_commande->date = $db->jdate($obj->date_commande);
1568 $generic_commande->delivery_date = $db->jdate($obj->delivery_date);
1569 $generic_commande->ref_client = $obj->ref_client;
1570 $generic_commande->total_ht = $obj->c_total_ht;
1571 $generic_commande->total_tva = $obj->c_total_tva;
1572 $generic_commande->total_ttc = $obj->c_total_ttc;
1573 $generic_commande->note_public = $obj->note_public;
1574 $generic_commande->note_private = $obj->note_private;
1576 $projectstatic->id = $obj->project_id;
1577 $projectstatic->ref = $obj->project_ref;
1578 $projectstatic->title = $obj->project_label;
1580 $marginInfo = array();
1581 if ($with_margin_info) {
1582 $generic_commande->fetch_lines();
1583 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1584 $total_ht += $obj->total_ht;
1585 $total_margin += $marginInfo[
'total_margin'];
1588 print
'<tr class="oddeven">';
1591 if (
$conf->main_checkbox_left_column) {
1592 print
'<td class="nowrap center">';
1593 if ($massactionbutton || $massaction) {
1595 if (in_array($obj->rowid, $arrayofselected)) {
1598 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1602 $totalarray[
'nbfield']++;
1609 if (!empty($arrayfields[
'rowid'][
'checked'])) {
1610 print
'<td class="nowrap right">'.$obj->rowid.
'</td>';
1612 $totalarray[
'nbfield']++;
1617 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1618 print
'<td class="nowraponall">';
1619 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1623 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1624 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1628 $totalarray[
'nbfield']++;
1633 if (!empty($arrayfields[
'pr.ref'][
'checked'])) {
1634 if (!empty($obj->product_rowid)) {
1635 $generic_product->id = $obj->product_rowid;
1636 $generic_product->ref = $obj->product_ref;
1637 $generic_product->label = $obj->product_label;
1638 $generic_product->status = $obj->product_status;
1639 $generic_product->status_buy = $obj->product_status_buy;
1640 $generic_product->status_batch = $obj->product_batch;
1641 $generic_product->barcode = $obj->product_barcode;
1642 print
'<td class="nowrap tdoverflowmax200">'.$generic_product->getNomUrl(1).
'</td>';
1644 print
'<td class="nowrap tdoverflowmax200"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1647 $totalarray[
'nbfield']++;
1651 if (!empty($arrayfields[
'pr.label'][
'checked'])) {
1653 $descline = empty($obj->description) ? $obj->product_label : $obj->description;
1654 print
'<td class="nowrap tdoverflowmax200">';
1659 $totalarray[
'nbfield']++;
1663 if (!empty($arrayfields[
'cdet.qty'][
'checked'])) {
1664 print
'<td class="nowrap right">'.$obj->qty.
'</td>';
1665 if (isset($totalarray[
'val'][
'cdet.qty']) || isset($subtotalarray[
'val'][
'cdet.qty'])) {
1666 $totalarray[
'val'][
'cdet.qty'] += $obj->qty;
1667 $subtotalarray[
'val'][
'cdet.qty'] += $obj->qty;
1669 $totalarray[
'val'][
'cdet.qty'] = $obj->qty;
1670 $subtotalarray[
'val'][
'cdet.qty'] = $obj->qty;
1673 $totalarray[
'nbfield']++;
1676 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.qty';
1677 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'cdet.qty';
1682 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1683 print
'<td class="nowrap tdoverflowmax200">'.$obj->ref_client.
'</td>';
1685 $totalarray[
'nbfield']++;
1690 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1691 print
'<td class="nowrap">';
1692 if ($obj->project_id > 0) {
1693 print $projectstatic->getNomUrl(1);
1697 $totalarray[
'nbfield']++;
1702 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1703 print
'<td class="nowrap">';
1704 if ($obj->project_id > 0) {
1705 print $projectstatic->title;
1709 $totalarray[
'nbfield']++;
1714 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1715 print
'<td class="tdoverflowmax150">';
1716 print $getNomUrl_cache[$obj->socid];
1720 if ($user->hasRight(
'facture',
'creer')) {
1721 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1722 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
1723 print img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
1729 $totalarray[
'nbfield']++;
1733 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1734 print
'<td class="nocellnopadd">';
1738 $totalarray[
'nbfield']++;
1742 if (!empty($arrayfields[
's.town'][
'checked'])) {
1743 print
'<td class="nocellnopadd">';
1747 $totalarray[
'nbfield']++;
1751 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1752 print
'<td class="nocellnopadd">';
1756 $totalarray[
'nbfield']++;
1760 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1761 print
"<td>".$obj->state_name.
"</td>\n";
1763 $totalarray[
'nbfield']++;
1767 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1768 print
'<td class="center">';
1769 $tmparray =
getCountry($obj->fk_pays,
'all');
1770 print $tmparray[
'label'];
1773 $totalarray[
'nbfield']++;
1777 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1778 print
'<td class="center">';
1779 if (empty($typenArray)) {
1780 $typenArray = $formcompany->typent_array(1);
1782 print $typenArray[$obj->typent_code];
1785 $totalarray[
'nbfield']++;
1790 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1791 print
'<td class="center">';
1794 if ($generic_commande->hasDelay()) {
1795 print img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
1799 $totalarray[
'nbfield']++;
1803 if (!empty($arrayfields[
'c.delivery_date'][
'checked'])) {
1804 print
'<td class="center" title="'.$langs->trans((
string) $arrayfields[
'c.delivery_date'][
'label']).
': '.
dol_print_date($db->jdate($obj->delivery_date),
'dayhour').
'">';
1808 $totalarray[
'nbfield']++;
1812 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1814 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
1817 $totalarray[
'nbfield']++;
1821 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1823 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
1826 $totalarray[
'nbfield']++;
1830 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1832 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
1835 $totalarray[
'nbfield']++;
1839 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1841 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none', 0);
1844 $totalarray[
'nbfield']++;
1848 if (!empty($arrayfields[
'cdet.total_ht'][
'checked'])) {
1849 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1851 $totalarray[
'nbfield']++;
1854 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_ht';
1855 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'cdet.total_ht';
1857 if (isset($totalarray[
'val'][
'cdet.total_ht']) || isset($subtotalarray[
'val'][
'cdet.total_ht'])) {
1858 $totalarray[
'val'][
'cdet.total_ht'] += $obj->total_ht;
1859 $subtotalarray[
'val'][
'cdet.total_ht'] += $obj->total_ht;
1861 $totalarray[
'val'][
'cdet.total_ht'] = $obj->total_ht;
1862 $subtotalarray[
'val'][
'cdet.total_ht'] = $obj->total_ht;
1866 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1867 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1869 $totalarray[
'nbfield']++;
1872 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_tva';
1873 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'cdet.total_tva';
1875 $totalarray[
'val'][
'cdet.total_tva'] += $obj->total_tva;
1876 $subtotalarray[
'val'][
'cdet.total_tva'] += $obj->total_tva;
1879 if (!empty($arrayfields[
'cdet.total_ttc'][
'checked'])) {
1880 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1882 $totalarray[
'nbfield']++;
1885 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_ttc';
1886 $subtotalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_ttc';
1888 $totalarray[
'val'][
'cdet.total_ttc'] += $obj->total_ttc;
1889 $subtotalarray[
'val'][
'cdet.total_ttc'] += $obj->total_ttc;
1892 if (!empty($arrayfields[
'c.fk_warehouse'][
'checked'])) {
1893 print
'<td class="nowrap">';
1894 if ($obj->warehouse > 0) {
1895 print img_picto(
'',
'stock',
'class="paddingrightonly"');
1897 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'], $obj->warehouse,
'none');
1900 $totalarray[
'nbfield']++;
1904 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1905 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1907 $totalarray[
'nbfield']++;
1912 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1913 print
'<td class="nowrap">';
1914 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->c_rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1917 $totalarray[
'nbfield']++;
1921 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1922 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1924 $totalarray[
'nbfield']++;
1928 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1929 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
1931 $totalarray[
'nbfield']++;
1935 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1936 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1938 $totalarray[
'nbfield']++;
1942 $userstatic->id = $obj->fk_user_author;
1943 $userstatic->login = $obj->login;
1944 $userstatic->lastname = $obj->lastname;
1945 $userstatic->firstname = $obj->firstname;
1946 $userstatic->email = $obj->user_email;
1947 $userstatic->status = $obj->user_statut;
1948 $userstatic->entity = $obj->entity;
1949 $userstatic->photo = $obj->photo;
1950 $userstatic->office_phone = $obj->office_phone;
1951 $userstatic->office_fax = $obj->office_fax;
1952 $userstatic->user_mobile = $obj->user_mobile;
1953 $userstatic->job = $obj->job;
1954 $userstatic->gender = $obj->gender;
1957 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1958 print
'<td class="tdoverflowmax200">';
1959 if ($userstatic->id) {
1960 print $userstatic->getNomUrl(-1);
1966 $totalarray[
'nbfield']++;
1970 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1973 if ($obj->socid > 0) {
1974 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1975 if ($listsalesrepresentatives < 0) {
1976 dol_print_error($db);
1978 $nbofsalesrepresentative = count($listsalesrepresentatives);
1979 if ($nbofsalesrepresentative > 6) {
1981 print $nbofsalesrepresentative;
1982 } elseif ($nbofsalesrepresentative > 0) {
1984 foreach ($listsalesrepresentatives as $val) {
1985 $userstatic->id = $val[
'id'];
1986 $userstatic->lastname = $val[
'lastname'];
1987 $userstatic->firstname = $val[
'firstname'];
1988 $userstatic->email = $val[
'email'];
1989 $userstatic->status = $val[
'statut'];
1990 $userstatic->entity = $val[
'entity'];
1991 $userstatic->photo = $val[
'photo'];
1992 $userstatic->login = $val[
'login'];
1993 $userstatic->office_phone = $val[
'office_phone'];
1994 $userstatic->office_fax = $val[
'office_fax'];
1995 $userstatic->user_mobile = $val[
'user_mobile'];
1996 $userstatic->job = $val[
'job'];
1997 $userstatic->gender = $val[
'gender'];
1999 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2001 if ($j < $nbofsalesrepresentative) {
2013 $totalarray[
'nbfield']++;
2018 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2019 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2021 $totalarray[
'nbfield']++;
2025 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2026 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2028 $totalarray[
'nbfield']++;
2031 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2032 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'total_margin';
2034 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2035 $subtotalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2038 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2039 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2041 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2046 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2048 $totalarray[
'nbfield']++;
2051 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2052 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'total_mark_rate';
2054 if ($i >= $imaxinloop - 1) {
2055 if (!empty($total_ht)) {
2056 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2057 $subtotalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2059 $totalarray[
'val'][
'total_mark_rate'] =
'';
2060 $subtotalarray[
'val'][
'total_mark_rate'] =
'';
2066 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2068 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2069 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2070 print $hookmanager->resPrint;
2073 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2074 print
'<td align="center" class="nowrap">';
2075 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2078 $totalarray[
'nbfield']++;
2083 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2084 print
'<td align="center" class="nowrap">';
2085 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2088 $totalarray[
'nbfield']++;
2093 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2094 print
'<td align="center" class="nowrap">';
2095 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuser');
2098 $totalarray[
'nbfield']++;
2103 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2104 print
'<td class="sensiblehtmlcontent center">';
2105 print dolPrintHTML($obj->note_public);
2108 $totalarray[
'nbfield']++;
2113 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2114 print
'<td class="center">';
2115 print dolPrintHTML($obj->note_private);
2118 $totalarray[
'nbfield']++;
2123 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2124 print
'<td class="center">';
2125 if (!empty($show_shippable_command) &&
isModEnabled(
'stock')) {
2127 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2128 $generic_commande->loadExpeditions();
2130 if (isset($generic_commande->expeditions[$obj->rowid])) {
2131 $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid];
2133 $reliquat = $obj->qty;
2135 if ($obj->product_type == 0 && $obj->fk_product > 0) {
2137 $generic_product->id = $obj->fk_product;
2140 if (empty($productstat_cache[$obj->fk_product])) {
2141 $generic_product->load_stock(
'nobatch');
2142 $productstat_cache[$obj->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2143 $productstat_cachevirtual[$obj->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2145 $generic_product->stock_reel = $productstat_cache[$obj->fk_product][
'stock_reel'];
2146 $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product][
'stock_reel'];
2149 if ($reliquat > $generic_product->stock_reel) {
2153 $text_info .= $reliquat.
' x '.$obj->product_ref.
' '.
dol_trunc($obj->product_label, 20);
2154 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2155 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2156 $text_info .= ($reliquat != $obj->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($obj->qty - $reliquat).
')</span>' :
'');
2157 $text_info .=
'<br>';
2164 $stock_order_supplier = 0;
2167 if (empty($productstat_cache[$obj->fk_product][
'stats_order_customer'])) {
2168 $generic_product->load_stats_commande(0,
'1,2');
2169 $productstat_cache[$obj->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
2171 $generic_product->stats_commande[
'qty'] = $productstat_cache[$obj->fk_product][
'stats_order_customer'];
2173 $stock_order = $generic_product->stats_commande[
'qty'];
2176 if (empty($productstat_cache[$obj->fk_product][
'stats_order_supplier'])) {
2177 $generic_product->load_stats_commande_fournisseur(0,
'3');
2178 $productstat_cache[$obj->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
2180 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$obj->fk_product][
'stats_order_supplier'];
2182 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
2185 $text_info .= $reliquat.
' x '.$obj->product_ref.
' '.
dol_trunc($obj->product_label, 20);
2186 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
2187 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) {
2189 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2191 if ($reliquat > $generic_product->stock_reel) {
2192 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2194 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2197 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
2199 $text_info .= ($reliquat != $obj->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($obj->qty - $reliquat).
')</span>' :
'');
2200 $text_info .=
'<br>';
2203 if ($notshippable == 0) {
2204 $text_icon = img_picto(
'',
'dolly',
'', 0, 0, 0,
'',
'green paddingleft');
2205 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
2207 $text_icon = img_picto(
'',
'dolly',
'', 0, 0, 0,
'',
'error paddingleft');
2208 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
2213 print $form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
2216 print $form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1, img_picto(
'',
'error'),
'', 2);
2221 $totalarray[
'nbfield']++;
2226 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2227 print
'<td class="center">';
2229 print yn($obj->billed, $langs->trans(
"Billed"));
2233 $totalarray[
'nbfield']++;
2237 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2238 print
'<td class="nowrap center">'.$obj->import_key.
'</td>';
2240 $totalarray[
'nbfield']++;
2244 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2245 print
'<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
2247 $totalarray[
'nbfield']++;
2252 if (!
$conf->main_checkbox_left_column) {
2253 print
'<td class="nowrap center">';
2254 if ($massactionbutton || $massaction) {
2256 if (in_array($obj->rowid, $arrayofselected)) {
2259 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2263 $totalarray[
'nbfield']++;
2269 $total += $obj->total_ht;
2270 $subtotal += $obj->total_ht;
2273 if ($sortfield ==
'pr.ref') {
2274 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_subtotal.tpl.php';
2277 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2282 foreach ($arrayfields as $key => $val) {
2283 if (!empty($val[
'checked'])) {
2287 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2292 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2293 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2294 print $hookmanager->resPrint;
2296 print
'</table>'.
"\n";
2299 print
'</form>'.
"\n";
2301 $hidegeneratedfilelistifempty = 1;
2302 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2303 $hidegeneratedfilelistifempty = 0;
2307 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2308 $urlsource .= str_replace(
'&',
'&', $param);
2310 $filedir = $diroutputmassaction;
2314 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, $genallowed, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
2316 dol_print_error($db);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.