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'));
54 $action =
GETPOST(
'action',
'aZ09');
55 $massaction =
GETPOST(
'massaction',
'alpha');
56 $show_files =
GETPOST(
'show_files',
'int');
57 $confirm =
GETPOST(
'confirm',
'alpha');
58 $toselect =
GETPOST(
'toselect',
'array');
59 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'orderlist';
61 $search_datecloture_start =
GETPOST(
'search_datecloture_start',
'int');
62 if (empty($search_datecloture_start)) {
63 $search_datecloture_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_datecloture_startmonth',
'int'),
GETPOST(
'search_datecloture_startday',
'int'),
GETPOST(
'search_datecloture_startyear',
'int'));
65 $search_datecloture_end =
GETPOST(
'search_datecloture_end',
'int');
66 if (empty($search_datecloture_end)) {
67 $search_datecloture_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_datecloture_endmonth',
'int'),
GETPOST(
'search_datecloture_endday',
'int'),
GETPOST(
'search_datecloture_endyear',
'int'));
69 $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'));
70 $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'));
71 $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'));
72 $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'));
73 $search_product_category =
GETPOST(
'search_product_category',
'int');
74 $search_ref =
GETPOST(
'search_ref',
'alpha') !=
'' ?
GETPOST(
'search_ref',
'alpha') :
GETPOST(
'sref',
'alpha');
75 $search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
76 $search_company =
GETPOST(
'search_company',
'alpha');
77 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
78 $search_town =
GETPOST(
'search_town',
'alpha');
79 $search_zip =
GETPOST(
'search_zip',
'alpha');
80 $search_state =
GETPOST(
"search_state",
'alpha');
81 $search_country =
GETPOST(
"search_country",
'int');
82 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
83 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
84 $socid =
GETPOST(
'socid',
'int');
85 $search_user =
GETPOST(
'search_user',
'int');
86 $search_sale =
GETPOST(
'search_sale',
'int');
87 $search_total_ht =
GETPOST(
'search_total_ht',
'alpha');
88 $search_total_vat =
GETPOST(
'search_total_vat',
'alpha');
89 $search_total_ttc =
GETPOST(
'search_total_ttc',
'alpha');
90 $search_warehouse =
GETPOST(
'search_warehouse',
'int');
91 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
92 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
93 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
94 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
95 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
96 $search_login =
GETPOST(
'search_login',
'alpha');
97 $search_categ_cus =
GETPOST(
"search_categ_cus",
'int');
98 $optioncss =
GETPOST(
'optioncss',
'alpha');
100 $search_status =
GETPOST(
'search_status',
'int');
101 $search_btn =
GETPOST(
'button_search',
'alpha');
102 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
103 $search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
104 $search_project =
GETPOST(
'search_project',
'alpha');
105 $search_shippable =
GETPOST(
'search_shippable',
'aZ09');
106 $search_fk_cond_reglement =
GETPOST(
"search_fk_cond_reglement",
'int');
107 $search_fk_shipping_method =
GETPOST(
"search_fk_shipping_method",
'int');
108 $search_fk_mode_reglement =
GETPOST(
"search_fk_mode_reglement",
'int');
109 $search_fk_input_reason =
GETPOST(
"search_fk_input_reason",
'int');
114 $socid = $user->socid;
118 $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].
'/temp/massgeneration/'.$user->id;
121 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
122 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
123 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
125 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
128 $offset = $limit * $page;
129 $pageprev = $page - 1;
130 $pagenext = $page + 1;
132 $sortfield =
'c.ref';
138 $show_shippable_command =
GETPOST(
'show_shippable_command',
'aZ09');
142 $hookmanager->initHooks(array(
'orderlist'));
146 $extrafields->fetch_name_optionals_label($object->table_element);
147 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
150 $fieldstosearchall = array(
152 'c.ref_client'=>
'RefCustomerOrder',
153 'pd.description'=>
'Description',
154 's.nom'=>
"ThirdParty",
155 's.name_alias'=>
"AliasNameShort",
158 'c.note_public'=>
'NotePublic',
160 if (empty($user->socid)) {
161 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
164 $checkedtypetiers = 0;
165 $arrayfields = array(
166 'c.ref'=>array(
'label'=>
"Ref",
'checked'=>1,
'position'=>5),
167 'c.ref_client'=>array(
'label'=>
"RefCustomerOrder",
'checked'=>-1,
'position'=>10),
168 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>-1,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>20),
169 'p.title'=>array(
'label'=>
"ProjectLabel",
'checked'=>0,
'enabled'=>(empty($conf->project->enabled) ? 0 : 1),
'position'=>25),
170 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>30),
171 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>-1,
'position'=>31),
172 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>35),
173 's.zip'=>array(
'label'=>
"Zip",
'checked'=>-1,
'position'=>40),
174 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>45),
175 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>50),
176 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>55),
177 'c.date_commande'=>array(
'label'=>
"OrderDateShort",
'checked'=>1,
'position'=>60),
178 'c.date_delivery'=>array(
'label'=>
"DateDeliveryPlanned",
'checked'=>1,
'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE),
'position'=>65),
179 'c.fk_shipping_method'=>array(
'label'=>
"SendingMethod",
'checked'=>-1,
'position'=>66 ,
'enabled'=>!empty($conf->expedition->enabled)),
180 'c.fk_cond_reglement'=>array(
'label'=>
"PaymentConditionsShort",
'checked'=>-1,
'position'=>67),
181 'c.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>-1,
'position'=>68),
182 'c.fk_input_reason'=>array(
'label'=>
"Channel",
'checked'=>-1,
'position'=>69),
183 'c.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>75),
184 'c.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>80),
185 'c.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>85),
186 'c.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>90),
187 'c.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>95),
188 'c.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>100),
189 'c.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>105),
190 'c.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1),
'position'=>110),
191 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>115),
192 'sale_representative'=>array(
'label'=>
"SaleRepresentativesOfThirdParty",
'checked'=>0,
'position'=>116),
193 '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)),
194 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)),
195 '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)),
196 '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)),
197 'c.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>120),
198 'c.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>125),
199 'c.date_cloture'=>array(
'label'=>
"DateClosing",
'checked'=>0,
'position'=>130),
200 'c.note_public'=>array(
'label'=>
'NotePublic',
'checked'=>0,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)),
'position'=>135),
201 'c.note_private'=>array(
'label'=>
'NotePrivate',
'checked'=>0,
'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)),
'position'=>140),
202 'shippable'=>array(
'label'=>
"Shippable",
'checked'=>1,
'enabled'=>(!empty($conf->expedition->enabled)),
'position'=>990),
203 'c.facture'=>array(
'label'=>
"Billed",
'checked'=>1,
'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)),
'position'=>995),
204 'c.import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>999),
205 'c.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
208 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
219 if (
GETPOST(
'cancel',
'alpha')) {
220 $action =
'list'; $massaction =
'';
222 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') {
226 $parameters = array(
'socid'=>$socid);
227 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
232 if (empty($reshook)) {
234 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
237 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
241 $search_product_category =
'';
243 $search_ref_customer =
'';
244 $search_company =
'';
245 $search_company_alias =
'';
250 $search_country =
'';
251 $search_type_thirdparty =
'';
252 $search_total_ht =
'';
253 $search_total_vat =
'';
254 $search_total_ttc =
'';
255 $search_warehouse =
'';
256 $search_multicurrency_code =
'';
257 $search_multicurrency_tx =
'';
258 $search_multicurrency_montant_ht =
'';
259 $search_multicurrency_montant_vat =
'';
260 $search_multicurrency_montant_ttc =
'';
262 $search_dateorder_start =
'';
263 $search_dateorder_end =
'';
264 $search_datedelivery_start =
'';
265 $search_datedelivery_end =
'';
266 $search_project_ref =
'';
267 $search_project =
'';
271 $search_array_options = array();
272 $search_categ_cus = 0;
273 $search_datecloture_start =
'';
274 $search_datecloture_end =
'';
275 $search_fk_cond_reglement =
'';
276 $search_fk_shipping_method =
'';
277 $search_fk_mode_reglement =
'';
278 $search_fk_input_reason =
'';
280 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
281 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
286 $objectclass =
'Commande';
287 $objectlabel =
'Orders';
288 $permissiontoread = $user->rights->commande->lire;
289 $permissiontoadd = $user->rights->commande->creer;
290 $permissiontodelete = $user->rights->commande->supprimer;
291 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
292 $permissiontovalidate = $user->rights->commande->order_advance->validate;
293 $permissiontoclose = $user->rights->commande->order_advance->close;
294 $permissiontocancel = $user->rights->commande->order_advance->annuler;
295 $permissiontosendbymail = $user->rights->commande->order_advance->send;
297 $permissiontovalidate = $user->rights->commande->creer;
298 $permissiontoclose = $user->rights->commande->creer;
299 $permissiontocancel = $user->rights->commande->creer;
300 $permissiontosendbymail = $user->rights->commande->creer;
302 $uploaddir = $conf->commande->multidir_output[$conf->entity];
303 $triggersendname =
'ORDER_SENTBYMAIL';
304 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
306 if ($massaction ==
'confirm_createbills') {
307 $orders =
GETPOST(
'toselect',
'array');
308 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
309 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
314 $TFactThird = array();
315 $TFactThirdNbLines = array();
317 $nb_bills_created = 0;
323 $nbOrders = is_array($orders) ? count($orders) : 1;
325 foreach ($orders as $id_order) {
327 if ($cmd->fetch($id_order) <= 0) {
330 $cmd->fetch_thirdparty();
333 if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
335 $objecttmp = $TFactThird[$cmd->socid];
338 $objecttmp->socid = $cmd->socid;
339 $objecttmp->thirdparty = $cmd->thirdparty;
341 $objecttmp->type = $objecttmp::TYPE_STANDARD;
342 $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id;
343 $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id;
345 $objecttmp->fk_project = $cmd->fk_project;
346 $objecttmp->multicurrency_code = $cmd->multicurrency_code;
347 if (empty($createbills_onebythird)) {
348 $objecttmp->ref_client = $cmd->ref_client;
352 if (empty($datefacture)) {
356 $objecttmp->date = $datefacture;
357 $objecttmp->origin =
'commande';
358 $objecttmp->origin_id = $id_order;
360 $objecttmp->array_options = $cmd->array_options;
362 $res = $objecttmp->create($user);
366 $lastref = $objecttmp->ref;
367 $lastid = $objecttmp->id;
369 $TFactThird[$cmd->socid] = $objecttmp;
370 $TFactThirdNbLines[$cmd->socid] = 0;
372 $langs->load(
"errors");
373 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
378 if ($objecttmp->id > 0) {
379 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order);
382 $errors[] = $cmd->ref.
' : '.$langs->trans($objecttmp->errors[0]);
387 $lines = $cmd->lines;
388 if (empty($lines) && method_exists($cmd,
'fetch_lines')) {
390 $lines = $cmd->lines;
394 $num = count($lines);
396 for ($i = 0; $i < $num; $i++) {
397 $desc = ($lines[$i]->desc ? $lines[$i]->desc :
'');
399 if (!empty($createbills_onebythird)) {
403 if ($lines[$i]->subprice < 0) {
406 $discount->fk_soc = $objecttmp->socid;
407 $discount->amount_ht = abs($lines[$i]->total_ht);
408 $discount->amount_tva = abs($lines[$i]->total_tva);
409 $discount->amount_ttc = abs($lines[$i]->total_ttc);
410 $discount->tva_tx = $lines[$i]->tva_tx;
411 $discount->fk_user = $user->id;
412 $discount->description = $desc;
413 $discountid = $discount->create($user);
414 if ($discountid > 0) {
415 $result = $objecttmp->insert_discount($discountid);
424 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
427 if ($lines[$i]->date_debut_prevue) {
428 $date_start = $lines[$i]->date_debut_prevue;
430 if ($lines[$i]->date_debut_reel) {
431 $date_start = $lines[$i]->date_debut_reel;
433 if ($lines[$i]->date_start) {
434 $date_start = $lines[$i]->date_start;
438 if ($lines[$i]->date_fin_prevue) {
439 $date_end = $lines[$i]->date_fin_prevue;
441 if ($lines[$i]->date_fin_reel) {
442 $date_end = $lines[$i]->date_fin_reel;
444 if ($lines[$i]->date_end) {
445 $date_end = $lines[$i]->date_end;
448 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
453 if (method_exists($lines[$i],
'fetch_optionals')) {
454 $lines[$i]->fetch_optionals();
455 $array_options = $lines[$i]->array_options;
458 $objecttmp->context[
'createfromclone'];
460 $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
462 if (!empty($createbills_onebythird)) {
463 $rang = $TFactThirdNbLines[$cmd->socid];
466 $result = $objecttmp->addline(
468 $lines[$i]->subprice,
471 $lines[$i]->localtax1_tx,
472 $lines[$i]->localtax2_tx,
473 $lines[$i]->fk_product,
474 $lines[$i]->remise_percent,
478 $lines[$i]->info_bits,
479 $lines[$i]->fk_remise_except,
484 $lines[$i]->special_code,
488 $lines[$i]->fk_fournprice,
498 if (!empty($createbills_onebythird))
499 $TFactThirdNbLines[$rcp->socid]++;
506 if ($result > 0 && $lines[$i]->product_type == 9) {
507 $fk_parent_line = $result;
516 if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
517 $TFactThird[$cmd->socid] = $objecttmp;
519 $TFact[$objecttmp->id] = $objecttmp;
524 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
527 if (!$error && $validate_invoices) {
528 $massaction = $action =
'builddoc';
530 foreach ($TAllFact as &$objecttmp) {
531 $result = $objecttmp->validate($user);
538 $id = $objecttmp->id;
542 $upload_dir = $conf->facture->dir_output;
543 $permissiontoadd = $user->rights->facture->creer;
546 $savobject = $object;
547 $object = $objecttmp;
548 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
549 $object = $savobject;
552 $massaction = $action =
'confirm_createbills';
558 if ($nb_bills_created == 1) {
559 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
560 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
563 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created), null,
'mesgs');
568 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
569 $param .=
'&contextpage='.urlencode($contextpage);
571 if ($limit > 0 && $limit != $conf->liste_limit) {
572 $param .=
'&limit='.urlencode($limit);
575 $param .=
'&sall='.urlencode($sall);
578 $param .=
'&socid='.urlencode($socid);
580 if ($search_status !=
'') {
581 $param .=
'&search_status='.urlencode($search_status);
583 if ($search_orderday) {
584 $param .=
'&search_orderday='.urlencode($search_orderday);
586 if ($search_ordermonth) {
587 $param .=
'&search_ordermonth='.urlencode($search_ordermonth);
589 if ($search_orderyear) {
590 $param .=
'&search_orderyear='.urlencode($search_orderyear);
592 if ($search_deliveryday) {
593 $param .=
'&search_deliveryday='.urlencode($search_deliveryday);
595 if ($search_deliverymonth) {
596 $param .=
'&search_deliverymonth='.urlencode($search_deliverymonth);
598 if ($search_deliveryyear) {
599 $param .=
'&search_deliveryyear='.urlencode($search_deliveryyear);
602 $param .=
'&search_ref='.urlencode($search_ref);
604 if ($search_company) {
605 $param .=
'&search_company='.urlencode($search_company);
607 if ($search_ref_customer) {
608 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
610 if ($search_user > 0) {
611 $param .=
'&search_user='.urlencode($search_user);
613 if ($search_sale > 0) {
614 $param .=
'&search_sale='.urlencode($search_sale);
616 if ($search_total_ht !=
'') {
617 $param .=
'&search_total_ht='.urlencode($search_total_ht);
619 if ($search_total_vat !=
'') {
620 $param .=
'&search_total_vat='.urlencode($search_total_vat);
622 if ($search_total_ttc !=
'') {
623 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
625 if ($search_project_ref >= 0) {
626 $param .=
"&search_project_ref=".urlencode($search_project_ref);
629 $param .=
'&show_files='.urlencode($show_files);
631 if ($optioncss !=
'') {
632 $param .=
'&optioncss='.urlencode($optioncss);
635 $param .=
'&billed='.urlencode($billed);
638 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?'.$param);
644 $_GET[
"origin"] = $_POST[
"origin"];
645 $_GET[
"originid"] = $_POST[
"originid"];
646 if (!empty($errors)) {
655 if ($action ==
'validate' && $permissiontoadd) {
656 if (
GETPOST(
'confirm') ==
'yes') {
657 $objecttmp =
new $objectclass($db);
660 foreach ($toselect as $checked) {
661 if ($objecttmp->fetch($checked)) {
662 if ($objecttmp->statut == 0) {
663 if (!empty($objecttmp->fk_warehouse)) {
664 $idwarehouse = $objecttmp->fk_warehouse;
668 if ($objecttmp->valid($user, $idwarehouse)) {
669 setEventMessage($langs->trans(
'hasBeenValidated', $objecttmp->ref),
'mesgs');
675 $langs->load(
"errors");
676 setEventMessage($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
'errors');
691 if ($action ==
'shipped' && $permissiontoadd) {
692 if (
GETPOST(
'confirm') ==
'yes') {
693 $objecttmp =
new $objectclass($db);
696 foreach ($toselect as $checked) {
697 if ($objecttmp->fetch($checked)) {
698 if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
699 if ($objecttmp->cloture($user)) {
700 setEventMessage($langs->trans(
'PassedInClosedStatus', $objecttmp->ref),
'mesgs');
706 $langs->load(
"errors");
707 setEventMessage($langs->trans(
'ErrorIsNotADraft', $objecttmp->ref),
'errors');
723 if (!$error && $massaction ===
'setbilled' && $permissiontoclose) {
726 $objecttmp =
new $objectclass($db);
728 foreach ($toselect as $toselectid) {
729 $result = $objecttmp->fetch($toselectid);
731 $result = $objecttmp->classifyBilled($user, 0);
768 if (!empty($conf->margin->enabled)) {
771 $companystatic =
new Societe($db);
773 $projectstatic =
new Project($db);
775 $title = $langs->trans(
"Orders");
776 $help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
780 if ($sall || $search_product_category > 0 || $search_user > 0) {
781 $sql =
'SELECT DISTINCT';
783 $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,';
784 $sql .=
" typent.code as typent_code,";
785 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
786 $sql .=
" country.code as country_code,";
787 $sql .=
' c.rowid, c.ref, c.total_ht, c.total_tva, c.total_ttc, c.ref_client, c.fk_user_author,';
788 $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,';
789 $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,';
790 $sql .=
' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
791 $sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
792 $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,';
793 $sql .=
' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,';
794 $sql .=
' c.fk_input_reason, c.import_key';
795 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
796 $sql .=
", cc.fk_categorie, cc.fk_soc";
799 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
800 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
801 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
805 $parameters = array();
806 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
807 $sql .= $hookmanager->resPrint;
808 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
809 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
810 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
811 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
812 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
813 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_societe as cc ON s.rowid = cc.fk_soc";
815 $sql .=
', '.MAIN_DB_PREFIX.
'commande as c';
816 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
817 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande_extrafields as ef on (c.rowid = ef.fk_object)";
819 if ($sall || $search_product_category > 0) {
820 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commandedet as pd ON c.rowid=pd.fk_commande';
822 if ($search_product_category > 0) {
823 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=pd.fk_product';
825 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = c.fk_projet";
826 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON c.fk_user_author = u.rowid';
829 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
830 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
832 if ($search_user > 0) {
833 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
834 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
838 $parameters = array();
839 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
840 $sql .= $hookmanager->resPrint;
842 $sql .=
' WHERE c.fk_soc = s.rowid';
843 $sql .=
' AND c.entity IN ('.getEntity(
'commande').
')';
844 if ($search_product_category > 0) {
845 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
848 $sql .=
' AND s.rowid = '.((int) $socid);
850 if (empty($user->rights->societe->client->voir) && !$socid) {
851 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
856 if ($search_ref_customer) {
862 if ($search_billed !=
'' && $search_billed >= 0) {
863 $sql .=
' AND c.facture = '.((int) $search_billed);
865 if ($search_status <>
'') {
866 if ($search_status <= 3 && $search_status >= -1) {
867 if ($search_status == 1 && empty($conf->expedition->enabled)) {
868 $sql .=
' AND c.fk_statut IN (1,2)';
870 $sql .=
' AND c.fk_statut = '.((int) $search_status);
873 if ($search_status == -2) {
875 $sql .=
" AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
877 if ($search_status == -3) {
880 $sql .=
' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))';
882 if ($search_status == -4) {
883 $sql .=
' AND (c.fk_statut IN (1,2))';
887 if ($search_datecloture_start) {
888 $sql .=
" AND c.date_cloture >= '".$db->idate($search_datecloture_start).
"'";
890 if ($search_datecloture_end) {
891 $sql .=
" AND c.date_cloture <= '".$db->idate($search_datecloture_end).
"'";
893 if ($search_dateorder_start) {
894 $sql .=
" AND c.date_commande >= '".$db->idate($search_dateorder_start).
"'";
896 if ($search_dateorder_end) {
897 $sql .=
" AND c.date_commande <= '".$db->idate($search_dateorder_end).
"'";
899 if ($search_datedelivery_start) {
900 $sql .=
" AND c.date_livraison >= '".$db->idate($search_datedelivery_start).
"'";
902 if ($search_datedelivery_end) {
903 $sql .=
" AND c.date_livraison <= '".$db->idate($search_datedelivery_end).
"'";
914 if ($search_country) {
915 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
917 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
918 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
920 if ($search_company) {
923 if ($search_company_alias) {
926 if ($search_sale > 0) {
927 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
929 if ($search_user > 0) {
930 $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);
932 if ($search_total_ht !=
'') {
935 if ($search_total_vat !=
'') {
938 if ($search_total_ttc !=
'') {
941 if ($search_warehouse !=
'' && $search_warehouse > 0) {
944 if ($search_multicurrency_code !=
'') {
945 $sql .=
" AND c.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
947 if ($search_multicurrency_tx !=
'') {
948 $sql .=
natural_search(
'c.multicurrency_tx', $search_multicurrency_tx, 1);
950 if ($search_multicurrency_montant_ht !=
'') {
951 $sql .=
natural_search(
'c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
953 if ($search_multicurrency_montant_vat !=
'') {
954 $sql .=
natural_search(
'c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
956 if ($search_multicurrency_montant_ttc !=
'') {
957 $sql .=
natural_search(
'c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
960 $sql .=
natural_search(array(
"u.login",
"u.firstname",
"u.lastname"), $search_login);
962 if ($search_project_ref !=
'') {
965 if ($search_project !=
'') {
968 if ($search_categ_cus > 0) {
969 $sql .=
" AND cc.fk_categorie = ".((int) $search_categ_cus);
971 if ($search_categ_cus == -2) {
972 $sql .=
" AND cc.fk_categorie IS NULL";
974 if ($search_fk_cond_reglement > 0) {
975 $sql .=
" AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement);
977 if ($search_fk_shipping_method > 0) {
978 $sql .=
" AND c.fk_shipping_method = ".((int) $search_fk_shipping_method);
980 if ($search_fk_mode_reglement > 0) {
981 $sql .=
" AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement);
983 if ($search_fk_input_reason > 0) {
984 $sql .=
" AND c.fk_input_reason = ".((int) $search_fk_input_reason);
988 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
990 $parameters = array();
991 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
992 $sql .= $hookmanager->resPrint;
995 $parameters = array();
996 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
997 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
999 $sql .= $db->order($sortfield, $sortorder);
1002 $nbtotalofrecords =
'';
1003 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1004 $result = $db->query($sql);
1005 $nbtotalofrecords = $db->num_rows($result);
1007 if (($page * $limit) > $nbtotalofrecords) {
1013 $sql .= $db->plimit($limit + 1, $offset);
1016 $resql = $db->query($sql);
1020 $soc->fetch($socid);
1021 $title = $langs->trans(
'CustomersOrders').
' - '.$soc->name;
1022 if (empty($search_company)) {
1023 $search_company = $soc->name;
1026 $title = $langs->trans(
'CustomersOrders');
1028 if (strval($search_status) ==
'0') {
1029 $title .=
' - '.$langs->trans(
'StatusOrderDraftShort');
1031 if ($search_status == 1) {
1032 $title .=
' - '.$langs->trans(
'StatusOrderValidatedShort');
1034 if ($search_status == 2) {
1035 $title .=
' - '.$langs->trans(
'StatusOrderSentShort');
1037 if ($search_status == 3) {
1038 $title .=
' - '.$langs->trans(
'StatusOrderToBillShort');
1040 if ($search_status == -1) {
1041 $title .=
' - '.$langs->trans(
'StatusOrderCanceledShort');
1043 if ($search_status == -2) {
1044 $title .=
' - '.$langs->trans(
'StatusOrderToProcessShort');
1046 if ($search_status == -3) {
1047 $title .=
' - '.$langs->trans(
'StatusOrderValidated').
', '.(empty($conf->expedition->enabled) ?
'' : $langs->trans(
"StatusOrderSent").
', ').$langs->trans(
'StatusOrderToBill');
1049 if ($search_status == -4) {
1050 $title .=
' - '.$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort");
1053 $num = $db->num_rows(
$resql);
1055 $arrayofselected = is_array($toselect) ? $toselect : array();
1057 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) {
1058 $obj = $db->fetch_object(
$resql);
1060 header(
"Location: ".DOL_URL_ROOT.
'/commande/card.php?id='.$id);
1068 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1069 $param .=
'&contextpage='.urlencode($contextpage);
1071 if ($limit > 0 && $limit != $conf->liste_limit) {
1072 $param .=
'&limit='.urlencode($limit);
1075 $param .=
'&sall='.urlencode($sall);
1078 $param .=
'&socid='.urlencode($socid);
1080 if ($search_status !=
'') {
1081 $param .=
'&search_status='.urlencode($search_status);
1083 if ($search_datecloture_start) {
1084 $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');
1086 if ($search_datecloture_end) {
1087 $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');
1089 if ($search_dateorder_start) {
1090 $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');
1092 if ($search_dateorder_end) {
1093 $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');
1095 if ($search_datedelivery_start) {
1096 $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');
1098 if ($search_datedelivery_end) {
1099 $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');
1102 $param .=
'&search_ref='.urlencode($search_ref);
1104 if ($search_company) {
1105 $param .=
'&search_company='.urlencode($search_company);
1107 if ($search_company_alias) {
1108 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1110 if ($search_ref_customer) {
1111 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
1113 if ($search_user > 0) {
1114 $param .=
'&search_user='.urlencode($search_user);
1116 if ($search_sale > 0) {
1117 $param .=
'&search_sale='.urlencode($search_sale);
1119 if ($search_total_ht !=
'') {
1120 $param .=
'&search_total_ht='.urlencode($search_total_ht);
1122 if ($search_total_vat !=
'') {
1123 $param .=
'&search_total_vat='.urlencode($search_total_vat);
1125 if ($search_total_ttc !=
'') {
1126 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
1128 if ($search_warehouse !=
'') {
1129 $param .=
'&search_warehouse='.urlencode($search_warehouse);
1131 if ($search_login) {
1132 $param .=
'&search_login='.urlencode($search_login);
1134 if ($search_multicurrency_code !=
'') {
1135 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1137 if ($search_multicurrency_tx !=
'') {
1138 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1140 if ($search_multicurrency_montant_ht !=
'') {
1141 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1143 if ($search_multicurrency_montant_vat !=
'') {
1144 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1146 if ($search_multicurrency_montant_ttc !=
'') {
1147 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1149 if ($search_project_ref >= 0) {
1150 $param .=
"&search_project_ref=".urlencode($search_project_ref);
1152 if ($search_town !=
'') {
1153 $param .=
'&search_town='.urlencode($search_town);
1155 if ($search_zip !=
'') {
1156 $param .=
'&search_zip='.urlencode($search_zip);
1158 if ($search_state !=
'') {
1159 $param .=
'&search_state='.urlencode($search_state);
1161 if ($search_country !=
'') {
1162 $param .=
'&search_country='.urlencode($search_country);
1164 if ($search_type_thirdparty && $search_type_thirdparty !=
'-1') {
1165 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1167 if ($search_product_category !=
'') {
1168 $param .=
'&search_product_category='.urlencode($search_product_category);
1170 if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
1171 $param .=
'&search_categ_cus='.urlencode($search_categ_cus);
1174 $param .=
'&show_files='.urlencode($show_files);
1176 if ($optioncss !=
'') {
1177 $param .=
'&optioncss='.urlencode($optioncss);
1179 if ($search_billed !=
'') {
1180 $param .=
'&search_billed='.urlencode($search_billed);
1182 if ($search_fk_cond_reglement > 0) {
1183 $param .=
'&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement);
1185 if ($search_fk_shipping_method > 0) {
1186 $param .=
'&search_fk_shipping_method='.urlencode($search_fk_shipping_method);
1188 if ($search_fk_mode_reglement > 0) {
1189 $param .=
'&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement);
1191 if ($search_fk_input_reason > 0) {
1192 $param .=
'&search_fk_input_reason='.urlencode($search_fk_input_reason);
1196 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1199 $parameters = array();
1200 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
1201 $param .= $hookmanager->resPrint;
1204 $arrayofmassactions = array(
1205 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1206 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1208 if ($permissiontovalidate) {
1209 $arrayofmassactions[
'prevalidate'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate");
1211 if ($permissiontosendbymail) {
1212 $arrayofmassactions[
'presend'] =
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail");
1214 if ($permissiontoclose) {
1215 $arrayofmassactions[
'preshipped'] =
img_picto(
'',
'dollyrevert',
'class="pictofixedwidth"').$langs->trans(
"ClassifyShipped");
1217 if ($permissiontocancel) {
1218 $arrayofmassactions[
'cancelorders'] =
img_picto(
'',
'close_title',
'class="pictofixedwidth"').$langs->trans(
"Cancel");
1220 if ($user->rights->facture->creer) {
1221 $arrayofmassactions[
'createbills'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"CreateInvoiceForThisCustomer");
1223 if ($permissiontoclose) {
1224 $arrayofmassactions[
'setbilled'] =
img_picto(
'',
'bill',
'class="pictofixedwidth"').$langs->trans(
"ClassifyBilled");
1226 if ($permissiontodelete) {
1227 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1229 if (in_array($massaction, array(
'presend',
'predelete',
'createbills'))) {
1230 $arrayofmassactions = array();
1232 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
1234 $url = DOL_URL_ROOT.
'/commande/card.php?action=create';
1235 if (!empty($socid)) {
1236 $url .=
'&socid='.$socid;
1238 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewOrder'),
'',
'fa fa-plus-circle', $url,
'', $contextpage ==
'orderlist' && $permissiontoadd);
1241 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
1242 if ($optioncss !=
'') {
1243 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1245 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1246 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1247 print
'<input type="hidden" name="action" value="list">';
1248 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1249 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1250 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1251 print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1252 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1254 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'order', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1256 $topicmail =
"SendOrderRef";
1257 $modelmail =
"order_send";
1259 $trackid =
'ord'.$object->id;
1260 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1262 if ($massaction ==
'prevalidate') {
1263 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassValidation"), $langs->trans(
"ConfirmMassValidationQuestion"),
"validate", null,
'', 0, 200, 500, 1);
1265 if ($massaction ==
'preshipped') {
1266 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"CloseOrder"), $langs->trans(
"ConfirmCloseOrder"),
"shipped", null,
'', 0, 200, 500, 1);
1269 if ($massaction ==
'createbills') {
1270 print
'<input type="hidden" name="massaction" value="confirm_createbills">';
1272 print
'<table class="noborder" width="100%" >';
1274 print
'<td class="titlefield">';
1275 print $langs->trans(
'DateInvoice');
1278 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
1283 print $langs->trans(
'CreateOneBillByThird');
1286 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
1291 print $langs->trans(
'ValidateInvoices');
1294 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
1295 print
$form->selectyesno(
'validate_invoices', 0, 1, 1);
1296 $langs->load(
"errors");
1297 print
' ('.$langs->trans(
"WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").
')';
1299 print
$form->selectyesno(
'validate_invoices', 0, 1);
1301 if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) {
1302 print
' <span class="opacitymedium">'.$langs->trans(
"IfValidateInvoiceIsNoOrderStayUnbilled").
'</span>';
1304 print
' <span class="opacitymedium">'.$langs->trans(
"OptionToSetOrderBilledNotEnabled").
'</span>';
1311 print
'<div class="center">';
1312 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisCustomer').
'"> ';
1313 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1319 foreach ($fieldstosearchall as $key => $val) {
1320 $fieldstosearchall[$key] = $langs->trans($val);
1322 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
1325 $moreforfilter =
'';
1328 if ($user->rights->user->user->lire) {
1329 $langs->load(
"commercial");
1330 $moreforfilter .=
'<div class="divsearchfield">';
1331 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1332 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth250 widthcentpercentminusx');
1333 $moreforfilter .=
'</div>';
1336 if ($user->rights->user->user->lire) {
1337 $moreforfilter .=
'<div class="divsearchfield">';
1338 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1339 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth250 widthcentpercentminusx');
1340 $moreforfilter .=
'</div>';
1343 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
1344 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1345 $moreforfilter .=
'<div class="divsearchfield">';
1346 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1347 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT, null,
'parent', null, null, 1);
1348 $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);
1349 $moreforfilter .=
'</div>';
1351 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
1352 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1353 $moreforfilter .=
'<div class="divsearchfield">';
1354 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1355 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle,
'maxwidth300 widthcentpercentminusx');
1356 $moreforfilter .=
'</div>';
1358 if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1359 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1361 $moreforfilter .=
'<div class="divsearchfield">';
1362 $tmptitle = $langs->trans(
'Warehouse');
1363 $moreforfilter .=
img_picto($tmptitle,
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse,
'search_warehouse',
'', 1, 0, 0, $tmptitle, 0, 0, array(),
'maxwidth250 widthcentpercentminusx');
1364 $moreforfilter .=
'</div>';
1366 $parameters = array();
1367 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1368 if (empty($reshook)) {
1369 $moreforfilter .= $hookmanager->resPrint;
1371 $moreforfilter = $hookmanager->resPrint;
1374 if (!empty($moreforfilter)) {
1375 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1376 print $moreforfilter;
1380 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1381 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1382 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1384 if (
GETPOST(
'autoselectall',
'int')) {
1385 $selectedfields .=
'<script>';
1386 $selectedfields .=
' $(document).ready(function() {';
1387 $selectedfields .=
' console.log("Autoclick on checkforselects");';
1388 $selectedfields .=
' $("#checkforselects").click();';
1389 $selectedfields .=
' $("#massaction").val("createbills").change();';
1390 $selectedfields .=
' });';
1391 $selectedfields .=
'</script>';
1394 print
'<div class="div-table-responsive">';
1395 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1397 print
'<tr class="liste_titre_filter">';
1399 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1400 print
'<td class="liste_titre">';
1401 print
'<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1405 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1406 print
'<td class="liste_titre" align="left">';
1407 print
'<input class="flat" type="text" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
1411 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1412 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1415 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1416 print
'<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1419 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1420 print
'<td class="liste_titre" align="left">';
1421 print
'<input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
1425 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1426 print
'<td class="liste_titre" align="left">';
1427 print
'<input class="flat maxwidth100" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'">';
1431 if (!empty($arrayfields[
's.town'][
'checked'])) {
1432 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1435 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1436 print
'<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1439 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1440 print
'<td class="liste_titre">';
1441 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1445 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1446 print
'<td class="liste_titre" align="center">';
1447 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1451 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1452 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1453 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);
1457 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1458 print
'<td class="liste_titre center">';
1459 print
'<div class="nowrap">';
1460 print
$form->selectDate($search_dateorder_start ? $search_dateorder_start : -1,
'search_dateorder_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1462 print
'<div class="nowrap">';
1463 print
$form->selectDate($search_dateorder_end ? $search_dateorder_end : -1,
'search_dateorder_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1467 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1468 print
'<td class="liste_titre center">';
1469 print
'<div class="nowrap">';
1470 print
$form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1,
'search_datedelivery_start_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1472 print
'<div class="nowrap">';
1473 print
$form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1,
'search_datedelivery_end_', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1478 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1479 print
'<td class="liste_titre">';
1480 $form->selectShippingMethod($search_fk_shipping_method,
'search_fk_shipping_method',
'', 1,
'', 1);
1484 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1485 print
'<td class="liste_titre">';
1486 $form->select_conditions_paiements($search_fk_cond_reglement,
'search_fk_cond_reglement', 1, 1, 1);
1490 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1491 print
'<td class="liste_titre">';
1492 $form->select_types_paiements($search_fk_mode_reglement,
'search_fk_mode_reglement',
'', 0, 1, 1, 0, -1);
1496 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1497 print
'<td class="liste_titre">';
1498 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1501 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1503 print
'<td class="liste_titre right">';
1504 print
'<input class="flat" type="text" size="4" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
1507 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1509 print
'<td class="liste_titre right">';
1510 print
'<input class="flat" type="text" size="4" name="search_total_vat" value="'.dol_escape_htmltag($search_total_vat).
'">';
1513 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1515 print
'<td class="liste_titre right">';
1516 print
'<input class="flat" type="text" size="5" name="search_total_ttc" value="'.$search_total_ttc.
'">';
1519 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1521 print
'<td class="liste_titre">';
1522 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1525 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1527 print
'<td class="liste_titre">';
1528 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1531 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1533 print
'<td class="liste_titre right">';
1534 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1537 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1539 print
'<td class="liste_titre right">';
1540 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1543 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1545 print
'<td class="liste_titre right">';
1546 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1549 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1551 print
'<td class="liste_titre" align="center">';
1552 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1555 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1556 print
'<td class="liste_titre"></td>';
1558 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1559 print
'<td class="liste_titre right">';
1562 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1563 print
'<td class="liste_titre right">';
1566 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1567 print
'<td class="liste_titre right">';
1570 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1571 print
'<td class="liste_titre right">';
1575 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1577 $parameters = array(
'arrayfields'=>$arrayfields);
1578 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
1579 print $hookmanager->resPrint;
1581 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1582 print
'<td class="liste_titre">';
1586 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1587 print
'<td class="liste_titre">';
1591 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1592 print
'<td class="liste_titre center">';
1593 print
'<div class="nowrap">';
1594 print
$form->selectDate($search_datecloture_start ? $search_datecloture_start : -1,
'search_datecloture_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1596 print
'<div class="nowrap">';
1597 print
$form->selectDate($search_datecloture_end ? $search_datecloture_end : -1,
'search_datecloture_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1602 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1603 print
'<td class="liste_titre">';
1607 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1608 print
'<td class="liste_titre">';
1612 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1613 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1615 if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) {
1616 print
'<input type="checkbox" name="show_shippable_command" value="1"'.($show_shippable_command ?
' checked' :
'').
'>';
1617 print $langs->trans(
'ShowShippableStatus');
1619 $show_shippable_command = 1;
1624 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1625 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1626 print
$form->selectyesno(
'search_billed', $search_billed, 1, 0, 1, 1);
1630 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1631 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1635 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1636 print
'<td class="liste_titre maxwidthonsmartphone center">';
1637 $liststatus = array(
1642 -3=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort").
'+'.$langs->trans(
"StatusOrderDelivered"),
1643 -2=>$langs->trans(
"StatusOrderValidatedShort").
'+'.$langs->trans(
"StatusOrderSentShort"),
1646 print
$form->selectarray(
'search_status', $liststatus, $search_status, -5, 0, 0,
'', 0, 0, 0,
'',
'maxwidth125', 1);
1650 print
'<td class="liste_titre" align="middle">';
1651 $searchpicto =
$form->showFilterButtons();
1658 print
'<tr class="liste_titre">';
1659 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1660 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref',
'', $param,
'', $sortfield, $sortorder);
1662 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1663 print_liste_field_titre($arrayfields[
'c.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'c.ref_client',
'', $param,
'', $sortfield, $sortorder);
1665 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1666 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
1668 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1669 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
"PHP_SELF"],
"p.title",
"", $param,
'', $sortfield, $sortorder);
1671 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1672 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1674 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1675 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1677 if (!empty($arrayfields[
's.town'][
'checked'])) {
1678 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1680 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1681 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1683 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1684 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1686 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1687 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1689 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1690 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1692 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
1693 print_liste_field_titre($arrayfields[
'c.date_commande'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_commande',
'', $param,
'', $sortfield, $sortorder,
'center ');
1695 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
1696 print_liste_field_titre($arrayfields[
'c.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
'c.date_livraison',
'', $param,
'', $sortfield, $sortorder,
'center ');
1698 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
1699 print_liste_field_titre($arrayfields[
'c.fk_shipping_method'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_shipping_method",
"", $param,
'', $sortfield, $sortorder);
1701 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
1702 print_liste_field_titre($arrayfields[
'c.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_cond_reglement",
"", $param,
'', $sortfield, $sortorder);
1704 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
1705 print_liste_field_titre($arrayfields[
'c.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_mode_reglement",
"", $param,
'', $sortfield, $sortorder);
1707 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
1708 print_liste_field_titre($arrayfields[
'c.fk_input_reason'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_input_reason",
"", $param,
'', $sortfield, $sortorder);
1710 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
1711 print_liste_field_titre($arrayfields[
'c.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1713 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
1714 print_liste_field_titre($arrayfields[
'c.total_vat'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1716 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
1717 print_liste_field_titre($arrayfields[
'c.total_ttc'][
'label'], $_SERVER[
"PHP_SELF"],
'c.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1719 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
1720 print_liste_field_titre($arrayfields[
'c.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1722 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
1723 print_liste_field_titre($arrayfields[
'c.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1725 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
1726 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1728 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
1729 print_liste_field_titre($arrayfields[
'c.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1731 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
1732 print_liste_field_titre($arrayfields[
'c.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'c.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1734 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1735 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1737 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1738 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1740 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1741 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1743 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1744 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1746 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1747 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1749 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1750 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1753 $totalarray = array(
1763 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1765 $parameters = array(
1766 'arrayfields' => $arrayfields,
1768 'sortfield' => $sortfield,
1769 'sortorder' => $sortorder,
1770 'totalarray' => &$totalarray,
1772 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1773 print $hookmanager->resPrint;
1774 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1775 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1777 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1778 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1780 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
1781 print_liste_field_titre($arrayfields[
'c.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1783 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
1784 print_liste_field_titre($arrayfields[
'c.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_public",
"", $param,
'', $sortfield, $sortorder,
'right ');
1786 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
1787 print_liste_field_titre($arrayfields[
'c.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"c.note_private",
"", $param,
'', $sortfield, $sortorder,
'right ');
1789 if (!empty($arrayfields[
'shippable'][
'checked'])) {
1790 print_liste_field_titre($arrayfields[
'shippable'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
1792 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
1793 print_liste_field_titre($arrayfields[
'c.facture'][
'label'], $_SERVER[
"PHP_SELF"],
'c.facture',
'', $param,
'', $sortfield, $sortorder,
'center ');
1795 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
1796 print_liste_field_titre($arrayfields[
'c.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"c.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1798 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
1799 print_liste_field_titre($arrayfields[
'c.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"c.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
1801 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1806 $productstat_cache = array();
1807 $productstat_cachevirtual = array();
1808 $getNomUrl_cache = array();
1810 $generic_commande =
new Commande($db);
1811 $generic_product =
new Product($db);
1812 $userstatic =
new User($db);
1815 $with_margin_info =
false;
1816 if (!empty($conf->margin->enabled) && (
1817 !empty($arrayfields[
'total_pa'][
'checked'])
1818 || !empty($arrayfields[
'total_margin'][
'checked'])
1819 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1820 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1823 $with_margin_info =
true;
1828 $imaxinloop = ($limit ? min($num, $limit) : $num);
1829 $last_num = min($num, $limit);
1830 while ($i < $imaxinloop) {
1831 $obj = $db->fetch_object(
$resql);
1839 $companystatic->id = $obj->socid;
1840 $companystatic->name = $obj->name;
1841 $companystatic->name_alias = $obj->alias;
1842 $companystatic->client = $obj->client;
1843 $companystatic->code_client = $obj->code_client;
1844 $companystatic->email = $obj->email;
1845 $companystatic->phone = $obj->phone;
1846 $companystatic->address = $obj->address;
1847 $companystatic->zip = $obj->zip;
1848 $companystatic->town = $obj->town;
1849 $companystatic->country_code = $obj->country_code;
1850 if (!isset($getNomUrl_cache[$obj->socid])) {
1851 $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1,
'customer');
1854 $generic_commande->id = $obj->rowid;
1855 $generic_commande->ref = $obj->ref;
1856 $generic_commande->statut = $obj->fk_statut;
1857 $generic_commande->billed = $obj->billed;
1858 $generic_commande->date = $db->jdate($obj->date_commande);
1859 $generic_commande->date_livraison = $db->jdate($obj->date_delivery);
1860 $generic_commande->delivery_date = $db->jdate($obj->date_delivery);
1861 $generic_commande->ref_client = $obj->ref_client;
1862 $generic_commande->total_ht = $obj->total_ht;
1863 $generic_commande->total_tva = $obj->total_tva;
1864 $generic_commande->total_ttc = $obj->total_ttc;
1865 $generic_commande->note_public = $obj->note_public;
1866 $generic_commande->note_private = $obj->note_private;
1868 $projectstatic->id = $obj->project_id;
1869 $projectstatic->ref = $obj->project_ref;
1870 $projectstatic->title = $obj->project_label;
1872 $marginInfo = array();
1873 if ($with_margin_info ===
true) {
1874 $generic_commande->fetch_lines();
1875 $marginInfo = $formmargin->getMarginInfosArray($generic_commande);
1876 $total_ht += $obj->total_ht;
1877 $total_margin += $marginInfo[
'total_margin'];
1880 print
'<tr class="oddeven">';
1883 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1884 print
'<td class="nowraponall">';
1885 print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
1888 $filedir = $conf->commande->multidir_output[$conf->entity].
'/'.
dol_sanitizeFileName($obj->ref);
1889 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1890 print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
1894 $totalarray[
'nbfield']++;
1899 if (!empty($arrayfields[
'c.ref_client'][
'checked'])) {
1900 print
'<td class="nowrap tdoverflowmax200">'.$obj->ref_client.
'</td>';
1902 $totalarray[
'nbfield']++;
1907 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1908 print
'<td class="nowrap">';
1909 if ($obj->project_id > 0) {
1910 print $projectstatic->getNomUrl(1);
1914 $totalarray[
'nbfield']++;
1919 if (!empty($arrayfields[
'p.title'][
'checked'])) {
1920 print
'<td class="nowrap">';
1921 if ($obj->project_id > 0) {
1922 print $projectstatic->title;
1926 $totalarray[
'nbfield']++;
1931 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1932 print
'<td class="tdoverflowmax200">';
1933 print $getNomUrl_cache[$obj->socid];
1936 if (
isModEnabled(
'facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) {
1937 if ($user->rights->facture->creer) {
1938 if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) {
1939 print
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$companystatic->id.
'&search_billed=0&autoselectall=1">';
1940 print
img_picto($langs->trans(
"CreateInvoiceForThisCustomer").
' : '.$companystatic->name,
'object_bill',
'hideonsmartphone').
'</a>';
1946 $totalarray[
'nbfield']++;
1950 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1951 print
'<td class="nocellnopadd">';
1955 $totalarray[
'nbfield']++;
1959 if (!empty($arrayfields[
's.town'][
'checked'])) {
1960 print
'<td class="nocellnopadd">';
1964 $totalarray[
'nbfield']++;
1968 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1969 print
'<td class="nocellnopadd">';
1973 $totalarray[
'nbfield']++;
1977 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1978 print
"<td>".$obj->state_name.
"</td>\n";
1980 $totalarray[
'nbfield']++;
1984 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1985 print
'<td class="center">';
1986 $tmparray =
getCountry($obj->fk_pays,
'all');
1987 print $tmparray[
'label'];
1990 $totalarray[
'nbfield']++;
1994 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1995 print
'<td class="center">';
1996 if (empty($typenArray)) {
1997 $typenArray = $formcompany->typent_array(1);
1999 print $typenArray[$obj->typent_code];
2002 $totalarray[
'nbfield']++;
2007 if (!empty($arrayfields[
'c.date_commande'][
'checked'])) {
2008 print
'<td class="center">';
2011 if ($generic_commande->hasDelay()) {
2012 print
img_picto($langs->trans(
"Late").
' : '.$generic_commande->showDelay(),
"warning");
2016 $totalarray[
'nbfield']++;
2020 if (!empty($arrayfields[
'c.date_delivery'][
'checked'])) {
2021 print
'<td class="center">';
2022 print
dol_print_date($db->jdate($obj->date_delivery),
'dayhour');
2025 $totalarray[
'nbfield']++;
2029 if (!empty($arrayfields[
'c.fk_shipping_method'][
'checked'])) {
2031 $form->formSelectShippingMethod(
'', $obj->fk_shipping_method,
'none', 1);
2034 $totalarray[
'nbfield']++;
2038 if (!empty($arrayfields[
'c.fk_cond_reglement'][
'checked'])) {
2040 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', 1, $obj->deposit_percent);
2043 $totalarray[
'nbfield']++;
2047 if (!empty($arrayfields[
'c.fk_mode_reglement'][
'checked'])) {
2049 $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1);
2052 $totalarray[
'nbfield']++;
2056 if (!empty($arrayfields[
'c.fk_input_reason'][
'checked'])) {
2058 $form->formInputReason($_SERVER[
'PHP_SELF'], $obj->fk_input_reason,
'none',
'');
2061 $totalarray[
'nbfield']++;
2065 if (!empty($arrayfields[
'c.total_ht'][
'checked'])) {
2066 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2068 $totalarray[
'nbfield']++;
2071 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ht';
2073 if (isset($totalarray[
'val'][
'c.total_ht'])) {
2074 $totalarray[
'val'][
'c.total_ht'] += $obj->total_ht;
2076 $totalarray[
'val'][
'c.total_ht'] = $obj->total_ht;
2080 if (!empty($arrayfields[
'c.total_vat'][
'checked'])) {
2081 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_tva).
"</span></td>\n";
2083 $totalarray[
'nbfield']++;
2086 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_tva';
2088 $totalarray[
'val'][
'c.total_tva'] += $obj->total_tva;
2091 if (!empty($arrayfields[
'c.total_ttc'][
'checked'])) {
2092 print
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2094 $totalarray[
'nbfield']++;
2097 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'c.total_ttc';
2099 $totalarray[
'val'][
'c.total_ttc'] += $obj->total_ttc;
2103 if (!empty($arrayfields[
'c.multicurrency_code'][
'checked'])) {
2104 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2106 $totalarray[
'nbfield']++;
2111 if (!empty($arrayfields[
'c.multicurrency_tx'][
'checked'])) {
2112 print
'<td class="nowrap">';
2113 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2116 $totalarray[
'nbfield']++;
2120 if (!empty($arrayfields[
'c.multicurrency_total_ht'][
'checked'])) {
2121 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2123 $totalarray[
'nbfield']++;
2127 if (!empty($arrayfields[
'c.multicurrency_total_vat'][
'checked'])) {
2128 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
2130 $totalarray[
'nbfield']++;
2134 if (!empty($arrayfields[
'c.multicurrency_total_ttc'][
'checked'])) {
2135 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2137 $totalarray[
'nbfield']++;
2141 $userstatic->id = $obj->fk_user_author;
2142 $userstatic->login = $obj->login;
2143 $userstatic->lastname = $obj->lastname;
2144 $userstatic->firstname = $obj->firstname;
2145 $userstatic->email = $obj->user_email;
2146 $userstatic->statut = $obj->user_statut;
2147 $userstatic->entity = $obj->entity;
2148 $userstatic->photo = $obj->photo;
2149 $userstatic->office_phone = $obj->office_phone;
2150 $userstatic->office_fax = $obj->office_fax;
2151 $userstatic->user_mobile = $obj->user_mobile;
2152 $userstatic->job = $obj->job;
2153 $userstatic->gender = $obj->gender;
2156 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2157 print
'<td class="tdoverflowmax200">';
2158 if ($userstatic->id) {
2159 print $userstatic->getNomUrl(-1);
2165 $totalarray[
'nbfield']++;
2169 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2172 if ($obj->socid > 0) {
2173 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2174 if ($listsalesrepresentatives < 0) {
2177 $nbofsalesrepresentative = count($listsalesrepresentatives);
2178 if ($nbofsalesrepresentative > 6) {
2180 print $nbofsalesrepresentative;
2181 } elseif ($nbofsalesrepresentative > 0) {
2183 foreach ($listsalesrepresentatives as $val) {
2184 $userstatic->id = $val[
'id'];
2185 $userstatic->lastname = $val[
'lastname'];
2186 $userstatic->firstname = $val[
'firstname'];
2187 $userstatic->email = $val[
'email'];
2188 $userstatic->statut = $val[
'statut'];
2189 $userstatic->entity = $val[
'entity'];
2190 $userstatic->photo = $val[
'photo'];
2191 $userstatic->login = $val[
'login'];
2192 $userstatic->office_phone = $val[
'office_phone'];
2193 $userstatic->office_fax = $val[
'office_fax'];
2194 $userstatic->user_mobile = $val[
'user_mobile'];
2195 $userstatic->job = $val[
'job'];
2196 $userstatic->gender = $val[
'gender'];
2198 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2200 if ($j < $nbofsalesrepresentative) {
2212 $totalarray[
'nbfield']++;
2217 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2218 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total']).
'</td>';
2220 $totalarray[
'nbfield']++;
2224 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2225 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin']).
'</td>';
2227 $totalarray[
'nbfield']++;
2230 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2232 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2235 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2236 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], null, null, null, null, 2).
'%').
'</td>';
2238 $totalarray[
'nbfield']++;
2242 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2243 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], null, null, null, null, 2).
'%').
'</td>';
2245 $totalarray[
'nbfield']++;
2248 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2250 if ($i >= $last_num - 1) {
2251 if (!empty($total_ht)) {
2252 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2254 $totalarray[
'val'][
'total_mark_rate'] =
'';
2260 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2262 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
2263 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
2264 print $hookmanager->resPrint;
2267 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
2268 print
'<td align="center" class="nowrap">';
2269 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2272 $totalarray[
'nbfield']++;
2277 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
2278 print
'<td align="center" class="nowrap">';
2279 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
2282 $totalarray[
'nbfield']++;
2287 if (!empty($arrayfields[
'c.date_cloture'][
'checked'])) {
2288 print
'<td align="center" class="nowrap">';
2289 print
dol_print_date($db->jdate($obj->date_cloture),
'dayhour',
'tzuser');
2292 $totalarray[
'nbfield']++;
2297 if (!empty($arrayfields[
'c.note_public'][
'checked'])) {
2298 print
'<td class="center">';
2302 $totalarray[
'nbfield']++;
2307 if (!empty($arrayfields[
'c.note_private'][
'checked'])) {
2308 print
'<td class="center">';
2312 $totalarray[
'nbfield']++;
2317 if (!empty($arrayfields[
'shippable'][
'checked'])) {
2318 print
'<td class="center">';
2319 if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) {
2320 if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
2321 $generic_commande->getLinesArray();
2322 $generic_commande->loadExpeditions();
2324 $numlines = count($generic_commande->lines);
2325 for ($lig = 0; $lig < $numlines; $lig++) {
2326 if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) {
2327 $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id];
2329 $reliquat = $generic_commande->lines[$lig]->qty;
2331 if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) {
2333 $generic_product->id = $generic_commande->lines[$lig]->fk_product;
2336 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) {
2337 $generic_product->load_stock(
'nobatch');
2338 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_reel;
2339 $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2341 $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stock_reel'];
2342 $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product][
'stock_reel'] = $generic_product->stock_theorique;
2345 if ($reliquat > $generic_product->stock_reel) {
2348 if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
2349 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->product_ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2350 $text_info .=
' - '.$langs->trans(
"Stock").
': <span class="'.($generic_product->stock_reel > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_reel.
'</span>';
2351 $text_info .=
' - '.$langs->trans(
"VirtualStock").
': <span class="'.($generic_product->stock_theorique > 0 ?
'ok' :
'error').
'">'.$generic_product->stock_theorique.
'</span>';
2352 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2353 $text_info .=
'<br>';
2360 $stock_order_supplier = 0;
2361 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
2362 if (!empty($conf->commande->enabled)) {
2363 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'])) {
2364 $generic_product->load_stats_commande(0,
'1,2');
2365 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'] = $generic_product->stats_commande[
'qty'];
2367 $generic_product->stats_commande[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_customer'];
2369 $stock_order = $generic_product->stats_commande[
'qty'];
2371 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
2372 if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'])) {
2373 $generic_product->load_stats_commande_fournisseur(0,
'3');
2374 $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'] = $generic_product->stats_commande_fournisseur[
'qty'];
2376 $generic_product->stats_commande_fournisseur[
'qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product][
'stats_order_supplier'];
2378 $stock_order_supplier = $generic_product->stats_commande_fournisseur[
'qty'];
2381 $text_info .= $reliquat.
' x '.$generic_commande->lines[$lig]->ref.
' '.
dol_trunc($generic_commande->lines[$lig]->product_label, 20);
2382 $text_stock_reel = $generic_product->stock_reel.
'/'.$stock_order;
2383 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
2385 $text_warning .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2387 if ($reliquat > $generic_product->stock_reel) {
2388 $text_info .=
'<span class="warning">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2390 $text_info .=
'<span class="ok">'.$langs->trans(
'Available').
' : '.$text_stock_reel.
'</span>';
2392 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
2393 $text_info .=
' '.$langs->trans(
'SupplierOrder').
' : '.$stock_order_supplier;
2395 $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ?
' <span class="opacitymedium">('.$langs->trans(
"QtyInOtherShipments").
' '.($generic_commande->lines[$lig]->qty - $reliquat).
')</span>' :
'');
2396 $text_info .=
'<br>';
2400 if ($notshippable == 0) {
2401 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'green paddingleft');
2402 $text_info = $text_icon.
' '.$langs->trans(
'Shippable').
'<br>'.$text_info;
2404 $text_icon =
img_picto(
'',
'dolly',
'',
false, 0, 0,
'',
'error paddingleft');
2405 $text_info = $text_icon.
' '.$langs->trans(
'NonShippable').
'<br>'.$text_info;
2410 print
$form->textwithtooltip(
'', $text_info, 2, 1, $text_icon,
'', 2);
2413 print
$form->textwithtooltip(
'', $langs->trans(
'NotEnoughForAllOrders').
'<br>'.$text_warning, 2, 1,
img_picto(
'',
'error'),
'', 2);
2418 $totalarray[
'nbfield']++;
2423 if (!empty($arrayfields[
'c.facture'][
'checked'])) {
2424 print
'<td class="center">'.yn($obj->billed).
'</td>';
2426 $totalarray[
'nbfield']++;
2430 if (!empty($arrayfields[
'c.import_key'][
'checked'])) {
2431 print
'<td class="nowrap center">'.$obj->import_key.
'</td>';
2433 $totalarray[
'nbfield']++;
2437 if (!empty($arrayfields[
'c.fk_statut'][
'checked'])) {
2438 print
'<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).
'</td>';
2440 $totalarray[
'nbfield']++;
2445 print
'<td class="nowrap center">';
2446 if ($massactionbutton || $massaction) {
2448 if (in_array($obj->rowid, $arrayofselected)) {
2451 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2455 $totalarray[
'nbfield']++;
2460 $total += $obj->total_ht;
2461 $subtotal += $obj->total_ht;
2466 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2471 foreach ($arrayfields as $key => $val) {
2472 if (!empty($val[
'checked'])) {
2476 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2481 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
2482 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
2483 print $hookmanager->resPrint;
2485 print
'</table>'.
"\n";
2488 print
'</form>'.
"\n";
2490 $hidegeneratedfilelistifempty = 1;
2491 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2492 $hidegeneratedfilelistifempty = 0;
2496 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2497 $urlsource .= str_replace(
'&',
'&', $param);
2499 $filedir = $diroutputmassaction;
2500 $genallowed = $permissiontoread;
2501 $delallowed = $permissiontoadd;
2503 print $formfile->showdocuments(
'massfilesarea_orders',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
const STATUS_CLOSED
Closed (Sent, billed or not)
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
const STATUS_DRAFT
Draft status.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
const STATUS_VALIDATED
Validated status.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage absolute discounts.
isModEnabled($module)
Is Dolibarr module enabled.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length. ...
Class to manage invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
const STATUS_CANCELED
Canceled status.