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