38 require
'../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54 $langs->loadLangs(array(
'orders',
'sendings',
'deliveries',
'companies',
'compta',
'bills',
'stocks',
'products'));
57 $action =
GETPOST(
'action',
'aZ09');
58 $massaction =
GETPOST(
'massaction',
'alpha');
59 $show_files =
GETPOST(
'show_files',
'int');
60 $confirm =
GETPOST(
'confirm',
'alpha');
61 $toselect =
GETPOST(
'toselect',
'array');
62 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'orderlist';
63 $mode =
GETPOST(
'mode',
'alpha');
66 $search_datecloture_start =
GETPOST(
'search_datecloture_start',
'int');
67 if (empty($search_datecloture_start)) {
68 $search_datecloture_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_datecloture_startmonth',
'int'),
GETPOST(
'search_datecloture_startday',
'int'),
GETPOST(
'search_datecloture_startyear',
'int'));
70 $search_datecloture_end =
GETPOST(
'search_datecloture_end',
'int');
71 if (empty($search_datecloture_end)) {
72 $search_datecloture_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_datecloture_endmonth',
'int'),
GETPOST(
'search_datecloture_endday',
'int'),
GETPOST(
'search_datecloture_endyear',
'int'));
74 $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'));
75 $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'));
76 $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'));
77 $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'));
79 $search_product_category =
GETPOST(
'search_product_category',
'int');
80 $search_ref =
GETPOST(
'search_ref',
'alpha') !=
'' ?
GETPOST(
'search_ref',
'alpha') :
GETPOST(
'sref',
'alpha');
81 $search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
82 $search_company =
GETPOST(
'search_company',
'alpha');
83 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
84 $search_parent_name = trim(
GETPOST(
'search_parent_name',
'alphanohtml'));
85 $search_town =
GETPOST(
'search_town',
'alpha');
86 $search_zip =
GETPOST(
'search_zip',
'alpha');
87 $search_state =
GETPOST(
'search_state',
'alpha');
88 $search_country =
GETPOST(
'search_country',
'int');
89 $search_type_thirdparty =
GETPOST(
'search_type_thirdparty',
'int');
90 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
91 $socid =
GETPOST(
'socid',
'int');
92 $search_user =
GETPOST(
'search_user',
'int');
93 $search_sale =
GETPOST(
'search_sale',
'int');
95 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
96 $search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
97 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
98 $search_warehouse =
GETPOST(
'search_warehouse',
'int');
100 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
101 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
102 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
103 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
104 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
106 $search_login =
GETPOST(
'search_login',
'alpha');
107 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
108 $optioncss =
GETPOST(
'optioncss',
'alpha');
110 $search_status =
GETPOST(
'search_status',
'int');
111 $search_btn =
GETPOST(
'button_search',
'alpha');
112 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
113 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
114 $search_project =
GETPOST(
'search_project',
'alpha');
115 $search_shippable =
GETPOST(
'search_shippable',
'aZ09');
117 $search_fk_cond_reglement =
GETPOST(
'search_fk_cond_reglement',
'int');
118 $search_fk_shipping_method =
GETPOST(
'search_fk_shipping_method',
'int');
119 $search_fk_mode_reglement =
GETPOST(
'search_fk_mode_reglement',
'int');
120 $search_fk_input_reason =
GETPOST(
'search_fk_input_reason',
'int');
125 $socid = $user->socid;
129 $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].
'/temp/massgeneration/'.$user->id;
132 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
133 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
134 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
136 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
139 $offset = $limit * $page;
140 $pageprev = $page - 1;
141 $pagenext = $page + 1;
143 $sortfield =
'c.ref';
149 $show_shippable_command =
GETPOST(
'show_shippable_command',
'aZ09');
153 $hookmanager->initHooks(array(
'orderlist'));
157 $extrafields->fetch_name_optionals_label($object->table_element);
158 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
161 $fieldstosearchall = array(
163 'c.ref_client'=>
'RefCustomerOrder',
164 'pd.description'=>
'Description',
165 's.nom'=>
"ThirdParty",
166 's.name_alias'=>
"AliasNameShort",
169 'c.note_public'=>
'NotePublic',
171 if (empty($user->socid)) {
172 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
175 $checkedtypetiers = 0;
176 $arrayfields = array(
177 'c.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
178 'c.ref_client'=>array(
'label'=>
"RefCustomerOrder",
'checked'=>-1,
'position'=>10),
179 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>-1,
'enabled'=>(!
isModEnabled(
'project') ? 0 : 1),
'position'=>20),
180 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(!
isModEnabled(
'project') ? 0 : 1),
'position'=>25),
181 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>30),
182 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>-1,
'position'=>31),
183 's2.nom'=>array(
'label'=>
'ParentCompany',
'position'=>32,
'checked'=>0),
184 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>35),
185 's.zip'=>array(
'label'=>
"Zip",
'checked'=>-1,
'position'=>40),
186 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>45),
187 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>50),
188 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>55),
189 'c.date_commande'=>array(
'label'=>
"OrderDateShort",
'checked'=>1,
'position'=>60),
190 'c.date_delivery'=>array(
'label'=>
"DateDeliveryPlanned",
'checked'=>1,
'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE),
'position'=>65),
191 'c.fk_shipping_method'=>array(
'label'=>
"SendingMethod",
'checked'=>-1,
'position'=>66 ,
'enabled'=>
isModEnabled(
"expedition")),
192 'c.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>-1,
'position'=>67),
193 'c.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>-1,
'position'=>68),
194 'c.fk_input_reason'=>array(
'label'=>
"Channel",
'checked'=>-1,
'position'=>69),
195 'c.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>75),
196 'c.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>80),
197 'c.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>85),
198 'c.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1),
'position'=>90),
199 'c.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1),
'position'=>95),
200 'c.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1),
'position'=>100),
201 'c.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1),
'position'=>105),
202 'c.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1),
'position'=>110),
203 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>115),
204 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>116),
205 'total_pa' => array(
'label' => (
getDolGlobalString(
'MARGIN_TYPE') ==
'1' ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") ? 0 : 1)),
206 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") ? 0 : 1)),
207 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
208 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
"margins",
"liretous") || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
209 'c.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>120),
210 'c.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>125),
211 'c.date_cloture'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>130),
212 'c.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES')),
'position'=>135),
213 'c.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'enabled'=>(!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES')),
'position'=>140),
214 'shippable'=>array(
'label'=>
"Shippable",
'checked'=>1,
'enabled'=>(
isModEnabled(
"expedition")),
'position'=>990),
215 'c.facture'=>array(
'label'=>
"Billed",
'checked'=>1,
'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)),
'position'=>995),
216 'c.import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>999),
217 'c.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
221 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
232 if (
GETPOST(
'cancel',
'alpha')) {
233 $action =
'list'; $massaction =
'';
235 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
239 $parameters = array(
'socid'=>$socid);
240 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
245 if (empty($reshook)) {
247 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
250 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
254 $search_product_category =
'';
256 $search_ref_customer =
'';
257 $search_company =
'';
258 $search_company_alias =
'';
259 $search_parent_name =
'';
264 $search_country =
'';
265 $search_type_thirdparty =
'';
266 $search_total_ht =
'';
267 $search_total_vat =
'';
268 $search_total_ttc =
'';
269 $search_warehouse =
'';
270 $search_multicurrency_code =
'';
271 $search_multicurrency_tx =
'';
272 $search_multicurrency_montant_ht =
'';
273 $search_multicurrency_montant_vat =
'';
274 $search_multicurrency_montant_ttc =
'';
276 $search_dateorder_start =
'';
277 $search_dateorder_end =
'';
278 $search_datedelivery_start =
'';
279 $search_datedelivery_end =
'';
280 $search_project_ref =
'';
281 $search_project =
'';
285 $search_array_options = array();
286 $search_categ_cus = 0;
287 $search_datecloture_start =
'';
288 $search_datecloture_end =
'';
289 $search_fk_cond_reglement =
'';
290 $search_fk_shipping_method =
'';
291 $search_fk_mode_reglement =
'';
292 $search_fk_input_reason =
'';
294 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
295 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
300 $objectclass =
'Commande';
301 $objectlabel =
'Orders';
302 $permissiontoread = $user->hasRight(
"commande",
"lire");
303 $permissiontoadd = $user->hasRight(
"commande",
"creer");
304 $permissiontodelete = $user->hasRight(
"commande",
"supprimer");
305 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
306 $permissiontovalidate = $user->hasRight(
"commande",
"order_advance",
"validate");
307 $permissiontoclose = $user->hasRight(
"commande",
"order_advance",
"close");
308 $permissiontocancel = $user->hasRight(
"commande",
"order_advance",
"annuler");
309 $permissiontosendbymail = $user->hasRight(
"commande",
"order_advance",
"send");
311 $permissiontovalidate = $user->hasRight(
"commande",
"creer");
312 $permissiontoclose = $user->hasRight(
"commande",
"creer");
313 $permissiontocancel = $user->hasRight(
"commande",
"creer");
314 $permissiontosendbymail = $user->hasRight(
"commande",
"creer");
316 $uploaddir = $conf->commande->multidir_output[$conf->entity];
317 $triggersendname =
'ORDER_SENTBYMAIL';
318 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
320 if ($massaction ==
'confirm_createbills') {
321 $orders =
GETPOST(
'toselect',
'array');
322 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
323 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
328 $TFactThird = array();
329 $TFactThirdNbLines = array();
331 $nb_bills_created = 0;
337 $nbOrders = is_array($orders) ? count($orders) : 1;
339 foreach ($orders as $id_order) {
341 if ($cmd->fetch($id_order) <= 0) {
344 $cmd->fetch_thirdparty();
347 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
349 $objecttmp = $TFactThird[$cmd->socid];
352 $objecttmp->socid = $cmd->socid;
353 $objecttmp->thirdparty = $cmd->thirdparty;
355 $objecttmp->type = $objecttmp::TYPE_STANDARD;
356 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
357 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
359 $objecttmp->fk_project = $cmd->fk_project;
360 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
361 if (empty($createbills_onebythird)) {
362 $objecttmp->ref_client = $cmd->ref_client;
366 if (empty($datefacture)) {
370 $objecttmp->date = $datefacture;
371 $objecttmp->origin =
'commande';
372 $objecttmp->origin_id = $id_order;
374 $objecttmp->array_options = $cmd->array_options;
376 $res = $objecttmp->create($user);
380 $lastref = $objecttmp->ref;
381 $lastid = $objecttmp->id;
383 $TFactThird[$cmd->socid] = $objecttmp;
384 $TFactThirdNbLines[$cmd->socid] = 0;
386 $langs->load(
"errors");
387 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
392 if ($objecttmp->id > 0) {
393 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
396 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
401 $lines = $cmd->lines;
402 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
404 $lines = $cmd->lines;
408 $num = count($lines);
410 for ($i = 0; $i < $num; $i++) {
411 $desc = ($lines[$i]->desc ? $lines[$i]->desc :
'');
413 if (!empty($createbills_onebythird)) {
417 if ($lines[$i]->subprice < 0) {
420 $discount->fk_soc = $objecttmp->socid;
421 $discount->amount_ht = abs($lines[$i]->total_ht);
422 $discount->amount_tva = abs($lines[$i]->total_tva);
423 $discount->amount_ttc = abs($lines[$i]->total_ttc);
424 $discount->tva_tx = $lines[$i]->tva_tx;
425 $discount->fk_user = $user->id;
426 $discount->description = $desc;
427 $discountid = $discount->create($user);
428 if ($discountid > 0) {
429 $result = $objecttmp->insert_discount($discountid);
438 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
441 if ($lines[$i]->date_debut_prevue) {
442 $date_start = $lines[$i]->date_debut_prevue;
444 if ($lines[$i]->date_debut_reel) {
445 $date_start = $lines[$i]->date_debut_reel;
447 if ($lines[$i]->date_start) {
448 $date_start = $lines[$i]->date_start;
452 if ($lines[$i]->date_fin_prevue) {
453 $date_end = $lines[$i]->date_fin_prevue;
455 if ($lines[$i]->date_fin_reel) {
456 $date_end = $lines[$i]->date_fin_reel;
458 if ($lines[$i]->date_end) {
459 $date_end = $lines[$i]->date_end;
462 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
467 if (method_exists($lines[$i],
'fetch_optionals')) {
468 $lines[$i]->fetch_optionals();
469 $array_options = $lines[$i]->array_options;
472 $objecttmp->context[
'createfromclone'];
474 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
476 if (!empty($createbills_onebythird)) {
477 $rang = $TFactThirdNbLines[$cmd->socid];
480 $result = $objecttmp->addline(
482 $lines[$i]->subprice,
485 $lines[$i]->localtax1_tx,
486 $lines[$i]->localtax2_tx,
487 $lines[$i]->fk_product,
488 $lines[$i]->remise_percent,
492 $lines[$i]->info_bits,
493 $lines[$i]->fk_remise_except,
498 $lines[$i]->special_code,
502 $lines[$i]->fk_fournprice,
512 if (!empty($createbills_onebythird))
513 $TFactThirdNbLines[$rcp->socid]++;
520 if ($result > 0 && $lines[$i]->product_type == 9) {
521 $fk_parent_line = $result;
530 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
531 $TFactThird[$cmd->socid] = $objecttmp;
533 $TFact[$objecttmp->id] = $objecttmp;
538 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
541 if (!$error && $validate_invoices) {
542 $massaction = $action =
'builddoc';
544 foreach ($TAllFact as &$objecttmp) {
545 $result = $objecttmp->validate($user);
552 $id = $objecttmp->id;
556 $upload_dir = $conf->facture->dir_output;
557 $permissiontoadd = $user->rights->facture->creer;
560 $savobject = $object;
561 $object = $objecttmp;
562 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
563 $object = $savobject;
566 $massaction = $action =
'confirm_createbills';
572 if ($nb_bills_created == 1) {
573 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
574 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
577 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
583 $param .=
'&mode='.urlencode($mode);
585 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
586 $param .=
'&contextpage='.urlencode($contextpage);
588 if ($limit > 0 && $limit != $conf->liste_limit) {
589 $param .=
'&limit='.urlencode($limit);
592 $param .=
'&sall='.urlencode($sall);
595 $param .=
'&socid='.urlencode($socid);
597 if ($search_status !=
'') {
598 $param .=
'&search_status='.urlencode($search_status);
600 if ($search_orderday) {
601 $param .=
'&search_orderday='.urlencode($search_orderday);
603 if ($search_ordermonth) {
604 $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
606 if ($search_orderyear) {
607 $param .=
'&search_orderyear='.urlencode($search_orderyear);
609 if ($search_deliveryday) {
610 $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
612 if ($search_deliverymonth) {
613 $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
615 if ($search_deliveryyear) {
616 $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
619 $param .=
'&search_ref='.urlencode($search_ref);
621 if ($search_company) {
622 $param .=
'&search_company='.urlencode($search_company);
624 if ($search_ref_customer) {
625 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
627 if ($search_user > 0) {
628 $param .=
'&search_user='.urlencode($search_user);
630 if ($search_sale > 0) {
631 $param .=
'&search_sale='.urlencode($search_sale);
633 if ($search_total_ht !=
'') {
634 $param .=
'&search_total_ht='.urlencode($search_total_ht);
636 if ($search_total_vat !=
'') {
637 $param .=
'&search_total_vat='.urlencode($search_total_vat);
639 if ($search_total_ttc !=
'') {
640 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
642 if ($search_project_ref >= 0) {
643 $param .=
"&search_project_ref=".urlencode($search_project_ref);
646 $param .=
'&show_files='.urlencode($show_files);
648 if ($optioncss !=
'') {
649 $param .=
'&optioncss='.urlencode($optioncss);
652 $param .=
'&billed='.urlencode($billed);
655 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
661 $_GET[
"origin"] = $_POST[
"origin"];
662 $_GET[
"originid"] = $_POST[
"originid"];
663 if (!empty($errors)) {
672 if ($action ==
'validate' && $permissiontoadd) {
673 if (
GETPOST(
'confirm') ==
'yes') {
674 $objecttmp =
new $objectclass($db);
677 foreach ($toselect as $checked) {
678 if ($objecttmp->fetch($checked)) {
679 if ($objecttmp->statut == 0) {
680 if (!empty($objecttmp->fk_warehouse)) {
681 $idwarehouse = $objecttmp->fk_warehouse;
685 if ($objecttmp->valid($user, $idwarehouse)) {
686 setEventMessages($langs->trans(
'hasBeenValidated', $objecttmp->ref),
null,
'mesgs');
692 $langs->load(
"errors");
693 setEventMessages($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
null,
'errors');
708 if ($action ==
'shipped' && $permissiontoadd) {
709 if (
GETPOST(
'confirm') ==
'yes') {
710 $objecttmp =
new $objectclass($db);
713 foreach ($toselect as $checked) {
714 if ($objecttmp->fetch($checked)) {
715 if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
716 if ($objecttmp->cloture($user)) {
717 setEventMessages($langs->trans(
'PassedInClosedStatus', $objecttmp->ref),
null,
'mesgs');
723 $langs->load(
"errors");
724 setEventMessages($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
null,
'errors');
741 if (!$error && $massaction ===
'setbilled' && $permissiontoclose) {
744 $objecttmp =
new $objectclass($db);
746 foreach ($toselect as $toselectid) {
747 $result = $objecttmp->fetch($toselectid);
749 $result = $objecttmp->classifyBilled($user, 0);
791 $companystatic =
new Societe($db);
792 $company_url_list = array();
794 $projectstatic =
new Project($db);
796 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
797 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
799 $title = $langs->trans(
"Orders");
800 $help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
803 if ($sall || $search_user > 0) {
804 $sql =
'SELECT DISTINCT';
806 $sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,';
807 $sql .=
" s.parent as fk_parent,";
808 $sql .=
" s2.nom as name2,";
809 $sql .=
" typent.code as typent_code,";
810 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
811 $sql .=
" country.code as country_code,";
812 $sql .=
' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
813 $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,';
814 $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,';
815 $sql .=
' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
816 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
817 $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,';
818 $sql .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
819 $sql .=
' c.fk_input_reason, c.import_key';
820 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
821 $sql .=
", cc.fk_categorie, cc.fk_soc";
825 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
826 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
827 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
832 $parameters = array();
833 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
834 $sql .= $hookmanager->resPrint;
838 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
839 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
840 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
841 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
842 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
843 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
844 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
846 $sql .=
', '.MAIN_DB_PREFIX.
'commande as c';
847 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
848 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
851 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commandedet as pd ON c.rowid=pd.fk_commande';
853 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
854 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
857 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
858 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
860 if ($search_user > 0) {
861 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
862 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
866 $parameters = array();
867 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
868 $sql .= $hookmanager->resPrint;
870 $sql .=
' WHERE c.fk_soc = s.rowid';
871 $sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
873 $sql .=
' AND s.rowid = '.((int) $socid);
875 if (empty($user->rights->societe->client->voir) && !$socid) {
876 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
881 if ($search_ref_customer) {
887 if ($search_billed !=
'' && $search_billed >= 0) {
888 $sql .=
' AND c.facture = '.((int) $search_billed);
890 if ($search_status <>
'') {
891 if ($search_status <= 3 && $search_status >= -1) {
892 if ($search_status == 1 && empty($conf->expedition->enabled)) {
893 $sql .=
' AND c.fk_statut IN (1,2)';
895 $sql .=
' AND c.fk_statut = '.((int) $search_status);
898 if ($search_status == -2) {
900 $sql .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
902 if ($search_status == -3) {
905 $sql .=
' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))';
907 if ($search_status == -4) {
908 $sql .=
' AND (c.fk_statut IN (1,2))';
912 if ($search_datecloture_start) {
913 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
915 if ($search_datecloture_end) {
916 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
918 if ($search_dateorder_start) {
919 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
921 if ($search_dateorder_end) {
922 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
924 if ($search_datedelivery_start) {
925 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
927 if ($search_datedelivery_end) {
928 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
939 if ($search_country) {
940 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
942 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
943 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
945 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
946 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
948 if ($search_company) {
951 if ($search_company_alias) {
955 if ($search_parent_name) {
958 if ($search_sale > 0) {
959 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
961 if ($search_user > 0) {
962 $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);
964 if ($search_total_ht !=
'') {
967 if ($search_total_vat !=
'') {
970 if ($search_total_ttc !=
'') {
973 if ($search_warehouse !=
'' && $search_warehouse > 0) {
976 if ($search_multicurrency_code !=
'') {
977 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
979 if ($search_multicurrency_tx !=
'') {
980 $sql .=
natural_search(
'c.multicurrency_tx', $search_multicurrency_tx, 1);
982 if ($search_multicurrency_montant_ht !=
'') {
983 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
985 if ($search_multicurrency_montant_vat !=
'') {
986 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
988 if ($search_multicurrency_montant_ttc !=
'') {
989 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
992 $sql .=
natural_search(array(
"u.login",
"u.firstname",
"u.lastname"), $search_login);
994 if ($search_project_ref !=
'') {
997 if ($search_project !=
'') {
1000 if ($search_categ_cus > 0) {
1001 $sql .=
" AND cc.fk_categorie = ".((int) $search_categ_cus);
1003 if ($search_categ_cus == -2) {
1004 $sql .=
" AND cc.fk_categorie IS NULL";
1006 if ($search_fk_cond_reglement > 0) {
1007 $sql .=
" AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
1009 if ($search_fk_shipping_method > 0) {
1010 $sql .=
" AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
1012 if ($search_fk_mode_reglement > 0) {
1013 $sql .=
" AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
1015 if ($search_fk_input_reason > 0) {
1016 $sql .=
" AND c.fk_input_reason = ".((int) $search_fk_input_reason);
1019 $searchCategoryProductOperator = -1;
1020 $searchCategoryProductList = array($search_product_category);
1021 if (!empty($searchCategoryProductList)) {
1022 $searchCategoryProductSqlList = array();
1023 $listofcategoryid =
'';
1024 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1025 if (intval($searchCategoryProduct) == -2) {
1026 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product)";
1027 } elseif (intval($searchCategoryProduct) > 0) {
1028 if ($searchCategoryProductOperator == 0) {
1029 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
1031 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1035 if ($listofcategoryid) {
1036 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"commandedet as cd WHERE cd.fk_commande = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1038 if ($searchCategoryProductOperator == 1) {
1039 if (!empty($searchCategoryProductSqlList)) {
1040 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1043 if (!empty($searchCategoryProductSqlList)) {
1044 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1049 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1051 $parameters = array();
1052 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1053 $sql .= $hookmanager->resPrint;
1056 $parameters = array();
1057 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
1058 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
1062 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1064 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1065 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1066 $resql = $db->query($sqlforcount);
1068 $objforcount = $db->fetch_object(
$resql);
1081 $sql .= $db->order($sortfield, $sortorder);
1083 $sql .= $db->plimit($limit + 1, $offset);
1087 $resql = $db->query($sql);
1091 $soc->fetch($socid);
1092 $title = $langs->trans(
'CustomersOrders').
' - '.$soc->name;
1093 if (empty($search_company)) {
1094 $search_company = $soc->name;
1097 $title = $langs->trans(
'CustomersOrders');
1099 if (strval($search_status) ==
'0') {
1100 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
1102 if ($search_status == 1) {
1103 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
1105 if ($search_status == 2) {
1106 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
1108 if ($search_status == 3) {
1109 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
1111 if ($search_status == -1) {
1112 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
1114 if ($search_status == -2) {
1115 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
1117 if ($search_status == -3) {
1118 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(empty($conf->expedition->enabled) ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
1120 if ($search_status == -4) {
1121 $title .=
' - '.$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort");
1124 $num = $db->num_rows(
$resql);
1126 $arrayofselected = is_array($toselect) ? $toselect : array();
1128 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
1129 $obj = $db->fetch_object(
$resql);
1131 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.$id);
1138 if (!empty($mode)) {
1139 $param .=
'&mode='.urlencode($mode);
1141 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1142 $param .=
'&contextpage='.urlencode($contextpage);
1144 if ($limit > 0 && $limit != $conf->liste_limit) {
1145 $param .=
'&limit='.urlencode($limit);
1148 $param .=
'&sall='.urlencode($sall);
1151 $param .=
'&socid='.urlencode($socid);
1153 if ($search_status !=
'') {
1154 $param .=
'&search_status='.urlencode($search_status);
1156 if ($search_datecloture_start) {
1157 $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');
1159 if ($search_datecloture_end) {
1160 $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');
1162 if ($search_dateorder_start) {
1163 $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');
1165 if ($search_dateorder_end) {
1166 $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');
1168 if ($search_datedelivery_start) {
1169 $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');
1171 if ($search_datedelivery_end) {
1172 $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');
1175 $param .=
'&search_ref='.urlencode($search_ref);
1177 if ($search_company) {
1178 $param .=
'&search_company='.urlencode($search_company);
1180 if ($search_company_alias) {
1181 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1183 if ($search_parent_name !=
'') {
1184 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1186 if ($search_ref_customer) {
1187 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
1189 if ($search_user > 0) {
1190 $param .=
'&search_user='.urlencode($search_user);
1192 if ($search_sale > 0) {
1193 $param .=
'&search_sale='.urlencode($search_sale);
1195 if ($search_total_ht !=
'') {
1196 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1198 if ($search_total_vat !=
'') {
1199 $param .=
'&search_total_vat='.urlencode($search_total_vat);
1201 if ($search_total_ttc !=
'') {
1202 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
1204 if ($search_warehouse !=
'') {
1205 $param .=
'&search_warehouse='.urlencode($search_warehouse);
1207 if ($search_login) {
1208 $param .=
'&search_login='.urlencode($search_login);
1210 if ($search_multicurrency_code !=
'') {
1211 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1213 if ($search_multicurrency_tx !=
'') {
1214 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1216 if ($search_multicurrency_montant_ht !=
'') {
1217 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1219 if ($search_multicurrency_montant_vat !=
'') {
1220 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1222 if ($search_multicurrency_montant_ttc !=
'') {
1223 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1225 if ($search_project_ref >= 0) {
1226 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1228 if ($search_town !=
'') {
1229 $param .=
'&search_town='.urlencode($search_town);
1231 if ($search_zip !=
'') {
1232 $param .=
'&search_zip='.urlencode($search_zip);
1234 if ($search_state !=
'') {
1235 $param .=
'&search_state='.urlencode($search_state);
1237 if ($search_country !=
'') {
1238 $param .=
'&search_country='.urlencode($search_country);
1240 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
1241 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1243 if ($search_product_category !=
'') {
1244 $param .=
'&search_product_category='.urlencode($search_product_category);
1246 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1247 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1250 $param .=
'&show_files='.urlencode($show_files);
1252 if ($optioncss !=
'') {
1253 $param .=
'&optioncss='.urlencode($optioncss);
1255 if ($search_billed !=
'') {
1256 $param .=
'&search_billed='.urlencode($search_billed);
1258 if ($search_fk_cond_reglement > 0) {
1259 $param .=
'&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
1261 if ($search_fk_shipping_method > 0) {
1262 $param .=
'&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
1264 if ($search_fk_mode_reglement > 0) {
1265 $param .=
'&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
1267 if ($search_fk_input_reason > 0) {
1268 $param .=
'&search_fk_input_reason='.urlencode($search_fk_input_reason);
1272 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1275 $parameters = array();
1276 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1277 $param .= $hookmanager->resPrint;
1280 $arrayofmassactions = array(
1281 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1282 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1284 if ($permissiontovalidate) {
1285 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1287 if ($permissiontosendbymail) {
1288 $arrayofmassactions[
'presend'] =
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail");
1290 if ($permissiontoclose) {
1291 $arrayofmassactions[
'preshipped'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').$langs->trans(
"ClassifyShipped");
1293 if ($permissiontocancel) {
1294 $arrayofmassactions[
'cancelorders'] =
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"Cancel");
1296 if (
isModEnabled(
'facture') && $user->hasRight(
"facture",
"creer")) {
1297 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisCustomer");
1299 if ($permissiontoclose) {
1300 $arrayofmassactions[
'setbilled'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"ClassifyBilled");
1302 if ($permissiontodelete) {
1303 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1305 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1306 $arrayofmassactions = array();
1308 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1310 $url = DOL_URL_ROOT.
'/commande/card.php?action=create';
1311 if (!empty($socid)) {
1312 $url .=
'&socid='.$socid;
1314 $newcardbutton =
'';
1315 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
1316 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
1317 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewOrder'),
'',
'fa fa-plus-circle', $url,
'', $contextpage ==
'orderlist' && $permissiontoadd);
1320 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1321 if ($optioncss !=
'') {
1322 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1324 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1325 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1326 print
'<input type="hidden" name="action" value="list">';
1327 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1328 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1329 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1330 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1331 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1332 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1335 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1337 $topicmail =
"SendOrderRef";
1338 $modelmail =
"order_send";
1340 $trackid =
'ord'.$object->id;
1341 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1343 if ($massaction ==
'prevalidate') {
1344 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1346 if ($massaction ==
'preshipped') {
1347 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"CloseOrder"), $langs->trans(
"ConfirmCloseOrder"),
"shipped",
null,
'', 0, 200, 500, 1);
1350 if ($massaction ==
'createbills') {
1351 print
'<input type="hidden" name="massaction" value="confirm_createbills">';
1353 print
'<table class="noborder centpercent">';
1356 print $langs->trans(
'DateInvoice');
1359 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1364 print $langs->trans(
'CreateOneBillByThird');
1367 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1372 print $langs->trans(
'ValidateInvoices');
1375 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
1376 print
$form->selectyesno(
'validate_invoices', 0, 1, 1);
1377 $langs->load(
"errors");
1378 print
' ('.$langs->trans(
"WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").
')';
1380 print
$form->selectyesno(
'validate_invoices', 0, 1);
1382 if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) {
1383 print
' <span class="opacitymedium">'.$langs->trans(
"IfValidateInvoiceIsNoOrderStayUnbilled").
'</span>';
1385 print
' <span class="opacitymedium">'.$langs->trans(
"OptionToSetOrderBilledNotEnabled").
'</span>';
1391 print
'<div class="center">';
1392 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1393 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1399 foreach ($fieldstosearchall as $key => $val) {
1400 $fieldstosearchall[$key] = $langs->trans($val);
1402 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1405 $moreforfilter =
'';
1408 if ($user->hasRight(
"user",
"user",
"lire")) {
1409 $langs->load(
"commercial");
1410 $moreforfilter .=
'<div class="divsearchfield">';
1411 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1412 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1413 $moreforfilter .=
'</div>';
1416 if ($user->hasRight(
"user",
"user",
"lire")) {
1417 $moreforfilter .=
'<div class="divsearchfield">';
1418 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1419 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1420 $moreforfilter .=
'</div>';
1424 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1425 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1426 $moreforfilter .=
'<div class="divsearchfield">';
1427 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1428 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1429 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300 widthcentpercentminusx', 1);
1430 $moreforfilter .=
'</div>';
1433 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire")) {
1434 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1435 $moreforfilter .=
'<div class="divsearchfield">';
1436 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1437 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'maxwidth300 widthcentpercentminusx');
1438 $moreforfilter .=
'</div>';
1441 if (
isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1442 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1444 $moreforfilter .=
'<div class="divsearchfield">';
1445 $tmptitle = $langs->trans(
'Warehouse');
1446 $moreforfilter .=
img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'maxwidth250 widthcentpercentminusx');
1447 $moreforfilter .=
'</div>';
1449 $parameters = array();
1450 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1451 if (empty($reshook)) {
1452 $moreforfilter .= $hookmanager->resPrint;
1454 $moreforfilter = $hookmanager->resPrint;
1457 if (!empty($moreforfilter)) {
1458 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1459 print $moreforfilter;
1463 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1464 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1465 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1467 if (
GETPOST(
'autoselectall',
'int')) {
1468 $selectedfields .=
'<script>';
1469 $selectedfields .=
' $(document).ready(function() {';
1470 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1471 $selectedfields .=
' $("#checkforselects").click();';
1472 $selectedfields .=
' $("#massaction").val("createbills").change();';
1473 $selectedfields .=
' });';
1474 $selectedfields .=
'</script>';
1477 print
'<div class="div-table-responsive">';
1478 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1480 print
'<tr class="liste_titre_filter">';
1482 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1483 print
'<td class="liste_titre" align="middle">';
1484 $searchpicto =
$form->showFilterButtons(
'left');
1490 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1491 print
'<td class="liste_titre">';
1492 print
'<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1496 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1497 print
'<td class="liste_titre" align="left">';
1498 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1502 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1503 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1506 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1507 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1510 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1511 print
'<td class="liste_titre" align="left">';
1512 print
'<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
1516 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1517 print
'<td class="liste_titre" align="left">';
1518 print
'<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1522 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1523 print
'<td class="liste_titre">';
1524 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1528 if (!empty($arrayfields[
's.town'][
'checked'])) {
1529 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1532 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1533 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1536 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1537 print
'<td class="liste_titre">';
1538 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1542 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1543 print
'<td class="liste_titre" align="center">';
1544 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1548 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1549 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1550 print
$form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1554 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1555 print
'<td class="liste_titre center">';
1556 print
'<div class="nowrap">';
1557 print
$form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1559 print
'<div class="nowrap">';
1560 print
$form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1564 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1565 print
'<td class="liste_titre center">';
1566 print
'<div class="nowrap">';
1567 print
$form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1569 print
'<div class="nowrap">';
1570 print
$form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1575 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1576 print
'<td class="liste_titre">';
1577 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1581 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1582 print
'<td class="liste_titre">';
1583 print
$form->getSelectConditionsPaiements($search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1587 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1588 print
'<td class="liste_titre">';
1589 print
$form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1,
'', 1);
1593 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1594 print
'<td class="liste_titre">';
1595 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1599 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1600 print
'<td class="liste_titre right">';
1601 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1605 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1606 print
'<td class="liste_titre right">';
1607 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1611 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1612 print
'<td class="liste_titre right">';
1613 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1617 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1618 print
'<td class="liste_titre">';
1619 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1623 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1624 print
'<td class="liste_titre">';
1625 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1629 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1630 print
'<td class="liste_titre right">';
1631 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1635 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1636 print
'<td class="liste_titre right">';
1637 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1641 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1642 print
'<td class="liste_titre right">';
1643 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1647 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1648 print
'<td class="liste_titre" align="center">';
1649 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1653 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1654 print
'<td class="liste_titre"></td>';
1656 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1657 print
'<td class="liste_titre right">';
1660 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1661 print
'<td class="liste_titre right">';
1664 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1665 print
'<td class="liste_titre right">';
1668 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1669 print
'<td class="liste_titre right">';
1674 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1677 $parameters = array(
'arrayfields'=>$arrayfields);
1678 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1679 print $hookmanager->resPrint;
1682 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1683 print
'<td class="liste_titre">';
1687 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1688 print
'<td class="liste_titre">';
1692 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1693 print
'<td class="liste_titre center">';
1694 print
'<div class="nowrap">';
1695 print
$form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1697 print
'<div class="nowrap">';
1698 print
$form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1703 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1704 print
'<td class="liste_titre">';
1708 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1709 print
'<td class="liste_titre">';
1713 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1714 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1716 if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) {
1717 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
1718 print $langs->trans(
'ShowShippableStatus');
1720 $show_shippable_command = 1;
1725 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1726 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1727 print
$form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1731 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1732 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1736 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1737 print
'<td class="liste_titre maxwidthonsmartphone center">';
1738 $liststatus = array(
1743 -3=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
1744 -2=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
1747 print
$form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'maxwidth125 onrightofpage', 1);
1751 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1752 print
'<td class="liste_titre" align="middle">';
1753 $searchpicto =
$form->showFilterButtons();
1760 print
'<tr class="liste_titre">';
1762 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1763 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1765 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1766 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
1768 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1769 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
1771 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1772 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1774 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1775 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
1777 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1778 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1780 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1781 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1783 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1784 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
1786 if (!empty($arrayfields[
's.town'][
'checked'])) {
1787 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1789 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1790 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1792 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1793 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1795 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1796 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1798 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1799 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1801 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1802 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
1804 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1805 print_liste_field_titre($arrayfields[
'c.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1807 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1808 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
1810 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1811 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
1813 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1814 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
1816 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1817 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
1819 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1820 print_liste_field_titre($arrayfields[
'c.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1822 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1823 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1825 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1826 print_liste_field_titre($arrayfields[
'c.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1828 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1829 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1831 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1832 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1834 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1835 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1837 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1838 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1840 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1841 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1843 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1844 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1846 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1847 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1849 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1850 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1852 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1853 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1855 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1856 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1858 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1859 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1862 $totalarray = array(
1873 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1876 $parameters = array(
1877 'arrayfields' => $arrayfields,
1879 'sortfield' => $sortfield,
1880 'sortorder' => $sortorder,
1881 'totalarray' => &$totalarray,
1883 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1884 print $hookmanager->resPrint;
1885 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1886 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1888 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1889 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1891 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1892 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1894 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1895 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'right ');
1897 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1898 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'right ');
1900 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1901 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1903 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1904 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
1906 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1907 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1909 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1910 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1912 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1913 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1919 $productstat_cache = array();
1920 $productstat_cachevirtual = array();
1921 $getNomUrl_cache = array();
1923 $generic_commande =
new Commande($db);
1924 $generic_product =
new Product($db);
1925 $userstatic =
new User($db);
1928 $with_margin_info =
false;
1930 !empty($arrayfields[
'total_pa'][
'checked'])
1931 || !empty($arrayfields[
'total_margin'][
'checked'])
1932 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1933 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1936 $with_margin_info =
true;
1941 $savnbfield = $totalarray[
'nbfield'];
1942 $totalarray = array();
1943 $totalarray[
'nbfield'] = 0;
1944 $imaxinloop = ($limit ? min($num, $limit) : $num);
1945 while ($i < $imaxinloop) {
1946 $obj = $db->fetch_object(
$resql);
1954 $companystatic->id = $obj->socid;
1955 $companystatic->name = $obj->name;
1956 $companystatic->name_alias = $obj->alias;
1957 $companystatic->client = $obj->client;
1958 $companystatic->fournisseur = $obj->fournisseur;
1959 $companystatic->code_client = $obj->code_client;
1960 $companystatic->email = $obj->email;
1961 $companystatic->phone = $obj->phone;
1962 $companystatic->address = $obj->address;
1963 $companystatic->zip = $obj->zip;
1964 $companystatic->town = $obj->town;
1965 $companystatic->country_code = $obj->country_code;
1966 if (!isset($getNomUrl_cache[$obj->socid])) {
1967 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1970 $generic_commande->id = $obj->rowid;
1971 $generic_commande->ref = $obj->ref;
1972 $generic_commande->statut = $obj->fk_statut;
1973 $generic_commande->billed = $obj->billed;
1974 $generic_commande->date = $db->jdate($obj->date_commande);
1975 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1976 $generic_commande->ref_client = $obj->ref_client;
1977 $generic_commande->total_ht = $obj->total_ht;
1978 $generic_commande->total_tva = $obj->total_tva;
1979 $generic_commande->total_ttc = $obj->total_ttc;
1980 $generic_commande->note_public = $obj->note_public;
1981 $generic_commande->note_private = $obj->note_private;
1983 $generic_commande->thirdparty = $companystatic;
1986 $projectstatic->id = $obj->project_id;
1987 $projectstatic->ref = $obj->project_ref;
1988 $projectstatic->title = $obj->project_label;
1990 $marginInfo = array();
1991 if ($with_margin_info ===
true) {
1992 $generic_commande->fetch_lines();
1993 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1994 $total_ht += $obj->total_ht;
1995 $total_margin += $marginInfo[
'total_margin'];
1998 if ($mode ==
'kanban') {
2000 print
'<tr><td colspan="12">';
2001 print
'<div class="box-flex-container">';
2004 print $generic_commande->getKanbanView(
'');
2006 if ($i == ($imaxinloop - 1)) {
2011 print
'<tr class="oddeven">';
2014 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2015 print
'<td class="nowrap center">';
2016 if ($massactionbutton || $massaction) {
2018 if (in_array($obj->rowid, $arrayofselected)) {
2021 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2024 $totalarray[
'nbfield']++;
2030 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
2031 print
'<td class="nowraponall">';
2032 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
2035 $filedir = $conf->commande->multidir_output[$conf->entity].
'/'.
dol_sanitizeFileName($obj->ref);
2036 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
2037 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
2041 $totalarray[
'nbfield']++;
2046 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
2047 print
'<td class="nowrap tdoverflowmax200">'.$obj->ref_client.
'</td>';
2049 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2055 print
'<td class="nowrap">';
2056 if ($obj->project_id > 0) {
2057 print $projectstatic->getNomUrl(1);
2061 $totalarray[
'nbfield']++;
2066 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2067 print
'<td class="nowrap">';
2068 if ($obj->project_id > 0) {
2069 print $projectstatic->title;
2073 $totalarray[
'nbfield']++;
2078 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2079 print
'<td class="tdoverflowmax150">';
2080 print $getNomUrl_cache[$obj->socid];
2083 if (
isModEnabled(
'facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
2084 if ($user->rights->facture->creer) {
2085 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
2086 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
2087 print
img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
2093 $totalarray[
'nbfield']++;
2098 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2099 print
'<td class="nocellnopadd">';
2103 $totalarray[
'nbfield']++;
2108 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2109 print
'<td class="tdoverflowmax200">';
2110 if ($obj->fk_parent > 0) {
2111 if (!isset($company_url_list[$obj->fk_parent])) {
2112 $companyparent =
new Societe($db);
2113 $res = $companyparent->fetch($obj->fk_parent);
2115 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2118 if (isset($company_url_list[$obj->fk_parent])) {
2119 print $company_url_list[$obj->fk_parent];
2124 $totalarray[
'nbfield']++;
2129 if (!empty($arrayfields[
's.town'][
'checked'])) {
2130 print
'<td class="nocellnopadd">';
2134 $totalarray[
'nbfield']++;
2139 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2140 print
'<td class="nocellnopadd">';
2144 $totalarray[
'nbfield']++;
2149 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2150 print
"<td>".$obj->state_name.
"</td>\n";
2152 $totalarray[
'nbfield']++;
2157 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2158 print
'<td class="center">';
2159 $tmparray =
getCountry($obj->fk_pays,
'all');
2160 print $tmparray[
'label'];
2163 $totalarray[
'nbfield']++;
2168 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2169 print
'<td class="center">';
2170 if (empty($typenArray)) {
2171 $typenArray = $formcompany->typent_array(1);
2173 print $typenArray[$obj->typent_code];
2176 $totalarray[
'nbfield']++;
2181 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
2182 print
'<td class="center">';
2185 if ($generic_commande->hasDelay()) {
2186 print
img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
2190 $totalarray[
'nbfield']++;
2195 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
2196 print
'<td class="center">';
2197 print
dol_print_date($db->jdate($obj->date_delivery),
'dayhour');
2200 $totalarray[
'nbfield']++;
2205 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
2207 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
2210 $totalarray[
'nbfield']++;
2215 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
2217 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
2220 $totalarray[
'nbfield']++;
2225 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
2227 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
2230 $totalarray[
'nbfield']++;
2235 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
2237 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none',
'');
2240 $totalarray[
'nbfield']++;
2245 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
2246 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2248 $totalarray[
'nbfield']++;
2251 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ht';
2253 if (isset($totalarray[
'val'][
'c.total_ht'])) {
2254 $totalarray[
'val'][
'c.total_ht'] += $obj->total_ht;
2256 $totalarray[
'val'][
'c.total_ht'] = $obj->total_ht;
2261 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
2262 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
2264 $totalarray[
'nbfield']++;
2267 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_tva';
2269 if (isset($totalarray[
'val'][
'c.total_tva'])) {
2270 $totalarray[
'val'][
'c.total_tva'] += $obj->total_tva;
2272 $totalarray[
'val'][
'c.total_tva'] = $obj->total_tva;
2277 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
2278 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2280 $totalarray[
'nbfield']++;
2283 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ttc';
2285 if (isset($totalarray[
'val'][
'c.total_ttc'])) {
2286 $totalarray[
'val'][
'c.total_ttc'] += $obj->total_ttc;
2288 $totalarray[
'val'][
'c.total_ttc'] = $obj->total_ttc;
2293 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
2294 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2296 $totalarray[
'nbfield']++;
2301 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
2302 print
'<td class="nowrap">';
2303 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2306 $totalarray[
'nbfield']++;
2311 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
2312 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2314 $totalarray[
'nbfield']++;
2318 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
2319 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
2321 $totalarray[
'nbfield']++;
2325 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
2326 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2328 $totalarray[
'nbfield']++;
2332 $userstatic->id = $obj->fk_user_author;
2333 $userstatic->login = $obj->login;
2334 $userstatic->lastname = $obj->lastname;
2335 $userstatic->firstname = $obj->firstname;
2336 $userstatic->email = $obj->user_email;
2337 $userstatic->statut = $obj->user_statut;
2338 $userstatic->entity = $obj->entity;
2339 $userstatic->photo = $obj->photo;
2340 $userstatic->office_phone = $obj->office_phone;
2341 $userstatic->office_fax = $obj->office_fax;
2342 $userstatic->user_mobile = $obj->user_mobile;
2343 $userstatic->job = $obj->job;
2344 $userstatic->gender = $obj->gender;
2347 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2348 print
'<td class="tdoverflowmax200">';
2349 if ($userstatic->id) {
2350 print $userstatic->getNomUrl(-1);
2356 $totalarray[
'nbfield']++;
2361 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2363 if ($obj->socid > 0) {
2364 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2365 if ($listsalesrepresentatives < 0) {
2368 $nbofsalesrepresentative = count($listsalesrepresentatives);
2369 if ($nbofsalesrepresentative > 6) {
2371 print $nbofsalesrepresentative;
2372 } elseif ($nbofsalesrepresentative > 0) {
2374 foreach ($listsalesrepresentatives as $val) {
2375 $userstatic->id = $val[
'id'];
2376 $userstatic->lastname = $val[
'lastname'];
2377 $userstatic->firstname = $val[
'firstname'];
2378 $userstatic->email = $val[
'email'];
2379 $userstatic->statut = $val[
'statut'];
2380 $userstatic->entity = $val[
'entity'];
2381 $userstatic->photo = $val[
'photo'];
2382 $userstatic->login = $val[
'login'];
2383 $userstatic->office_phone = $val[
'office_phone'];
2384 $userstatic->office_fax = $val[
'office_fax'];
2385 $userstatic->user_mobile = $val[
'user_mobile'];
2386 $userstatic->job = $val[
'job'];
2387 $userstatic->gender = $val[
'gender'];
2389 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2391 if ($j < $nbofsalesrepresentative) {
2403 $totalarray[
'nbfield']++;
2408 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2409 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2411 $totalarray[
'nbfield']++;
2416 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2417 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2419 $totalarray[
'nbfield']++;
2422 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2424 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2428 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2429 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2431 $totalarray[
'nbfield']++;
2436 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2437 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2439 $totalarray[
'nbfield']++;
2442 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2444 if ($i >= $imaxinloop - 1) {
2445 if (!empty($total_ht)) {
2446 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2448 $totalarray[
'val'][
'total_mark_rate'] =
'';
2454 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2456 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2457 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2458 print $hookmanager->resPrint;
2461 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2462 print
'<td align="center" class="nowrap">';
2463 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2466 $totalarray[
'nbfield']++;
2471 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2472 print
'<td align="center" class="nowrap">';
2473 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2476 $totalarray[
'nbfield']++;
2481 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2482 print
'<td align="center" class="nowrap">';
2483 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuser');
2486 $totalarray[
'nbfield']++;
2491 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2492 print
'<td class="center">';
2496 $totalarray[
'nbfield']++;
2501 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2502 print
'<td class="center">';
2506 $totalarray[
'nbfield']++;
2511 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2512 print
'<td class="center">';
2513 if (!empty($show_shippable_command) &&
isModEnabled(
'stock')) {
2514 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2515 $generic_commande->getLinesArray();
2516 $generic_commande->loadExpeditions();
2518 $numlines = count($generic_commande->lines);
2519 for ($lig = 0; $lig < $numlines; $lig++) {
2520 if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
2521 $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
2523 $reliquat = $generic_commande->lines[$lig]->qty;
2525 if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) {
2527 $generic_product->id = $generic_commande->lines[$lig]->fk_product;
2530 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
2531 $generic_product->load_stock(
'nobatch,warehouseopen');
2532 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2533 $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2535 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'];
2536 $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2539 if ($reliquat > $generic_product->stock_reel) {
2542 if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
2543 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->product_ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2544 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2545 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2546 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2547 $text_info .=
'<br>';
2554 $stock_order_supplier = 0;
2555 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
2557 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'])) {
2558 $generic_product->load_stats_commande(0,
'1,2');
2559 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
2561 $generic_product->stats_commande[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'];
2563 $stock_order = $generic_product->stats_commande[
'qty'];
2565 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
2566 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'])) {
2567 $generic_product->load_stats_commande_fournisseur(0,
'3');
2568 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
2570 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'];
2572 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
2575 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2576 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
2577 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
2579 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2581 if ($reliquat > $generic_product->stock_reel) {
2582 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2584 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2586 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
2587 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
2589 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2590 $text_info .=
'<br>';
2594 if ($notshippable == 0) {
2595 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'green paddingleft');
2596 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
2598 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'error paddingleft');
2599 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
2604 print
$form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
2607 print
$form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1,
img_picto(
'',
'error'),
'', 2);
2612 $totalarray[
'nbfield']++;
2617 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2618 print
'<td class="center">'.yn($obj->billed).
'</td>';
2620 $totalarray[
'nbfield']++;
2625 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2626 print
'<td class="nowrap center">'.$obj->import_key.
'</td>';
2628 $totalarray[
'nbfield']++;
2633 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2634 print
'<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
2636 $totalarray[
'nbfield']++;
2641 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2642 print
'<td class="nowrap center">';
2643 if ($massactionbutton || $massaction) {
2645 if (in_array($obj->rowid, $arrayofselected)) {
2648 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2652 $totalarray[
'nbfield']++;
2658 $total += $obj->total_ht;
2659 $subtotal += $obj->total_ht;
2665 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2670 foreach ($arrayfields as $key => $val) {
2671 if (!empty($val[
'checked'])) {
2675 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2680 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2681 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2682 print $hookmanager->resPrint;
2684 print
'</table>'.
"\n";
2687 print
'</form>'.
"\n";
2689 $hidegeneratedfilelistifempty = 1;
2690 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2691 $hidegeneratedfilelistifempty = 0;
2695 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2696 $urlsource .= str_replace(
'&',
'&', $param);
2698 $filedir = $diroutputmassaction;
2699 $genallowed = $permissiontoread;
2700 $delallowed = $permissiontoadd;
2702 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!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 absolute discounts.
Class to manage invoices.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
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...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.