36 require
'../main.inc.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43 if (!empty($conf->margin->enabled)) {
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
52 $langs->loadLangs(array(
"orders",
'sendings',
'deliveries',
'companies',
'compta',
'bills',
'stocks',
'products'));
55 $action =
GETPOST(
'action',
'aZ09');
56 $massaction =
GETPOST(
'massaction',
'alpha');
57 $show_files =
GETPOST(
'show_files',
'int');
58 $confirm =
GETPOST(
'confirm',
'alpha');
59 $toselect =
GETPOST(
'toselect',
'array');
60 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'orderlist';
63 $search_datecloture_start =
GETPOST(
'search_datecloture_start',
'int');
64 if (empty($search_datecloture_start)) {
65 $search_datecloture_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_datecloture_startmonth',
'int'),
GETPOST(
'search_datecloture_startday',
'int'),
GETPOST(
'search_datecloture_startyear',
'int'));
67 $search_datecloture_end =
GETPOST(
'search_datecloture_end',
'int');
68 if (empty($search_datecloture_end)) {
69 $search_datecloture_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_datecloture_endmonth',
'int'),
GETPOST(
'search_datecloture_endday',
'int'),
GETPOST(
'search_datecloture_endyear',
'int'));
71 $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'));
72 $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'));
73 $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'));
74 $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'));
75 $search_product_category =
GETPOST(
'search_product_category',
'int');
76 $search_ref =
GETPOST(
'search_ref',
'alpha') !=
'' ?
GETPOST(
'search_ref',
'alpha') :
GETPOST(
'sref',
'alpha');
77 $search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
78 $search_company =
GETPOST(
'search_company',
'alpha');
79 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
80 $search_town =
GETPOST(
'search_town',
'alpha');
81 $search_zip =
GETPOST(
'search_zip',
'alpha');
82 $search_state =
GETPOST(
"search_state",
'alpha');
83 $search_country =
GETPOST(
"search_country",
'int');
84 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
85 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
86 $socid =
GETPOST(
'socid',
'int');
87 $search_user =
GETPOST(
'search_user',
'int');
88 $search_sale =
GETPOST(
'search_sale',
'int');
89 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
90 $search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
91 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
92 $search_warehouse =
GETPOST(
'search_warehouse',
'int');
93 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
94 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
95 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
96 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
97 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
98 $search_login =
GETPOST(
'search_login',
'alpha');
99 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
100 $optioncss =
GETPOST(
'optioncss',
'alpha');
102 $search_status =
GETPOST(
'search_status',
'int');
103 $search_btn =
GETPOST(
'button_search',
'alpha');
104 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
105 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
106 $search_project =
GETPOST(
'search_project',
'alpha');
107 $search_shippable =
GETPOST(
'search_shippable',
'aZ09');
109 $search_fk_cond_reglement =
GETPOST(
"search_fk_cond_reglement",
'int');
110 $search_fk_shipping_method =
GETPOST(
"search_fk_shipping_method",
'int');
111 $search_fk_mode_reglement =
GETPOST(
"search_fk_mode_reglement",
'int');
112 $search_fk_input_reason =
GETPOST(
"search_fk_input_reason",
'int');
117 $socid = $user->socid;
121 $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].
'/temp/massgeneration/'.$user->id;
124 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
125 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
126 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
128 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
131 $offset = $limit * $page;
132 $pageprev = $page - 1;
133 $pagenext = $page + 1;
135 $sortfield =
'c.ref';
141 $show_shippable_command =
GETPOST(
'show_shippable_command',
'aZ09');
145 $hookmanager->initHooks(array(
'orderlist'));
149 $extrafields->fetch_name_optionals_label($object->table_element);
150 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
153 $fieldstosearchall = array(
155 'c.ref_client'=>
'RefCustomerOrder',
156 'pd.description'=>
'Description',
157 's.nom'=>
"ThirdParty",
158 's.name_alias'=>
"AliasNameShort",
161 'c.note_public'=>
'NotePublic',
163 if (empty($user->socid)) {
164 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
167 $checkedtypetiers = 0;
168 $arrayfields = array(
169 'c.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
170 'c.ref_client'=>array(
'label'=>
"RefCustomerOrder",
'checked'=>-1,
'position'=>10),
171 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>-1,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>20),
172 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>25),
173 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>30),
174 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>-1,
'position'=>31),
175 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>35),
176 's.zip'=>array(
'label'=>
"Zip",
'checked'=>-1,
'position'=>40),
177 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>45),
178 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>50),
179 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>55),
180 'c.date_commande'=>array(
'label'=>
"OrderDateShort",
'checked'=>1,
'position'=>60),
181 'c.date_delivery'=>array(
'label'=>
"DateDeliveryPlanned",
'checked'=>1,
'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE),
'position'=>65),
182 'c.fk_shipping_method'=>array(
'label'=>
"SendingMethod",
'checked'=>-1,
'position'=>66 ,
'enabled'=>!empty($conf->expedition->enabled)),
183 'c.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>-1,
'position'=>67),
184 'c.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>-1,
'position'=>68),
185 'c.fk_input_reason'=>array(
'label'=>
"Channel",
'checked'=>-1,
'position'=>69),
186 'c.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>75),
187 'c.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>80),
188 'c.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>85),
189 'c.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>90),
190 'c.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>95),
191 'c.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>100),
192 'c.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>105),
193 'c.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>110),
194 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>115),
195 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>116),
196 'total_pa' => array(
'label' => (
getDolGlobalString(
'MARGIN_TYPE') ==
'1' ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
197 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
198 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)),
199 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)),
200 'c.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>120),
201 'c.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>125),
202 'c.date_cloture'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>130),
203 'c.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)),
'position'=>135),
204 'c.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)),
'position'=>140),
205 'shippable'=>array(
'label'=>
"Shippable",
'checked'=>1,
'enabled'=>(!empty($conf->expedition->enabled)),
'position'=>990),
206 'c.facture'=>array(
'label'=>
"Billed",
'checked'=>1,
'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)),
'position'=>995),
207 'c.import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>999),
208 'c.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
211 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
223 if (
GETPOST(
'cancel',
'alpha')) {
224 $action =
'list'; $massaction =
'';
226 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
230 $parameters = array(
'socid'=>$socid,
'arrayfields'=>&$arrayfields);
231 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
236 if (empty($reshook)) {
238 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
241 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
245 $search_product_category =
'';
247 $search_ref_customer =
'';
248 $search_company =
'';
249 $search_company_alias =
'';
254 $search_country =
'';
255 $search_type_thirdparty =
'';
256 $search_total_ht =
'';
257 $search_total_vat =
'';
258 $search_total_ttc =
'';
259 $search_warehouse =
'';
260 $search_multicurrency_code =
'';
261 $search_multicurrency_tx =
'';
262 $search_multicurrency_montant_ht =
'';
263 $search_multicurrency_montant_vat =
'';
264 $search_multicurrency_montant_ttc =
'';
266 $search_dateorder_start =
'';
267 $search_dateorder_end =
'';
268 $search_datedelivery_start =
'';
269 $search_datedelivery_end =
'';
270 $search_project_ref =
'';
271 $search_project =
'';
275 $search_array_options = array();
276 $search_categ_cus = 0;
277 $search_datecloture_start =
'';
278 $search_datecloture_end =
'';
279 $search_fk_cond_reglement =
'';
280 $search_fk_shipping_method =
'';
281 $search_fk_mode_reglement =
'';
282 $search_fk_input_reason =
'';
284 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
285 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
290 $objectclass =
'Commande';
291 $objectlabel =
'Orders';
292 $permissiontoread = $user->rights->commande->lire;
293 $permissiontoadd = $user->rights->commande->creer;
294 $permissiontodelete = $user->rights->commande->supprimer;
295 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
296 $permissiontovalidate = $user->rights->commande->order_advance->validate;
297 $permissiontoclose = $user->rights->commande->order_advance->close;
298 $permissiontocancel = $user->rights->commande->order_advance->annuler;
299 $permissiontosendbymail = $user->rights->commande->order_advance->send;
301 $permissiontovalidate = $user->rights->commande->creer;
302 $permissiontoclose = $user->rights->commande->creer;
303 $permissiontocancel = $user->rights->commande->creer;
304 $permissiontosendbymail = $user->rights->commande->creer;
306 $uploaddir = $conf->commande->multidir_output[$conf->entity];
307 $triggersendname =
'ORDER_SENTBYMAIL';
308 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
310 if ($massaction ==
'confirm_createbills') {
311 $orders =
GETPOST(
'toselect',
'array');
312 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
313 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
318 $TFactThird = array();
319 $TFactThirdNbLines = array();
321 $nb_bills_created = 0;
327 $nbOrders = is_array($orders) ? count($orders) : 1;
329 foreach ($orders as $id_order) {
331 if ($cmd->fetch($id_order) <= 0) {
334 $cmd->fetch_thirdparty();
337 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
339 $objecttmp = $TFactThird[$cmd->socid];
342 $objecttmp->socid = $cmd->socid;
343 $objecttmp->thirdparty = $cmd->thirdparty;
345 $objecttmp->type = $objecttmp::TYPE_STANDARD;
346 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
347 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
349 $objecttmp->fk_project = $cmd->fk_project;
350 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
351 if (empty($createbills_onebythird)) {
352 $objecttmp->ref_client = $cmd->ref_client;
356 if (empty($datefacture)) {
360 $objecttmp->date = $datefacture;
361 $objecttmp->origin =
'commande';
362 $objecttmp->origin_id = $id_order;
364 $objecttmp->array_options = $cmd->array_options;
366 $res = $objecttmp->create($user);
370 $lastref = $objecttmp->ref;
371 $lastid = $objecttmp->id;
373 $TFactThird[$cmd->socid] = $objecttmp;
374 $TFactThirdNbLines[$cmd->socid] = 0;
376 $langs->load(
"errors");
377 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
382 if ($objecttmp->id > 0) {
383 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
386 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
391 $lines = $cmd->lines;
392 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
394 $lines = $cmd->lines;
398 $num = count($lines);
400 for ($i = 0; $i < $num; $i++) {
401 $desc = ($lines[$i]->desc ? $lines[$i]->desc :
'');
403 if (!empty($createbills_onebythird)) {
407 if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) {
410 $discount->fk_soc = $objecttmp->socid;
411 $discount->amount_ht = abs($lines[$i]->total_ht);
412 $discount->amount_tva = abs($lines[$i]->total_tva);
413 $discount->amount_ttc = abs($lines[$i]->total_ttc);
414 $discount->tva_tx = $lines[$i]->tva_tx;
415 $discount->fk_user = $user->id;
416 $discount->description = $desc;
417 $discountid = $discount->create($user);
418 if ($discountid > 0) {
419 $result = $objecttmp->insert_discount($discountid);
428 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
431 if ($lines[$i]->date_debut_prevue) {
432 $date_start = $lines[$i]->date_debut_prevue;
434 if ($lines[$i]->date_debut_reel) {
435 $date_start = $lines[$i]->date_debut_reel;
437 if ($lines[$i]->date_start) {
438 $date_start = $lines[$i]->date_start;
442 if ($lines[$i]->date_fin_prevue) {
443 $date_end = $lines[$i]->date_fin_prevue;
445 if ($lines[$i]->date_fin_reel) {
446 $date_end = $lines[$i]->date_fin_reel;
448 if ($lines[$i]->date_end) {
449 $date_end = $lines[$i]->date_end;
452 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
457 if (method_exists($lines[$i],
'fetch_optionals')) {
458 $lines[$i]->fetch_optionals();
459 $array_options = $lines[$i]->array_options;
462 $objecttmp->context[
'createfromclone'];
464 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
466 if (!empty($createbills_onebythird)) {
467 $rang = $TFactThirdNbLines[$cmd->socid];
470 $result = $objecttmp->addline(
472 $lines[$i]->subprice,
475 $lines[$i]->localtax1_tx,
476 $lines[$i]->localtax2_tx,
477 $lines[$i]->fk_product,
478 $lines[$i]->remise_percent,
482 $lines[$i]->info_bits,
483 $lines[$i]->fk_remise_except,
488 $lines[$i]->special_code,
492 $lines[$i]->fk_fournprice,
502 if (!empty($createbills_onebythird))
503 $TFactThirdNbLines[$rcp->socid]++;
507 $errors[] = $objecttmp->error;
511 if ($result > 0 && $lines[$i]->product_type == 9) {
512 $fk_parent_line = $result;
521 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
522 $TFactThird[$cmd->socid] = $objecttmp;
524 $TFact[$objecttmp->id] = $objecttmp;
529 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
532 if (!$error && $validate_invoices) {
533 $massaction = $action =
'builddoc';
535 foreach ($TAllFact as &$objecttmp) {
536 $result = $objecttmp->validate($user);
543 $id = $objecttmp->id;
547 $upload_dir = $conf->facture->dir_output;
548 $permissiontoadd = $user->rights->facture->creer;
551 $savobject = $object;
552 $object = $objecttmp;
553 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
554 $object = $savobject;
557 $massaction = $action =
'confirm_createbills';
563 if ($nb_bills_created == 1) {
564 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
565 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
568 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
573 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
574 $param .=
'&contextpage='.urlencode($contextpage);
576 if ($limit > 0 && $limit != $conf->liste_limit) {
577 $param .=
'&limit='.urlencode($limit);
580 $param .=
'&sall='.urlencode($sall);
583 $param .=
'&socid='.urlencode($socid);
585 if ($search_status !=
'') {
586 $param .=
'&search_status='.urlencode($search_status);
588 if ($search_orderday) {
589 $param .=
'&search_orderday='.urlencode($search_orderday);
591 if ($search_ordermonth) {
592 $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
594 if ($search_orderyear) {
595 $param .=
'&search_orderyear='.urlencode($search_orderyear);
597 if ($search_deliveryday) {
598 $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
600 if ($search_deliverymonth) {
601 $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
603 if ($search_deliveryyear) {
604 $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
607 $param .=
'&search_ref='.urlencode($search_ref);
609 if ($search_company) {
610 $param .=
'&search_company='.urlencode($search_company);
612 if ($search_ref_customer) {
613 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
615 if ($search_user > 0) {
616 $param .=
'&search_user='.urlencode($search_user);
618 if ($search_sale > 0) {
619 $param .=
'&search_sale='.urlencode($search_sale);
621 if ($search_total_ht !=
'') {
622 $param .=
'&search_total_ht='.urlencode($search_total_ht);
624 if ($search_total_vat !=
'') {
625 $param .=
'&search_total_vat='.urlencode($search_total_vat);
627 if ($search_total_ttc !=
'') {
628 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
630 if ($search_project_ref >= 0) {
631 $param .=
"&search_project_ref=".urlencode($search_project_ref);
634 $param .=
'&show_files='.urlencode($show_files);
636 if ($optioncss !=
'') {
637 $param .=
'&optioncss='.urlencode($optioncss);
640 $param .=
'&billed='.urlencode($billed);
643 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
649 $_GET[
"origin"] = $_POST[
"origin"];
650 $_GET[
"originid"] = $_POST[
"originid"];
651 if (!empty($errors)) {
660 if ($action ==
'validate' && $permissiontoadd) {
661 if (
GETPOST(
'confirm') ==
'yes') {
662 $objecttmp =
new $objectclass($db);
665 foreach ($toselect as $checked) {
666 if ($objecttmp->fetch($checked)) {
667 if ($objecttmp->statut == 0) {
668 if (!empty($objecttmp->fk_warehouse)) {
669 $idwarehouse = $objecttmp->fk_warehouse;
673 if ($objecttmp->valid($user, $idwarehouse)) {
674 setEventMessage($langs->trans(
'hasBeenValidated', $objecttmp->ref),
'mesgs');
680 $langs->load(
"errors");
681 setEventMessage($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
'errors');
696 if ($action ==
'shipped' && $permissiontoadd) {
697 if (
GETPOST(
'confirm') ==
'yes') {
698 $objecttmp =
new $objectclass($db);
701 foreach ($toselect as $checked) {
702 if ($objecttmp->fetch($checked)) {
703 if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
704 if ($objecttmp->cloture($user)) {
705 setEventMessage($langs->trans(
'PassedInClosedStatus', $objecttmp->ref),
'mesgs');
711 $langs->load(
"errors");
712 setEventMessage($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
'errors');
728 if (!$error && $massaction ===
'setbilled' && $permissiontoclose) {
731 $objecttmp =
new $objectclass($db);
733 foreach ($toselect as $toselectid) {
734 $result = $objecttmp->fetch($toselectid);
736 $result = $objecttmp->classifyBilled($user, 0);
773 if (!empty($conf->margin->enabled)) {
776 $companystatic =
new Societe($db);
778 $projectstatic =
new Project($db);
780 $title = $langs->trans(
"Orders");
781 $help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
785 if ($sall || $search_product_category > 0 || $search_user > 0) {
786 $sql =
'SELECT DISTINCT';
788 $sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
789 $sql .=
" typent.code as typent_code,";
790 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
791 $sql .=
" country.code as country_code,";
792 $sql .=
' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
793 $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,';
794 $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,';
795 $sql .=
' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
796 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
797 $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,';
798 $sql .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
799 $sql .=
' c.fk_input_reason, c.import_key';
800 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
801 $sql .=
", cc.fk_categorie, cc.fk_soc";
804 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
805 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
806 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
810 $parameters = array();
811 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
812 $sql .= $hookmanager->resPrint;
813 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
814 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
815 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
816 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
817 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
818 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
820 $sql .=
', '.MAIN_DB_PREFIX.
'commande as c';
821 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
822 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
824 if ($sall || $search_product_category > 0) {
825 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commandedet as pd ON c.rowid=pd.fk_commande';
827 if ($search_product_category > 0) {
828 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=pd.fk_product';
830 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
831 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
834 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
835 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
837 if ($search_user > 0) {
838 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
839 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
843 $parameters = array();
844 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
845 $sql .= $hookmanager->resPrint;
847 $sql .=
' WHERE c.fk_soc = s.rowid';
848 $sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
849 if ($search_product_category > 0) {
850 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
853 $sql .=
' AND s.rowid = '.((int) $socid);
855 if (empty($user->rights->societe->client->voir) && !$socid) {
856 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
861 if ($search_ref_customer) {
867 if ($search_billed !=
'' && $search_billed >= 0) {
868 $sql .=
' AND c.facture = '.((int) $search_billed);
870 if ($search_status <>
'') {
871 if ($search_status <= 3 && $search_status >= -1) {
872 if ($search_status == 1 && empty($conf->expedition->enabled)) {
873 $sql .=
' AND c.fk_statut IN (1,2)';
875 $sql .=
' AND c.fk_statut = '.((int) $search_status);
878 if ($search_status == -2) {
880 $sql .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
882 if ($search_status == -3) {
885 $sql .=
' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))';
887 if ($search_status == -4) {
888 $sql .=
' AND (c.fk_statut IN (1,2))';
892 if ($search_datecloture_start) {
893 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
895 if ($search_datecloture_end) {
896 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
898 if ($search_dateorder_start) {
899 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
901 if ($search_dateorder_end) {
902 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
904 if ($search_datedelivery_start) {
905 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
907 if ($search_datedelivery_end) {
908 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
919 if ($search_country) {
920 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
922 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
923 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
925 if ($search_company) {
928 if ($search_company_alias) {
931 if ($search_sale > 0) {
932 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
934 if ($search_user > 0) {
935 $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);
937 if ($search_total_ht !=
'') {
940 if ($search_total_vat !=
'') {
943 if ($search_total_ttc !=
'') {
946 if ($search_warehouse !=
'' && $search_warehouse > 0) {
949 if ($search_multicurrency_code !=
'') {
950 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
952 if ($search_multicurrency_tx !=
'') {
953 $sql .=
natural_search(
'c.multicurrency_tx', $search_multicurrency_tx, 1);
955 if ($search_multicurrency_montant_ht !=
'') {
956 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
958 if ($search_multicurrency_montant_vat !=
'') {
959 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
961 if ($search_multicurrency_montant_ttc !=
'') {
962 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
965 $sql .=
natural_search(array(
"u.login",
"u.firstname",
"u.lastname"), $search_login);
967 if ($search_project_ref !=
'') {
970 if ($search_project !=
'') {
973 if ($search_categ_cus > 0) {
974 $sql .=
" AND cc.fk_categorie = ".((int) $search_categ_cus);
976 if ($search_categ_cus == -2) {
977 $sql .=
" AND cc.fk_categorie IS NULL";
979 if ($search_fk_cond_reglement > 0) {
980 $sql .=
" AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
982 if ($search_fk_shipping_method > 0) {
983 $sql .=
" AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
985 if ($search_fk_mode_reglement > 0) {
986 $sql .=
" AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
988 if ($search_fk_input_reason > 0) {
989 $sql .=
" AND c.fk_input_reason = ".((int) $search_fk_input_reason);
993 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
995 $parameters = array();
996 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
997 $sql .= $hookmanager->resPrint;
1000 $parameters = array();
1001 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
1002 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
1004 $sql .= $db->order($sortfield, $sortorder);
1007 $nbtotalofrecords =
'';
1008 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1009 $result = $db->query($sql);
1010 $nbtotalofrecords = $db->num_rows($result);
1012 if (($page * $limit) > $nbtotalofrecords) {
1018 $sql .= $db->plimit($limit + 1, $offset);
1021 $resql = $db->query($sql);
1025 $soc->fetch($socid);
1026 $title = $langs->trans(
'CustomersOrders').
' - '.$soc->name;
1027 if (empty($search_company)) {
1028 $search_company = $soc->name;
1031 $title = $langs->trans(
'CustomersOrders');
1033 if (strval($search_status) ==
'0') {
1034 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
1036 if ($search_status == 1) {
1037 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
1039 if ($search_status == 2) {
1040 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
1042 if ($search_status == 3) {
1043 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
1045 if ($search_status == -1) {
1046 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
1048 if ($search_status == -2) {
1049 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
1051 if ($search_status == -3) {
1052 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(empty($conf->expedition->enabled) ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
1054 if ($search_status == -4) {
1055 $title .=
' - '.$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort");
1058 $num = $db->num_rows(
$resql);
1060 $arrayofselected = is_array($toselect) ? $toselect : array();
1062 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
1063 $obj = $db->fetch_object(
$resql);
1065 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.$id);
1073 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1074 $param .=
'&contextpage='.urlencode($contextpage);
1076 if ($limit > 0 && $limit != $conf->liste_limit) {
1077 $param .=
'&limit='.urlencode($limit);
1080 $param .=
'&sall='.urlencode($sall);
1083 $param .=
'&socid='.urlencode($socid);
1085 if ($search_status !=
'') {
1086 $param .=
'&search_status='.urlencode($search_status);
1088 if ($search_datecloture_start) {
1089 $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');
1091 if ($search_datecloture_end) {
1092 $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');
1094 if ($search_dateorder_start) {
1095 $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');
1097 if ($search_dateorder_end) {
1098 $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');
1100 if ($search_datedelivery_start) {
1101 $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');
1103 if ($search_datedelivery_end) {
1104 $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');
1107 $param .=
'&search_ref='.urlencode($search_ref);
1109 if ($search_company) {
1110 $param .=
'&search_company='.urlencode($search_company);
1112 if ($search_company_alias) {
1113 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1115 if ($search_ref_customer) {
1116 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
1118 if ($search_user > 0) {
1119 $param .=
'&search_user='.urlencode($search_user);
1121 if ($search_sale > 0) {
1122 $param .=
'&search_sale='.urlencode($search_sale);
1124 if ($search_total_ht !=
'') {
1125 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1127 if ($search_total_vat !=
'') {
1128 $param .=
'&search_total_vat='.urlencode($search_total_vat);
1130 if ($search_total_ttc !=
'') {
1131 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
1133 if ($search_warehouse !=
'') {
1134 $param .=
'&search_warehouse='.urlencode($search_warehouse);
1136 if ($search_login) {
1137 $param .=
'&search_login='.urlencode($search_login);
1139 if ($search_multicurrency_code !=
'') {
1140 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1142 if ($search_multicurrency_tx !=
'') {
1143 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1145 if ($search_multicurrency_montant_ht !=
'') {
1146 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1148 if ($search_multicurrency_montant_vat !=
'') {
1149 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1151 if ($search_multicurrency_montant_ttc !=
'') {
1152 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1154 if ($search_project_ref >= 0) {
1155 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1157 if ($search_town !=
'') {
1158 $param .=
'&search_town='.urlencode($search_town);
1160 if ($search_zip !=
'') {
1161 $param .=
'&search_zip='.urlencode($search_zip);
1163 if ($search_state !=
'') {
1164 $param .=
'&search_state='.urlencode($search_state);
1166 if ($search_country !=
'') {
1167 $param .=
'&search_country='.urlencode($search_country);
1169 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
1170 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1172 if ($search_product_category !=
'') {
1173 $param .=
'&search_product_category='.urlencode($search_product_category);
1175 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1176 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1179 $param .=
'&show_files='.urlencode($show_files);
1181 if ($optioncss !=
'') {
1182 $param .=
'&optioncss='.urlencode($optioncss);
1184 if ($search_billed !=
'') {
1185 $param .=
'&search_billed='.urlencode($search_billed);
1187 if ($search_fk_cond_reglement > 0) {
1188 $param .=
'&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
1190 if ($search_fk_shipping_method > 0) {
1191 $param .=
'&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
1193 if ($search_fk_mode_reglement > 0) {
1194 $param .=
'&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
1196 if ($search_fk_input_reason > 0) {
1197 $param .=
'&search_fk_input_reason='.urlencode($search_fk_input_reason);
1201 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1204 $parameters = array();
1205 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1206 $param .= $hookmanager->resPrint;
1209 $arrayofmassactions = array(
1210 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1211 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1213 if ($permissiontovalidate) {
1214 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1216 if ($permissiontosendbymail) {
1217 $arrayofmassactions[
'presend'] =
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail");
1219 if ($permissiontoclose) {
1220 $arrayofmassactions[
'preshipped'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').$langs->trans(
"ClassifyShipped");
1222 if ($permissiontocancel) {
1223 $arrayofmassactions[
'cancelorders'] =
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"Cancel");
1225 if ($user->rights->facture->creer) {
1226 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisCustomer");
1228 if ($permissiontoclose) {
1229 $arrayofmassactions[
'setbilled'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"ClassifyBilled");
1231 if ($permissiontodelete) {
1232 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1234 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1235 $arrayofmassactions = array();
1237 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1239 $url = DOL_URL_ROOT.
'/commande/card.php?action=create';
1240 if (!empty($socid)) {
1241 $url .=
'&socid='.$socid;
1243 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewOrder'),
'',
'fa fa-plus-circle', $url,
'', $contextpage ==
'orderlist' && $permissiontoadd);
1246 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1247 if ($optioncss !=
'') {
1248 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1250 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1251 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1252 print
'<input type="hidden" name="action" value="list">';
1253 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1254 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1255 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1256 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1257 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1259 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1261 $topicmail =
"SendOrderRef";
1262 $modelmail =
"order_send";
1264 $trackid =
'ord'.$object->id;
1265 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1267 if ($massaction ==
'prevalidate') {
1268 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate",
null,
'', 0, 200, 500, 1);
1270 if ($massaction ==
'preshipped') {
1271 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"CloseOrder"), $langs->trans(
"ConfirmCloseOrder"),
"shipped",
null,
'', 0, 200, 500, 1);
1274 if ($massaction ==
'createbills') {
1275 print
'<input type="hidden" name="massaction" value="confirm_createbills">';
1277 print
'<table class="noborder" width="100%" >';
1279 print
'<td class="titlefield">';
1280 print $langs->trans(
'DateInvoice');
1283 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1288 print $langs->trans(
'CreateOneBillByThird');
1291 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1296 print $langs->trans(
'ValidateInvoices');
1299 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
1300 print
$form->selectyesno(
'validate_invoices', 0, 1, 1);
1301 $langs->load(
"errors");
1302 print
' ('.$langs->trans(
"WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").
')';
1304 print
$form->selectyesno(
'validate_invoices', 0, 1);
1306 if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) {
1307 print
' <span class="opacitymedium">'.$langs->trans(
"IfValidateInvoiceIsNoOrderStayUnbilled").
'</span>';
1309 print
' <span class="opacitymedium">'.$langs->trans(
"OptionToSetOrderBilledNotEnabled").
'</span>';
1316 print
'<div class="center">';
1317 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1318 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1324 foreach ($fieldstosearchall as $key => $val) {
1325 $fieldstosearchall[$key] = $langs->trans($val);
1327 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1330 $moreforfilter =
'';
1333 if ($user->rights->user->user->lire) {
1334 $langs->load(
"commercial");
1335 $moreforfilter .=
'<div class="divsearchfield">';
1336 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1337 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1338 $moreforfilter .=
'</div>';
1341 if ($user->rights->user->user->lire) {
1342 $moreforfilter .=
'<div class="divsearchfield">';
1343 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1344 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1345 $moreforfilter .=
'</div>';
1348 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1349 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1350 $moreforfilter .=
'<div class="divsearchfield">';
1351 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1352 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
1353 $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);
1354 $moreforfilter .=
'</div>';
1356 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
1357 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1358 $moreforfilter .=
'<div class="divsearchfield">';
1359 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1360 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'maxwidth300 widthcentpercentminusx');
1361 $moreforfilter .=
'</div>';
1363 if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1364 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1366 $moreforfilter .=
'<div class="divsearchfield">';
1367 $tmptitle = $langs->trans(
'Warehouse');
1368 $moreforfilter .=
img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'maxwidth250 widthcentpercentminusx');
1369 $moreforfilter .=
'</div>';
1371 $parameters = array();
1372 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1373 if (empty($reshook)) {
1374 $moreforfilter .= $hookmanager->resPrint;
1376 $moreforfilter = $hookmanager->resPrint;
1379 if (!empty($moreforfilter)) {
1380 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1381 print $moreforfilter;
1385 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1386 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1387 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1389 if (
GETPOST(
'autoselectall',
'int')) {
1390 $selectedfields .=
'<script>';
1391 $selectedfields .=
' $(document).ready(function() {';
1392 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1393 $selectedfields .=
' $("#checkforselects").click();';
1394 $selectedfields .=
' $("#massaction").val("createbills").change();';
1395 $selectedfields .=
' });';
1396 $selectedfields .=
'</script>';
1399 print
'<div class="div-table-responsive">';
1400 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1402 print
'<tr class="liste_titre_filter">';
1404 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1405 print
'<td class="liste_titre">';
1406 print
'<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1410 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1411 print
'<td class="liste_titre" align="left">';
1412 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1416 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1417 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1420 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1421 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1424 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1425 print
'<td class="liste_titre" align="left">';
1426 print
'<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
1430 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1431 print
'<td class="liste_titre" align="left">';
1432 print
'<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1436 if (!empty($arrayfields[
's.town'][
'checked'])) {
1437 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1440 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1441 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1444 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1445 print
'<td class="liste_titre">';
1446 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1450 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1451 print
'<td class="liste_titre" align="center">';
1452 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1456 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1457 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1458 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);
1462 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1463 print
'<td class="liste_titre center">';
1464 print
'<div class="nowrap">';
1465 print
$form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1467 print
'<div class="nowrap">';
1468 print
$form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1472 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1473 print
'<td class="liste_titre center">';
1474 print
'<div class="nowrap">';
1475 print
$form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1477 print
'<div class="nowrap">';
1478 print
$form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1483 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1484 print
'<td class="liste_titre">';
1485 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1489 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1490 print
'<td class="liste_titre">';
1491 $form->select_conditions_paiements($search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1495 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1496 print
'<td class="liste_titre">';
1497 $form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1);
1501 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1502 print
'<td class="liste_titre">';
1503 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1506 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1508 print
'<td class="liste_titre right">';
1509 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1512 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1514 print
'<td class="liste_titre right">';
1515 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1518 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1520 print
'<td class="liste_titre right">';
1521 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1524 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1526 print
'<td class="liste_titre">';
1527 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1530 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1532 print
'<td class="liste_titre">';
1533 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1536 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1538 print
'<td class="liste_titre right">';
1539 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1542 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1544 print
'<td class="liste_titre right">';
1545 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1548 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1550 print
'<td class="liste_titre right">';
1551 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1554 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1556 print
'<td class="liste_titre" align="center">';
1557 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1560 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1561 print
'<td class="liste_titre"></td>';
1563 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1564 print
'<td class="liste_titre right">';
1567 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1568 print
'<td class="liste_titre right">';
1571 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1572 print
'<td class="liste_titre right">';
1575 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1576 print
'<td class="liste_titre right">';
1580 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1582 $parameters = array(
'arrayfields'=>$arrayfields);
1583 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1584 print $hookmanager->resPrint;
1586 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1587 print
'<td class="liste_titre">';
1591 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1592 print
'<td class="liste_titre">';
1596 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1597 print
'<td class="liste_titre center">';
1598 print
'<div class="nowrap">';
1599 print
$form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1601 print
'<div class="nowrap">';
1602 print
$form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1607 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1608 print
'<td class="liste_titre">';
1612 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1613 print
'<td class="liste_titre">';
1617 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1618 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1620 if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) {
1621 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
1622 print $langs->trans(
'ShowShippableStatus');
1624 $show_shippable_command = 1;
1629 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1630 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1631 print
$form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1635 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1636 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1640 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1641 print
'<td class="liste_titre maxwidthonsmartphone center">';
1642 $liststatus = array(
1647 -3=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
1648 -2=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
1651 print
$form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'maxwidth125', 1);
1655 print
'<td class="liste_titre" align="middle">';
1656 $searchpicto =
$form->showFilterButtons();
1663 print
'<tr class="liste_titre">';
1664 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1665 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
1667 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1668 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
1670 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1671 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1673 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1674 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
1676 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1677 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1679 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1680 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1682 if (!empty($arrayfields[
's.town'][
'checked'])) {
1683 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1685 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1686 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1688 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1689 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1691 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1692 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1694 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1695 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1697 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1698 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
1700 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1701 print_liste_field_titre($arrayfields[
'c.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1703 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1704 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
1706 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1707 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
1709 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1710 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
1712 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1713 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
1715 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1716 print_liste_field_titre($arrayfields[
'c.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1718 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1719 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1721 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1722 print_liste_field_titre($arrayfields[
'c.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1724 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1725 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1727 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1728 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1730 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1731 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1733 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1734 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1736 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1737 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1739 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1740 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1742 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1743 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1745 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1746 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1748 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1749 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1751 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1752 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1754 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1755 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1758 $totalarray = array(
1768 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1770 $parameters = array(
1771 'arrayfields' => $arrayfields,
1773 'sortfield' => $sortfield,
1774 'sortorder' => $sortorder,
1775 'totalarray' => &$totalarray,
1777 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1778 print $hookmanager->resPrint;
1779 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1780 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1782 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1783 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1785 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1786 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1788 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1789 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'right ');
1791 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1792 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'right ');
1794 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1795 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1797 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1798 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
1800 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1801 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1803 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1804 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1806 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1811 $productstat_cache = array();
1812 $productstat_cachevirtual = array();
1813 $getNomUrl_cache = array();
1815 $generic_commande =
new Commande($db);
1816 $generic_product =
new Product($db);
1817 $userstatic =
new User($db);
1820 $with_margin_info =
false;
1821 if (!empty($conf->margin->enabled) && (
1822 !empty($arrayfields[
'total_pa'][
'checked'])
1823 || !empty($arrayfields[
'total_margin'][
'checked'])
1824 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1825 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1828 $with_margin_info =
true;
1833 $savnbfield = $totalarray[
'nbfield'];
1834 $totalarray = array();
1835 $totalarray[
'nbfield'] = 0;
1836 $imaxinloop = ($limit ? min($num, $limit) : $num);
1837 while ($i < $imaxinloop) {
1838 $obj = $db->fetch_object(
$resql);
1846 $companystatic->id = $obj->socid;
1847 $companystatic->name = $obj->name;
1848 $companystatic->name_alias = $obj->alias;
1849 $companystatic->client = $obj->client;
1850 $companystatic->code_client = $obj->code_client;
1851 $companystatic->email = $obj->email;
1852 $companystatic->phone = $obj->phone;
1853 $companystatic->address = $obj->address;
1854 $companystatic->zip = $obj->zip;
1855 $companystatic->town = $obj->town;
1856 $companystatic->country_code = $obj->country_code;
1857 if (!isset($getNomUrl_cache[$obj->socid])) {
1858 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer');
1861 $generic_commande->id = $obj->rowid;
1862 $generic_commande->ref = $obj->ref;
1863 $generic_commande->statut = $obj->fk_statut;
1864 $generic_commande->billed = $obj->billed;
1865 $generic_commande->date = $db->jdate($obj->date_commande);
1866 $generic_commande->date_livraison = $db->jdate($obj->date_delivery);
1867 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1868 $generic_commande->ref_client = $obj->ref_client;
1869 $generic_commande->total_ht = $obj->total_ht;
1870 $generic_commande->total_tva = $obj->total_tva;
1871 $generic_commande->total_ttc = $obj->total_ttc;
1872 $generic_commande->note_public = $obj->note_public;
1873 $generic_commande->note_private = $obj->note_private;
1875 $projectstatic->id = $obj->project_id;
1876 $projectstatic->ref = $obj->project_ref;
1877 $projectstatic->title = $obj->project_label;
1879 $marginInfo = array();
1880 if ($with_margin_info ===
true) {
1881 $generic_commande->fetch_lines();
1882 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1883 $total_ht += $obj->total_ht;
1884 $total_margin += $marginInfo[
'total_margin'];
1887 print
'<tr class="oddeven">';
1890 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1891 print
'<td class="nowraponall">';
1892 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1895 $filedir = $conf->commande->multidir_output[$conf->entity].
'/'.
dol_sanitizeFileName($obj->ref);
1896 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1897 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1901 $totalarray[
'nbfield']++;
1906 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1907 print
'<td class="nowrap tdoverflowmax200">'.$obj->ref_client.
'</td>';
1909 $totalarray[
'nbfield']++;
1914 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1915 print
'<td class="nowrap">';
1916 if ($obj->project_id > 0) {
1917 print $projectstatic->getNomUrl(1);
1921 $totalarray[
'nbfield']++;
1926 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1927 print
'<td class="nowrap">';
1928 if ($obj->project_id > 0) {
1929 print $projectstatic->title;
1933 $totalarray[
'nbfield']++;
1938 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1939 print
'<td class="tdoverflowmax200">';
1940 print $getNomUrl_cache[$obj->socid];
1943 if (
isModEnabled(
'facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
1944 if ($user->rights->facture->creer) {
1945 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1946 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
1947 print
img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
1953 $totalarray[
'nbfield']++;
1957 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1958 print
'<td class="nocellnopadd">';
1962 $totalarray[
'nbfield']++;
1966 if (!empty($arrayfields[
's.town'][
'checked'])) {
1967 print
'<td class="nocellnopadd">';
1971 $totalarray[
'nbfield']++;
1975 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1976 print
'<td class="nocellnopadd">';
1980 $totalarray[
'nbfield']++;
1984 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1985 print
"<td>".$obj->state_name.
"</td>\n";
1987 $totalarray[
'nbfield']++;
1991 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1992 print
'<td class="center">';
1993 $tmparray =
getCountry($obj->fk_pays,
'all');
1994 print $tmparray[
'label'];
1997 $totalarray[
'nbfield']++;
2001 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2002 print
'<td class="center">';
2003 if (empty($typenArray)) {
2004 $typenArray = $formcompany->typent_array(1);
2006 print $typenArray[$obj->typent_code];
2009 $totalarray[
'nbfield']++;
2014 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
2015 print
'<td class="center">';
2018 if ($generic_commande->hasDelay()) {
2019 print
img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
2023 $totalarray[
'nbfield']++;
2027 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
2028 print
'<td class="center">';
2029 print
dol_print_date($db->jdate($obj->date_delivery),
'dayhour');
2032 $totalarray[
'nbfield']++;
2036 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
2038 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
2041 $totalarray[
'nbfield']++;
2045 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
2047 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
2050 $totalarray[
'nbfield']++;
2054 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
2056 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
2059 $totalarray[
'nbfield']++;
2063 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
2065 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none',
'');
2068 $totalarray[
'nbfield']++;
2072 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
2073 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2075 $totalarray[
'nbfield']++;
2078 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ht';
2080 if (isset($totalarray[
'val'][
'c.total_ht'])) {
2081 $totalarray[
'val'][
'c.total_ht'] += $obj->total_ht;
2083 $totalarray[
'val'][
'c.total_ht'] = $obj->total_ht;
2087 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
2088 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
2090 $totalarray[
'nbfield']++;
2093 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_tva';
2095 $totalarray[
'val'][
'c.total_tva'] += $obj->total_tva;
2098 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
2099 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2101 $totalarray[
'nbfield']++;
2104 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ttc';
2106 $totalarray[
'val'][
'c.total_ttc'] += $obj->total_ttc;
2110 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
2111 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2113 $totalarray[
'nbfield']++;
2118 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
2119 print
'<td class="nowrap">';
2120 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2123 $totalarray[
'nbfield']++;
2127 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
2128 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2130 $totalarray[
'nbfield']++;
2134 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
2135 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
2137 $totalarray[
'nbfield']++;
2141 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
2142 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2144 $totalarray[
'nbfield']++;
2148 $userstatic->id = $obj->fk_user_author;
2149 $userstatic->login = $obj->login;
2150 $userstatic->lastname = $obj->lastname;
2151 $userstatic->firstname = $obj->firstname;
2152 $userstatic->email = $obj->user_email;
2153 $userstatic->statut = $obj->user_statut;
2154 $userstatic->entity = $obj->entity;
2155 $userstatic->photo = $obj->photo;
2156 $userstatic->office_phone = $obj->office_phone;
2157 $userstatic->office_fax = $obj->office_fax;
2158 $userstatic->user_mobile = $obj->user_mobile;
2159 $userstatic->job = $obj->job;
2160 $userstatic->gender = $obj->gender;
2163 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2164 print
'<td class="tdoverflowmax200">';
2165 if ($userstatic->id) {
2166 print $userstatic->getNomUrl(-1);
2172 $totalarray[
'nbfield']++;
2176 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2179 if ($obj->socid > 0) {
2180 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2181 if ($listsalesrepresentatives < 0) {
2184 $nbofsalesrepresentative = count($listsalesrepresentatives);
2185 if ($nbofsalesrepresentative > 6) {
2187 print $nbofsalesrepresentative;
2188 } elseif ($nbofsalesrepresentative > 0) {
2190 foreach ($listsalesrepresentatives as $val) {
2191 $userstatic->id = $val[
'id'];
2192 $userstatic->lastname = $val[
'lastname'];
2193 $userstatic->firstname = $val[
'firstname'];
2194 $userstatic->email = $val[
'email'];
2195 $userstatic->statut = $val[
'statut'];
2196 $userstatic->entity = $val[
'entity'];
2197 $userstatic->photo = $val[
'photo'];
2198 $userstatic->login = $val[
'login'];
2199 $userstatic->office_phone = $val[
'office_phone'];
2200 $userstatic->office_fax = $val[
'office_fax'];
2201 $userstatic->user_mobile = $val[
'user_mobile'];
2202 $userstatic->job = $val[
'job'];
2203 $userstatic->gender = $val[
'gender'];
2205 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2207 if ($j < $nbofsalesrepresentative) {
2219 $totalarray[
'nbfield']++;
2224 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2225 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2227 $totalarray[
'nbfield']++;
2231 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2232 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2234 $totalarray[
'nbfield']++;
2237 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2239 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2242 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2243 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2245 $totalarray[
'nbfield']++;
2249 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2250 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'],
null,
null,
null,
null, 2).
'%').
'</td>';
2252 $totalarray[
'nbfield']++;
2255 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2257 if ($i >= $imaxinloop - 1) {
2258 if (!empty($total_ht)) {
2259 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2261 $totalarray[
'val'][
'total_mark_rate'] =
'';
2267 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2269 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2270 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2271 print $hookmanager->resPrint;
2274 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2275 print
'<td align="center" class="nowrap">';
2276 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2279 $totalarray[
'nbfield']++;
2284 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2285 print
'<td align="center" class="nowrap">';
2286 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2289 $totalarray[
'nbfield']++;
2294 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2295 print
'<td align="center" class="nowrap">';
2296 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuser');
2299 $totalarray[
'nbfield']++;
2304 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2305 print
'<td class="center">';
2309 $totalarray[
'nbfield']++;
2314 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2315 print
'<td class="center">';
2319 $totalarray[
'nbfield']++;
2324 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2325 print
'<td class="center">';
2326 if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) {
2327 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2328 $generic_commande->getLinesArray();
2329 $generic_commande->loadExpeditions();
2331 $numlines = count($generic_commande->lines);
2332 for ($lig = 0; $lig < $numlines; $lig++) {
2333 if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
2334 $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
2336 $reliquat = $generic_commande->lines[$lig]->qty;
2338 if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) {
2340 $generic_product->id = $generic_commande->lines[$lig]->fk_product;
2343 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
2344 $generic_product->load_stock(
'nobatch,warehouseopen');
2345 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2346 $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2348 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'];
2349 $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2352 if ($reliquat > $generic_product->stock_reel) {
2355 if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
2356 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->product_ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2357 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2358 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2359 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2360 $text_info .=
'<br>';
2367 $stock_order_supplier = 0;
2368 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
2369 if (!empty($conf->commande->enabled)) {
2370 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'])) {
2371 $generic_product->load_stats_commande(0,
'1,2');
2372 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
2374 $generic_product->stats_commande[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'];
2376 $stock_order = $generic_product->stats_commande[
'qty'];
2378 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
2379 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'])) {
2380 $generic_product->load_stats_commande_fournisseur(0,
'3');
2381 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
2383 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'];
2385 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
2388 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2389 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
2390 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
2392 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2394 if ($reliquat > $generic_product->stock_reel) {
2395 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2397 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2399 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
2400 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
2402 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2403 $text_info .=
'<br>';
2407 if ($notshippable == 0) {
2408 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'green paddingleft');
2409 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
2411 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'error paddingleft');
2412 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
2417 print
$form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
2420 print
$form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1,
img_picto(
'',
'error'),
'', 2);
2425 $totalarray[
'nbfield']++;
2430 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2431 print
'<td class="center">'.yn($obj->billed).
'</td>';
2433 $totalarray[
'nbfield']++;
2437 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2438 print
'<td class="nowrap center">'.$obj->import_key.
'</td>';
2440 $totalarray[
'nbfield']++;
2444 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2445 print
'<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
2447 $totalarray[
'nbfield']++;
2452 print
'<td class="nowrap center">';
2453 if ($massactionbutton || $massaction) {
2455 if (in_array($obj->rowid, $arrayofselected)) {
2458 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2462 $totalarray[
'nbfield']++;
2467 $total += $obj->total_ht;
2468 $subtotal += $obj->total_ht;
2473 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2478 foreach ($arrayfields as $key => $val) {
2479 if (!empty($val[
'checked'])) {
2483 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2488 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2489 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2490 print $hookmanager->resPrint;
2492 print
'</table>'.
"\n";
2495 print
'</form>'.
"\n";
2497 $hidegeneratedfilelistifempty = 1;
2498 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2499 $hidegeneratedfilelistifempty = 0;
2503 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2504 $urlsource .= str_replace(
'&',
'&', $param);
2506 $filedir = $diroutputmassaction;
2507 $genallowed = $permissiontoread;
2508 $delallowed = $permissiontoadd;
2510 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);