36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43if (isModEnabled(
'margin')) {
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
51if (isModEnabled(
'categorie')) {
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
57$langs->loadLangs(array(
"orders",
'sendings',
'deliveries',
'companies',
'compta',
'bills',
'stocks',
'products'));
59$action =
GETPOST(
'action',
'aZ09');
60$massaction =
GETPOST(
'massaction',
'alpha');
61$show_files =
GETPOST(
'show_files',
'int');
62$confirm =
GETPOST(
'confirm',
'alpha');
63$toselect =
GETPOST(
'toselect',
'array');
64$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'orderlistdet';
65$productobuy =
GETPOST(
'productobuy',
'alpha');
66$productonly =
GETPOST(
'productonly',
'alpha');
67$disablelinefree =
GETPOST(
'disablelinefree',
'alpha');
69$search_datecloture_start =
GETPOST(
'search_datecloture_start',
'int');
70if (empty($search_datecloture_start)) {
71 $search_datecloture_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_datecloture_startmonth',
'int'),
GETPOST(
'search_datecloture_startday',
'int'),
GETPOST(
'search_datecloture_startyear',
'int'));
73$search_datecloture_end =
GETPOST(
'search_datecloture_end',
'int');
74if (empty($search_datecloture_end)) {
75 $search_datecloture_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_datecloture_endmonth',
'int'),
GETPOST(
'search_datecloture_endday',
'int'),
GETPOST(
'search_datecloture_endyear',
'int'));
77$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'));
78$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'));
79$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'));
80$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'));
82if (isModEnabled(
'categorie')) {
83 $search_product_category_array =
GETPOST(
"search_category_".Categorie::TYPE_PRODUCT.
"_list",
"array");
84 $searchCategoryProductOperator = 0;
85 if (GETPOSTISSET(
'formfilteraction')) {
86 $searchCategoryProductOperator =
GETPOSTINT(
'search_category_product_operator');
88 $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
93$search_id =
GETPOST(
'search_id',
'alpha');
94$search_refProduct =
GETPOST(
'search_refProduct',
'alpha');
95$search_descProduct =
GETPOST(
'search_descProduct',
'alpha');
97$search_ref =
GETPOST(
'search_ref',
'alpha') !=
'' ?
GETPOST(
'search_ref',
'alpha') :
GETPOST(
'sref',
'alpha');
98$search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
99$search_company =
GETPOST(
'search_company',
'alpha');
100$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
101$search_town =
GETPOST(
'search_town',
'alpha');
102$search_zip =
GETPOST(
'search_zip',
'alpha');
103$search_state =
GETPOST(
"search_state",
'alpha');
104$search_country =
GETPOST(
"search_country",
'int');
105$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
106$sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
107$socid =
GETPOST(
'socid',
'int');
108$search_user =
GETPOST(
'search_user',
'int');
109$search_sale =
GETPOST(
'search_sale',
'int');
110$search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
111$search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
112$search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
113$search_warehouse =
GETPOST(
'search_warehouse',
'int');
114$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
115$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
116$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
117$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
118$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
119$search_login =
GETPOST(
'search_login',
'alpha');
120$search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
121$optioncss =
GETPOST(
'optioncss',
'alpha');
122$search_billed = GETPOSTISSET(
'search_billed') ?
GETPOST(
'search_billed',
'int') :
GETPOST(
'billed',
'int');
123$search_status =
GETPOST(
'search_status',
'int');
124$search_btn =
GETPOST(
'button_search',
'alpha');
125$search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
126$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
127$search_project =
GETPOST(
'search_project',
'alpha');
128$search_shippable =
GETPOST(
'search_shippable',
'aZ09');
129$search_fk_cond_reglement =
GETPOST(
"search_fk_cond_reglement",
'int');
130$search_fk_shipping_method =
GETPOST(
"search_fk_shipping_method",
'int');
131$search_fk_mode_reglement =
GETPOST(
"search_fk_mode_reglement",
'int');
132$search_fk_input_reason =
GETPOST(
"search_fk_input_reason",
'int');
134$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].
'/temp/massgeneration/'.$user->id;
137$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
138$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
139$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
140$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
141if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
144$offset = $limit * $page;
145$pageprev = $page - 1;
146$pagenext = $page + 1;
148 $sortfield =
'pr.ref';
154$show_shippable_command =
GETPOST(
'show_shippable_command',
'aZ09');
158$hookmanager->initHooks(array(
'orderlistdetail'));
162$extrafields->fetch_name_optionals_label($object->table_element);
163$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
166$fieldstosearchall = array(
168 'c.ref_client'=>
'RefCustomerOrder',
169 'cdet.description'=>
'Description',
170 's.nom'=>
"ThirdParty",
171 's.name_alias'=>
"AliasNameShort",
174 'c.note_public'=>
'NotePublic',
176if (empty($user->socid)) {
177 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
180$checkedtypetiers = 0;
183 'rowid'=> array(
'label'=>
'TechnicalID',
'checked'=>1,
'position'=>1,
'enabled'=>(
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') ? 1 : 0)),
184 'pr.ref'=> array(
'label'=>
'ProductRef',
'checked'=>1,
'position'=>1),
185 'pr.desc'=> array(
'label'=>
'ProductDescription',
'checked'=>-1,
'position'=>1),
186 'cdet.qty'=> array(
'label'=>
'QtyOrdered',
'checked'=>1,
'position'=>1),
187 'c.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
188 'c.ref_client'=>array(
'label'=>
"RefCustomerOrder",
'checked'=>-1,
'position'=>10),
189 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>-1,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>20),
190 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>25),
191 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>30),
192 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>-1,
'position'=>31),
193 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>35),
194 's.zip'=>array(
'label'=>
"Zip",
'checked'=>-1,
'position'=>40),
195 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>45),
196 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>50),
197 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>55),
198 'c.date_commande'=>array(
'label'=>
"OrderDateShort",
'checked'=>1,
'position'=>60),
199 'c.date_delivery'=>array(
'label'=>
"DateDeliveryPlanned",
'checked'=>1,
'enabled'=>!
getDolGlobalString(
'ORDER_DISABLE_DELIVERY_DATE'),
'position'=>65),
200 'c.fk_shipping_method'=>array(
'label'=>
"SendingMethod",
'checked'=>-1,
'position'=>66 ,
'enabled'=>isModEnabled(
'expedition')),
201 'c.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>-1,
'position'=>67),
202 'c.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>-1,
'position'=>68),
203 'c.fk_input_reason'=>array(
'label'=>
"Channel",
'checked'=>-1,
'position'=>69),
204 'cdet.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>75),
205 'c.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>80),
206 'cdet.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>85),
207 'c.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>90),
208 'c.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>95),
209 'c.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>100),
210 'c.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>105),
211 'c.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>110),
212 'c.fk_warehouse'=>array(
'label'=>
'Warehouse',
'checked'=>0,
'enabled'=>(!isModEnabled(
'stock') && !
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') ? 0 : 1),
'position'=>110),
213 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>115),
214 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>116),
215 'total_pa' => array(
'label' => (
getDolGlobalString(
'MARGIN_TYPE') ==
'1' ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (!isModEnabled(
'margin') || !$user->rights->margins->liretous ? 0 : 1)),
216 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (!isModEnabled(
'margin') || !$user->rights->margins->liretous ? 0 : 1)),
217 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (!isModEnabled(
'margin') || !$user->rights->margins->liretous || !
getDolGlobalString(
'DISPLAY_MARGIN_RATES') ? 0 : 1)),
218 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (!isModEnabled(
'margin') || !$user->rights->margins->liretous || !
getDolGlobalString(
'DISPLAY_MARK_RATES') ? 0 : 1)),
219 'c.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>120),
220 'c.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>125),
221 'c.date_cloture'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>130),
222 'c.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'enabled'=>(!
getDolGlobalString(
'MAIN_LIST_ALLOW_PUBLIC_NOTES')),
'position'=>135),
223 'c.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'enabled'=>(!
getDolGlobalString(
'MAIN_LIST_ALLOW_PRIVATE_NOTES')),
'position'=>140),
224 'shippable'=>array(
'label'=>
"Shippable",
'checked'=>1,
'enabled'=>(isModEnabled(
'expedition')),
'position'=>990),
225 'c.facture'=>array(
'label'=>
"Billed",
'checked'=>1,
'enabled'=>(!
getDolGlobalString(
'WORKFLOW_BILL_ON_SHIPMENT')),
'position'=>995),
226 'c.import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>999),
227 'c.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
231include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
236if (!$user->hasRight(
'societe',
'client',
'voir')) {
237 $search_sale = $user->id;
243 $socid = $user->socid;
252if (
GETPOST(
'cancel',
'alpha')) {
256if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
260$parameters = array(
'socid'=>$socid);
261$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
266if (empty($reshook)) {
268 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
271 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
274 $disablelinefree =
'';
278 $search_product_category_array = array();
279 $searchCategoryProductOperator = 0;
281 $search_refProduct =
'';
282 $search_descProduct =
'';
284 $search_ref_customer =
'';
285 $search_company =
'';
286 $search_company_alias =
'';
291 $search_country =
'';
292 $search_type_thirdparty =
'';
293 $search_total_ht =
'';
294 $search_total_vat =
'';
295 $search_total_ttc =
'';
296 $search_warehouse =
'';
297 $search_multicurrency_code =
'';
298 $search_multicurrency_tx =
'';
299 $search_multicurrency_montant_ht =
'';
300 $search_multicurrency_montant_vat =
'';
301 $search_multicurrency_montant_ttc =
'';
303 $search_dateorder_start =
'';
304 $search_dateorder_end =
'';
305 $search_datedelivery_start =
'';
306 $search_datedelivery_end =
'';
307 $search_project_ref =
'';
308 $search_project =
'';
312 $search_array_options = array();
313 $search_categ_cus = 0;
314 $search_datecloture_start =
'';
315 $search_datecloture_end =
'';
316 $search_fk_cond_reglement =
'';
317 $search_fk_shipping_method =
'';
318 $search_fk_mode_reglement =
'';
319 $search_fk_input_reason =
'';
321 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
322 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
327 $objectclass =
'Commande';
328 $objectlabel =
'Orders';
329 $permissiontoread = $user->hasRight(
"commande",
"lire");
330 $permissiontoadd = $user->hasRight(
"commande",
"creer");
331 $permissiontodelete = $user->hasRight(
"commande",
"supprimer");
332 $permissiontoexport = $user->hasRight(
"commande",
"commande",
"export");
334 $permissiontovalidate = $user->hasRight(
"commande",
"order_advance",
"validate");
335 $permissiontoclose = $user->hasRight(
"commande",
"order_advance",
"close");
336 $permissiontocancel = $user->hasRight(
"commande",
"order_advance",
"annuler");
337 $permissiontosendbymail = $user->hasRight(
"commande",
"order_advance",
"send");
339 $permissiontovalidate = $user->hasRight(
"commande",
"creer");
340 $permissiontoclose = $user->hasRight(
"commande",
"creer");
341 $permissiontocancel = $user->hasRight(
"commande",
"creer");
342 $permissiontosendbymail = $user->hasRight(
"commande",
"creer");
344 $uploaddir = $conf->commande->multidir_output[$conf->entity];
345 $triggersendname =
'ORDER_SENTBYMAIL';
346 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
360$form =
new Form($db);
364if (isModEnabled(
'margin')) {
367$companystatic =
new Societe($db);
369$projectstatic =
new Project($db);
371$title = $langs->trans(
"Orders");
372$help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
376if ($sall || $search_product_category_array > 0 || $search_user > 0) {
377 $sql =
'SELECT DISTINCT';
379$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.code_client,';
380$sql .=
" typent.code as typent_code,";
381$sql .=
" state.code_departement as state_code, state.nom as state_name,";
382$sql .=
" country.code as country_code,";
383$sql .=
' c.rowid as c_rowid, c.ref, c.ref_client, c.fk_user_author,';
384$sql .=
' 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,';
385$sql .=
' 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,';
386$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,';
387$sql .=
' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
388$sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
389$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,';
390$sql .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
391$sql .=
' c.fk_input_reason, c.import_key,';
393$sql .=
' cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc,';
394$sql .=
' 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';
396if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
397 $sql .=
", cc.fk_categorie, cc.fk_soc";
400if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
401 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
402 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
406$parameters = array();
407$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
408$sql .= $hookmanager->resPrint;
409$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
410$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
411$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
412$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
413if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
414 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
418$sql .=
', '.MAIN_DB_PREFIX.
'commandedet as cdet';
419$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande as c ON cdet.fk_commande=c.rowid';
420$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as pr ON pr.rowid=cdet.fk_product';
422if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
423 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
425$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
426$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
427if ($search_user > 0) {
428 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
429 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
432$parameters = array();
433$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
434$sql .= $hookmanager->resPrint;
436$sql .=
' WHERE c.fk_soc = s.rowid';
437$sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
438$sql .=
' AND cdet.product_type <> 9';
440if (!empty($productobuy)) {
441 $sql .=
" AND pr.tobuy = 1";
443if (!empty($productonly)) {
444 $sql .=
" AND (cdet.product_type = 0 OR cdet.product_type = 1)";
446if (!empty($disablelinefree)) {
447 $sql .=
" AND cdet.fk_product IS NOT NULL";
450 $sql .=
' AND s.rowid = '.((int) $socid);
455if ($search_refProduct) {
458if ($search_descProduct) {
459 $sql .=
natural_search(array(
'pr.label',
'cdet.description'), $search_descProduct);
464if ($search_ref_customer) {
470if ($search_billed !=
'' && $search_billed >= 0) {
471 $sql .=
' AND c.facture = '.((int) $search_billed);
473if ($search_status !=
'') {
474 if ($search_status <= 3 && $search_status >= -1) {
475 if ($search_status == 1 && !isModEnabled(
'expedition')) {
476 $sql .=
' AND c.fk_statut IN (1,2)';
478 $sql .=
' AND c.fk_statut = '.((int) $search_status);
481 if ($search_status == -2) {
483 $sql .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
485 if ($search_status == -3) {
488 $sql .=
' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))';
490 if ($search_status == -4) {
491 $sql .=
' AND (c.fk_statut IN (1,2))';
495if ($search_datecloture_start) {
496 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
498if ($search_datecloture_end) {
499 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
501if ($search_dateorder_start) {
502 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
504if ($search_dateorder_end) {
505 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
507if ($search_datedelivery_start) {
508 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
510if ($search_datedelivery_end) {
511 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
522if ($search_country) {
523 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
525if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
526 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
528if ($search_company) {
531if ($search_company_alias) {
534if ($search_user > 0) {
535 $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);
537if ($search_total_ht !=
'') {
540if ($search_total_vat !=
'') {
543if ($search_total_ttc !=
'') {
546if ($search_warehouse !=
'' && $search_warehouse > 0) {
549if ($search_multicurrency_code !=
'') {
550 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
552if ($search_multicurrency_tx !=
'') {
553 $sql .=
natural_search(
'c.multicurrency_tx', $search_multicurrency_tx, 1);
555if ($search_multicurrency_montant_ht !=
'') {
556 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
558if ($search_multicurrency_montant_vat !=
'') {
559 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
561if ($search_multicurrency_montant_ttc !=
'') {
562 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
565 $sql .=
natural_search(array(
"u.login",
"u.firstname",
"u.lastname"), $search_login);
567if ($search_project_ref !=
'') {
570if ($search_project !=
'') {
573if ($search_categ_cus > 0) {
574 $sql .=
" AND cc.fk_categorie = ".((int) $search_categ_cus);
576if ($search_categ_cus == -2) {
577 $sql .=
" AND cc.fk_categorie IS NULL";
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 NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
595 } elseif ($search_sale > 0) {
596 $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).
")";
600$searchCategoryProductList = $search_product_category_array;
601if (!empty($searchCategoryProductList)) {
602 $searchCategoryProjectSqlList = array();
603 $listofcategoryid =
'';
604 foreach ($searchCategoryProductList as $searchCategoryProject) {
605 if (intval($searchCategoryProject) == -2) {
606 $searchCategoryProjectSqlList[] =
"NOT EXISTS (SELECT cp.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as cp WHERE cdet.fk_product = cp.fk_product)";
607 } elseif (intval($searchCategoryProject) > 0) {
608 if ($searchCategoryProductOperator == 0) {
609 $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).
")";
611 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProject);
615 if ($listofcategoryid) {
616 $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).
"))";
618 if ($searchCategoryProductOperator == 1) {
619 if (!empty($searchCategoryProjectSqlList)) {
620 $sql .=
" AND (".implode(
' OR ', $searchCategoryProjectSqlList).
")";
623 if (!empty($searchCategoryProjectSqlList)) {
624 $sql .=
" AND (".implode(
' AND ', $searchCategoryProjectSqlList).
")";
630include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
633$parameters = array();
634$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
635$sql .= $hookmanager->resPrint;
638$parameters = array();
639$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
640$sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
642$sql .= $db->order($sortfield, $sortorder);
645$nbtotalofrecords =
'';
647 $result = $db->query($sql);
648 $nbtotalofrecords = $db->num_rows($result);
650 if (($page * $limit) > $nbtotalofrecords) {
656$sql .= $db->plimit($limit + 1, $offset);
659$resql = $db->query($sql);
664 $title = $langs->trans(
'ListOrderLigne').
' - '.$soc->name;
665 if (empty($search_company)) {
666 $search_company = $soc->name;
669 $title = $langs->trans(
'ListOrderLigne');
671 if (strval($search_status) ==
'0') {
672 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
674 if ($search_status == 1) {
675 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
677 if ($search_status == 2) {
678 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
680 if ($search_status == 3) {
681 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
683 if ($search_status == -1) {
684 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
686 if ($search_status == -2) {
687 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
689 if ($search_status == -3) {
690 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(!isModEnabled(
'expedition') ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
692 if ($search_status == -4) {
693 $title .=
' - '.$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort");
696 $num = $db->num_rows($resql);
698 $arrayofselected = is_array($toselect) ? $toselect : array();
700 if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $sall) {
701 $obj = $db->fetch_object($resql);
703 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.$id);
711 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
712 $param .=
'&contextpage='.urlencode($contextpage);
714 if ($limit > 0 && $limit != $conf->liste_limit) {
715 $param .=
'&limit='.((int) $limit);
718 $param .=
'&sall='.urlencode($sall);
721 $param .=
'&socid='.urlencode($socid);
724 $param .=
'&search_id='.urlencode($search_id);
727 if ($search_refProduct) {
728 $param .=
'&search_refProduct='.urlencode($search_refProduct);
730 if ($search_descProduct) {
731 $param .=
'&search_descProduct='.urlencode($search_descProduct);
733 if ($search_status !=
'') {
734 $param .=
'&search_status='.urlencode($search_status);
736 if ($search_datecloture_start) {
737 $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');
739 if ($search_datecloture_end) {
740 $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');
742 if ($search_dateorder_start) {
743 $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');
745 if ($search_dateorder_end) {
746 $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');
748 if ($search_datedelivery_start) {
749 $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');
751 if ($search_datedelivery_end) {
752 $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');
755 $param .=
'&search_ref='.urlencode($search_ref);
757 if ($search_company) {
758 $param .=
'&search_company='.urlencode($search_company);
760 if ($search_company_alias) {
761 $param .=
'&search_company_alias='.urlencode($search_company_alias);
763 if ($search_ref_customer) {
764 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
766 if ($search_user > 0) {
767 $param .=
'&search_user='.urlencode($search_user);
769 if ($search_sale > 0) {
770 $param .=
'&search_sale='.urlencode($search_sale);
772 if ($search_total_ht !=
'') {
773 $param .=
'&search_total_ht='.urlencode($search_total_ht);
775 if ($search_total_vat !=
'') {
776 $param .=
'&search_total_vat='.urlencode($search_total_vat);
778 if ($search_total_ttc !=
'') {
779 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
781 if ($search_warehouse !=
'') {
782 $param .=
'&search_warehouse='.urlencode($search_warehouse);
785 $param .=
'&search_login='.urlencode($search_login);
787 if ($search_multicurrency_code !=
'') {
788 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
790 if ($search_multicurrency_tx !=
'') {
791 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
793 if ($search_multicurrency_montant_ht !=
'') {
794 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
796 if ($search_multicurrency_montant_vat !=
'') {
797 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
799 if ($search_multicurrency_montant_ttc !=
'') {
800 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
802 if ($search_project_ref >= 0) {
803 $param .=
"&search_project_ref=".urlencode($search_project_ref);
805 if ($search_town !=
'') {
806 $param .=
'&search_town='.urlencode($search_town);
808 if ($search_zip !=
'') {
809 $param .=
'&search_zip='.urlencode($search_zip);
811 if ($search_state !=
'') {
812 $param .=
'&search_state='.urlencode($search_state);
814 if ($search_country !=
'') {
815 $param .=
'&search_country='.urlencode($search_country);
817 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
818 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
820 if (!empty($search_product_category_array)) {
821 foreach ($search_product_category_array as $tmpval) {
822 $param .=
'&search_categegory_product_list[]='.urlencode($tmpval);
825 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
826 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
829 $param .=
'&show_files='.urlencode($show_files);
831 if ($optioncss !=
'') {
832 $param .=
'&optioncss='.urlencode($optioncss);
834 if ($search_billed !=
'') {
835 $param .=
'&search_billed='.urlencode($search_billed);
837 if ($search_fk_cond_reglement > 0) {
838 $param .=
'&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
840 if ($search_fk_shipping_method > 0) {
841 $param .=
'&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
843 if ($search_fk_mode_reglement > 0) {
844 $param .=
'&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
846 if ($search_fk_input_reason > 0) {
847 $param .=
'&search_fk_input_reason='.urlencode($search_fk_input_reason);
849 if (!empty($productobuy)) {
850 $param .=
'&productobuy='.urlencode($productobuy);
852 if (!empty($productonly)) {
853 $param .=
'&productonly='.urlencode($productonly);
855 if (!empty($disablelinefree)) {
856 $param .=
'&disablelinefree='.urlencode($disablelinefree);
860 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
863 $parameters = array(
'param' => &$param);
864 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
865 $param .= $hookmanager->resPrint;
868 $arrayofmassactions = array(
875 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
877 $url = DOL_URL_ROOT.
'/commande/card.php?action=create';
878 if (!empty($socid)) {
879 $url .=
'&socid='.$socid;
884 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
885 if ($optioncss !=
'') {
886 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
888 print
'<input type="hidden" name="token" value="'.newToken().
'">';
889 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
890 print
'<input type="hidden" name="action" value="list">';
891 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
892 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
893 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
894 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
895 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
897 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
899 $topicmail =
"SendOrderRef";
900 $modelmail =
"order_send";
902 $trackid =
'ord'.$object->id;
903 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
906 foreach ($fieldstosearchall as $key => $val) {
907 $fieldstosearchall[$key] = $langs->trans($val);
909 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
914 $moreforfilter .=
'<div class="divsearchfield">';
915 $moreforfilter .=
'<input type="checkbox" id="productobuy" name="productobuy"'.(!empty($productobuy) ?
'value="productobuychecked" checked' :
'').
'><label for="productobuy">'.$langs->trans(
"productobuy").
'</label>';
916 $moreforfilter .=
'</div>';
917 $moreforfilter .=
'<div class="divsearchfield">';
918 $moreforfilter .=
'<input type="checkbox" id="productonly" name="productonly"'.(!empty($productonly) ?
'value="productonlychecked" checked' :
'').
'><label for="productonly">'.$langs->trans(
"productonly").
'</label>';
919 $moreforfilter .=
'</div>';
920 $moreforfilter .=
'<div class="divsearchfield">';
921 $moreforfilter .=
'<input type="checkbox" id="disablelinefree" name="disablelinefree"'.(!empty($disablelinefree) ?
'value="disablelinefreechecked" checked' :
'').
'><label for="disablelinefree">'.$langs->trans(
"disablelinefree").
'</label>';
922 $moreforfilter .=
'</div><br>';
925 if ($user->hasRight(
'user',
'user',
'lire')) {
926 $langs->load(
"commercial");
927 $moreforfilter .=
'<div class="divsearchfield">';
928 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
929 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
930 $moreforfilter .=
'</div>';
933 if ($user->hasRight(
'user',
'user',
'lire')) {
934 $moreforfilter .=
'<div class="divsearchfield">';
935 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
936 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
937 $moreforfilter .=
'</div>';
940 if (isModEnabled(
"categorie") && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
942 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $search_product_category_array,
'minwidth300imp minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0);
944 if (isModEnabled(
"categorie") && $user->hasRight(
'categorie',
'lire')) {
945 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
946 $moreforfilter .=
'<div class="divsearchfield">';
947 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
948 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'maxwidth300 widthcentpercentminusx');
949 $moreforfilter .=
'</div>';
951 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
952 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
954 $moreforfilter .=
'<div class="divsearchfield">';
955 $tmptitle = $langs->trans(
'Warehouse');
956 $moreforfilter .=
img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'maxwidth250 widthcentpercentminusx');
957 $moreforfilter .=
'</div>';
961 $parameters = array();
962 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
963 if (empty($reshook)) {
964 $moreforfilter .= $hookmanager->resPrint;
966 $moreforfilter = $hookmanager->resPrint;
969 if (!empty($moreforfilter)) {
970 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
971 print $moreforfilter;
975 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
976 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
977 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
979 if (
GETPOST(
'autoselectall',
'int')) {
980 $selectedfields .=
'<script>';
981 $selectedfields .=
' $(document).ready(function() {';
982 $selectedfields .=
' console.log("Autoclick on checkforselects");';
983 $selectedfields .=
' $("#checkforselects").click();';
984 $selectedfields .=
' $("#massaction").val("createbills").change();';
985 $selectedfields .=
' });';
986 $selectedfields .=
'</script>';
989 print
'<div class="div-table-responsive">';
990 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
992 print
'<tr class="liste_titre_filter">';
996 print
'<td class="liste_titre" align="middle">';
997 $searchpicto = $form->showFilterButtons(
'left');
1002 if (!empty($arrayfields[
'rowid'][
'checked'])) {
1003 print
'<td class="liste_titre" data-key="id">';
1004 print
'<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).
'">';
1008 if (!empty($arrayfields[
'pr.ref'][
'checked'])) {
1009 print
'<td class="liste_titre">';
1010 print
'<input class="flat" size="6" type="text" name="search_refProduct" value="'.dol_escape_htmltag($search_refProduct).
'">';
1014 if (!empty($arrayfields[
'pr.desc'][
'checked'])) {
1015 print
'<td class="liste_titre">';
1016 print
'<input class="flat" size="6" type="text" name="search_descProduct" value="'.dol_escape_htmltag($search_descProduct).
'">';
1020 if (!empty($arrayfields[
'cdet.qty'][
'checked'])) {
1021 print
'<td class="liste_titre"></td>';
1025 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1026 print
'<td class="liste_titre">';
1027 print
'<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1031 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1032 print
'<td class="liste_titre" align="left">';
1033 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1037 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1038 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1041 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1042 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1045 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1046 print
'<td class="liste_titre" align="left">';
1047 print
'<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
1051 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1052 print
'<td class="liste_titre" align="left">';
1053 print
'<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1057 if (!empty($arrayfields[
's.town'][
'checked'])) {
1058 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1061 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1062 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1065 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1066 print
'<td class="liste_titre">';
1067 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1071 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1072 print
'<td class="liste_titre" align="center">';
1073 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1077 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1078 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1079 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);
1083 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1084 print
'<td class="liste_titre center">';
1085 print
'<div class="nowrapfordate">';
1086 print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1088 print
'<div class="nowrapfordate">';
1089 print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1093 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1094 print
'<td class="liste_titre center">';
1095 print
'<div class="nowrapfordate">';
1096 print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1098 print
'<div class="nowrapfordate">';
1099 print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1104 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1105 print
'<td class="liste_titre">';
1106 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1110 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1111 print
'<td class="liste_titre">';
1112 $form->select_conditions_paiements($search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1116 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1117 print
'<td class="liste_titre">';
1118 $form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1);
1122 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1123 print
'<td class="liste_titre">';
1124 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1127 if (!empty($arrayfields[
'cdet.total_ht'][
'checked'])) {
1129 print
'<td class="liste_titre right">';
1130 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1133 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1135 print
'<td class="liste_titre right">';
1136 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1139 if (!empty($arrayfields[
'cdet.total_ttc'][
'checked'])) {
1141 print
'<td class="liste_titre right">';
1142 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1145 if (!empty($arrayfields[
'c.fk_warehouse'][
'checked'])) {
1147 print
'<td class="liste_titre right"></td>';
1149 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1151 print
'<td class="liste_titre">';
1152 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1155 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1157 print
'<td class="liste_titre">';
1158 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1161 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1163 print
'<td class="liste_titre right">';
1164 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1167 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1169 print
'<td class="liste_titre right">';
1170 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1173 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1175 print
'<td class="liste_titre right">';
1176 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1179 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1181 print
'<td class="liste_titre" align="center">';
1182 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1185 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1186 print
'<td class="liste_titre"></td>';
1188 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1189 print
'<td class="liste_titre right">';
1192 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1193 print
'<td class="liste_titre right">';
1196 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1197 print
'<td class="liste_titre right">';
1200 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1201 print
'<td class="liste_titre right">';
1205 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1207 $parameters = array(
'arrayfields'=>$arrayfields);
1208 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1209 print $hookmanager->resPrint;
1211 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1212 print
'<td class="liste_titre">';
1216 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1217 print
'<td class="liste_titre">';
1221 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1222 print
'<td class="liste_titre center">';
1223 print
'<div class="nowrapfordate">';
1224 print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1226 print
'<div class="nowrapfordate">';
1227 print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1232 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1233 print
'<td class="liste_titre">';
1237 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1238 print
'<td class="liste_titre">';
1242 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1243 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1246 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
1247 print $langs->trans(
'ShowShippableStatus');
1249 $show_shippable_command = 1;
1254 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1255 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1256 print $form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1260 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1261 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1265 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1266 print
'<td class="liste_titre maxwidthonsmartphone center">';
1267 $liststatus = array(
1271 -2 => $langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
1272 -3 => $langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
1276 print $form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'maxwidth125', 1);
1281 print
'<td class="liste_titre" align="middle">';
1282 $searchpicto = $form->showFilterButtons();
1289 print
'<tr class="liste_titre">';
1292 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1296 if (!empty($arrayfields[
'rowid'][
'checked'])) {
1297 print_liste_field_titre($arrayfields[
'rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'rowid',
'', $param,
'', $sortfield, $sortorder);
1299 if (!empty($arrayfields[
'pr.ref'][
'checked'])) {
1300 print_liste_field_titre($arrayfields[
'pr.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'pr.ref',
'', $param,
'', $sortfield, $sortorder);
1302 if (!empty($arrayfields[
'pr.desc'][
'checked'])) {
1303 print_liste_field_titre($arrayfields[
'pr.desc'][
'label'], $_SERVER[
"PHP_SELF"],
'pr.desc',
'', $param,
'', $sortfield, $sortorder);
1305 if (!empty($arrayfields[
'cdet.qty'][
'checked'])) {
1306 print_liste_field_titre($arrayfields[
'cdet.qty'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.qty',
'', $param,
'', $sortfield, $sortorder);
1309 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1310 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
1312 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1313 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
1315 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1316 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1318 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1319 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
1321 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1322 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1324 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1325 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1327 if (!empty($arrayfields[
's.town'][
'checked'])) {
1328 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1330 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1331 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1333 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1334 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1336 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1337 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1339 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1340 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1342 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1343 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
1345 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1346 print_liste_field_titre($arrayfields[
'c.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1348 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1349 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
1351 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1352 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
1354 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1355 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
1357 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1358 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
1360 if (!empty($arrayfields[
'cdet.total_ht'][
'checked'])) {
1361 print_liste_field_titre($arrayfields[
'cdet.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1363 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1364 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1366 if (!empty($arrayfields[
'cdet.total_ttc'][
'checked'])) {
1367 print_liste_field_titre($arrayfields[
'cdet.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'cdet.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1369 if (!empty($arrayfields[
'c.fk_warehouse'][
'checked'])) {
1370 print_liste_field_titre($arrayfields[
'c.fk_warehouse'][
'label'],
"",
'',
'', $param,
'', $sortfield, $sortorder);
1372 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1373 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1375 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1376 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1378 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1379 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1381 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1382 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1384 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1385 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1387 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1388 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1390 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1391 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1393 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1394 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1396 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1397 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1399 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1400 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1402 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1403 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1406 $totalarray = array(
1409 'cdet.total_ht' => 0,
1410 'cdet.total_tva' => 0,
1411 'cdet.total_ttc' => 0,
1416 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1418 $parameters = array(
1419 'arrayfields' => $arrayfields,
1421 'sortfield' => $sortfield,
1422 'sortorder' => $sortorder,
1423 'totalarray' => &$totalarray,
1425 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1426 print $hookmanager->resPrint;
1427 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1428 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1430 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1431 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1433 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1434 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1436 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1437 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'right ');
1439 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1440 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'right ');
1442 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1443 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1445 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1446 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
1448 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1449 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1451 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1452 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1455 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1461 $productstat_cache = array();
1462 $productstat_cachevirtual = array();
1463 $getNomUrl_cache = array();
1465 $generic_commande =
new Commande($db);
1466 $generic_product =
new Product($db);
1467 $userstatic =
new User($db);
1470 $with_margin_info =
false;
1471 if (isModEnabled(
'margin') && (
1472 !empty($arrayfields[
'total_pa'][
'checked'])
1473 || !empty($arrayfields[
'total_margin'][
'checked'])
1474 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1475 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1478 $with_margin_info =
true;
1487 $totalarray = array();
1488 $totalarray[
'nbfield'] = 0;
1489 $subtotalarray[
'nbfield'] = 0;
1490 $totalarray[
'val'][
'cdet.total_tva'] = 0;
1491 $totalarray[
'val'][
'cdet.total_ttc'] = 0;
1492 $imaxinloop = ($limit ? min($num, $limit) : $num);
1493 while ($i < $imaxinloop) {
1494 $obj = $db->fetch_object($resql);
1504 $oldref = $obj->product_ref;
1506 if ($oldref != $obj->product_ref && $sortfield ==
'pr.ref') {
1507 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_subtotal.tpl.php';
1508 $oldref = $obj->product_ref;
1511 $companystatic->id = $obj->socid;
1512 $companystatic->name = $obj->name;
1513 $companystatic->name_alias = $obj->alias;
1514 $companystatic->client = $obj->client;
1515 $companystatic->code_client = $obj->code_client;
1516 $companystatic->email = $obj->email;
1517 $companystatic->phone = $obj->phone;
1518 $companystatic->address = $obj->address;
1519 $companystatic->zip = $obj->zip;
1520 $companystatic->town = $obj->town;
1521 $companystatic->country_code = $obj->country_code;
1522 if (!isset($getNomUrl_cache[$obj->socid])) {
1523 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer');
1526 $generic_commande->id = $obj->c_rowid;
1527 $generic_commande->ref = $obj->ref;
1528 $generic_commande->statut = $obj->fk_statut;
1529 $generic_commande->billed = $obj->billed;
1530 $generic_commande->date = $db->jdate($obj->date_commande);
1531 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1532 $generic_commande->ref_client = $obj->ref_client;
1533 $generic_commande->total_ht = $obj->c_total_ht;
1534 $generic_commande->total_tva = $obj->c_total_tva;
1535 $generic_commande->total_ttc = $obj->c_total_ttc;
1536 $generic_commande->note_public = $obj->note_public;
1537 $generic_commande->note_private = $obj->note_private;
1539 $projectstatic->id = $obj->project_id;
1540 $projectstatic->ref = $obj->project_ref;
1541 $projectstatic->title = $obj->project_label;
1543 $marginInfo = array();
1544 if ($with_margin_info ===
true) {
1545 $generic_commande->fetch_lines();
1546 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1547 $total_ht += $obj->total_ht;
1548 $total_margin += $marginInfo[
'total_margin'];
1551 print
'<tr class="oddeven">';
1555 print
'<td class="nowrap center">';
1556 if ($massactionbutton || $massaction) {
1558 if (in_array($obj->rowid, $arrayofselected)) {
1561 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1565 $totalarray[
'nbfield']++;
1571 if (!empty($arrayfields[
'rowid'][
'checked'])) {
1572 print
'<td class="nowrap right">'.$obj->rowid.
'</td>';
1574 $totalarray[
'nbfield']++;
1579 if (!empty($arrayfields[
'pr.ref'][
'checked'])) {
1580 if (!empty($obj->product_rowid)) {
1581 $generic_product->id = $obj->product_rowid;
1582 $generic_product->ref = $obj->product_ref;
1583 $generic_product->label = $obj->product_label;
1584 $generic_product->status = $obj->product_status;
1585 $generic_product->status_buy = $obj->product_status_buy;
1586 $generic_product->status_batch = $obj->product_batch;
1587 $generic_product->barcode = $obj->product_barcode;
1588 print
'<td class="nowrap tdoverflowmax200">'.$generic_product->getNomUrl(1).
'</td>';
1590 print
'<td class="nowrap tdoverflowmax200">Ligne libre</td>';
1593 $totalarray[
'nbfield']++;
1597 if (!empty($arrayfields[
'pr.desc'][
'checked'])) {
1599 !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description;
1600 print
'<td class="nowrap tdoverflowmax200">';
1605 $totalarray[
'nbfield']++;
1609 if (!empty($arrayfields[
'cdet.qty'][
'checked'])) {
1610 print
'<td class="nowrap right">'.$obj->qty.
'</td>';
1611 if (isset($totalarray[
'val'][
'cdet.qty']) || isset($subtotalarray[
'val'][
'cdet.qty'])) {
1612 $totalarray[
'val'][
'cdet.qty'] += $obj->qty;
1613 $subtotalarray[
'val'][
'cdet.qty'] += $obj->qty;
1615 $totalarray[
'val'][
'cdet.qty'] = $obj->qty;
1616 $subtotalarray[
'val'][
'cdet.qty'] = $obj->qty;
1619 $totalarray[
'nbfield']++;
1622 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.qty';
1623 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'cdet.qty';
1628 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1629 print
'<td class="nowraponall">';
1630 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1633 $filedir = $conf->commande->multidir_output[$conf->entity].
'/'.
dol_sanitizeFileName($obj->ref);
1634 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1635 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1639 $totalarray[
'nbfield']++;
1644 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1645 print
'<td class="nowrap tdoverflowmax200">'.$obj->ref_client.
'</td>';
1647 $totalarray[
'nbfield']++;
1652 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1653 print
'<td class="nowrap">';
1654 if ($obj->project_id > 0) {
1655 print $projectstatic->getNomUrl(1);
1659 $totalarray[
'nbfield']++;
1664 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1665 print
'<td class="nowrap">';
1666 if ($obj->project_id > 0) {
1667 print $projectstatic->title;
1671 $totalarray[
'nbfield']++;
1676 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1677 print
'<td class="tdoverflowmax200">';
1678 print $getNomUrl_cache[$obj->socid];
1682 if ($user->hasRight(
'facture',
'creer')) {
1683 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1684 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
1685 print
img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
1691 $totalarray[
'nbfield']++;
1695 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1696 print
'<td class="nocellnopadd">';
1700 $totalarray[
'nbfield']++;
1704 if (!empty($arrayfields[
's.town'][
'checked'])) {
1705 print
'<td class="nocellnopadd">';
1709 $totalarray[
'nbfield']++;
1713 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1714 print
'<td class="nocellnopadd">';
1718 $totalarray[
'nbfield']++;
1722 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1723 print
"<td>".$obj->state_name.
"</td>\n";
1725 $totalarray[
'nbfield']++;
1729 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1730 print
'<td class="center">';
1731 $tmparray =
getCountry($obj->fk_pays,
'all');
1732 print $tmparray[
'label'];
1735 $totalarray[
'nbfield']++;
1739 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1740 print
'<td class="center">';
1741 if (empty($typenArray)) {
1742 $typenArray = $formcompany->typent_array(1);
1744 print $typenArray[$obj->typent_code];
1747 $totalarray[
'nbfield']++;
1752 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1753 print
'<td class="center">';
1756 if ($generic_commande->hasDelay()) {
1757 print
img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
1761 $totalarray[
'nbfield']++;
1765 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1766 print
'<td class="center">';
1767 print
dol_print_date($db->jdate($obj->date_delivery),
'dayhour');
1770 $totalarray[
'nbfield']++;
1774 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1776 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
1779 $totalarray[
'nbfield']++;
1783 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1785 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
1788 $totalarray[
'nbfield']++;
1792 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1794 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
1797 $totalarray[
'nbfield']++;
1801 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1803 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none',
'');
1806 $totalarray[
'nbfield']++;
1810 if (!empty($arrayfields[
'cdet.total_ht'][
'checked'])) {
1811 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1813 $totalarray[
'nbfield']++;
1816 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_ht';
1817 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'cdet.total_ht';
1819 if (isset($totalarray[
'val'][
'cdet.total_ht']) || isset($subtotalarray[
'val'][
'cdet.total_ht'])) {
1820 $totalarray[
'val'][
'cdet.total_ht'] += $obj->total_ht;
1821 $subtotalarray[
'val'][
'cdet.total_ht'] += $obj->total_ht;
1823 $totalarray[
'val'][
'cdet.total_ht'] = $obj->total_ht;
1824 $subtotalarray[
'val'][
'cdet.total_ht'] = $obj->total_ht;
1828 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1829 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
1831 $totalarray[
'nbfield']++;
1834 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_tva';
1835 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'cdet.total_tva';
1837 $totalarray[
'val'][
'cdet.total_tva'] += $obj->total_tva;
1838 $subtotalarray[
'val'][
'cdet.total_tva'] += $obj->total_tva;
1841 if (!empty($arrayfields[
'cdet.total_ttc'][
'checked'])) {
1842 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1844 $totalarray[
'nbfield']++;
1847 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_ttc';
1848 $subtotalarray[
'pos'][$totalarray[
'nbfield']] =
'cdet.total_ttc';
1850 $totalarray[
'val'][
'cdet.total_ttc'] += $obj->total_ttc;
1851 $subtotalarray[
'val'][
'cdet.total_ttc'] += $obj->total_ttc;
1854 if (!empty($arrayfields[
'c.fk_warehouse'][
'checked'])) {
1855 print
'<td class="nowrap">';
1856 if ($obj->warehouse > 0) {
1857 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
1859 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'], $obj->warehouse,
'none');
1862 $totalarray[
'nbfield']++;
1866 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1867 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1869 $totalarray[
'nbfield']++;
1874 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1875 print
'<td class="nowrap">';
1876 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1879 $totalarray[
'nbfield']++;
1883 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1884 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1886 $totalarray[
'nbfield']++;
1890 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1891 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
1893 $totalarray[
'nbfield']++;
1897 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1898 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1900 $totalarray[
'nbfield']++;
1904 $userstatic->id = $obj->fk_user_author;
1905 $userstatic->login = $obj->login;
1906 $userstatic->lastname = $obj->lastname;
1907 $userstatic->firstname = $obj->firstname;
1908 $userstatic->email = $obj->user_email;
1909 $userstatic->statut = $obj->user_statut;
1910 $userstatic->entity = $obj->entity;
1911 $userstatic->photo = $obj->photo;
1912 $userstatic->office_phone = $obj->office_phone;
1913 $userstatic->office_fax = $obj->office_fax;
1914 $userstatic->user_mobile = $obj->user_mobile;
1915 $userstatic->job = $obj->job;
1916 $userstatic->gender = $obj->gender;
1919 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1920 print
'<td class="tdoverflowmax200">';
1921 if ($userstatic->id) {
1922 print $userstatic->getNomUrl(-1);
1928 $totalarray[
'nbfield']++;
1932 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1935 if ($obj->socid > 0) {
1936 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
1937 if ($listsalesrepresentatives < 0) {
1940 $nbofsalesrepresentative = count($listsalesrepresentatives);
1941 if ($nbofsalesrepresentative > 6) {
1943 print $nbofsalesrepresentative;
1944 } elseif ($nbofsalesrepresentative > 0) {
1946 foreach ($listsalesrepresentatives as $val) {
1947 $userstatic->id = $val[
'id'];
1948 $userstatic->lastname = $val[
'lastname'];
1949 $userstatic->firstname = $val[
'firstname'];
1950 $userstatic->email = $val[
'email'];
1951 $userstatic->statut = $val[
'statut'];
1952 $userstatic->entity = $val[
'entity'];
1953 $userstatic->photo = $val[
'photo'];
1954 $userstatic->login = $val[
'login'];
1955 $userstatic->office_phone = $val[
'office_phone'];
1956 $userstatic->office_fax = $val[
'office_fax'];
1957 $userstatic->user_mobile = $val[
'user_mobile'];
1958 $userstatic->job = $val[
'job'];
1959 $userstatic->gender = $val[
'gender'];
1961 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
1963 if ($j < $nbofsalesrepresentative) {
1975 $totalarray[
'nbfield']++;
1980 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1981 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
1983 $totalarray[
'nbfield']++;
1987 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1988 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
1990 $totalarray[
'nbfield']++;
1993 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
1994 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'total_margin';
1996 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
1997 $subtotalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2000 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2001 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], null, null, null, null, 2).
'%').
'</td>';
2003 $totalarray[
'nbfield']++;
2007 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2008 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], null, null, null, null, 2).
'%').
'</td>';
2010 $totalarray[
'nbfield']++;
2013 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2014 $totalarray[
'pos'][$subtotalarray[
'nbfield']] =
'total_mark_rate';
2016 if ($i >= $imaxinloop - 1) {
2017 if (!empty($total_ht)) {
2018 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2019 $subtotalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2021 $totalarray[
'val'][
'total_mark_rate'] =
'';
2022 $subtotalarray[
'val'][
'total_mark_rate'] =
'';
2028 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2030 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2031 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2032 print $hookmanager->resPrint;
2035 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2036 print
'<td align="center" class="nowrap">';
2037 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2040 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2046 print
'<td align="center" class="nowrap">';
2047 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2050 $totalarray[
'nbfield']++;
2055 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2056 print
'<td align="center" class="nowrap">';
2057 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuser');
2060 $totalarray[
'nbfield']++;
2065 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2066 print
'<td class="center">';
2070 $totalarray[
'nbfield']++;
2075 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2076 print
'<td class="center">';
2080 $totalarray[
'nbfield']++;
2085 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2086 print
'<td class="center">';
2087 if (!empty($show_shippable_command) && isModEnabled(
'stock')) {
2088 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2089 $generic_commande->loadExpeditions();
2091 if (isset($generic_commande->expeditions[$obj->rowid])) {
2092 $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid];
2094 $reliquat = $obj->qty;
2096 if ($obj->product_type == 0 && $obj->fk_product > 0) {
2098 $generic_product->id = $obj->fk_product;
2101 if (empty($productstat_cache[$obj->fk_product])) {
2102 $generic_product->load_stock(
'nobatch');
2103 $productstat_cache[$obj->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2104 $productstat_cachevirtual[$obj->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2106 $generic_product->stock_reel = $productstat_cache[$obj->fk_product][
'stock_reel'];
2107 $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product][
'stock_reel'];
2110 if ($reliquat > $generic_product->stock_reel) {
2114 $text_info .= $reliquat.
' x '.$obj->product_ref.
' '.
dol_trunc($obj->product_label, 20);
2115 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2116 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2117 $text_info .= ($reliquat != $obj->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($obj->qty - $reliquat).
')</span>' :
'');
2118 $text_info .=
'<br>';
2125 $stock_order_supplier = 0;
2127 if (isModEnabled(
'commande')) {
2128 if (empty($productstat_cache[$obj->fk_product][
'stats_order_customer'])) {
2129 $generic_product->load_stats_commande(0,
'1,2');
2130 $productstat_cache[$obj->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
2132 $generic_product->stats_commande[
'qty'] = $productstat_cache[$obj->fk_product][
'stats_order_customer'];
2134 $stock_order = $generic_product->stats_commande[
'qty'];
2136 if (isModEnabled(
'supplier_order')) {
2137 if (empty($productstat_cache[$obj->fk_product][
'stats_order_supplier'])) {
2138 $generic_product->load_stats_commande_fournisseur(0,
'3');
2139 $productstat_cache[$obj->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
2141 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$obj->fk_product][
'stats_order_supplier'];
2143 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
2146 $text_info .= $reliquat.
' x '.$obj->product_ref.
' '.
dol_trunc($obj->product_label, 20);
2147 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
2148 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) {
2150 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2152 if ($reliquat > $generic_product->stock_reel) {
2153 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2155 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2157 if (isModEnabled(
'supplier_order')) {
2158 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
2160 $text_info .= ($reliquat != $obj->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($obj->qty - $reliquat).
')</span>' :
'');
2161 $text_info .=
'<br>';
2164 if ($notshippable == 0) {
2165 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'green paddingleft');
2166 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
2168 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'error paddingleft');
2169 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
2174 print $form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
2177 print $form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1,
img_picto(
'',
'error'),
'', 2);
2182 $totalarray[
'nbfield']++;
2187 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2188 print
'<td class="center">'.yn($obj->billed).
'</td>';
2190 $totalarray[
'nbfield']++;
2194 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2195 print
'<td class="nowrap center">'.$obj->import_key.
'</td>';
2197 $totalarray[
'nbfield']++;
2201 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2202 print
'<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
2204 $totalarray[
'nbfield']++;
2210 print
'<td class="nowrap center">';
2211 if ($massactionbutton || $massaction) {
2213 if (in_array($obj->rowid, $arrayofselected)) {
2216 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2220 $totalarray[
'nbfield']++;
2226 $total += $obj->total_ht;
2227 $subtotal += $obj->total_ht;
2230 if ($sortfield ==
'pr.ref') {
2231 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_subtotal.tpl.php';
2234 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2239 foreach ($arrayfields as $key => $val) {
2240 if (!empty($val[
'checked'])) {
2244 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2249 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2250 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2251 print $hookmanager->resPrint;
2253 print
'</table>'.
"\n";
2256 print
'</form>'.
"\n";
2258 $hidegeneratedfilelistifempty = 1;
2259 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2260 $hidegeneratedfilelistifempty = 0;
2264 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2265 $urlsource .= str_replace(
'&',
'&', $param);
2267 $filedir = $diroutputmassaction;
2268 $genallowed = $permissiontoread;
2269 $delallowed = $permissiontoadd;
2271 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage 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=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dolPrintHTML($s, $allowiframe=0)
Return a string ready to be output on HTML page To use text inside an attribute, you can simply use d...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.