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';
233 if (
GETPOST(
'cancel',
'alpha')) {
234 $action =
'list'; $massaction =
'';
236 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
240 $parameters = array(
'socid'=>$socid,
'arrayfields'=>&$arrayfields);
241 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
246 if (empty($reshook)) {
248 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
251 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
255 $search_product_category =
'';
257 $search_ref_customer =
'';
258 $search_company =
'';
259 $search_company_alias =
'';
260 $search_parent_name =
'';
265 $search_country =
'';
266 $search_type_thirdparty =
'';
267 $search_total_ht =
'';
268 $search_total_vat =
'';
269 $search_total_ttc =
'';
270 $search_warehouse =
'';
271 $search_multicurrency_code =
'';
272 $search_multicurrency_tx =
'';
273 $search_multicurrency_montant_ht =
'';
274 $search_multicurrency_montant_vat =
'';
275 $search_multicurrency_montant_ttc =
'';
277 $search_dateorder_start =
'';
278 $search_dateorder_end =
'';
279 $search_datedelivery_start =
'';
280 $search_datedelivery_end =
'';
281 $search_project_ref =
'';
282 $search_project =
'';
286 $search_array_options = array();
287 $search_categ_cus = 0;
288 $search_datecloture_start =
'';
289 $search_datecloture_end =
'';
290 $search_fk_cond_reglement =
'';
291 $search_fk_shipping_method =
'';
292 $search_fk_mode_reglement =
'';
293 $search_fk_input_reason =
'';
295 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
296 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
301 $objectclass =
'Commande';
302 $objectlabel =
'Orders';
303 $permissiontoread = $user->hasRight(
"commande",
"lire");
304 $permissiontoadd = $user->hasRight(
"commande",
"creer");
305 $permissiontodelete = $user->hasRight(
"commande",
"supprimer");
306 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
307 $permissiontovalidate = $user->hasRight(
"commande",
"order_advance",
"validate");
308 $permissiontoclose = $user->hasRight(
"commande",
"order_advance",
"close");
309 $permissiontocancel = $user->hasRight(
"commande",
"order_advance",
"annuler");
310 $permissiontosendbymail = $user->hasRight(
"commande",
"order_advance",
"send");
312 $permissiontovalidate = $user->hasRight(
"commande",
"creer");
313 $permissiontoclose = $user->hasRight(
"commande",
"creer");
314 $permissiontocancel = $user->hasRight(
"commande",
"creer");
315 $permissiontosendbymail = $user->hasRight(
"commande",
"creer");
317 $uploaddir = $conf->commande->multidir_output[$conf->entity];
318 $triggersendname =
'ORDER_SENTBYMAIL';
319 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
321 if ($massaction ==
'confirm_createbills') {
322 $orders =
GETPOST(
'toselect',
'array');
323 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
324 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
329 $TFactThird = array();
330 $TFactThirdNbLines = array();
332 $nb_bills_created = 0;
338 $nbOrders = is_array($orders) ? count($orders) : 1;
340 foreach ($orders as $id_order) {
342 if ($cmd->fetch($id_order) <= 0) {
345 $cmd->fetch_thirdparty();
348 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
350 $objecttmp = $TFactThird[$cmd->socid];
353 $objecttmp->socid = $cmd->socid;
354 $objecttmp->thirdparty = $cmd->thirdparty;
356 $objecttmp->type = $objecttmp::TYPE_STANDARD;
357 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
358 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
360 $objecttmp->fk_project = $cmd->fk_project;
361 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
362 if (empty($createbills_onebythird)) {
363 $objecttmp->ref_client = $cmd->ref_client;
367 if (empty($datefacture)) {
371 $objecttmp->date = $datefacture;
372 $objecttmp->origin =
'commande';
373 $objecttmp->origin_id = $id_order;
375 $objecttmp->array_options = $cmd->array_options;
377 $res = $objecttmp->create($user);
381 $lastref = $objecttmp->ref;
382 $lastid = $objecttmp->id;
384 $TFactThird[$cmd->socid] = $objecttmp;
385 $TFactThirdNbLines[$cmd->socid] = 0;
387 $langs->load(
"errors");
388 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
393 if ($objecttmp->id > 0) {
394 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
397 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
402 $lines = $cmd->lines;
403 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
405 $lines = $cmd->lines;
409 $num = count($lines);
411 for ($i = 0; $i < $num; $i++) {
412 $desc = ($lines[$i]->desc ? $lines[$i]->desc :
'');
414 if (!empty($createbills_onebythird)) {
418 if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) {
421 $discount->fk_soc = $objecttmp->socid;
422 $discount->amount_ht = abs($lines[$i]->total_ht);
423 $discount->amount_tva = abs($lines[$i]->total_tva);
424 $discount->amount_ttc = abs($lines[$i]->total_ttc);
425 $discount->tva_tx = $lines[$i]->tva_tx;
426 $discount->fk_user = $user->id;
427 $discount->description = $desc;
428 $discountid = $discount->create($user);
429 if ($discountid > 0) {
430 $result = $objecttmp->insert_discount($discountid);
439 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
442 if ($lines[$i]->date_debut_prevue) {
443 $date_start = $lines[$i]->date_debut_prevue;
445 if ($lines[$i]->date_debut_reel) {
446 $date_start = $lines[$i]->date_debut_reel;
448 if ($lines[$i]->date_start) {
449 $date_start = $lines[$i]->date_start;
453 if ($lines[$i]->date_fin_prevue) {
454 $date_end = $lines[$i]->date_fin_prevue;
456 if ($lines[$i]->date_fin_reel) {
457 $date_end = $lines[$i]->date_fin_reel;
459 if ($lines[$i]->date_end) {
460 $date_end = $lines[$i]->date_end;
463 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
468 if (method_exists($lines[$i],
'fetch_optionals')) {
469 $lines[$i]->fetch_optionals();
470 $array_options = $lines[$i]->array_options;
473 $objecttmp->context[
'createfromclone'];
475 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
477 if (!empty($createbills_onebythird)) {
478 $rang = $TFactThirdNbLines[$cmd->socid];
481 $result = $objecttmp->addline(
483 $lines[$i]->subprice,
486 $lines[$i]->localtax1_tx,
487 $lines[$i]->localtax2_tx,
488 $lines[$i]->fk_product,
489 $lines[$i]->remise_percent,
493 $lines[$i]->info_bits,
494 $lines[$i]->fk_remise_except,
499 $lines[$i]->special_code,
503 $lines[$i]->fk_fournprice,
513 if (!empty($createbills_onebythird))
514 $TFactThirdNbLines[$rcp->socid]++;
521 if ($result > 0 && $lines[$i]->product_type == 9) {
522 $fk_parent_line = $result;
531 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
532 $TFactThird[$cmd->socid] = $objecttmp;
534 $TFact[$objecttmp->id] = $objecttmp;
539 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
542 if (!$error && $validate_invoices) {
543 $massaction = $action =
'builddoc';
545 foreach ($TAllFact as &$objecttmp) {
546 $result = $objecttmp->validate($user);
553 $id = $objecttmp->id;
557 $upload_dir = $conf->facture->dir_output;
558 $permissiontoadd = $user->hasRight(
'facture',
'creer');
561 $savobject = $object;
562 $object = $objecttmp;
563 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
564 $object = $savobject;
567 $massaction = $action =
'confirm_createbills';
573 if ($nb_bills_created == 1) {
574 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
575 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
578 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
584 $param .=
'&mode='.urlencode($mode);
586 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
587 $param .=
'&contextpage='.urlencode($contextpage);
589 if ($limit > 0 && $limit != $conf->liste_limit) {
590 $param .=
'&limit='.urlencode($limit);
593 $param .=
'&sall='.urlencode($sall);
596 $param .=
'&socid='.urlencode($socid);
598 if ($search_status !=
'') {
599 $param .=
'&search_status='.urlencode($search_status);
601 if ($search_orderday) {
602 $param .=
'&search_orderday='.urlencode($search_orderday);
604 if ($search_ordermonth) {
605 $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
607 if ($search_orderyear) {
608 $param .=
'&search_orderyear='.urlencode($search_orderyear);
610 if ($search_deliveryday) {
611 $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
613 if ($search_deliverymonth) {
614 $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
616 if ($search_deliveryyear) {
617 $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
620 $param .=
'&search_ref='.urlencode($search_ref);
622 if ($search_company) {
623 $param .=
'&search_company='.urlencode($search_company);
625 if ($search_ref_customer) {
626 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
628 if ($search_user > 0) {
629 $param .=
'&search_user='.urlencode($search_user);
631 if ($search_sale > 0) {
632 $param .=
'&search_sale='.urlencode($search_sale);
634 if ($search_total_ht !=
'') {
635 $param .=
'&search_total_ht='.urlencode($search_total_ht);
637 if ($search_total_vat !=
'') {
638 $param .=
'&search_total_vat='.urlencode($search_total_vat);
640 if ($search_total_ttc !=
'') {
641 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
643 if ($search_project_ref >= 0) {
644 $param .=
"&search_project_ref=".urlencode($search_project_ref);
647 $param .=
'&show_files='.urlencode($show_files);
649 if ($optioncss !=
'') {
650 $param .=
'&optioncss='.urlencode($optioncss);
653 $param .=
'&billed='.urlencode($billed);
656 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
662 $_GET[
"origin"] = $_POST[
"origin"];
663 $_GET[
"originid"] = $_POST[
"originid"];
664 if (!empty($errors)) {
673 if ($action ==
'validate' && $permissiontoadd) {
674 if (
GETPOST(
'confirm') ==
'yes') {
675 $objecttmp =
new $objectclass($db);
678 foreach ($toselect as $checked) {
679 if ($objecttmp->fetch($checked)) {
680 if ($objecttmp->statut == 0) {
681 if (!empty($objecttmp->fk_warehouse)) {
682 $idwarehouse = $objecttmp->fk_warehouse;
686 if ($objecttmp->valid($user, $idwarehouse)) {
687 setEventMessages($langs->trans(
'hasBeenValidated', $objecttmp->ref),
null,
'mesgs');
693 $langs->load(
"errors");
694 setEventMessages($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
null,
'errors');
709 if ($action ==
'shipped' && $permissiontoadd) {
710 if (
GETPOST(
'confirm') ==
'yes') {
711 $objecttmp =
new $objectclass($db);
714 foreach ($toselect as $checked) {
715 if ($objecttmp->fetch($checked)) {
716 if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
717 if ($objecttmp->cloture($user)) {
718 setEventMessages($langs->trans(
'PassedInClosedStatus', $objecttmp->ref),
null,
'mesgs');
724 $langs->load(
"errors");
725 setEventMessages($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
null,
'errors');
742 if (!$error && $massaction ===
'setbilled' && $permissiontoclose) {
745 $objecttmp =
new $objectclass($db);
747 foreach ($toselect as $toselectid) {
748 $result = $objecttmp->fetch($toselectid);
750 $result = $objecttmp->classifyBilled($user, 0);
792 $companystatic =
new Societe($db);
793 $company_url_list = array();
795 $projectstatic =
new Project($db);
797 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
798 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
800 $title = $langs->trans(
"Orders");
801 $help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
804 if ($sall || $search_user > 0) {
805 $sql =
'SELECT DISTINCT';
807 $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,';
808 $sql .=
" s.parent as fk_parent,";
809 $sql .=
" s2.nom as name2,";
810 $sql .=
" typent.code as typent_code,";
811 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
812 $sql .=
" country.code as country_code,";
813 $sql .=
' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
814 $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,';
815 $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,';
816 $sql .=
' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
817 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
818 $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,';
819 $sql .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
820 $sql .=
' c.fk_input_reason, c.import_key';
821 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
822 $sql .=
", cc.fk_categorie, cc.fk_soc";
826 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
827 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
828 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
833 $parameters = array();
834 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
835 $sql .= $hookmanager->resPrint;
839 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
840 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
841 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
842 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
843 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
844 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
845 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
847 $sql .=
', '.MAIN_DB_PREFIX.
'commande as c';
848 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
849 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
852 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commandedet as pd ON c.rowid=pd.fk_commande';
854 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
855 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
858 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
859 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
861 if ($search_user > 0) {
862 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
863 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
867 $parameters = array();
868 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
869 $sql .= $hookmanager->resPrint;
871 $sql .=
' WHERE c.fk_soc = s.rowid';
872 $sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
874 $sql .=
' AND s.rowid = '.((int) $socid);
876 if (empty($user->rights->societe->client->voir) && !$socid) {
877 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
882 if ($search_ref_customer) {
888 if ($search_billed !=
'' && $search_billed >= 0) {
889 $sql .=
' AND c.facture = '.((int) $search_billed);
891 if ($search_status <>
'') {
892 if ($search_status <= 3 && $search_status >= -1) {
893 if ($search_status == 1 && empty($conf->expedition->enabled)) {
894 $sql .=
' AND c.fk_statut IN (1,2)';
896 $sql .=
' AND c.fk_statut = '.((int) $search_status);
899 if ($search_status == -2) {
901 $sql .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
903 if ($search_status == -3) {
906 $sql .=
' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))';
908 if ($search_status == -4) {
909 $sql .=
' AND (c.fk_statut IN (1,2))';
913 if ($search_datecloture_start) {
914 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
916 if ($search_datecloture_end) {
917 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
919 if ($search_dateorder_start) {
920 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
922 if ($search_dateorder_end) {
923 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
925 if ($search_datedelivery_start) {
926 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
928 if ($search_datedelivery_end) {
929 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
940 if ($search_country) {
941 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
943 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
944 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
946 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
949 if ($search_company) {
952 if ($search_company_alias) {
956 if ($search_parent_name) {
959 if ($search_sale > 0) {
960 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
962 if ($search_user > 0) {
963 $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);
965 if ($search_total_ht !=
'') {
968 if ($search_total_vat !=
'') {
971 if ($search_total_ttc !=
'') {
974 if ($search_warehouse !=
'' && $search_warehouse > 0) {
977 if ($search_multicurrency_code !=
'') {
978 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
980 if ($search_multicurrency_tx !=
'') {
983 if ($search_multicurrency_montant_ht !=
'') {
984 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
986 if ($search_multicurrency_montant_vat !=
'') {
987 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
989 if ($search_multicurrency_montant_ttc !=
'') {
990 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
995 if ($search_project_ref !=
'') {
998 if ($search_project !=
'') {
1001 if ($search_categ_cus > 0) {
1002 $sql .=
" AND cc.fk_categorie = ".((int) $search_categ_cus);
1004 if ($search_categ_cus == -2) {
1005 $sql .=
" AND cc.fk_categorie IS NULL";
1007 if ($search_fk_cond_reglement > 0) {
1008 $sql .=
" AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
1010 if ($search_fk_shipping_method > 0) {
1011 $sql .=
" AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
1013 if ($search_fk_mode_reglement > 0) {
1014 $sql .=
" AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
1016 if ($search_fk_input_reason > 0) {
1017 $sql .=
" AND c.fk_input_reason = ".((int) $search_fk_input_reason);
1020 $searchCategoryProductOperator = -1;
1021 $searchCategoryProductList = array($search_product_category);
1022 if (!empty($searchCategoryProductList)) {
1023 $searchCategoryProductSqlList = array();
1024 $listofcategoryid =
'';
1025 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1026 if (intval($searchCategoryProduct) == -2) {
1027 $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)";
1028 } elseif (intval($searchCategoryProduct) > 0) {
1029 if ($searchCategoryProductOperator == 0) {
1030 $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).
")";
1032 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1036 if ($listofcategoryid) {
1037 $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).
"))";
1039 if ($searchCategoryProductOperator == 1) {
1040 if (!empty($searchCategoryProductSqlList)) {
1041 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1044 if (!empty($searchCategoryProductSqlList)) {
1045 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1050 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1052 $parameters = array();
1053 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1054 $sql .= $hookmanager->resPrint;
1057 $parameters = array();
1058 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
1059 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
1063 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1065 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
1066 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1067 $resql = $db->query($sqlforcount);
1069 $objforcount = $db->fetch_object($resql);
1082 $sql .= $db->order($sortfield, $sortorder);
1084 $sql .= $db->plimit($limit + 1, $offset);
1088 $resql = $db->query(
$sql);
1092 $soc->fetch($socid);
1093 $title = $langs->trans(
'CustomersOrders').
' - '.$soc->name;
1094 if (empty($search_company)) {
1095 $search_company = $soc->name;
1098 $title = $langs->trans(
'CustomersOrders');
1100 if (strval($search_status) ==
'0') {
1101 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
1103 if ($search_status == 1) {
1104 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
1106 if ($search_status == 2) {
1107 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
1109 if ($search_status == 3) {
1110 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
1112 if ($search_status == -1) {
1113 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
1115 if ($search_status == -2) {
1116 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
1118 if ($search_status == -3) {
1119 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(empty($conf->expedition->enabled) ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
1121 if ($search_status == -4) {
1122 $title .=
' - '.$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort");
1125 $num = $db->num_rows($resql);
1127 $arrayofselected = is_array($toselect) ? $toselect : array();
1129 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
1130 $obj = $db->fetch_object($resql);
1132 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.$id);
1139 if (!empty($mode)) {
1140 $param .=
'&mode='.urlencode($mode);
1142 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1143 $param .=
'&contextpage='.urlencode($contextpage);
1145 if ($limit > 0 && $limit != $conf->liste_limit) {
1146 $param .=
'&limit='.urlencode($limit);
1149 $param .=
'&sall='.urlencode($sall);
1152 $param .=
'&socid='.urlencode($socid);
1154 if ($search_status !=
'') {
1155 $param .=
'&search_status='.urlencode($search_status);
1157 if ($search_datecloture_start) {
1158 $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');
1160 if ($search_datecloture_end) {
1161 $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');
1163 if ($search_dateorder_start) {
1164 $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');
1166 if ($search_dateorder_end) {
1167 $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');
1169 if ($search_datedelivery_start) {
1170 $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');
1172 if ($search_datedelivery_end) {
1173 $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');
1176 $param .=
'&search_ref='.urlencode($search_ref);
1178 if ($search_company) {
1179 $param .=
'&search_company='.urlencode($search_company);
1181 if ($search_company_alias) {
1182 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1184 if ($search_parent_name !=
'') {
1185 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1187 if ($search_ref_customer) {
1188 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
1190 if ($search_user > 0) {
1191 $param .=
'&search_user='.urlencode($search_user);
1193 if ($search_sale > 0) {
1194 $param .=
'&search_sale='.urlencode($search_sale);
1196 if ($search_total_ht !=
'') {
1197 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1199 if ($search_total_vat !=
'') {
1200 $param .=
'&search_total_vat='.urlencode($search_total_vat);
1202 if ($search_total_ttc !=
'') {
1203 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
1205 if ($search_warehouse !=
'') {
1206 $param .=
'&search_warehouse='.urlencode($search_warehouse);
1208 if ($search_login) {
1209 $param .=
'&search_login='.urlencode($search_login);
1211 if ($search_multicurrency_code !=
'') {
1212 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1214 if ($search_multicurrency_tx !=
'') {
1215 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1217 if ($search_multicurrency_montant_ht !=
'') {
1218 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1220 if ($search_multicurrency_montant_vat !=
'') {
1221 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1223 if ($search_multicurrency_montant_ttc !=
'') {
1224 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1226 if ($search_project_ref >= 0) {
1227 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1229 if ($search_town !=
'') {
1230 $param .=
'&search_town='.urlencode($search_town);
1232 if ($search_zip !=
'') {
1233 $param .=
'&search_zip='.urlencode($search_zip);
1235 if ($search_state !=
'') {
1236 $param .=
'&search_state='.urlencode($search_state);
1238 if ($search_country !=
'') {
1239 $param .=
'&search_country='.urlencode($search_country);
1241 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
1242 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1244 if ($search_product_category !=
'') {
1245 $param .=
'&search_product_category='.urlencode($search_product_category);
1247 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1248 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1251 $param .=
'&show_files='.urlencode($show_files);
1253 if ($optioncss !=
'') {
1254 $param .=
'&optioncss='.urlencode($optioncss);
1256 if ($search_billed !=
'') {
1257 $param .=
'&search_billed='.urlencode($search_billed);
1259 if ($search_fk_cond_reglement > 0) {
1260 $param .=
'&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
1262 if ($search_fk_shipping_method > 0) {
1263 $param .=
'&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
1265 if ($search_fk_mode_reglement > 0) {
1266 $param .=
'&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
1268 if ($search_fk_input_reason > 0) {
1269 $param .=
'&search_fk_input_reason='.urlencode($search_fk_input_reason);
1273 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1276 $parameters = array();
1277 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1278 $param .= $hookmanager->resPrint;
1281 $arrayofmassactions = array(
1282 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1283 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1285 if ($permissiontovalidate) {
1286 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1288 if ($permissiontoclose) {
1289 $arrayofmassactions[
'preshipped'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').$langs->trans(
"ClassifyShipped");
1291 if ($permissiontoclose) {
1292 $arrayofmassactions[
'setbilled'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"ClassifyBilled");
1294 if ($permissiontocancel) {
1295 $arrayofmassactions[
'cancelorders'] =
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"Cancel");
1297 if ($permissiontodelete) {
1298 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1300 if (
isModEnabled(
'facture') && $user->hasRight(
"facture",
"creer")) {
1301 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisCustomer");
1303 if ($permissiontosendbymail) {
1304 $arrayofmassactions[
'presend'] =
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail");
1306 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1307 $arrayofmassactions = array();
1309 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1311 $url = DOL_URL_ROOT.
'/commande/card.php?action=create';
1312 if (!empty($socid)) {
1313 $url .=
'&socid='.$socid;
1315 $newcardbutton =
'';
1316 $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'));
1317 $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'));
1318 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewOrder'),
'',
'fa fa-plus-circle', $url,
'', $contextpage ==
'orderlist' && $permissiontoadd);
1321 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1322 if ($optioncss !=
'') {
1323 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1325 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1326 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1327 print
'<input type="hidden" name="action" value="list">';
1328 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1329 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1330 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1331 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1332 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1333 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1336 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1338 $topicmail =
"SendOrderRef";
1339 $modelmail =
"order_send";
1341 $trackid =
'ord'.$object->id;
1342 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1344 if ($massaction ==
'prevalidate') {
1345 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1347 if ($massaction ==
'preshipped') {
1348 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"CloseOrder"), $langs->trans(
"ConfirmCloseOrder"),
"shipped",
null,
'', 0, 200, 500, 1);
1351 if ($massaction ==
'createbills') {
1352 print
'<input type="hidden" name="massaction" value="confirm_createbills">';
1354 print
'<table class="noborder centpercent">';
1357 print $langs->trans(
'DateInvoice');
1360 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1365 print $langs->trans(
'CreateOneBillByThird');
1368 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1373 print $langs->trans(
'ValidateInvoices');
1376 if (
isModEnabled(
'stock') && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
1377 print
$form->selectyesno(
'validate_invoices', 0, 1, 1);
1378 $langs->load(
"errors");
1379 print
' ('.$langs->trans(
"WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").
')';
1381 print
$form->selectyesno(
'validate_invoices', 0, 1);
1383 if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) {
1384 print
' <span class="opacitymedium">'.$langs->trans(
"IfValidateInvoiceIsNoOrderStayUnbilled").
'</span>';
1386 print
' <span class="opacitymedium">'.$langs->trans(
"OptionToSetOrderBilledNotEnabled").
'</span>';
1392 print
'<div class="center">';
1393 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1394 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1400 foreach ($fieldstosearchall as $key => $val) {
1401 $fieldstosearchall[$key] = $langs->trans($val);
1403 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1406 $moreforfilter =
'';
1409 if ($user->hasRight(
"user",
"user",
"lire")) {
1410 $langs->load(
"commercial");
1411 $moreforfilter .=
'<div class="divsearchfield">';
1412 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1413 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1414 $moreforfilter .=
'</div>';
1417 if ($user->hasRight(
"user",
"user",
"lire")) {
1418 $moreforfilter .=
'<div class="divsearchfield">';
1419 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1420 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1421 $moreforfilter .=
'</div>';
1425 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1426 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1427 $moreforfilter .=
'<div class="divsearchfield">';
1428 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1429 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1430 $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);
1431 $moreforfilter .=
'</div>';
1434 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"lire")) {
1435 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1436 $moreforfilter .=
'<div class="divsearchfield">';
1437 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1438 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'maxwidth300 widthcentpercentminusx');
1439 $moreforfilter .=
'</div>';
1442 if (
isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1443 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1445 $moreforfilter .=
'<div class="divsearchfield">';
1446 $tmptitle = $langs->trans(
'Warehouse');
1447 $moreforfilter .=
img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'maxwidth250 widthcentpercentminusx');
1448 $moreforfilter .=
'</div>';
1450 $parameters = array();
1451 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1452 if (empty($reshook)) {
1453 $moreforfilter .= $hookmanager->resPrint;
1455 $moreforfilter = $hookmanager->resPrint;
1458 if (!empty($moreforfilter)) {
1459 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1460 print $moreforfilter;
1464 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1465 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
''));
1466 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1468 if (
GETPOST(
'autoselectall',
'int')) {
1469 $selectedfields .=
'<script>';
1470 $selectedfields .=
' $(document).ready(function() {';
1471 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1472 $selectedfields .=
' $("#checkforselects").click();';
1473 $selectedfields .=
' $("#massaction").val("createbills").change();';
1474 $selectedfields .=
' });';
1475 $selectedfields .=
'</script>';
1478 print
'<div class="div-table-responsive">';
1479 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1481 print
'<tr class="liste_titre_filter">';
1483 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1484 print
'<td class="liste_titre" align="middle">';
1485 $searchpicto =
$form->showFilterButtons(
'left');
1491 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1492 print
'<td class="liste_titre">';
1493 print
'<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1497 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1498 print
'<td class="liste_titre" align="left">';
1499 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1503 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1504 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1507 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1508 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1511 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1512 print
'<td class="liste_titre" align="left">';
1513 print
'<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
1517 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1518 print
'<td class="liste_titre" align="left">';
1519 print
'<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1523 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1524 print
'<td class="liste_titre">';
1525 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1529 if (!empty($arrayfields[
's.town'][
'checked'])) {
1530 print
'<td class="liste_titre"><input class="flat width50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1533 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1534 print
'<td class="liste_titre"><input class="flat width50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1537 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1538 print
'<td class="liste_titre">';
1539 print
'<input class="flat width50" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1543 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1544 print
'<td class="liste_titre" align="center">';
1545 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1549 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1550 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1551 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);
1555 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1556 print
'<td class="liste_titre center">';
1557 print
'<div class="nowrap">';
1558 print
$form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1560 print
'<div class="nowrap">';
1561 print
$form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1565 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1566 print
'<td class="liste_titre center">';
1567 print
'<div class="nowrap">';
1568 print
$form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1570 print
'<div class="nowrap">';
1571 print
$form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1576 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1577 print
'<td class="liste_titre">';
1578 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1582 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1583 print
'<td class="liste_titre">';
1584 print
$form->getSelectConditionsPaiements($search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1588 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1589 print
'<td class="liste_titre">';
1590 print
$form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1,
'', 1);
1594 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1595 print
'<td class="liste_titre">';
1596 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1600 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1601 print
'<td class="liste_titre right">';
1602 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1606 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1607 print
'<td class="liste_titre right">';
1608 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1612 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1613 print
'<td class="liste_titre right">';
1614 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1618 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1619 print
'<td class="liste_titre">';
1620 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1624 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1625 print
'<td class="liste_titre">';
1626 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1630 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1631 print
'<td class="liste_titre right">';
1632 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1636 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1637 print
'<td class="liste_titre right">';
1638 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1642 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1643 print
'<td class="liste_titre right">';
1644 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1648 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1649 print
'<td class="liste_titre" align="center">';
1650 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1654 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1655 print
'<td class="liste_titre"></td>';
1657 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1658 print
'<td class="liste_titre right">';
1661 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1662 print
'<td class="liste_titre right">';
1665 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1666 print
'<td class="liste_titre right">';
1669 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1670 print
'<td class="liste_titre right">';
1675 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1678 $parameters = array(
'arrayfields'=>$arrayfields);
1679 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1680 print $hookmanager->resPrint;
1683 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1684 print
'<td class="liste_titre">';
1688 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1689 print
'<td class="liste_titre">';
1693 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1694 print
'<td class="liste_titre center">';
1695 print
'<div class="nowrap">';
1696 print
$form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1698 print
'<div class="nowrap">';
1699 print
$form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1704 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1705 print
'<td class="liste_titre">';
1709 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1710 print
'<td class="liste_titre">';
1714 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1715 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1717 if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) {
1718 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
1719 print $langs->trans(
'ShowShippableStatus');
1721 $show_shippable_command = 1;
1726 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1727 print
'<td class="liste_titre maxwidthonsmartphone center">';
1728 print
$form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1732 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1733 print
'<td class="liste_titre maxwidthonsmartphone center">';
1737 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1738 print
'<td class="liste_titre right parentonrightofpage">';
1739 $liststatus = array(
1744 -3=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
1745 -2=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
1748 print
$form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1752 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1753 print
'<td class="liste_titre" align="middle">';
1754 $searchpicto =
$form->showFilterButtons();
1761 print
'<tr class="liste_titre">';
1763 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1764 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1766 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1767 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
1769 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1770 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
1772 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1773 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1775 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1776 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
1778 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1779 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1781 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1782 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1784 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1785 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
1787 if (!empty($arrayfields[
's.town'][
'checked'])) {
1788 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1790 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1791 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1793 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1794 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1796 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1797 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1799 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1800 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1802 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1803 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
1805 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1806 print_liste_field_titre($arrayfields[
'c.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1808 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1809 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
1811 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1812 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
1814 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1815 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
1817 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1818 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
1820 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1821 print_liste_field_titre($arrayfields[
'c.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1823 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1824 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1826 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1827 print_liste_field_titre($arrayfields[
'c.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1829 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1830 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1832 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1833 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1835 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1836 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1838 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1839 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1841 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1842 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1844 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1845 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1847 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1848 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1850 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1851 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1853 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1854 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1856 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1857 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1859 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1860 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1863 $totalarray = array(
1874 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1877 $parameters = array(
1878 'arrayfields' => $arrayfields,
1880 'sortfield' => $sortfield,
1881 'sortorder' => $sortorder,
1882 'totalarray' => &$totalarray,
1884 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1885 print $hookmanager->resPrint;
1886 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1887 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1889 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1890 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1892 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1893 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1895 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1896 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'right ');
1898 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1899 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'right ');
1901 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1902 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1904 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1905 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
1907 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1908 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1910 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1911 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
1913 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1914 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1920 $productstat_cache = array();
1921 $productstat_cachevirtual = array();
1922 $getNomUrl_cache = array();
1924 $generic_commande =
new Commande($db);
1925 $generic_product =
new Product($db);
1926 $userstatic =
new User($db);
1929 $with_margin_info =
false;
1931 !empty($arrayfields[
'total_pa'][
'checked'])
1932 || !empty($arrayfields[
'total_margin'][
'checked'])
1933 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1934 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1937 $with_margin_info =
true;
1942 $savnbfield = $totalarray[
'nbfield'];
1943 $totalarray = array();
1944 $totalarray[
'nbfield'] = 0;
1945 $imaxinloop = ($limit ? min($num, $limit) : $num);
1946 while ($i < $imaxinloop) {
1947 $obj = $db->fetch_object($resql);
1955 $companystatic->id = $obj->socid;
1956 $companystatic->name = $obj->name;
1957 $companystatic->name_alias = $obj->alias;
1958 $companystatic->client = $obj->client;
1959 $companystatic->fournisseur = $obj->fournisseur;
1960 $companystatic->code_client = $obj->code_client;
1961 $companystatic->email = $obj->email;
1962 $companystatic->phone = $obj->phone;
1963 $companystatic->address = $obj->address;
1964 $companystatic->zip = $obj->zip;
1965 $companystatic->town = $obj->town;
1966 $companystatic->country_code = $obj->country_code;
1967 if (!isset($getNomUrl_cache[$obj->socid])) {
1968 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1971 $generic_commande->id = $obj->rowid;
1972 $generic_commande->ref = $obj->ref;
1973 $generic_commande->statut = $obj->fk_statut;
1974 $generic_commande->billed = $obj->billed;
1975 $generic_commande->date = $db->jdate($obj->date_commande);
1976 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1977 $generic_commande->ref_client = $obj->ref_client;
1978 $generic_commande->total_ht = $obj->total_ht;
1979 $generic_commande->total_tva = $obj->total_tva;
1980 $generic_commande->total_ttc = $obj->total_ttc;
1981 $generic_commande->note_public = $obj->note_public;
1982 $generic_commande->note_private = $obj->note_private;
1984 $generic_commande->thirdparty = $companystatic;
1987 $projectstatic->id = $obj->project_id;
1988 $projectstatic->ref = $obj->project_ref;
1989 $projectstatic->title = $obj->project_label;
1991 $marginInfo = array();
1992 if ($with_margin_info ===
true) {
1993 $generic_commande->fetch_lines();
1994 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1995 $total_ht += $obj->total_ht;
1996 $total_margin += $marginInfo[
'total_margin'];
1999 if ($mode ==
'kanban') {
2001 print
'<tr><td colspan="12">';
2002 print
'<div class="box-flex-container kanban">';
2005 print $generic_commande->getKanbanView(
'');
2007 if ($i == ($imaxinloop - 1)) {
2012 print
'<tr class="oddeven">';
2015 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2016 print
'<td class="nowrap center">';
2017 if ($massactionbutton || $massaction) {
2019 if (in_array($obj->rowid, $arrayofselected)) {
2022 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2025 $totalarray[
'nbfield']++;
2031 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
2032 print
'<td class="nowraponall">';
2033 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
2036 $filedir = $conf->commande->multidir_output[$conf->entity].
'/'.
dol_sanitizeFileName($obj->ref);
2037 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
2038 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
2042 $totalarray[
'nbfield']++;
2047 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
2048 print
'<td class="nowrap tdoverflowmax200">'.$obj->ref_client.
'</td>';
2050 $totalarray[
'nbfield']++;
2055 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2056 print
'<td class="nowrap">';
2057 if ($obj->project_id > 0) {
2058 print $projectstatic->getNomUrl(1);
2062 $totalarray[
'nbfield']++;
2067 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2068 print
'<td class="nowrap">';
2069 if ($obj->project_id > 0) {
2070 print $projectstatic->title;
2074 $totalarray[
'nbfield']++;
2079 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2080 print
'<td class="tdoverflowmax150">';
2082 print $companystatic->getNomUrl(1,
'customer', 100, 0, 1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2084 print $getNomUrl_cache[$obj->socid];
2088 if (
isModEnabled(
'facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
2089 if ($user->rights->facture->creer) {
2090 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
2091 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
2092 print
img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
2098 $totalarray[
'nbfield']++;
2103 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2104 print
'<td class="nocellnopadd">';
2108 $totalarray[
'nbfield']++;
2113 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2114 print
'<td class="tdoverflowmax200">';
2115 if ($obj->fk_parent > 0) {
2116 if (!isset($company_url_list[$obj->fk_parent])) {
2117 $companyparent =
new Societe($db);
2118 $res = $companyparent->fetch($obj->fk_parent);
2120 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2123 if (isset($company_url_list[$obj->fk_parent])) {
2124 print $company_url_list[$obj->fk_parent];
2129 $totalarray[
'nbfield']++;
2134 if (!empty($arrayfields[
's.town'][
'checked'])) {
2135 print
'<td class="nocellnopadd">';
2139 $totalarray[
'nbfield']++;
2144 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2145 print
'<td class="nocellnopadd">';
2149 $totalarray[
'nbfield']++;
2154 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2155 print
"<td>".$obj->state_name.
"</td>\n";
2157 $totalarray[
'nbfield']++;
2162 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2163 print
'<td class="center">';
2164 $tmparray =
getCountry($obj->fk_pays,
'all');
2165 print $tmparray[
'label'];
2168 $totalarray[
'nbfield']++;
2173 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2174 print
'<td class="center">';
2175 if (empty($typenArray)) {
2176 $typenArray = $formcompany->typent_array(1);
2178 print $typenArray[$obj->typent_code];
2181 $totalarray[
'nbfield']++;
2186 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
2187 print
'<td class="center">';
2190 if ($generic_commande->hasDelay()) {
2191 print
img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
2195 $totalarray[
'nbfield']++;
2200 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
2201 print
'<td class="center">';
2202 print
dol_print_date($db->jdate($obj->date_delivery),
'dayhour');
2205 $totalarray[
'nbfield']++;
2210 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
2212 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
2215 $totalarray[
'nbfield']++;
2220 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
2222 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
2225 $totalarray[
'nbfield']++;
2230 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
2232 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
2235 $totalarray[
'nbfield']++;
2240 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
2242 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none',
'');
2245 $totalarray[
'nbfield']++;
2250 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
2251 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2253 $totalarray[
'nbfield']++;
2256 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ht';
2258 if (isset($totalarray[
'val'][
'c.total_ht'])) {
2259 $totalarray[
'val'][
'c.total_ht'] += $obj->total_ht;
2261 $totalarray[
'val'][
'c.total_ht'] = $obj->total_ht;
2266 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
2267 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
2269 $totalarray[
'nbfield']++;
2272 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_tva';
2274 if (isset($totalarray[
'val'][
'c.total_tva'])) {
2275 $totalarray[
'val'][
'c.total_tva'] += $obj->total_tva;
2277 $totalarray[
'val'][
'c.total_tva'] = $obj->total_tva;
2282 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
2283 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2285 $totalarray[
'nbfield']++;
2288 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ttc';
2290 if (isset($totalarray[
'val'][
'c.total_ttc'])) {
2291 $totalarray[
'val'][
'c.total_ttc'] += $obj->total_ttc;
2293 $totalarray[
'val'][
'c.total_ttc'] = $obj->total_ttc;
2298 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
2299 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2301 $totalarray[
'nbfield']++;
2306 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
2307 print
'<td class="nowrap">';
2308 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2311 $totalarray[
'nbfield']++;
2316 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
2317 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2319 $totalarray[
'nbfield']++;
2323 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
2324 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
2326 $totalarray[
'nbfield']++;
2330 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
2331 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2333 $totalarray[
'nbfield']++;
2337 $userstatic->id = $obj->fk_user_author;
2338 $userstatic->login = $obj->login;
2339 $userstatic->lastname = $obj->lastname;
2340 $userstatic->firstname = $obj->firstname;
2341 $userstatic->email = $obj->user_email;
2342 $userstatic->statut = $obj->user_statut;
2343 $userstatic->entity = $obj->entity;
2344 $userstatic->photo = $obj->photo;
2345 $userstatic->office_phone = $obj->office_phone;
2346 $userstatic->office_fax = $obj->office_fax;
2347 $userstatic->user_mobile = $obj->user_mobile;
2348 $userstatic->job = $obj->job;
2349 $userstatic->gender = $obj->gender;
2352 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2353 print
'<td class="tdoverflowmax200">';
2354 if ($userstatic->id) {
2355 print $userstatic->getNomUrl(-1);
2361 $totalarray[
'nbfield']++;
2366 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2368 if ($obj->socid > 0) {
2369 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2370 if ($listsalesrepresentatives < 0) {
2373 $nbofsalesrepresentative = count($listsalesrepresentatives);
2374 if ($nbofsalesrepresentative > 6) {
2376 print $nbofsalesrepresentative;
2377 } elseif ($nbofsalesrepresentative > 0) {
2379 foreach ($listsalesrepresentatives as $val) {
2380 $userstatic->id = $val[
'id'];
2381 $userstatic->lastname = $val[
'lastname'];
2382 $userstatic->firstname = $val[
'firstname'];
2383 $userstatic->email = $val[
'email'];
2384 $userstatic->statut = $val[
'statut'];
2385 $userstatic->entity = $val[
'entity'];
2386 $userstatic->photo = $val[
'photo'];
2387 $userstatic->login = $val[
'login'];
2388 $userstatic->office_phone = $val[
'office_phone'];
2389 $userstatic->office_fax = $val[
'office_fax'];
2390 $userstatic->user_mobile = $val[
'user_mobile'];
2391 $userstatic->job = $val[
'job'];
2392 $userstatic->gender = $val[
'gender'];
2394 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2396 if ($j < $nbofsalesrepresentative) {
2408 $totalarray[
'nbfield']++;
2413 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2414 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2416 $totalarray[
'nbfield']++;
2421 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2422 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2424 $totalarray[
'nbfield']++;
2427 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2429 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2433 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2434 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2436 $totalarray[
'nbfield']++;
2441 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2442 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2444 $totalarray[
'nbfield']++;
2447 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2449 if ($i >= $imaxinloop - 1) {
2450 if (!empty($total_ht)) {
2451 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2453 $totalarray[
'val'][
'total_mark_rate'] =
'';
2459 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2461 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2462 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2463 print $hookmanager->resPrint;
2466 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2467 print
'<td align="center" class="nowrap">';
2468 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2471 $totalarray[
'nbfield']++;
2476 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2477 print
'<td align="center" class="nowrap">';
2478 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2481 $totalarray[
'nbfield']++;
2486 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2487 print
'<td align="center" class="nowrap">';
2488 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuser');
2491 $totalarray[
'nbfield']++;
2496 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2497 print
'<td class="center">';
2501 $totalarray[
'nbfield']++;
2506 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2507 print
'<td class="center">';
2511 $totalarray[
'nbfield']++;
2516 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2517 print
'<td class="center">';
2518 if (!empty($show_shippable_command) &&
isModEnabled(
'stock')) {
2519 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2520 $generic_commande->getLinesArray();
2521 $generic_commande->loadExpeditions();
2523 $numlines = count($generic_commande->lines);
2524 for ($lig = 0; $lig < $numlines; $lig++) {
2525 if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
2526 $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
2528 $reliquat = $generic_commande->lines[$lig]->qty;
2530 if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) {
2532 $generic_product->id = $generic_commande->lines[$lig]->fk_product;
2535 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
2536 $generic_product->load_stock(
'nobatch,warehouseopen');
2537 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2538 $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2540 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'];
2541 $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2544 if ($reliquat > $generic_product->stock_reel) {
2547 if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
2548 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->product_ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2549 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2550 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2551 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2552 $text_info .=
'<br>';
2559 $stock_order_supplier = 0;
2560 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
2562 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'])) {
2563 $generic_product->load_stats_commande(0,
'1,2');
2564 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
2566 $generic_product->stats_commande[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'];
2568 $stock_order = $generic_product->stats_commande[
'qty'];
2570 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
2571 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'])) {
2572 $generic_product->load_stats_commande_fournisseur(0,
'3');
2573 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
2575 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'];
2577 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
2580 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2581 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
2582 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
2584 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2586 if ($reliquat > $generic_product->stock_reel) {
2587 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2589 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2591 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
2592 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
2594 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2595 $text_info .=
'<br>';
2599 if ($notshippable == 0) {
2600 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'green paddingleft');
2601 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
2603 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'error paddingleft');
2604 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
2609 print
$form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
2612 print
$form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1,
img_picto(
'',
'error'),
'', 2);
2617 $totalarray[
'nbfield']++;
2622 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2623 print
'<td class="center">'.yn($obj->billed).
'</td>';
2625 $totalarray[
'nbfield']++;
2630 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2631 print
'<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).
'</td>';
2633 $totalarray[
'nbfield']++;
2638 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2639 print
'<td class="nowrap right">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
2641 $totalarray[
'nbfield']++;
2646 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
2647 print
'<td class="nowrap center">';
2648 if ($massactionbutton || $massaction) {
2650 if (in_array($obj->rowid, $arrayofselected)) {
2653 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2657 $totalarray[
'nbfield']++;
2663 $total += $obj->total_ht;
2664 $subtotal += $obj->total_ht;
2670 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2675 foreach ($arrayfields as $key => $val) {
2676 if (!empty($val[
'checked'])) {
2680 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2685 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
2686 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2687 print $hookmanager->resPrint;
2689 print
'</table>'.
"\n";
2692 print
'</form>'.
"\n";
2694 $hidegeneratedfilelistifempty = 1;
2695 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2696 $hidegeneratedfilelistifempty = 0;
2700 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2701 $urlsource .= str_replace(
'&',
'&', $param);
2703 $filedir = $diroutputmassaction;
2704 $genallowed = $permissiontoread;
2705 $delallowed = $permissiontoadd;
2707 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);