dolibarr 24.0.3
list.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
6 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
7 * Copyright (C) 2023-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
8 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
42require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
44require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
45require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
50
51$langs->loadLangs(array("sendings", "receptions", 'companies', 'bills', 'orders'));
52
53$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search
54
55$socid = GETPOSTINT('socid');
56
57$action = GETPOST('action', 'alpha');
58$massaction = GETPOST('massaction', 'alpha');
59$toselect = GETPOST('toselect', 'array:int');
60$show_files = GETPOSTINT('show_files');
61$optioncss = GETPOST('optioncss', 'alpha');
62$mode = GETPOST('mode', 'alpha');
63
64
65$search_ref_rcp = GETPOST("search_ref_rcp");
66$search_ref_liv = GETPOST('search_ref_liv');
67$search_ref_supplier = GETPOST('search_ref_supplier');
68$search_company = GETPOST("search_company");
69$search_town = GETPOST('search_town', 'alpha');
70$search_zip = GETPOST('search_zip', 'alpha');
71$search_state = GETPOST("search_state");
72$search_country = GETPOST("search_country", 'aZ09');
73$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
74$search_date_delivery_startday = GETPOSTINT('search_date_delivery_startday');
75$search_date_delivery_startmonth = GETPOSTINT('search_date_delivery_startmonth');
76$search_date_delivery_startyear = GETPOSTINT('search_date_delivery_startyear');
77$search_date_delivery_endday = GETPOSTINT('search_date_delivery_endday');
78$search_date_delivery_endmonth = GETPOSTINT('search_date_delivery_endmonth');
79$search_date_delivery_endyear = GETPOSTINT('search_date_delivery_endyear');
80$search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver
81$search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear);
82$search_date_create_startday = GETPOSTINT('search_date_create_startday');
83$search_date_create_startmonth = GETPOSTINT('search_date_create_startmonth');
84$search_date_create_startyear = GETPOSTINT('search_date_create_startyear');
85$search_date_create_endday = GETPOSTINT('search_date_create_endday');
86$search_date_create_endmonth = GETPOSTINT('search_date_create_endmonth');
87$search_date_create_endyear = GETPOSTINT('search_date_create_endyear');
88$search_date_create_start = dol_mktime(0, 0, 0, $search_date_create_startmonth, $search_date_create_startday, $search_date_create_startyear); // Use tzserver
89$search_date_create_end = dol_mktime(23, 59, 59, $search_date_create_endmonth, $search_date_create_endday, $search_date_create_endyear);
90$search_billed = GETPOST("search_billed", 'intcomma');
91$search_status = GETPOST('search_status', 'intcomma');
92$search_all = GETPOST('search_all', 'alphanohtml');
93$search_note_private = GETPOST('search_note_private', 'alpha');
94$search_note_public = GETPOST('search_note_public', 'alpha');
95
96$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
97$sortfield = GETPOST('sortfield', 'aZ09comma');
98$sortorder = GETPOST('sortorder', 'aZ09comma');
99$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
100if (!$sortfield) {
101 $sortfield = "e.ref";
102}
103if (!$sortorder) {
104 $sortorder = "DESC";
105}
106if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
107 // If $page is not defined, or '' or -1 or if we click on clear filters
108 $page = 0;
109}
110$offset = $limit * $page;
111$pageprev = $page - 1;
112$pagenext = $page + 1;
113
114$diroutputmassaction = $conf->reception->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;
115$object = new Reception($db);
116
117// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
118$hookmanager->initHooks(array('receptionlist'));
119$extrafields = new ExtraFields($db);
120
121// Fetch optionals attributes and labels
122$extrafields->fetch_name_optionals_label($object->table_element);
123$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
124
125// List of fields to search into when doing a "search in all"
126$fieldstosearchall = array(
127 'e.ref' => "Ref",
128 'e.ref_supplier' => "RefSupplier",
129 's.nom' => "ThirdParty",
130 'e.note_public' => 'NotePublic',
131);
132if (empty($user->socid)) {
133 $fieldstosearchall["e.note_private"] = "NotePrivate";
134}
135
136$checkedtypetiers = '0';
137$arrayfields = array(
138 'e.ref' => array('label' => $langs->trans("Ref"), 'checked' => '1'),
139 'e.ref_supplier' => array('label' => $langs->trans("RefSupplier"), 'checked' => '1'),
140 's.nom' => array('label' => $langs->trans("ThirdParty"), 'checked' => '1'),
141 's.town' => array('label' => $langs->trans("Town"), 'checked' => '1'),
142 's.zip' => array('label' => $langs->trans("Zip"), 'checked' => '1'),
143 'state.nom' => array('label' => $langs->trans("StateShort"), 'checked' => '0'),
144 'country.code_iso' => array('label' => $langs->trans("Country"), 'checked' => '0'),
145 'typent.code' => array('label' => $langs->trans("ThirdPartyType"), 'checked' => $checkedtypetiers),
146 'e.date_delivery' => array('label' => $langs->trans("DateDeliveryPlanned"), 'checked' => '1'),
147 'e.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => '0', 'position' => 500),
148 'e.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => '0', 'position' => 500),
149 'e.note_public' => array('label' => 'NotePublic', 'checked' => '0', 'position' => 520, 'enabled' => (getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES') ? '0' : '1')),
150 'e.note_private' => array('label' => 'NotePrivate', 'checked' => '0', 'position' => 521, 'enabled' => (getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES') ? '0' : '1')),
151 'e.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => '1', 'position' => 1000),
152 'e.billed' => array('label' => $langs->trans("Billed"), 'checked' => '1', 'position' => 1000, 'enabled' => 'getDolGlobalString("WORKFLOW_BILL_ON_RECEPTION") !== "0"')
153);
154
155// Extra fields
156include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
157
158// Add hook to complete $arrayfields
159$parameters = array('arrayfields' => &$arrayfields);
160$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
161
162$object->fields = dol_sort_array($object->fields, 'position');
163$arrayfields = dol_sort_array($arrayfields, 'position');
164
165$error = 0;
166
167// Security check
168$receptionid = GETPOSTINT('id');
169if ($user->socid) {
170 $socid = $user->socid;
171}
172$result = restrictedArea($user, 'reception', $receptionid, '');
173
174
175/*
176 * Actions
177 */
178
179if (GETPOST('cancel', 'alpha')) {
180 $action = 'list';
181 $massaction = '';
182}
183if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_createbills') {
184 $massaction = '';
185}
186
187$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
188$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
189if ($reshook < 0) {
190 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
191}
192
193include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
194
195// Purge search criteria
196if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
197 $search_ref_supplier = '';
198 $search_ref_rcp = '';
199 $search_ref_liv = '';
200 $search_company = '';
201 $search_town = '';
202 $search_zip = "";
203 $search_state = "";
204 $search_country = '';
205 $search_type_thirdparty = '';
206 $search_date_delivery_startday = '';
207 $search_date_delivery_startmonth = '';
208 $search_date_delivery_startyear = '';
209 $search_date_delivery_endday = '';
210 $search_date_delivery_endmonth = '';
211 $search_date_delivery_endyear = '';
212 $search_date_delivery_start = '';
213 $search_date_delivery_end = '';
214 $search_date_create_startday = '';
215 $search_date_create_startmonth = '';
216 $search_date_create_startyear = '';
217 $search_date_create_endday = '';
218 $search_date_create_endmonth = '';
219 $search_date_create_endyear = '';
220 $search_date_create_start = '';
221 $search_date_create_end = '';
222 $search_billed = '';
223 $search_status = '';
224 $toselect = array();
225 $search_array_options = array();
226}
227
228if (empty($reshook)) {
229 // Mass actions
230 $objectclass = 'Reception';
231 $objectlabel = 'Receptions';
232 $permissiontoread = $user->hasRight('reception', 'lire');
233 $permissiontoadd = $user->hasRight('reception', 'creer');
234 $permissiontodelete = $user->hasRight('reception', 'supprimer');
235 $uploaddir = $conf->reception->multidir_output[$conf->entity];
236 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
237
238 if (!$error && $massaction == 'confirm_createbills' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) {
239 $receptions = $toselect; // Ids already checked for access by the mass actions include
240 $createbills_onebythird = GETPOSTINT('createbills_onebythird');
241 $validate_invoices = GETPOSTINT('validate_invoices');
242
243 $errors = array();
244
245 $TFact = array();
246 $TFactThird = array();
247 '@phan-var FactureFournisseur[] $TFactThird';
248 $TFactThirdNbLines = array();
249
250 $nb_bills_created = 0;
251 $lastid = 0;
252 $lastref = '';
253
254 $db->begin();
255
256 //sort ids to keep order if one bill per third
257 sort($receptions);
258 foreach ($receptions as $id_reception) {
259 $soc = null;
260 $rcp = new Reception($db);
261 // We not allow invoice reception that are in draft status
262 if ($rcp->fetch($id_reception) <= 0 || $rcp->statut == $rcp::STATUS_DRAFT) {
263 $errors[] = $langs->trans('StatusOfRefMustBe', $rcp->ref, $langs->transnoentities("StatusReceptionValidatedShort"));
264 $error++;
265 continue;
266 }
267
268 $objecttmp = new FactureFournisseur($db);
269 if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) {
270 // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we reuse it.
271 $objecttmp = $TFactThird[$rcp->socid];
272
273 // Add all links of this new reception to the existing invoice
274 $objecttmp->fetchObjectLinked();
275 $objecttmp->clearObjectLinkedCache(); // force refetch after upcoming add_object_linked() calls so BILL_SUPPLIER_VALIDATE trigger sees all linked receptions
276 $rcp->fetchObjectLinked();
277 if (!empty($rcp->linkedObjectsIds['order_supplier']) && is_array($rcp->linkedObjectsIds['order_supplier'])) {
278 foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) {
279 if (empty($objecttmp->linkedObjectsIds['order_supplier']) || !in_array($value, $objecttmp->linkedObjectsIds['order_supplier'])) { //Don't try to link if already linked
280 $objecttmp->add_object_linked('order_supplier', $value); // add supplier order linked object
281 }
282 }
283 }
284 } else {
285 $cond_reglement_id = 0;
286 $mode_reglement_id = 0;
287 $fk_account = 0;
288 $transport_mode_id = 0;
289 $multicurrency_code = null;
290
291 if (!empty($rcp->cond_reglement_id)) {
292 $cond_reglement_id = $rcp->cond_reglement_id;
293 }
294 if (!empty($rcp->mode_reglement_id)) {
295 $mode_reglement_id = $rcp->mode_reglement_id;
296 }
297 if (!empty($rcp->fk_account)) {
298 $fk_account = $rcp->fk_account;
299 }
300 if (!empty($rcp->transport_mode_id)) {
301 $transport_mode_id = $rcp->transport_mode_id;
302 }
303 if (!empty($rcp->multicurrency_code)) {
304 $multicurrency_code = $rcp->multicurrency_code;
305 }
306
307 if (empty($cond_reglement_id)
308 || empty($mode_reglement_id)
309 || empty($fk_account)
310 || empty($transport_mode_id)
311 || empty($multicurrency_code)
312 ) {
313 if (!isset($rcp->supplier_order)) {
314 $rcp->fetch_origin();
315 }
316
317 // try to get from source of reception (supplier order)
318 if (!empty($rcp->origin_object)) {
319 $supplierOrder = $rcp->origin_object;
320 if (empty($cond_reglement_id) && !empty($supplierOrder->cond_reglement_id)) {
321 $cond_reglement_id = $supplierOrder->cond_reglement_id;
322 }
323 if (empty($mode_reglement_id) && !empty($supplierOrder->mode_reglement_id)) {
324 $mode_reglement_id = $supplierOrder->mode_reglement_id;
325 }
326 if (empty($fk_account) && !empty($supplierOrder->fk_account)) {
327 $fk_account = $supplierOrder->fk_account;
328 }
329 if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) {
330 $transport_mode_id = $supplierOrder->transport_mode_id;
331 }
332 if (empty($multicurrency_code) && !empty($supplierOrder->multicurrency_code)) {
333 $multicurrency_code = $supplierOrder->multicurrency_code;
334 }
335 }
336
337 // try get from third party of reception
338 if (!empty($rcp->thirdparty)) {
339 $soc = $rcp->thirdparty;
340 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
341 $cond_reglement_id = $soc->cond_reglement_supplier_id;
342 }
343 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
344 $mode_reglement_id = $soc->mode_reglement_supplier_id;
345 }
346 if (empty($fk_account) && !empty($soc->fk_account)) {
347 $fk_account = $soc->fk_account;
348 }
349 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
350 $transport_mode_id = $soc->transport_mode_id;
351 }
352 if (empty($multicurrency_code) && !empty($soc->multicurrency_code)) {
353 $multicurrency_code = $soc->multicurrency_code;
354 }
355 }
356 }
357
358 // If we want one invoice per reception or if there is no first invoice yet for this thirdparty.
359 $objecttmp->socid = $rcp->socid;
360 $objecttmp->type = $objecttmp::TYPE_STANDARD;
361 $objecttmp->cond_reglement_id = $cond_reglement_id;
362 $objecttmp->mode_reglement_id = $mode_reglement_id;
363 $objecttmp->fk_account = $fk_account;
364 $objecttmp->transport_mode_id = $transport_mode_id;
365 $objecttmp->multicurrency_code = $multicurrency_code;
366
367 // if the VAT reverse-charge is activated by default in supplier card to resume the information
368 if (is_object($soc)) {
369 $objecttmp->vat_reverse_charge = $soc->vat_reverse_charge;
370 }
371
372 $objecttmp->fk_project = $rcp->fk_project;
373 //$objecttmp->multicurrency_code = $rcp->multicurrency_code;
374 if (empty($createbills_onebythird)) {
375 $objecttmp->ref_supplier = $rcp->ref;
376 } else {
377 // Set a unique value for the invoice for the n reception
378 $objecttmp->ref_supplier = $langs->trans("Reception").' '.dol_print_date(dol_now(), 'dayhourlog').'-'.$rcp->socid;
379 }
380
381 $datefacture = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
382 if (empty($datefacture)) {
383 $datefacture = dol_now();
384 }
385
386 $objecttmp->date = $datefacture;
387 $objecttmp->origin = 'reception';
388 $objecttmp->origin_id = (int) $id_reception;
389
390 // Auto calculation of date due if not filled by user
391 if (empty($objecttmp->date_echeance)) {
392 $objecttmp->date_echeance = $objecttmp->calculate_date_lim_reglement();
393 }
394
395 $objecttmp->array_options = $rcp->array_options; // Copy extrafields
396
397 // Set $objecttmp->linked_objects with all links order_supplier existing on reception, so same links will be added to the generated supplier invoice
398 $rcp->fetchObjectLinked();
399 if (count($rcp->linkedObjectsIds['order_supplier']) > 0) {
400 foreach ($rcp->linkedObjectsIds['order_supplier'] as $key => $value) {
401 $objecttmp->linked_objects['order_supplier'] = $value;
402 }
403 }
404
405 $res = $objecttmp->create($user); // This should create the supplier invoice + links into $objecttmp->linked_objects + add a link to ->origin_id
406
407 //var_dump($objecttmp->error);exit;
408 if ($res > 0) {
409 $nb_bills_created++;
410 $lastref = $objecttmp->ref;
411 $lastid = $objecttmp->id;
412
413 $TFactThird[$rcp->socid] = $objecttmp;
414 $TFactThirdNbLines[$rcp->socid] = 0; //init nblines to have lines ordered by expedition and rang
415 } else {
416 $langs->load("errors");
417 $errors[] = $rcp->ref.' : '.$langs->trans($objecttmp->error);
418 $error++;
419 }
420 }
421
422 if ($objecttmp->id > 0) {
423 if (!isset($rcp->origin_object)) {
424 $rcp->fetch_origin();
425 }
426 if ($rcp->origin_object->multicurrency_code != $objecttmp->multicurrency_code) {
427 $errors[] = $rcp->ref." : ".$langs->trans("ReceptionMustBeInTheSameCurrencyThanOther");
428 }
429
430 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_reception);
431
432 if ($res == 0) {
433 $errors[] = $objecttmp->error;
434 $error++;
435 }
436
437 if (!$error) {
438 $lines = $rcp->lines;
439 if (empty($lines) && method_exists($rcp, 'fetch_lines')) {
440 $rcp->fetch_lines();
441 $lines = $rcp->lines;
442 }
443
444 $fk_parent_line = 0;
445 $num = count($lines);
446
447 for ($i = 0; $i < $num; $i++) {
448 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
449 // If we build one invoice for several reception, we must put the ref of reception on the invoice line
450 if (!empty($createbills_onebythird)) {
451 $desc = dol_concatdesc($desc, $langs->trans("Reception").' '.$rcp->ref);
452 $desc .= (!empty($rcp->date_reception) ? ' - '.dol_print_date($rcp->date_reception, 'day') : '');
453 }
454
455 if ($lines[$i]->subprice < 0) {
456 // Negative line, we create a discount line
457 $discount = new DiscountAbsolute($db);
458 $discount->discount_type = 1;
459 $discount->fk_soc = $objecttmp->socid;
460 $discount->socid = $objecttmp->socid;
461 $discount->amount_ht = abs($lines[$i]->total_ht);
462 $discount->amount_tva = abs($lines[$i]->total_tva);
463 $discount->amount_ttc = abs($lines[$i]->total_ttc);
464 $discount->tva_tx = $lines[$i]->tva_tx;
465 $discount->fk_user = $user->id;
466 $discount->description = $desc;
467 $discountid = $discount->create($user);
468 if ($discountid > 0) {
469 $result = $objecttmp->insert_discount($discountid);
470 //$result=$discount->link_to_invoice($lineid,$id);
471 } else {
472 setEventMessages($discount->error, $discount->errors, 'errors');
473 $error++;
474 break;
475 }
476 } else {
477 // Positive line
478 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
479 // Date start
480 $date_start = false;
481 if ($lines[$i]->date_debut_prevue) {
482 $date_start = $lines[$i]->date_debut_prevue;
483 }
484 if ($lines[$i]->date_debut_reel) {
485 $date_start = $lines[$i]->date_debut_reel;
486 }
487 if ($lines[$i]->date_start) {
488 $date_start = $lines[$i]->date_start;
489 }
490 //Date end
491 $date_end = false;
492 if ($lines[$i]->date_fin_prevue) {
493 $date_end = $lines[$i]->date_fin_prevue;
494 }
495 if ($lines[$i]->date_fin_reel) {
496 $date_end = $lines[$i]->date_fin_reel;
497 }
498 if ($lines[$i]->date_end) {
499 $date_end = $lines[$i]->date_end;
500 }
501 // Reset fk_parent_line for no child products and special product
502 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
503 $fk_parent_line = 0;
504 }
505
506 // Extrafields
507 if (method_exists($lines[$i], 'fetch_optionals')) {
508 $lines[$i]->fetch_optionals();
509 $array_options = $lines[$i]->array_options;
510 }
511
512 $objecttmp->context['createfromclone'] = 'createfromclone';
513
514 $rang = $i;
515 //there may already be rows from previous receptions
516 if (!empty($createbills_onebythird)) {
517 $rang = $TFactThirdNbLines[$rcp->socid];
518 }
519
520 $result = $objecttmp->addline(
521 $desc,
522 $lines[$i]->subprice,
523 $lines[$i]->tva_tx,
524 $lines[$i]->localtax1_tx,
525 $lines[$i]->localtax2_tx,
526 $lines[$i]->qty,
527 $lines[$i]->fk_product,
528 $lines[$i]->remise_percent,
530 $date_end,
531 0,
532 (int) $lines[$i]->info_bits,
533 'HT',
534 $product_type,
535 $rang,
536 0,
537 array(),
538 null,
539 $lines[$i]->rowid,
540 $lines[$i]->multicurrency_subprice,
541 $lines[$i]->ref_supplier
542 );
543
544 $rcp->add_object_linked('facture_fourn_det', $result);
545
546 if ($result > 0) {
547 $lineid = $result;
548 if (!empty($createbills_onebythird)) { //increment rang to keep order
549 $TFactThirdNbLines[$rcp->socid]++;
550 }
551 } else {
552 $lineid = 0;
553 $error++;
554 break;
555 }
556 // Defined the new fk_parent_line
557 if ($result > 0 && $lines[$i]->product_type == 9) {
558 $fk_parent_line = $result;
559 }
560 }
561 }
562 }
563 }
564
565 //$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
566
567 if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) {
568 $TFactThird[$rcp->socid] = $objecttmp;
569 } else {
570 $TFact[$objecttmp->id] = $objecttmp;
571 }
572 }
573
574 // Build doc with all invoices
575 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
576 $toselect = array();
577
578 if (!$error && $validate_invoices) {
579 $massaction = $action = 'builddoc';
580 foreach ($TAllFact as &$objecttmp) {
581 $result = $objecttmp->validate($user);
582 if ($result <= 0) {
583 $error++;
584 setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
585 break;
586 }
587
588 $id = $objecttmp->id; // For builddoc action
589 $lastref = $objecttmp->ref; // generated ref
590 $object = $objecttmp;
591
592 // Fac builddoc
593 $donotredirect = 1;
594 $upload_dir = $conf->fournisseur->facture->dir_output;
595 $permissiontoadd = ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer'));
596
597 // Call action to build doc
598 $savobject = $object;
599 $object = $objecttmp;
600 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
601 $object = $savobject;
602 }
603
604 $massaction = $action = 'confirm_createbills';
605 }
606
607 if (!$error) {
608 $db->commit();
609
610 if ($nb_bills_created == 1) {
611 $texttoshow = $langs->trans('BillXCreated', '{s1}');
612 $texttoshow = str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?id='.urlencode((string) ($lastid)).'">'.$lastref.'</a>', $texttoshow);
613 setEventMessages($texttoshow, null, 'mesgs');
614 } else {
615 setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
616 }
617 } else {
618 $db->rollback();
619
620 $action = 'create';
621 $_GET["origin"] = GETPOST("origin", 'alpha');
622 $_GET["originid"] = GETPOSTINT("originid");
623 setEventMessages($object->error, $errors, 'errors');
624 $error++;
625 }
626 }
627}
628
629
630/*
631 * View
632 */
633
634$now = dol_now();
635
636$form = new Form($db);
637$companystatic = new Societe($db);
638$reception = new Reception($db);
639$formcompany = new FormCompany($db);
640$formfile = new FormFile($db);
641
642$title = $langs->trans('Receptions');
643$helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:M&oacute;dulo_Receptiones';
644llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'bodyforlist mod-reception page-list');
645
646$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 as status, e.billed,e.note_private, e.note_public,";
647$sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
648$sql .= " typent.code as typent_code,";
649$sql .= " state.code_departement as state_code, state.nom as state_name,";
650$sql .= " e.date_creation as date_creation, e.tms as date_modification";
651// Add fields from extrafields
652if (!empty($extrafields->attributes[$object->table_element]['label'])) {
653 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
654 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
655 }
656}
657// Add fields from hooks
658$parameters = array();
659$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
660$sql .= $hookmanager->resPrint;
661
662$sqlfields = $sql; // $sql fields to remove for count total
663
664$sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
665if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
666 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
667}
668$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
669$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
670$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
671$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
672$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'";
673$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
674// Add table from hooks
675$parameters = array();
676// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
677$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
678$sql .= $hookmanager->resPrint;
679$sql .= " WHERE e.entity IN (".getEntity('reception').")";
680if ($socid) {
681 $sql .= " AND e.fk_soc = ".((int) $socid);
682}
683if ($search_status != '' && $search_status >= 0) {
684 $sql .= " AND e.fk_statut = ".((int) $search_status);
685}
686if ($search_billed != '' && $search_billed >= 0) {
687 $sql .= ' AND e.billed = '.((int) $search_billed);
688}
689if ($search_town) {
690 $sql .= natural_search('s.town', $search_town);
691}
692if ($search_zip) {
693 $sql .= natural_search("s.zip", $search_zip);
694}
695if ($search_state) {
696 $sql .= natural_search("state.nom", $search_state);
697}
698if ($search_country) {
699 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
700}
701if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
702 $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
703}
704if ($search_date_delivery_start) {
705 $sql .= " AND e.date_delivery >= '".$db->idate($search_date_delivery_start)."'";
706}
707if ($search_date_delivery_end) {
708 $sql .= " AND e.date_delivery <= '".$db->idate($search_date_delivery_end)."'";
709}
710if ($search_date_create_start) {
711 $sql .= " AND e.date_creation >= '".$db->idate($search_date_create_start)."'";
712}
713
714if ($search_note_public) {
715 $sql .= " AND e.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public))."%'";
716}
717if ($search_note_private) {
718 $sql .= " AND e.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private))."%'";
719}
720if ($search_date_create_end) {
721 $sql .= " AND e.date_creation <= '".$db->idate($search_date_create_end)."'";
722}
723if ($search_ref_rcp) {
724 $sql .= natural_search('e.ref', $search_ref_rcp);
725}
726if ($search_ref_liv) {
727 $sql .= natural_search('l.ref', $search_ref_liv);
728}
729if ($search_company) {
730 $sql .= natural_search('s.nom', $search_company);
731}
732if ($search_ref_supplier) {
733 $sql .= natural_search('e.ref_supplier', $search_ref_supplier);
734}
735if ($search_all) {
736 $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
737}
738// Search on sale representative
739/*
740if ($search_sale && $search_sale != '-1') {
741 if ($search_sale == -2) {
742 $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
743 } elseif ($search_sale > 0) {
744 $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
745 }
746}
747*/
748// Add where from extra fields
749include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
750// Add where from hooks
751$parameters = array();
752$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
753$sql .= $hookmanager->resPrint;
754
755// Add HAVING from hooks
756$parameters = array();
757$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook
758if (empty($reshook)) {
759 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
760} else {
761 $sql = $hookmanager->resPrint;
762}
763
764$nbtotalofrecords = '';
765if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
766 /* The fast and low memory method to get and count full list converts the sql into a sql count */
767 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
768 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
769 $resql = $db->query($sqlforcount);
770 if ($resql) {
771 $objforcount = $db->fetch_object($resql);
772 $nbtotalofrecords = $objforcount->nbtotalofrecords;
773 } else {
775 }
776
777 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
778 $page = 0;
779 $offset = 0;
780 }
781 $db->free($resql);
782}
783
784// Complete request and execute it with limit
785$sql .= $db->order($sortfield, $sortorder);
786if ($limit) {
787 $sql .= $db->plimit($limit + 1, $offset);
788}
789
790//print $sql;
791$resql = $db->query($sql);
792if (!$resql) {
794 exit;
795}
796
797$num = $db->num_rows($resql);
798
799$reception = new Reception($db);
800
801$arrayofselected = is_array($toselect) ? $toselect : array();
802
803$param = '';
804if (!empty($mode)) {
805 $param .= '&mode='.urlencode($mode);
806}
807if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
808 $param .= '&contextpage='.urlencode($contextpage);
809}
810if ($limit > 0 && $limit != $conf->liste_limit) {
811 $param .= '&limit='.((int) $limit);
812}
813if ($search_all) {
814 $param .= "&search_all=".urlencode($search_all);
815}
816if ($search_ref_rcp) {
817 $param .= "&search_ref_rcp=".urlencode($search_ref_rcp);
818}
819if ($search_ref_liv) {
820 $param .= "&search_ref_liv=".urlencode($search_ref_liv);
821}
822if ($search_company) {
823 $param .= "&search_company=".urlencode($search_company);
824}
825if ($optioncss != '') {
826 $param .= '&optioncss='.urlencode($optioncss);
827}
828if ($search_billed != '' && $search_billed >= 0) {
829 $param .= "&search_billed=".urlencode((string) ($search_billed));
830}
831if ($search_town) {
832 $param .= "&search_town=".urlencode($search_town);
833}
834if ($search_zip) {
835 $param .= "&search_zip=".urlencode($search_zip);
836}
837if ($search_state) {
838 $param .= "&search_state=".urlencode($search_state);
839}
840if ($search_status != '') {
841 $param .= "&search_status=".urlencode($search_status);
842}
843if ($search_country) {
844 $param .= "&search_country=".urlencode((string) ($search_country));
845}
846if ($search_type_thirdparty) {
847 $param .= "&search_type_thirdparty=".urlencode((string) ($search_type_thirdparty));
848}
849if ($search_date_delivery_startday) {
850 $param .= '&search_date_delivery_startday='.urlencode((string) ($search_date_delivery_startday));
851}
852if ($search_date_delivery_startmonth) {
853 $param .= '&search_date_delivery_startmonth='.urlencode((string) ($search_date_delivery_startmonth));
854}
855if ($search_date_delivery_startyear) {
856 $param .= '&search_date_delivery_startyear='.urlencode((string) ($search_date_delivery_startyear));
857}
858if ($search_date_delivery_endday) {
859 $param .= '&search_date_delivery_endday='.urlencode((string) ($search_date_delivery_endday));
860}
861if ($search_date_delivery_endmonth) {
862 $param .= '&search_date_delivery_endmonth='.urlencode((string) ($search_date_delivery_endmonth));
863}
864if ($search_date_delivery_endyear) {
865 $param .= '&search_date_delivery_endyear='.urlencode((string) ($search_date_delivery_endyear));
866}
867if ($search_date_create_startday) {
868 $param .= '&search_date_create_startday='.urlencode((string) ($search_date_create_startday));
869}
870if ($search_date_create_startmonth) {
871 $param .= '&search_date_create_startmonth='.urlencode((string) ($search_date_create_startmonth));
872}
873if ($search_date_create_startyear) {
874 $param .= '&search_date_create_startyear='.urlencode((string) ($search_date_create_startyear));
875}
876if ($search_date_create_endday) {
877 $param .= '&search_date_create_endday='.urlencode((string) ($search_date_create_endday));
878}
879if ($search_date_create_endmonth) {
880 $param .= '&search_date_create_endmonth='.urlencode((string) ($search_date_create_endmonth));
881}
882if ($search_date_create_endyear) {
883 $param .= '&search_date_create_endyear='.urlencode((string) ($search_date_create_endyear));
884}
885if ($search_ref_supplier) {
886 $param .= "&search_ref_supplier=".urlencode($search_ref_supplier);
887}
888// Add $param from extra fields
889if ($search_array_options) {
890 foreach ($search_array_options as $key => $val) {
891 $crit = $val;
892 $tmpkey = preg_replace('/search_options_/', '', $key);
893 if (is_array($val) && array_key_exists('start', $val) && array_key_exists('end', $val)) {
894 // date range from list filters is stored as array('start' => <timestamp>, 'end' => <timestamp>)
895 // start date
896 $param .= '&search_options_'.$tmpkey.'_startyear='.dol_print_date($val['start'], '%Y');
897 $param .= '&search_options_'.$tmpkey.'_startmonth='.dol_print_date($val['start'], '%m');
898 $param .= '&search_options_'.$tmpkey.'_startday='.dol_print_date($val['start'], '%d');
899 $param .= '&search_options_'.$tmpkey.'_starthour='.dol_print_date($val['start'], '%H');
900 $param .= '&search_options_'.$tmpkey.'_startmin='.dol_print_date($val['start'], '%M');
901 // end date
902 $param .= '&search_options_'.$tmpkey.'_endyear='.dol_print_date($val['end'], '%Y');
903 $param .= '&search_options_'.$tmpkey.'_endmonth='.dol_print_date($val['end'], '%m');
904 $param .= '&search_options_'.$tmpkey.'_endday='.dol_print_date($val['end'], '%d');
905 $param .= '&search_options_'.$tmpkey.'_endhour='.dol_print_date($val['end'], '%H');
906 $param .= '&search_options_'.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M');
907 $val = '';
908 }
909 if ($val != '') {
910 $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
911 }
912 }
913}
914
915
916$arrayofmassactions = array(
917 'builddoc' => img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
918 // 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
919);
920
921if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
922 $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisReceptions");
923}
924if (in_array($massaction, array('presend', 'createbills'))) {
925 $arrayofmassactions = array();
926}
927$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
928
929// Currently: a sending can't create from sending list
930// $url = DOL_URL_ROOT.'/expedition/card.php?action=create';
931// if (!empty($socid)) $url .= '&socid='.$socid;
932// $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer);
933$newcardbutton = '';
934$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition'));
935$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition'));
936$newcardbutton .= dolGetButtonTitle($langs->trans('Statistics'), '', 'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.'/reception/stats/index.php?mode=statistics'.preg_replace('/(&|\?)*(mode|groupby)=[^&]+/', '', $param), '', ($mode == 'statistics' ? 2 : 1), array('morecss' => 'reposition'));
937$newcardbutton .= dolGetButtonTitleSeparator();
938$newcardbutton .= dolGetButtonTitle($langs->trans('NewReception'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/reception/card.php?action=create', '', $user->hasRight('reception', 'creer'));
939
940$i = 0;
941print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
942if ($optioncss != '') {
943 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
944}
945print '<input type="hidden" name="token" value="'.newToken().'">';
946print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
947print '<input type="hidden" name="action" value="list">';
948print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
949print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
950print '<input type="hidden" name="mode" value="'.$mode.'">';
951
952// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
953print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dollyrevert', 0, $newcardbutton, '', $limit, 0, 0, 1);
954
955if ($massaction == 'createbills') {
956 //var_dump($_REQUEST);
957 print '<input type="hidden" name="massaction" value="confirm_createbills">';
958
959 print '<table class="noborder centpercent">';
960 print '<tr>';
961 print '<td class="titlefieldmiddle">';
962 print $langs->trans('DateInvoice');
963 print '</td>';
964 print '<td>';
965 print $form->selectDate('', '', 0, 0, 0, '', 1, 1);
966 print '</td>';
967 print '</tr>';
968 print '<tr>';
969 print '<td>';
970 print $langs->trans('CreateOneBillByThird');
971 print '</td>';
972 print '<td>';
973 print $form->selectyesno('createbills_onebythird', '', 1);
974 print '</td>';
975 print '</tr>';
976 print '<tr>';
977 print '<td>';
978 print $langs->trans('ValidateInvoices');
979 print '</td>';
980 print '<td>';
981 if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) {
982 print $form->selectyesno('validate_invoices', 0, 1, 1);
983 print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')';
984 } else {
985 print $form->selectyesno('validate_invoices', 0, 1);
986 }
987 print '</td>';
988 print '</tr>';
989 print '</table>';
990
991 print '<br>';
992 print '<div class="center">';
993 print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisReceptions').'"> ';
994 print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
995 print '</div>';
996 print '<br>';
997}
998
999if ($search_all) {
1000 foreach ($fieldstosearchall as $key => $val) {
1001 $fieldstosearchall[$key] = $langs->trans($val);
1002 }
1003 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';
1004}
1005
1006$moreforfilter = '';
1007
1008if (!empty($moreforfilter)) {
1009 print '<div class="liste_titre liste_titre_bydiv centpercent">';
1010 print $moreforfilter;
1011 $parameters = array();
1012 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1013 print $hookmanager->resPrint;
1014 print '</div>';
1015}
1016
1017$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
1018$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column);
1019if ($massactionbutton) {
1020 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields
1021}
1022
1023print '<div class="div-table-responsive">';
1024print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
1025
1026// Fields title search
1027// --------------------------------------------------------------------
1028print '<tr class="liste_titre_filter">';
1029// Action column
1030if ($conf->main_checkbox_left_column) {
1031 print '<td class="liste_titre center maxwidthsearch">';
1032 $searchpicto = $form->showFilterButtons('left');
1033 print $searchpicto;
1034 print '</td>';
1035}
1036// Ref
1037if (!empty($arrayfields['e.ref']['checked'])) {
1038 print '<td class="liste_titre">';
1039 print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.'">';
1040 print '</td>';
1041}
1042// Ref customer
1043if (!empty($arrayfields['e.ref_supplier']['checked'])) {
1044 print '<td class="liste_titre">';
1045 print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.'">';
1046 print '</td>';
1047}
1048// Thirdparty
1049if (!empty($arrayfields['s.nom']['checked'])) {
1050 print '<td class="liste_titre left">';
1051 print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
1052 print '</td>';
1053}
1054// Town
1055if (!empty($arrayfields['s.town']['checked'])) {
1056 print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
1057}
1058// Zip
1059if (!empty($arrayfields['s.zip']['checked'])) {
1060 print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
1061}
1062// State
1063if (!empty($arrayfields['state.nom']['checked'])) {
1064 print '<td class="liste_titre">';
1065 print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
1066 print '</td>';
1067}
1068// Country
1069if (!empty($arrayfields['country.code_iso']['checked'])) {
1070 print '<td class="liste_titre center">';
1071 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
1072 print '</td>';
1073}
1074// Company type
1075if (!empty($arrayfields['typent.code']['checked'])) {
1076 print '<td class="liste_titre maxwidthonsmartphone center">';
1077 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'), '', 1);
1078 print '</td>';
1079}
1080// Date delivery planned
1081if (!empty($arrayfields['e.date_delivery']['checked'])) {
1082 print '<td class="liste_titre center">';
1083 print '<div class="nowrapfordate">';
1084 print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1085 print '</div>';
1086 print '<div class="nowrapfordate">';
1087 print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1088 print '</div>';
1089 print '</td>';
1090}
1091if (!empty($arrayfields['l.ref']['checked'])) {
1092 // Delivery ref
1093 print '<td class="liste_titre">';
1094 print '<input class="flat" type="text" name="search_ref_liv" value="'.dol_escape_htmltag($search_ref_liv).'"';
1095 print '</td>';
1096}
1097if (!empty($arrayfields['l.date_delivery']['checked'])) {
1098 // Date received
1099 print '<td class="liste_titre center">&nbsp;</td>';
1100}
1101// Extra fields
1102include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
1103
1104// Fields from hook
1105$parameters = array('arrayfields' => $arrayfields);
1106$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
1107print $hookmanager->resPrint;
1108// Date creation
1109if (!empty($arrayfields['e.datec']['checked'])) {
1110 print '<td class="liste_titre center">';
1111 print '<div class="nowrapfordate">';
1112 print $form->selectDate($search_date_create_start ? $search_date_create_start : -1, 'search_date_create_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
1113 print '</div>';
1114 print '<div class="nowrapfordate">';
1115 print $form->selectDate($search_date_create_end ? $search_date_create_end : -1, 'search_date_create_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
1116 print '</div>';
1117 print '</td>';
1118}
1119// Date modification
1120if (!empty($arrayfields['e.tms']['checked'])) {
1121 print '<td class="liste_titre">';
1122 print '</td>';
1123}
1124if (!empty($arrayfields['e.note_public']['checked'])) {
1125 // Note public
1126 print '<td class="liste_titre">';
1127 print '<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).'">';
1128 print '</td>';
1129}
1130if (!empty($arrayfields['e.note_private']['checked'])) {
1131 // Note private
1132 print '<td class="liste_titre">';
1133 print '<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).'">';
1134 print '</td>';
1135}
1136// Status
1137if (!empty($arrayfields['e.fk_statut']['checked'])) {
1138 print '<td class="liste_titre right parentonrightofpage">';
1139 print $form->selectarray('search_status', array('0' => $langs->trans('StatusReceptionDraftShort'), '1' => $langs->trans('StatusReceptionValidatedShort'), '2' => $langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
1140 print '</td>';
1141}
1142// Status billed
1143if (!empty($arrayfields['e.billed']['checked'])) {
1144 print '<td class="liste_titre maxwidthonsmartphone center">';
1145 print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
1146 print '</td>';
1147}
1148// Action column
1149if (!$conf->main_checkbox_left_column) {
1150 print '<td class="liste_titre middle">';
1151 $searchpicto = $form->showFilterButtons();
1152 print $searchpicto;
1153 print '</td>';
1154}
1155print '</tr>'."\n";
1156
1157$totalarray = array();
1158$totalarray['nbfield'] = 0;
1159
1160// Fields title label
1161// --------------------------------------------------------------------
1162print '<tr class="liste_titre">';
1163// Action column
1164if ($conf->main_checkbox_left_column) {
1165 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1166 $totalarray['nbfield']++;
1167}
1168if (!empty($arrayfields['e.ref']['checked'])) {
1169 // @phan-suppress-next-line PhanTypeInvalidDimOffset
1170 print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
1171 $totalarray['nbfield']++;
1172}
1173if (!empty($arrayfields['e.ref_supplier']['checked'])) {
1174 print_liste_field_titre($arrayfields['e.ref_supplier']['label'], $_SERVER["PHP_SELF"], "e.ref_supplier", "", $param, '', $sortfield, $sortorder);
1175 $totalarray['nbfield']++;
1176}
1177if (!empty($arrayfields['s.nom']['checked'])) {
1178 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left ');
1179 $totalarray['nbfield']++;
1180}
1181if (!empty($arrayfields['s.town']['checked'])) {
1182 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
1183 $totalarray['nbfield']++;
1184}
1185if (!empty($arrayfields['s.zip']['checked'])) {
1186 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
1187 $totalarray['nbfield']++;
1188}
1189if (!empty($arrayfields['state.nom']['checked'])) {
1190 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
1191 $totalarray['nbfield']++;
1192}
1193if (!empty($arrayfields['country.code_iso']['checked'])) {
1194 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
1195 $totalarray['nbfield']++;
1196}
1197if (!empty($arrayfields['typent.code']['checked'])) {
1198 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
1199 $totalarray['nbfield']++;
1200}
1201if (!empty($arrayfields['e.date_delivery']['checked'])) {
1202 print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
1203 $totalarray['nbfield']++;
1204}
1205if (!empty($arrayfields['l.ref']['checked'])) {
1206 print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
1207 $totalarray['nbfield']++;
1208}
1209if (!empty($arrayfields['l.date_delivery']['checked'])) {
1210 print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
1211 $totalarray['nbfield']++;
1212}
1213// Extra fields
1214include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1215// Hook fields
1216$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, '$totalarray' => &$totalarray);
1217$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
1218print $hookmanager->resPrint;
1219if (!empty($arrayfields['e.datec']['checked'])) {
1220 print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1221 $totalarray['nbfield']++;
1222}
1223if (!empty($arrayfields['e.tms']['checked'])) {
1224 print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1225 $totalarray['nbfield']++;
1226}
1227if (!empty($arrayfields['e.note_public']['checked'])) {
1228 print_liste_field_titre($arrayfields['e.note_public']['label'], $_SERVER["PHP_SELF"], "e.note_public", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1229 $totalarray['nbfield']++;
1230}
1231if (!empty($arrayfields['e.note_private']['checked'])) {
1232 print_liste_field_titre($arrayfields['e.note_private']['label'], $_SERVER["PHP_SELF"], "e.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1233 $totalarray['nbfield']++;
1234}
1235if (!empty($arrayfields['e.fk_statut']['checked'])) {
1236 print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
1237 $totalarray['nbfield']++;
1238}
1239if (!empty($arrayfields['e.billed']['checked'])) {
1240 print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
1241 $totalarray['nbfield']++;
1242}
1243// Action column
1244if (!$conf->main_checkbox_left_column) {
1245 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1246 $totalarray['nbfield']++;
1247}
1248print "</tr>\n";
1249
1250
1251// Loop on record
1252// --------------------------------------------------------------------
1253$i = 0;
1254$savnbfield = $totalarray['nbfield'];
1255$totalarray = array();
1256$totalarray['nbfield'] = 0;
1257$imaxinloop = ($limit ? min($num, $limit) : $num);
1258while ($i < $imaxinloop) {
1259 $obj = $db->fetch_object($resql);
1260 if (empty($obj)) {
1261 break; // Should not happen
1262 }
1263
1264 $reception->id = $obj->rowid;
1265 $reception->ref = $obj->ref;
1266 //$reception->ref_supplier = $obj->ref_supplier;
1267 $reception->statut = $obj->status;
1268 $reception->status = $obj->status;
1269 $reception->socid = $obj->socid;
1270 $reception->billed = $obj->billed;
1271 $reception->note_public = $obj->note_public;
1272 $reception->note_private = $obj->note_private;
1273
1274 $reception->fetch_thirdparty();
1275
1276 $object = $reception;
1277
1278 $companystatic->id = $obj->socid;
1279 $companystatic->ref = $obj->name;
1280 $companystatic->name = $obj->name;
1281
1282 if ($mode == 'kanban') {
1283 if ($i == 0) {
1284 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
1285 print '<div class="box-flex-container kanban">';
1286 }
1287 $object->date_delivery = $obj->delivery_date;
1288 $object->town = $obj->town;
1289
1290 // Output Kanban
1291 $selected = -1;
1292 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1293 $selected = 0;
1294 if (in_array($object->id, $arrayofselected)) {
1295 $selected = 1;
1296 }
1297 }
1298 print $object->getKanbanView('', array('thirdparty' => $companystatic->getNomUrl(1), 'selected' => $selected));
1299 if ($i == min($num, $limit) - 1) {
1300 print '</div>';
1301 print '</td></tr>';
1302 }
1303 } else {
1304 print '<tr class="oddeven row-with-select">';
1305
1306 // Action column
1307 if ($conf->main_checkbox_left_column) {
1308 print '<td class="nowrap center">';
1309 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1310 $selected = 0;
1311 if (in_array($obj->rowid, $arrayofselected)) {
1312 $selected = 1;
1313 }
1314 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1315 }
1316 print '</td>';
1317 }
1318 // Ref
1319 if (!empty($arrayfields['e.ref']['checked'])) {
1320 print '<td class="nowraponall">';
1321 print $reception->getNomUrl(1);
1322 $filename = dol_sanitizeFileName($reception->ref);
1323 $filedir = $conf->reception->dir_output.'/'.dol_sanitizeFileName($reception->ref);
1324 $urlsource = $_SERVER['PHP_SELF'].'?id='.$reception->id;
1325 print $formfile->getDocumentsLink($reception->element, $filename, $filedir);
1326 print "</td>\n";
1327
1328 if (!$i) {
1329 $totalarray['nbfield']++;
1330 }
1331 }
1332
1333 // Ref supplier
1334 if (!empty($arrayfields['e.ref_supplier']['checked'])) {
1335 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).'">';
1336 print dol_escape_htmltag($obj->ref_supplier);
1337 print "</td>\n";
1338 if (!$i) {
1339 $totalarray['nbfield']++;
1340 }
1341 }
1342
1343 // Third party
1344 if (!empty($arrayfields['s.nom']['checked'])) {
1345 print '<td class="tdoverflowmax150">';
1346 print $companystatic->getNomUrl(1);
1347 print '</td>';
1348 if (!$i) {
1349 $totalarray['nbfield']++;
1350 }
1351 }
1352 // Town
1353 if (!empty($arrayfields['s.town']['checked'])) {
1354 print '<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->town).'">';
1355 print dol_escape_htmltag($obj->town);
1356 print '</td>';
1357 if (!$i) {
1358 $totalarray['nbfield']++;
1359 }
1360 }
1361 // Zip
1362 if (!empty($arrayfields['s.zip']['checked'])) {
1363 print '<td class="nocellnopadd center"">';
1364 print dol_escape_htmltag($obj->zip);
1365 print '</td>';
1366 if (!$i) {
1367 $totalarray['nbfield']++;
1368 }
1369 }
1370 // State
1371 if (!empty($arrayfields['state.nom']['checked'])) {
1372 print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n";
1373 if (!$i) {
1374 $totalarray['nbfield']++;
1375 }
1376 }
1377 // Country
1378 if (!empty($arrayfields['country.code_iso']['checked'])) {
1379 print '<td class="center">';
1380 $tmparray = getCountry($obj->fk_pays, 'all');
1381 print dol_escape_htmltag($tmparray['label']);
1382 print '</td>';
1383 if (!$i) {
1384 $totalarray['nbfield']++;
1385 }
1386 }
1387 // Type ent
1388 if (!empty($arrayfields['typent.code']['checked'])) {
1389 print '<td class="center">';
1390 if (!isset($typenArray) || empty($typenArray)) { // @phan-suppress-current-line PhanPluginUndeclaredVariableIsset
1391 $typenArray = $formcompany->typent_array(1);
1392 }
1393 if (isset($typenArray[$obj->typent_code])) {
1394 print $typenArray[$obj->typent_code];
1395 }
1396 print '</td>';
1397 if (!$i) {
1398 $totalarray['nbfield']++;
1399 }
1400 }
1401
1402 // Date delivery planned
1403 if (!empty($arrayfields['e.date_delivery']['checked'])) {
1404 print '<td class="center">';
1405 print dol_print_date($db->jdate($obj->delivery_date), "day");
1406 /*$now = time();
1407 if ( ($now - $db->jdate($obj->date_reception)) > $conf->warnings->lim && $obj->statutid == 1 )
1408 {
1409 }*/
1410 print "</td>\n";
1411 if (!$i) {
1412 $totalarray['nbfield']++;
1413 }
1414 }
1415
1416 if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) {
1417 $reception->fetchObjectLinked($reception->id, $reception->element);
1418 $receiving = '';
1419 if (count($reception->linkedObjects['delivery']) > 0) {
1420 $receiving = reset($reception->linkedObjects['delivery']);
1421 }
1422
1423 if (!empty($arrayfields['l.ref']['checked'])) {
1424 // Ref
1425 print '<td>';
1426 print !empty($receiving) ? $receiving->getNomUrl($db) : '';
1427 print '</td>';
1428 }
1429
1430 if (!empty($arrayfields['l.date_delivery']['checked'])) {
1431 // Date received
1432 print '<td class="center">';
1433 print dol_print_date($db->jdate($obj->date_reception), "day");
1434 print '</td>'."\n";
1435 }
1436 }
1437
1438 // Extra fields
1439 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1440
1441 // Fields from hook
1442 $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1443 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1444 print $hookmanager->resPrint;
1445 // Date creation
1446 if (!empty($arrayfields['e.datec']['checked'])) {
1447 print '<td class="center nowraponall">';
1448 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuserrel');
1449 print '</td>';
1450 if (!$i) {
1451 $totalarray['nbfield']++;
1452 }
1453 }
1454 // Date modification
1455 if (!empty($arrayfields['e.tms']['checked'])) {
1456 print '<td class="center nowraponall">';
1457 print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuserrel');
1458 print '</td>';
1459 if (!$i) {
1460 $totalarray['nbfield']++;
1461 }
1462 }
1463 // Note public
1464 if (!empty($arrayfields['e.note_public']['checked'])) {
1465 print '<td class="sensiblehtmlcontent center">';
1466 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_public, 5)).'</div>';
1467 print '</td>';
1468 if (!$i) {
1469 $totalarray['nbfield']++;
1470 }
1471 }
1472 // Note private
1473 if (!empty($arrayfields['e.note_private']['checked'])) {
1474 print '<td class="sensiblehtmlcontent center">';
1475 print '<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(dolGetFirstLineOfText($obj->note_private, 5)).'</div>';
1476 print '</td>';
1477 if (!$i) {
1478 $totalarray['nbfield']++;
1479 }
1480 }
1481 // Status
1482 if (!empty($arrayfields['e.fk_statut']['checked'])) {
1483 print '<td class="right nowrap">'.$reception->LibStatut($obj->status, 5).'</td>';
1484 if (!$i) {
1485 $totalarray['nbfield']++;
1486 }
1487 }
1488 // Billed
1489 if (!empty($arrayfields['e.billed']['checked'])) {
1490 print '<td class="center">'.yn($obj->billed).'</td>';
1491 if (!$i) {
1492 $totalarray['nbfield']++;
1493 }
1494 }
1495
1496 // Action column
1497 if (!$conf->main_checkbox_left_column) {
1498 print '<td class="nowrap center">';
1499 if ($massactionbutton || $massaction) {
1500 // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1501 $selected = 0;
1502 if (in_array($obj->rowid, $arrayofselected)) {
1503 $selected = 1;
1504 }
1505 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1506 }
1507 print '</td>';
1508 }
1509 if (!$i) {
1510 $totalarray['nbfield']++;
1511 }
1512
1513 print "</tr>\n";
1514 }
1515 $i++;
1516}
1517
1518// If no record found
1519if ($num == 0) {
1520 $colspan = 1;
1521 foreach ($arrayfields as $key => $val) {
1522 if (!empty($val['checked'])) {
1523 $colspan++;
1524 }
1525 }
1526 print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1527}
1528
1529// Show total line
1530include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1531
1532$parameters = array('arrayfields' => $arrayfields, 'totalarray' => $totalarray, 'sql' => $sql);
1533$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1534print $hookmanager->resPrint;
1535
1536print "</table>";
1537print "</div>";
1538print '</form>';
1539
1540$db->free($resql);
1541
1542$hidegeneratedfilelistifempty = 1;
1543if ($massaction == 'builddoc' || $action == 'remove_file') {
1544 $hidegeneratedfilelistifempty = 0;
1545}
1546
1547// Show list of available documents
1548$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
1549$urlsource .= str_replace('&amp;', '&', $param);
1550
1551$filedir = $diroutputmassaction;
1552$genallowed = $user->hasRight('reception', 'lire');
1553$delallowed = $user->hasRight('reception', 'creer');
1554$title = '';
1555
1556print $formfile->showdocuments('massfilesarea_receipts', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
1557
1558// End of page
1559llxFooter();
1560$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:501
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage absolute discounts.
Class to manage standard extra fields.
Class to manage suppliers invoices.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage receptions.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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...
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.