dolibarr  16.0.1
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36 
37 $langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills', 'orders'));
38 
39 $socid = GETPOST('socid', 'int');
40 $massaction = GETPOST('massaction', 'alpha');
41 $toselect = GETPOST('toselect', 'array');
42 
43 $diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id;
44 
45 $search_ref_rcp = GETPOST("search_ref_rcp");
46 $search_ref_liv = GETPOST('search_ref_liv');
47 $search_ref_supplier = GETPOST('search_ref_supplier');
48 $search_company = GETPOST("search_company");
49 $search_town = GETPOST('search_town', 'alpha');
50 $search_zip = GETPOST('search_zip', 'alpha');
51 $search_state = GETPOST("search_state");
52 $search_country = GETPOST("search_country", 'int');
53 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
54 $search_billed = GETPOST("search_billed", 'int');
55 $sall = GETPOST('sall', 'alphanohtml');
56 $optioncss = GETPOST('optioncss', 'alpha');
57 
58 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
59 $sortfield = GETPOST('sortfield', 'aZ09comma');
60 $sortorder = GETPOST('sortorder', 'aZ09comma');
61 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
62 if (!$sortfield) {
63  $sortfield = "e.ref";
64 }
65 if (!$sortorder) {
66  $sortorder = "DESC";
67 }
68 if (empty($page) || $page == -1) {
69  $page = 0;
70 } // If $page is not defined, or '' or -1
71 $offset = $limit * $page;
72 $pageprev = $page - 1;
73 $pagenext = $page + 1;
74 
75 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
76 $contextpage = 'receptionlist';
77 
78 $search_status = GETPOST('search_status', 'intcomma');
79 
80 $object = new Reception($db);
81 
82 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
83 $hookmanager->initHooks(array('receptionlist'));
84 $extrafields = new ExtraFields($db);
85 
86 // fetch optionals attributes and labels
87 $extrafields->fetch_name_optionals_label($object->table_element);
88 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
89 
90 // List of fields to search into when doing a "search in all"
91 $fieldstosearchall = array(
92  'e.ref'=>"Ref",
93  's.nom'=>"ThirdParty",
94  'e.note_public'=>'NotePublic',
95 );
96 if (empty($user->socid)) {
97  $fieldstosearchall["e.note_private"] = "NotePrivate";
98 }
99 
100 $checkedtypetiers = 0;
101 $arrayfields = array(
102  'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
103  'e.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1),
104  's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
105  's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
106  's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
107  'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
108  'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
109  'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
110  'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
111  'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
112  'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
113  'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
114  'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)))
115 );
116 
117 // Extra fields
118 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
119 
120 $object->fields = dol_sort_array($object->fields, 'position');
121 $arrayfields = dol_sort_array($arrayfields, 'position');
122 
123 $error = 0;
124 
125 // Security check
126 $receptionid = GETPOST('id', 'int');
127 if ($user->socid) {
128  $socid = $user->socid;
129 }
130 $result = restrictedArea($user, 'reception', $receptionid, '');
131 
132 
133 /*
134  * Actions
135  */
136 
137 if (GETPOST('cancel')) {
138  $action = 'list'; $massaction = '';
139 }
140 if (!GETPOST('confirmmassaction') && $massaction != 'confirm_createbills') {
141  $massaction = '';
142 }
143 
144 $parameters = array('socid'=>$socid);
145 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
146 if ($reshook < 0) {
147  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
148 }
149 
150 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
151 
152 // Purge search criteria
153 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
154  $search_ref_supplier = '';
155  $search_ref_rcp = '';
156  $search_ref_liv = '';
157  $search_company = '';
158  $search_town = '';
159  $search_zip = "";
160  $search_state = "";
161  $search_country = '';
162  $search_type_thirdparty = '';
163  $search_billed = '';
164  $search_status = '';
165  $search_array_options = array();
166 }
167 
168 if (empty($reshook)) {
169  // Mass actions
170  $objectclass = 'Reception';
171  $objectlabel = 'Receptions';
172  $permissiontoread = $user->rights->reception->lire;
173  $permissiontoadd = $user->rights->reception->creer;
174  $permissiontodelete = $user->rights->reception->supprimer;
175  $uploaddir = $conf->reception->multidir_output[$conf->entity];
176  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
177 
178  if ($massaction == 'confirm_createbills') {
179  $receptions = GETPOST('toselect', 'array');
180  $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
181  $validate_invoices = GETPOST('validate_invoices', 'int');
182 
183  $errors = array();
184 
185  $TFact = array();
186  $TFactThird = array();
187  $TFactThirdNbLines = array();
188 
189  $nb_bills_created = 0;
190  $lastid= 0;
191  $lastref = '';
192 
193  $db->begin();
194 
195  //sort ids to keep order if one bill per third
196  sort($receptions);
197  foreach ($receptions as $id_reception) {
198  $rcp = new Reception($db);
199  // We only invoice reception that are validated
200  if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != $rcp::STATUS_VALIDATED) {
201  $errors[] = $langs->trans('StatusOfRefMustBe', $rcp->ref, $langs->transnoentities("StatusSupplierOrderValidatedShort"));
202  $error++;
203  continue;
204  }
205 
206  $objecttmp = new FactureFournisseur($db);
207  if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) {
208  // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it.
209  $objecttmp = $TFactThird[$rcp->socid];
210 
211  // Add all links of this new reception to the existing invoice
212  $objecttmp->fetchObjectLinked();
213  $rcp->fetchObjectLinked();
214  if (count($rcp->linkedObjectsIds['order_supplier']) > 0) {
215  foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) {
216  if (empty($objecttmp->linkedObjectsIds['order_supplier']) || !in_array($value, $objecttmp->linkedObjectsIds['order_supplier'])) { //Dont try to link if already linked
217  $objecttmp->add_object_linked('order_supplier', $value); // add supplier order linked object
218  }
219  }
220  }
221  } else {
222  // If we want one invoice per reception or if there is no first invoice yet for this thirdparty.
223  $objecttmp->socid = $rcp->socid;
224  $objecttmp->type = $objecttmp::TYPE_STANDARD;
225  $objecttmp->cond_reglement_id = $rcp->cond_reglement_id || $rcp->thirdparty->cond_reglement_supplier_id;
226  $objecttmp->mode_reglement_id = $rcp->mode_reglement_id || $rcp->thirdparty->mode_reglement_supplier_id;
227 
228  $objecttmp->fk_account = !empty($rcp->thirdparty->fk_account) ? $rcp->thirdparty->fk_account : 0;
229  $objecttmp->remise_percent = !empty($rcp->thirdparty->remise_percent) ? $rcp->thirdparty->remise_percent : 0;
230  $objecttmp->remise_absolue = !empty($rcp->thirdparty->remise_absolue) ? $rcp->thirdparty->remise_absolue : 0;
231 
232  $objecttmp->fk_project = $rcp->fk_project;
233  //$objecttmp->multicurrency_code = $rcp->multicurrency_code;
234  if (empty($createbills_onebythird)) {
235  $objecttmp->ref_supplier = $rcp->ref;
236  } else {
237  // Set a unique value for the invoice for the n reception
238  $objecttmp->ref_supplier = $langs->trans("Reception").' '.dol_print_date(dol_now(), 'dayhourlog').'-'.$rcp->socid;
239  }
240 
241  $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
242  if (empty($datefacture)) {
243  $datefacture = dol_now();
244  }
245 
246  $objecttmp->date = $datefacture;
247  $objecttmp->origin = 'reception';
248  $objecttmp->origin_id = $id_reception;
249 
250  $objecttmp->array_options = $rcp->array_options; // Copy extrafields
251 
252  // Set $objecttmp->linked_objects with all links order_supplier existing on reception, so same links will be added to the generated supplier invoice
253  $rcp->fetchObjectLinked();
254  if (count($rcp->linkedObjectsIds['order_supplier']) > 0) {
255  foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) {
256  $objecttmp->linked_objects['order_supplier'] = $value;
257  }
258  }
259 
260  $res = $objecttmp->create($user); // This should create the supplier invoice + links into $objecttmp->linked_objects + add a link to ->origin_id
261 
262  //var_dump($objecttmp->error);exit;
263  if ($res > 0) {
264  $nb_bills_created++;
265  $lastref = $objecttmp->ref;
266  $lastid = $objecttmp->id;
267 
268  $TFactThird[$rcp->socid] = $objecttmp;
269  $TFactThirdNbLines[$rcp->socid] = 0; //init nblines to have lines ordered by expedition and rang
270  } else {
271  $langs->load("errors");
272  $errors[] = $rcp->ref.' : '.$langs->trans($objecttmp->error);
273  $error++;
274  }
275  }
276 
277  if ($objecttmp->id > 0) {
278  $res = $objecttmp->add_object_linked($objecttmp->origin, $id_reception);
279 
280  if ($res == 0) {
281  $errors[] = $objecttmp->error;
282  $error++;
283  }
284 
285  if (!$error) {
286  $lines = $rcp->lines;
287  if (empty($lines) && method_exists($rcp, 'fetch_lines')) {
288  $rcp->fetch_lines();
289  $lines = $rcp->lines;
290  }
291 
292  $fk_parent_line = 0;
293  $num = count($lines);
294 
295  for ($i = 0; $i < $num; $i++) {
296  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
297  // If we build one invoice for several reception, we must put the ref of reception on the invoice line
298  if (!empty($createbills_onebythird)) {
299  $desc = dol_concatdesc($desc, $langs->trans("Reception").' '.$rcp->ref.' - '.dol_print_date($rcp->date, 'day'));
300  }
301 
302  if ($lines[$i]->subprice < 0) {
303  // Negative line, we create a discount line
304  $discount = new DiscountAbsolute($db);
305  $discount->fk_soc = $objecttmp->socid;
306  $discount->amount_ht = abs($lines[$i]->total_ht);
307  $discount->amount_tva = abs($lines[$i]->total_tva);
308  $discount->amount_ttc = abs($lines[$i]->total_ttc);
309  $discount->tva_tx = $lines[$i]->tva_tx;
310  $discount->fk_user = $user->id;
311  $discount->description = $desc;
312  $discountid = $discount->create($user);
313  if ($discountid > 0) {
314  $result = $objecttmp->insert_discount($discountid);
315  //$result=$discount->link_to_invoice($lineid,$id);
316  } else {
317  setEventMessages($discount->error, $discount->errors, 'errors');
318  $error++;
319  break;
320  }
321  } else {
322  // Positive line
323  $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
324  // Date start
325  $date_start = false;
326  if ($lines[$i]->date_debut_prevue) {
327  $date_start = $lines[$i]->date_debut_prevue;
328  }
329  if ($lines[$i]->date_debut_reel) {
330  $date_start = $lines[$i]->date_debut_reel;
331  }
332  if ($lines[$i]->date_start) {
333  $date_start = $lines[$i]->date_start;
334  }
335  //Date end
336  $date_end = false;
337  if ($lines[$i]->date_fin_prevue) {
338  $date_end = $lines[$i]->date_fin_prevue;
339  }
340  if ($lines[$i]->date_fin_reel) {
341  $date_end = $lines[$i]->date_fin_reel;
342  }
343  if ($lines[$i]->date_end) {
344  $date_end = $lines[$i]->date_end;
345  }
346  // Reset fk_parent_line for no child products and special product
347  if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
348  $fk_parent_line = 0;
349  }
350 
351  // Extrafields
352  if (method_exists($lines[$i], 'fetch_optionals')) {
353  $lines[$i]->fetch_optionals();
354  $array_options = $lines[$i]->array_options;
355  }
356 
357  $objecttmp->context['createfromclone'];
358 
359  $rang = $i;
360  //there may already be rows from previous receptions
361  if (!empty($createbills_onebythird))
362  $rang = $TFactThirdNbLines[$rcp->socid];
363 
364  $result = $objecttmp->addline(
365  $desc,
366  $lines[$i]->subprice,
367  $lines[$i]->tva_tx,
368  $lines[$i]->localtax1_tx,
369  $lines[$i]->localtax2_tx,
370  $lines[$i]->qty,
371  $lines[$i]->fk_product,
372  $lines[$i]->remise_percent,
373  $date_start,
374  $date_end,
375  0,
376  $lines[$i]->info_bits,
377  'HT',
378  $product_type,
379  $rang,
380  false,
381  0,
382  null,
383  $lines[$i]->rowid,
384  0,
385  $lines[$i]->ref_supplier
386  );
387 
388  $rcp->add_object_linked('facture_fourn_det', $result);
389 
390  if ($result > 0) {
391  $lineid = $result;
392  if (!empty($createbills_onebythird)) //increment rang to keep order
393  $TFactThirdNbLines[$rcp->socid]++;
394  } else {
395  $lineid = 0;
396  $error++;
397  break;
398  }
399  // Defined the new fk_parent_line
400  if ($result > 0 && $lines[$i]->product_type == 9) {
401  $fk_parent_line = $result;
402  }
403  }
404  }
405  }
406  }
407 
408  //$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
409 
410  if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) {
411  $TFactThird[$rcp->socid] = $objecttmp;
412  } else {
413  $TFact[$objecttmp->id] = $objecttmp;
414  }
415  }
416 
417  // Build doc with all invoices
418  $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
419  $toselect = array();
420 
421  if (!$error && $validate_invoices) {
422  $massaction = $action = 'builddoc';
423  foreach ($TAllFact as &$objecttmp) {
424  $result = $objecttmp->validate($user);
425  if ($result <= 0) {
426  $error++;
427  setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
428  break;
429  }
430 
431  $id = $objecttmp->id; // For builddoc action
432  $object =$objecttmp;
433 
434  // Fac builddoc
435  $donotredirect = 1;
436  $upload_dir = $conf->fournisseur->facture->dir_output;
437  $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
438 
439  // Call action to build doc
440  $savobject = $object;
441  $object = $objecttmp;
442  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
443  $object = $savobject;
444  }
445 
446  $massaction = $action = 'confirm_createbills';
447  }
448 
449  if (!$error) {
450  $db->commit();
451 
452  if ($nb_bills_created == 1) {
453  $texttoshow = $langs->trans('BillXCreated', '{s1}');
454  $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?id='.urlencode($lastid).'">'.$lastref.'</a>', $texttoshow);
455  setEventMessages($texttoshow, null, 'mesgs');
456  } else {
457  setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
458  }
459  } else {
460  $db->rollback();
461 
462  $action = 'create';
463  $_GET["origin"] = $_POST["origin"];
464  $_GET["originid"] = $_POST["originid"];
465  setEventMessages($object->error, $errors, 'errors');
466  $error++;
467  }
468  }
469 }
470 
471 
472 /*
473  * View
474  */
475 
476 $form = new Form($db);
477 $companystatic = new Societe($db);
478 $reception = new Reception($db);
479 $formcompany = new FormCompany($db);
480 $formfile = new FormFile($db);
481 
482 
483 $helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:M&oacute;dulo_Receptiones';
484 llxHeader('', $langs->trans('ListOfReceptions'), $helpurl);
485 
486 $sql = "SELECT e.rowid, e.ref, e.ref_supplier, e.date_reception as date_reception, e.date_delivery as delivery_date, l.date_delivery as date_reception2, e.fk_statut, e.billed,";
487 $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
488 $sql .= " typent.code as typent_code,";
489 $sql .= " state.code_departement as state_code, state.nom as state_name,";
490 $sql .= ' e.date_creation as date_creation, e.tms as date_update';
491 // Add fields from extrafields
492 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
493  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
494  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
495  }
496 }
497 // Add fields from hooks
498 $parameters = array();
499 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
500 $sql .= $hookmanager->resPrint;
501 $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
502 if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
503  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
504 }
505 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
506 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
507 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
508 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
509 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'";
510 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
511 if (empty($user->rights->societe->client->voir) && !$socid) { // Internal user with no permission to see all
512  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
513 }
514 // Add joins from hooks
515 $parameters = array();
516 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
517 $sql .= $hookmanager->resPrint;
518 $sql .= " WHERE e.entity IN (".getEntity('reception').")";
519 if (empty($user->rights->societe->client->voir) && !$socid) { // Internal user with no permission to see all
520  $sql .= " AND e.fk_soc = sc.fk_soc";
521  $sql .= " AND sc.fk_user = ".((int) $user->id);
522 }
523 if ($socid) {
524  $sql .= " AND e.fk_soc = ".((int) $socid);
525 }
526 if ($search_status <> '' && $search_status >= 0) {
527  $sql .= " AND e.fk_statut = ".((int) $search_status);
528 }
529 if ($search_billed != '' && $search_billed >= 0) {
530  $sql .= ' AND e.billed = '.((int) $search_billed);
531 }
532 if ($search_town) {
533  $sql .= natural_search('s.town', $search_town);
534 }
535 if ($search_zip) {
536  $sql .= natural_search("s.zip", $search_zip);
537 }
538 if ($search_state) {
539  $sql .= natural_search("state.nom", $search_state);
540 }
541 if ($search_country) {
542  $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
543 }
544 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
545  $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
546 }
547 if ($search_ref_rcp) {
548  $sql .= natural_search('e.ref', $search_ref_rcp);
549 }
550 if ($search_ref_liv) {
551  $sql .= natural_search('l.ref', $search_ref_liv);
552 }
553 if ($search_company) {
554  $sql .= natural_search('s.nom', $search_company);
555 }
556 if ($search_ref_supplier) {
557  $sql .= natural_search('e.ref_supplier', $search_ref_supplier);
558 }
559 if ($sall) {
560  $sql .= natural_search(array_keys($fieldstosearchall), $sall);
561 }
562 
563 // Add where from extra fields
564 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
565 // Add where from hooks
566 $parameters = array();
567 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
568 $sql .= $hookmanager->resPrint;
569 
570 $nbtotalofrecords = '';
571 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
572  $result = $db->query($sql);
573  $nbtotalofrecords = $db->num_rows($result);
574 }
575 
576 $sql .= $db->order($sortfield, $sortorder);
577 $sql .= $db->plimit($limit + 1, $offset);
578 
579 //print $sql;
580 $resql = $db->query($sql);
581 if (!$resql) {
582  dol_print_error($db);
583  exit;
584 }
585 
586 $num = $db->num_rows($resql);
587 
588 $reception = new Reception($db);
589 
590 $arrayofselected = is_array($toselect) ? $toselect : array();
591 
592 $param = '';
593 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
594  $param .= '&contextpage='.urlencode($contextpage);
595 }
596 if ($limit > 0 && $limit != $conf->liste_limit) {
597  $param .= '&limit='.urlencode($limit);
598 }
599 if ($sall) {
600  $param .= "&sall=".urlencode($sall);
601 }
602 if ($search_ref_rcp) {
603  $param .= "&search_ref_rcp=".urlencode($search_ref_rcp);
604 }
605 if ($search_ref_liv) {
606  $param .= "&search_ref_liv=".urlencode($search_ref_liv);
607 }
608 if ($search_company) {
609  $param .= "&search_company=".urlencode($search_company);
610 }
611 if ($optioncss != '') {
612  $param .= '&optioncss='.urlencode($optioncss);
613 }
614 if ($search_billed != '' && $search_billed >= 0) {
615  $param .= "&search_billed=".urlencode($search_billed);
616 }
617 if ($search_town) {
618  $param .= "&search_town=".urlencode($search_town);
619 }
620 if ($search_zip) {
621  $param .= "&search_zip=".urlencode($search_zip);
622 }
623 if ($search_state) {
624  $param .= "&search_state=".urlencode($search_state);
625 }
626 if ($search_status != '') {
627  $param .= "&search_status=".urlencode($search_status);
628 }
629 if ($search_country) {
630  $param .= "&search_country=".urlencode($search_country);
631 }
632 if ($search_type_thirdparty) {
633  $param .= "&search_type_thirdparty=".urlencode($search_type_thirdparty);
634 }
635 if ($search_ref_supplier) {
636  $param .= "&search_ref_supplier=".urlencode($search_ref_supplier);
637 }
638 // Add $param from extra fields
639 if ($search_array_options) {
640  foreach ($search_array_options as $key => $val) {
641  $crit = $val;
642  $tmpkey = preg_replace('/search_options_/', '', $key);
643  if (is_array($val) && array_key_exists('start', $val) && array_key_exists('end', $val)) {
644  // date range from list filters is stored as array('start' => <timestamp>, 'end' => <timestamp>)
645  // start date
646  $param .= '&search_options_'.$tmpkey.'_startyear='.dol_print_date($val['start'], '%Y');
647  $param .= '&search_options_'.$tmpkey.'_startmonth='.dol_print_date($val['start'], '%m');
648  $param .= '&search_options_'.$tmpkey.'_startday='.dol_print_date($val['start'], '%d');
649  $param .= '&search_options_'.$tmpkey.'_starthour='.dol_print_date($val['start'], '%H');
650  $param .= '&search_options_'.$tmpkey.'_startmin='.dol_print_date($val['start'], '%M');
651  // end date
652  $param .= '&search_options_'.$tmpkey.'_endyear='.dol_print_date($val['end'], '%Y');
653  $param .= '&search_options_'.$tmpkey.'_endmonth='.dol_print_date($val['end'], '%m');
654  $param .= '&search_options_'.$tmpkey.'_endday='.dol_print_date($val['end'], '%d');
655  $param .= '&search_options_'.$tmpkey.'_endhour='.dol_print_date($val['end'], '%H');
656  $param .= '&search_options_'.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M');
657  $val = '';
658  }
659  if ($val != '') {
660  $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
661  }
662  }
663 }
664 
665 
666 $arrayofmassactions = array(
667  // 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
668 );
669 
670 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
671  $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisReceptions");
672 }
673 if ($massaction == 'createbills') {
674  $arrayofmassactions = array();
675 }
676 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
677 //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
678 
679 $i = 0;
680 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
681 if ($optioncss != '') {
682  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
683 }
684 print '<input type="hidden" name="token" value="'.newToken().'">';
685 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
686 print '<input type="hidden" name="action" value="list">';
687 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
688 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
689 
690 print_barre_liste($langs->trans('ListOfReceptions'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dollyrevert', 0, '', '', $limit, 0, 0, 1);
691 
692 if ($massaction == 'createbills') {
693  //var_dump($_REQUEST);
694  print '<input type="hidden" name="massaction" value="confirm_createbills">';
695 
696  print '<table class="noborder" width="100%" >';
697  print '<tr>';
698  print '<td class="titlefieldmiddle">';
699  print $langs->trans('DateInvoice');
700  print '</td>';
701  print '<td>';
702  print $form->selectDate('', '', '', '', '', '', 1, 1);
703  print '</td>';
704  print '</tr>';
705  print '<tr>';
706  print '<td>';
707  print $langs->trans('CreateOneBillByThird');
708  print '</td>';
709  print '<td>';
710  print $form->selectyesno('createbills_onebythird', '', 1);
711  print '</td>';
712  print '</tr>';
713  print '<tr>';
714  print '<td>';
715  print $langs->trans('ValidateInvoices');
716  print '</td>';
717  print '<td>';
718  if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
719  print $form->selectyesno('validate_invoices', 0, 1, 1);
720  print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')';
721  } else {
722  print $form->selectyesno('validate_invoices', 0, 1);
723  }
724  print '</td>';
725  print '</tr>';
726  print '</table>';
727 
728  print '<br>';
729  print '<div class="center">';
730  print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisReceptions').'"> ';
731  print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
732  print '</div>';
733  print '<br>';
734 }
735 
736 if ($sall) {
737  foreach ($fieldstosearchall as $key => $val) {
738  $fieldstosearchall[$key] = $langs->trans($val);
739  }
740  print $langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall);
741 }
742 
743 $moreforfilter = '';
744 if (!empty($moreforfilter)) {
745  print '<div class="liste_titre liste_titre_bydiv centpercent">';
746  print $moreforfilter;
747  $parameters = array('type'=>$type);
748  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
749  print $hookmanager->resPrint;
750  print '</div>';
751 }
752 
753 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
754 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
755 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
756 
757 
758 print '<div class="div-table-responsive">';
759 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
760 
761 // Fields title search
762 // --------------------------------------------------------------------
763 print '<tr class="liste_titre_filter">';
764 // Ref
765 if (!empty($arrayfields['e.ref']['checked'])) {
766  print '<td class="liste_titre">';
767  print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.'">';
768  print '</td>';
769 }
770 // Ref customer
771 if (!empty($arrayfields['e.ref_supplier']['checked'])) {
772  print '<td class="liste_titre">';
773  print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.'">';
774  print '</td>';
775 }
776 // Thirdparty
777 if (!empty($arrayfields['s.nom']['checked'])) {
778  print '<td class="liste_titre left">';
779  print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
780  print '</td>';
781 }
782 // Town
783 if (!empty($arrayfields['s.town']['checked'])) {
784  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
785 }
786 // Zip
787 if (!empty($arrayfields['s.zip']['checked'])) {
788  print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
789 }
790 // State
791 if (!empty($arrayfields['state.nom']['checked'])) {
792  print '<td class="liste_titre">';
793  print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
794  print '</td>';
795 }
796 // Country
797 if (!empty($arrayfields['country.code_iso']['checked'])) {
798  print '<td class="liste_titre center">';
799  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
800  print '</td>';
801 }
802 // Company type
803 if (!empty($arrayfields['typent.code']['checked'])) {
804  print '<td class="liste_titre maxwidthonsmartphone center">';
805  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);
806  print '</td>';
807 }
808 // Date delivery planned
809 if (!empty($arrayfields['e.date_delivery']['checked'])) {
810  print '<td class="liste_titre">&nbsp;</td>';
811 }
812 if (!empty($arrayfields['l.ref']['checked'])) {
813  // Delivery ref
814  print '<td class="liste_titre">';
815  print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
816  print '</td>';
817 }
818 if (!empty($arrayfields['l.date_delivery']['checked'])) {
819  // Date received
820  print '<td class="liste_titre">&nbsp;</td>';
821 }
822 // Extra fields
823 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
824 
825 // Fields from hook
826 $parameters = array('arrayfields'=>$arrayfields);
827 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
828 print $hookmanager->resPrint;
829 // Date creation
830 if (!empty($arrayfields['e.datec']['checked'])) {
831  print '<td class="liste_titre">';
832  print '</td>';
833 }
834 // Date modification
835 if (!empty($arrayfields['e.tms']['checked'])) {
836  print '<td class="liste_titre">';
837  print '</td>';
838 }
839 // Status
840 if (!empty($arrayfields['e.fk_statut']['checked'])) {
841  print '<td class="liste_titre maxwidthonsmartphone right">';
842  print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1);
843  print '</td>';
844 }
845 // Status billed
846 if (!empty($arrayfields['e.billed']['checked'])) {
847  print '<td class="liste_titre maxwidthonsmartphone center">';
848  print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
849  print '</td>';
850 }
851 // Action column
852 print '<td class="liste_titre middle">';
853 $searchpicto = $form->showFilterAndCheckAddButtons(0);
854 print $searchpicto;
855 print '</td>';
856 print "</tr>\n";
857 
858 print '<tr class="liste_titre">';
859 if (!empty($arrayfields['e.ref']['checked'])) {
860  print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
861 }
862 if (!empty($arrayfields['e.ref_supplier']['checked'])) {
863  print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder);
864 }
865 if (!empty($arrayfields['s.nom']['checked'])) {
866  print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
867 }
868 if (!empty($arrayfields['s.town']['checked'])) {
869  print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
870 }
871 if (!empty($arrayfields['s.zip']['checked'])) {
872  print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
873 }
874 if (!empty($arrayfields['state.nom']['checked'])) {
875  print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
876 }
877 if (!empty($arrayfields['country.code_iso']['checked'])) {
878  print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
879 }
880 if (!empty($arrayfields['typent.code']['checked'])) {
881  print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
882 }
883 if (!empty($arrayfields['e.date_delivery']['checked'])) {
884  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
885 }
886 if (!empty($arrayfields['l.ref']['checked'])) {
887  print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
888 }
889 if (!empty($arrayfields['l.date_delivery']['checked'])) {
890  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
891 }
892 // Extra fields
893 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
894 // Hook fields
895 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
896 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
897 print $hookmanager->resPrint;
898 if (!empty($arrayfields['e.datec']['checked'])) {
899  print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
900 }
901 if (!empty($arrayfields['e.tms']['checked'])) {
902  print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
903 }
904 if (!empty($arrayfields['e.fk_statut']['checked'])) {
905  print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
906 }
907 if (!empty($arrayfields['e.billed']['checked'])) {
908  print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
909 }
910 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
911 print "</tr>\n";
912 
913 $i = 0;
914 $totalarray = array();
915 $totalarray['nbfield'] = 0;
916 while ($i < min($num, $limit)) {
917  $obj = $db->fetch_object($resql);
918 
919  $reception->id = $obj->rowid;
920  $reception->ref = $obj->ref;
921 
922  $companystatic->id = $obj->socid;
923  $companystatic->ref = $obj->name;
924  $companystatic->name = $obj->name;
925 
926 
927  print '<tr class="oddeven">';
928 
929  // Ref
930  if (!empty($arrayfields['e.ref']['checked'])) {
931  print '<td class="nowraponall">';
932  print $reception->getNomUrl(1);
933  $filename = dol_sanitizeFileName($reception->ref);
934  $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref);
935  $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->id;
936  print $formfile->getDocumentsLink($reception->element, $filename, $filedir);
937  print "</td>\n";
938 
939  if (!$i) {
940  $totalarray['nbfield']++;
941  }
942  }
943 
944  // Ref supplier
945  if (!empty($arrayfields['e.ref_supplier']['checked'])) {
946  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
947  print dol_escape_htmltag($obj->ref_supplier);
948  print "</td>\n";
949  if (!$i) {
950  $totalarray['nbfield']++;
951  }
952  }
953 
954  // Third party
955  if (!empty($arrayfields['s.nom']['checked'])) {
956  print '<td class="tdoverflowmax150">';
957  print $companystatic->getNomUrl(1);
958  print '</td>';
959  if (!$i) {
960  $totalarray['nbfield']++;
961  }
962  }
963  // Town
964  if (!empty($arrayfields['s.town']['checked'])) {
965  print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->town).'">';
966  print dol_escape_htmltag($obj->town);
967  print '</td>';
968  if (!$i) {
969  $totalarray['nbfield']++;
970  }
971  }
972  // Zip
973  if (!empty($arrayfields['s.zip']['checked'])) {
974  print '<td class="nocellnopadd center"">';
975  print dol_escape_htmltag($obj->zip);
976  print '</td>';
977  if (!$i) {
978  $totalarray['nbfield']++;
979  }
980  }
981  // State
982  if (!empty($arrayfields['state.nom']['checked'])) {
983  print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
984  if (!$i) {
985  $totalarray['nbfield']++;
986  }
987  }
988  // Country
989  if (!empty($arrayfields['country.code_iso']['checked'])) {
990  print '<td class="center">';
991  $tmparray = getCountry($obj->fk_pays, 'all');
992  print dol_escape_htmltag($tmparray['label']);
993  print '</td>';
994  if (!$i) {
995  $totalarray['nbfield']++;
996  }
997  }
998  // Type ent
999  if (!empty($arrayfields['typent.code']['checked'])) {
1000  print '<td class="center">';
1001  if (count($typenArray) == 0) {
1002  $typenArray = $formcompany->typent_array(1);
1003  }
1004  print $typenArray[$obj->typent_code];
1005  print '</td>';
1006  if (!$i) {
1007  $totalarray['nbfield']++;
1008  }
1009  }
1010 
1011  // Date delivery planed
1012  if (!empty($arrayfields['e.date_delivery']['checked'])) {
1013  print '<td class="center">';
1014  print dol_print_date($db->jdate($obj->delivery_date), "day");
1015  /*$now = time();
1016  if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 )
1017  {
1018  }*/
1019  print "</td>\n";
1020  if (!$i) {
1021  $totalarray['nbfield']++;
1022  }
1023  }
1024 
1025  if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
1026  $reception->fetchObjectLinked($reception->id, $reception->element);
1027  $receiving = '';
1028  if (count($reception->linkedObjects['delivery']) > 0) {
1029  $receiving = reset($reception->linkedObjects['delivery']);
1030  }
1031 
1032  if (!empty($arrayfields['l.ref']['checked'])) {
1033  // Ref
1034  print '<td>';
1035  print !empty($receiving) ? $receiving->getNomUrl($db) : '';
1036  print '</td>';
1037  }
1038 
1039  if (!empty($arrayfields['l.date_delivery']['checked'])) {
1040  // Date received
1041  print '<td class="center">';
1042  print dol_print_date($db->jdate($obj->date_reception), "day");
1043  print '</td>'."\n";
1044  }
1045  }
1046 
1047  // Extra fields
1048  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1049 
1050  // Fields from hook
1051  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1052  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1053  print $hookmanager->resPrint;
1054  // Date creation
1055  if (!empty($arrayfields['e.datec']['checked'])) {
1056  print '<td class="center nowrap">';
1057  print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
1058  print '</td>';
1059  if (!$i) {
1060  $totalarray['nbfield']++;
1061  }
1062  }
1063  // Date modification
1064  if (!empty($arrayfields['e.tms']['checked'])) {
1065  print '<td class="center nowrap">';
1066  print dol_print_date($db->jdate($obj->date_update), 'dayhour');
1067  print '</td>';
1068  if (!$i) {
1069  $totalarray['nbfield']++;
1070  }
1071  }
1072  // Status
1073  if (!empty($arrayfields['e.fk_statut']['checked'])) {
1074  print '<td class="right nowrap">'.$reception->LibStatut($obj->fk_statut, 5).'</td>';
1075  if (!$i) {
1076  $totalarray['nbfield']++;
1077  }
1078  }
1079  // Billed
1080  if (!empty($arrayfields['e.billed']['checked'])) {
1081  print '<td class="center">'.yn($obj->billed).'</td>';
1082  if (!$i) {
1083  $totalarray['nbfield']++;
1084  }
1085  }
1086 
1087  // Action column
1088  print '<td class="center">';
1089  if ($massactionbutton || $massaction) {
1090  // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1091  $selected = 0;
1092  if (in_array($obj->rowid, $arrayofselected)) {
1093  $selected = 1;
1094  }
1095  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1096  }
1097  print '</td>';
1098  if (!$i) {
1099  $totalarray['nbfield']++;
1100  }
1101 
1102  print "</tr>\n";
1103 
1104  $i++;
1105 }
1106 
1107 // If no record found
1108 if ($num == 0) {
1109  $colspan = 1;
1110  foreach ($arrayfields as $key => $val) {
1111  if (!empty($val['checked'])) {
1112  $colspan++;
1113  }
1114  }
1115  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1116 }
1117 
1118 // Show total line
1119 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1120 
1121 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1122 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1123 print $hookmanager->resPrint;
1124 
1125 print "</table>";
1126 print "</div>";
1127 print '</form>';
1128 $db->free($resql);
1129 
1130 llxFooter();
1131 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
Class to manage suppliers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
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...
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
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.
Class to manage generation of HTML components Only common components must be here.
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 receptions.
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.
Class to offer components to list and upload files.
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.
Definition: index.php:742
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.
llxFooter()
Empty footer.
Definition: wrapper.php:73
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid