27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 $langs->loadLangs(array(
"sendings",
"receptions",
"deliveries",
'companies',
'bills',
'orders'));
39 $socid =
GETPOST(
'socid',
'int');
40 $massaction =
GETPOST(
'massaction',
'alpha');
41 $toselect =
GETPOST(
'toselect',
'array');
43 $diroutputmassaction = $conf->reception->dir_output.
'/temp/massgeneration/'.$user->id;
45 $search_ref_rcp =
GETPOST(
"search_ref_rcp");
46 $search_ref_liv =
GETPOST(
'search_ref_liv');
47 $search_ref_supplier =
GETPOST(
'search_ref_supplier');
48 $search_company =
GETPOST(
"search_company");
49 $search_town =
GETPOST(
'search_town',
'alpha');
50 $search_zip =
GETPOST(
'search_zip',
'alpha');
51 $search_state =
GETPOST(
"search_state");
52 $search_country =
GETPOST(
"search_country",
'int');
53 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
54 $search_billed =
GETPOST(
"search_billed",
'int');
55 $sall =
GETPOST(
'sall',
'alphanohtml');
56 $optioncss =
GETPOST(
'optioncss',
'alpha');
58 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
59 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68 if (empty($page) || $page == -1) {
71 $offset = $limit * $page;
72 $pageprev = $page - 1;
73 $pagenext = $page + 1;
76 $contextpage =
'receptionlist';
78 $search_status =
GETPOST(
'search_status',
'intcomma');
83 $hookmanager->initHooks(array(
'receptionlist'));
87 $extrafields->fetch_name_optionals_label($object->table_element);
88 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
91 $fieldstosearchall = array(
93 's.nom'=>
"ThirdParty",
94 'e.note_public'=>
'NotePublic',
96 if (empty($user->socid)) {
97 $fieldstosearchall[
"e.note_private"] =
"NotePrivate";
100 $checkedtypetiers = 0;
101 $arrayfields = array(
102 'e.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
103 'e.ref_supplier'=>array(
'label'=>$langs->trans(
"RefSupplier"),
'checked'=>1),
104 's.nom'=>array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1),
105 's.town'=>array(
'label'=>$langs->trans(
"Town"),
'checked'=>1),
106 's.zip'=>array(
'label'=>$langs->trans(
"Zip"),
'checked'=>1),
107 'state.nom'=>array(
'label'=>$langs->trans(
"StateShort"),
'checked'=>0),
108 'country.code_iso'=>array(
'label'=>$langs->trans(
"Country"),
'checked'=>0),
109 'typent.code'=>array(
'label'=>$langs->trans(
"ThirdPartyType"),
'checked'=>$checkedtypetiers),
110 'e.date_delivery'=>array(
'label'=>$langs->trans(
"DateDeliveryPlanned"),
'checked'=>1),
111 'e.datec'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
112 'e.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
113 'e.fk_statut'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
114 'e.billed'=>array(
'label'=>$langs->trans(
"Billed"),
'checked'=>1,
'position'=>1000,
'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)))
118 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
126 $receptionid =
GETPOST(
'id',
'int');
128 $socid = $user->socid;
138 $action =
'list'; $massaction =
'';
140 if (!
GETPOST(
'confirmmassaction') && $massaction !=
'confirm_createbills') {
144 $parameters = array(
'socid'=>$socid);
145 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
150 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
153 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
154 $search_ref_supplier =
'';
155 $search_ref_rcp =
'';
156 $search_ref_liv =
'';
157 $search_company =
'';
161 $search_country =
'';
162 $search_type_thirdparty =
'';
165 $search_array_options = array();
168 if (empty($reshook)) {
170 $objectclass =
'Reception';
171 $objectlabel =
'Receptions';
172 $permissiontoread = $user->rights->reception->lire;
173 $permissiontoadd = $user->rights->reception->creer;
174 $permissiontodelete = $user->rights->reception->supprimer;
175 $uploaddir = $conf->reception->multidir_output[$conf->entity];
176 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
178 if ($massaction ==
'confirm_createbills') {
179 $receptions =
GETPOST(
'toselect',
'array');
180 $createbills_onebythird =
GETPOST(
'createbills_onebythird',
'int');
181 $validate_invoices =
GETPOST(
'validate_invoices',
'int');
186 $TFactThird = array();
187 $TFactThirdNbLines = array();
189 $nb_bills_created = 0;
197 foreach ($receptions as $id_reception) {
200 if ($rcp->fetch($id_reception) <= 0 || $rcp->statut != $rcp::STATUS_VALIDATED) {
201 $errors[] = $langs->trans(
'StatusOfRefMustBe', $rcp->ref, $langs->transnoentities(
"StatusSupplierOrderValidatedShort"));
207 if (!empty($createbills_onebythird) && !empty($TFactThird[$rcp->socid])) {
209 $objecttmp = $TFactThird[$rcp->socid];
212 $objecttmp->fetchObjectLinked();
213 $rcp->fetchObjectLinked();
214 if (count($rcp->linkedObjectsIds[
'order_supplier']) > 0) {
215 foreach ($rcp->linkedObjectsIds[
'order_supplier'] as $key => $value) {
216 if (empty($objecttmp->linkedObjectsIds[
'order_supplier']) || !in_array($value, $objecttmp->linkedObjectsIds[
'order_supplier'])) {
217 $objecttmp->add_object_linked(
'order_supplier', $value);
223 $objecttmp->socid = $rcp->socid;
224 $objecttmp->type = $objecttmp::TYPE_STANDARD;
225 $objecttmp->cond_reglement_id = $rcp->cond_reglement_id || $rcp->thirdparty->cond_reglement_supplier_id;
226 $objecttmp->mode_reglement_id = $rcp->mode_reglement_id || $rcp->thirdparty->mode_reglement_supplier_id;
228 $objecttmp->fk_account = !empty($rcp->thirdparty->fk_account) ? $rcp->thirdparty->fk_account : 0;
229 $objecttmp->remise_percent = !empty($rcp->thirdparty->remise_percent) ? $rcp->thirdparty->remise_percent : 0;
230 $objecttmp->remise_absolue = !empty($rcp->thirdparty->remise_absolue) ? $rcp->thirdparty->remise_absolue : 0;
232 $objecttmp->fk_project = $rcp->fk_project;
234 if (empty($createbills_onebythird)) {
235 $objecttmp->ref_supplier = $rcp->ref;
238 $objecttmp->ref_supplier = $langs->trans(
"Reception").
' '.
dol_print_date(
dol_now(),
'dayhourlog').
'-'.$rcp->socid;
242 if (empty($datefacture)) {
246 $objecttmp->date = $datefacture;
247 $objecttmp->origin =
'reception';
248 $objecttmp->origin_id = $id_reception;
250 $objecttmp->array_options = $rcp->array_options;
253 $rcp->fetchObjectLinked();
254 if (count($rcp->linkedObjectsIds[
'order_supplier']) > 0) {
255 foreach ($rcp->linkedObjectsIds[
'order_supplier'] as $key => $value) {
256 $objecttmp->linked_objects[
'order_supplier'] = $value;
260 $res = $objecttmp->create($user);
265 $lastref = $objecttmp->ref;
266 $lastid = $objecttmp->id;
268 $TFactThird[$rcp->socid] = $objecttmp;
269 $TFactThirdNbLines[$rcp->socid] = 0;
271 $langs->load(
"errors");
272 $errors[] = $rcp->ref.
' : '.$langs->trans($objecttmp->error);
277 if ($objecttmp->id > 0) {
278 $res = $objecttmp->add_object_linked($objecttmp->origin, $id_reception);
281 $errors[] = $objecttmp->error;
286 $lines = $rcp->lines;
287 if (empty($lines) && method_exists($rcp,
'fetch_lines')) {
289 $lines = $rcp->lines;
293 $num = count($lines);
295 for ($i = 0; $i < $num; $i++) {
296 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
298 if (!empty($createbills_onebythird)) {
302 if ($lines[$i]->subprice < 0) {
305 $discount->fk_soc = $objecttmp->socid;
306 $discount->amount_ht = abs($lines[$i]->total_ht);
307 $discount->amount_tva = abs($lines[$i]->total_tva);
308 $discount->amount_ttc = abs($lines[$i]->total_ttc);
309 $discount->tva_tx = $lines[$i]->tva_tx;
310 $discount->fk_user = $user->id;
311 $discount->description = $desc;
312 $discountid = $discount->create($user);
313 if ($discountid > 0) {
314 $result = $objecttmp->insert_discount($discountid);
323 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
326 if ($lines[$i]->date_debut_prevue) {
327 $date_start = $lines[$i]->date_debut_prevue;
329 if ($lines[$i]->date_debut_reel) {
330 $date_start = $lines[$i]->date_debut_reel;
332 if ($lines[$i]->date_start) {
333 $date_start = $lines[$i]->date_start;
337 if ($lines[$i]->date_fin_prevue) {
338 $date_end = $lines[$i]->date_fin_prevue;
340 if ($lines[$i]->date_fin_reel) {
341 $date_end = $lines[$i]->date_fin_reel;
343 if ($lines[$i]->date_end) {
344 $date_end = $lines[$i]->date_end;
347 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
352 if (method_exists($lines[$i],
'fetch_optionals')) {
353 $lines[$i]->fetch_optionals();
354 $array_options = $lines[$i]->array_options;
357 $objecttmp->context[
'createfromclone'];
361 if (!empty($createbills_onebythird))
362 $rang = $TFactThirdNbLines[$rcp->socid];
364 $result = $objecttmp->addline(
366 $lines[$i]->subprice,
368 $lines[$i]->localtax1_tx,
369 $lines[$i]->localtax2_tx,
371 $lines[$i]->fk_product,
372 $lines[$i]->remise_percent,
376 $lines[$i]->info_bits,
385 $lines[$i]->ref_supplier
388 $rcp->add_object_linked(
'facture_fourn_det', $result);
392 if (!empty($createbills_onebythird))
393 $TFactThirdNbLines[$rcp->socid]++;
400 if ($result > 0 && $lines[$i]->product_type == 9) {
401 $fk_parent_line = $result;
410 if (!empty($createbills_onebythird) && empty($TFactThird[$rcp->socid])) {
411 $TFactThird[$rcp->socid] = $objecttmp;
413 $TFact[$objecttmp->id] = $objecttmp;
418 $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
421 if (!$error && $validate_invoices) {
422 $massaction = $action =
'builddoc';
423 foreach ($TAllFact as &$objecttmp) {
424 $result = $objecttmp->validate($user);
431 $id = $objecttmp->id;
436 $upload_dir = $conf->fournisseur->facture->dir_output;
437 $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
440 $savobject = $object;
441 $object = $objecttmp;
442 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
443 $object = $savobject;
446 $massaction = $action =
'confirm_createbills';
452 if ($nb_bills_created == 1) {
453 $texttoshow = $langs->trans(
'BillXCreated',
'{s1}');
454 $texttoshow = str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?id='.urlencode($lastid).
'">'.$lastref.
'</a>', $texttoshow);
457 setEventMessages($langs->trans(
'BillCreated', $nb_bills_created),
null,
'mesgs');
463 $_GET[
"origin"] = $_POST[
"origin"];
464 $_GET[
"originid"] = $_POST[
"originid"];
477 $companystatic =
new Societe($db);
483 $helpurl =
'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones';
484 llxHeader(
'', $langs->trans(
'ListOfReceptions'), $helpurl);
486 $sql =
"SELECT e.rowid, e.ref, e.ref_supplier, e.date_reception as date_reception, e.date_delivery as delivery_date, l.date_delivery as date_reception2, e.fk_statut, e.billed,";
487 $sql .=
' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
488 $sql .=
" typent.code as typent_code,";
489 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
490 $sql .=
' e.date_creation as date_creation, e.tms as date_update';
492 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
493 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
494 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
498 $parameters = array();
499 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
500 $sql .= $hookmanager->resPrint;
501 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception as e";
502 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
503 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (e.rowid = ef.fk_object)";
505 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = e.fk_soc";
506 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
507 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
508 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
509 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery'";
510 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"delivery as l ON l.rowid = ee.fk_target";
511 if (empty($user->rights->societe->client->voir) && !$socid) {
512 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
515 $parameters = array();
516 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
517 $sql .= $hookmanager->resPrint;
518 $sql .=
" WHERE e.entity IN (".getEntity(
'reception').
")";
519 if (empty($user->rights->societe->client->voir) && !$socid) {
520 $sql .=
" AND e.fk_soc = sc.fk_soc";
521 $sql .=
" AND sc.fk_user = ".((int) $user->id);
524 $sql .=
" AND e.fk_soc = ".((int) $socid);
526 if ($search_status <>
'' && $search_status >= 0) {
527 $sql .=
" AND e.fk_statut = ".((int) $search_status);
529 if ($search_billed !=
'' && $search_billed >= 0) {
530 $sql .=
' AND e.billed = '.((int) $search_billed);
541 if ($search_country) {
542 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
544 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
545 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
547 if ($search_ref_rcp) {
550 if ($search_ref_liv) {
553 if ($search_company) {
556 if ($search_ref_supplier) {
564 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
566 $parameters = array();
567 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
568 $sql .= $hookmanager->resPrint;
570 $nbtotalofrecords =
'';
571 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
572 $result = $db->query($sql);
573 $nbtotalofrecords = $db->num_rows($result);
576 $sql .= $db->order($sortfield, $sortorder);
577 $sql .= $db->plimit($limit + 1, $offset);
580 $resql = $db->query($sql);
586 $num = $db->num_rows(
$resql);
590 $arrayofselected = is_array($toselect) ? $toselect : array();
593 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
594 $param .=
'&contextpage='.urlencode($contextpage);
596 if ($limit > 0 && $limit != $conf->liste_limit) {
597 $param .=
'&limit='.urlencode($limit);
600 $param .=
"&sall=".urlencode($sall);
602 if ($search_ref_rcp) {
603 $param .=
"&search_ref_rcp=".urlencode($search_ref_rcp);
605 if ($search_ref_liv) {
606 $param .=
"&search_ref_liv=".urlencode($search_ref_liv);
608 if ($search_company) {
609 $param .=
"&search_company=".urlencode($search_company);
611 if ($optioncss !=
'') {
612 $param .=
'&optioncss='.urlencode($optioncss);
614 if ($search_billed !=
'' && $search_billed >= 0) {
615 $param .=
"&search_billed=".urlencode($search_billed);
618 $param .=
"&search_town=".urlencode($search_town);
621 $param .=
"&search_zip=".urlencode($search_zip);
624 $param .=
"&search_state=".urlencode($search_state);
626 if ($search_status !=
'') {
627 $param .=
"&search_status=".urlencode($search_status);
629 if ($search_country) {
630 $param .=
"&search_country=".urlencode($search_country);
632 if ($search_type_thirdparty) {
633 $param .=
"&search_type_thirdparty=".urlencode($search_type_thirdparty);
635 if ($search_ref_supplier) {
636 $param .=
"&search_ref_supplier=".urlencode($search_ref_supplier);
639 if ($search_array_options) {
640 foreach ($search_array_options as $key => $val) {
642 $tmpkey = preg_replace(
'/search_options_/',
'', $key);
643 if (is_array($val) && array_key_exists(
'start', $val) && array_key_exists(
'end', $val)) {
646 $param .=
'&search_options_'.$tmpkey.
'_startyear='.
dol_print_date($val[
'start'],
'%Y');
647 $param .=
'&search_options_'.$tmpkey.
'_startmonth='.
dol_print_date($val[
'start'],
'%m');
648 $param .=
'&search_options_'.$tmpkey.
'_startday='.
dol_print_date($val[
'start'],
'%d');
649 $param .=
'&search_options_'.$tmpkey.
'_starthour='.
dol_print_date($val[
'start'],
'%H');
650 $param .=
'&search_options_'.$tmpkey.
'_startmin='.
dol_print_date($val[
'start'],
'%M');
652 $param .=
'&search_options_'.$tmpkey.
'_endyear='.
dol_print_date($val[
'end'],
'%Y');
653 $param .=
'&search_options_'.$tmpkey.
'_endmonth='.
dol_print_date($val[
'end'],
'%m');
654 $param .=
'&search_options_'.$tmpkey.
'_endday='.
dol_print_date($val[
'end'],
'%d');
655 $param .=
'&search_options_'.$tmpkey.
'_endhour='.
dol_print_date($val[
'end'],
'%H');
656 $param .=
'&search_options_'.$tmpkey.
'_endmin='.
dol_print_date($val[
'end'],
'%M');
660 $param .=
'&search_options_'.$tmpkey.
'='.urlencode($val);
666 $arrayofmassactions = array(
670 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
671 $arrayofmassactions[
'createbills'] = $langs->trans(
"CreateInvoiceForThisReceptions");
673 if ($massaction ==
'createbills') {
674 $arrayofmassactions = array();
676 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
680 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
681 if ($optioncss !=
'') {
682 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
684 print
'<input type="hidden" name="token" value="'.newToken().
'">';
685 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
686 print
'<input type="hidden" name="action" value="list">';
687 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
688 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
690 print_barre_liste($langs->trans(
'ListOfReceptions'), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'dollyrevert', 0,
'',
'', $limit, 0, 0, 1);
692 if ($massaction ==
'createbills') {
694 print
'<input type="hidden" name="massaction" value="confirm_createbills">';
696 print
'<table class="noborder" width="100%" >';
698 print
'<td class="titlefieldmiddle">';
699 print $langs->trans(
'DateInvoice');
702 print
$form->selectDate(
'',
'',
'',
'',
'',
'', 1, 1);
707 print $langs->trans(
'CreateOneBillByThird');
710 print
$form->selectyesno(
'createbills_onebythird',
'', 1);
715 print $langs->trans(
'ValidateInvoices');
718 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
719 print
$form->selectyesno(
'validate_invoices', 0, 1, 1);
720 print
' ('.$langs->trans(
"AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").
')';
722 print
$form->selectyesno(
'validate_invoices', 0, 1);
729 print
'<div class="center">';
730 print
'<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans(
'CreateInvoiceForThisReceptions').
'"> ';
731 print
'<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
737 foreach ($fieldstosearchall as $key => $val) {
738 $fieldstosearchall[$key] = $langs->trans($val);
740 print $langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall);
744 if (!empty($moreforfilter)) {
745 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
746 print $moreforfilter;
747 $parameters = array(
'type'=>$type);
748 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
749 print $hookmanager->resPrint;
753 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
754 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
755 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
758 print
'<div class="div-table-responsive">';
759 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
763 print
'<tr class="liste_titre_filter">';
765 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
766 print
'<td class="liste_titre">';
767 print
'<input class="flat" size="6" type="text" name="search_ref_rcp" value="'.$search_ref_rcp.
'">';
771 if (!empty($arrayfields[
'e.ref_supplier'][
'checked'])) {
772 print
'<td class="liste_titre">';
773 print
'<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$search_ref_supplier.
'">';
777 if (!empty($arrayfields[
's.nom'][
'checked'])) {
778 print
'<td class="liste_titre left">';
779 print
'<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
783 if (!empty($arrayfields[
's.town'][
'checked'])) {
784 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.
'"></td>';
787 if (!empty($arrayfields[
's.zip'][
'checked'])) {
788 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.
'"></td>';
791 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
792 print
'<td class="liste_titre">';
793 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
797 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
798 print
'<td class="liste_titre center">';
799 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
803 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
804 print
'<td class="liste_titre maxwidthonsmartphone center">';
805 print
$form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
809 if (!empty($arrayfields[
'e.date_delivery'][
'checked'])) {
810 print
'<td class="liste_titre"> </td>';
812 if (!empty($arrayfields[
'l.ref'][
'checked'])) {
814 print
'<td class="liste_titre">';
815 print
'<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.
'"';
818 if (!empty($arrayfields[
'l.date_delivery'][
'checked'])) {
820 print
'<td class="liste_titre"> </td>';
823 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
826 $parameters = array(
'arrayfields'=>$arrayfields);
827 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
828 print $hookmanager->resPrint;
830 if (!empty($arrayfields[
'e.datec'][
'checked'])) {
831 print
'<td class="liste_titre">';
835 if (!empty($arrayfields[
'e.tms'][
'checked'])) {
836 print
'<td class="liste_titre">';
840 if (!empty($arrayfields[
'e.fk_statut'][
'checked'])) {
841 print
'<td class="liste_titre maxwidthonsmartphone right">';
842 print
$form->selectarray(
'search_status', array(
'0'=>$langs->trans(
'StatusReceptionDraftShort'),
'1'=>$langs->trans(
'StatusReceptionValidatedShort'),
'2'=>$langs->trans(
'StatusReceptionProcessedShort')), $search_status, 1);
846 if (!empty($arrayfields[
'e.billed'][
'checked'])) {
847 print
'<td class="liste_titre maxwidthonsmartphone center">';
848 print
$form->selectyesno(
'search_billed', $search_billed, 1, 0, 1);
852 print
'<td class="liste_titre middle">';
853 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
858 print
'<tr class="liste_titre">';
859 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
860 print_liste_field_titre($arrayfields[
'e.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref",
"", $param,
'', $sortfield, $sortorder);
862 if (!empty($arrayfields[
'e.ref_supplier'][
'checked'])) {
863 print_liste_field_titre($arrayfields[
'e.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"e.ref_supplier",
"", $param,
'', $sortfield, $sortorder);
865 if (!empty($arrayfields[
's.nom'][
'checked'])) {
866 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder,
'left ');
868 if (!empty($arrayfields[
's.town'][
'checked'])) {
869 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
871 if (!empty($arrayfields[
's.zip'][
'checked'])) {
872 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
874 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
875 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
877 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
878 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
880 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
881 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
883 if (!empty($arrayfields[
'e.date_delivery'][
'checked'])) {
884 print_liste_field_titre($arrayfields[
'e.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
"e.date_delivery",
"", $param,
'', $sortfield, $sortorder,
'center ');
886 if (!empty($arrayfields[
'l.ref'][
'checked'])) {
887 print_liste_field_titre($arrayfields[
'l.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"l.ref",
"", $param,
'', $sortfield, $sortorder);
889 if (!empty($arrayfields[
'l.date_delivery'][
'checked'])) {
890 print_liste_field_titre($arrayfields[
'l.date_delivery'][
'label'], $_SERVER[
"PHP_SELF"],
"l.date_delivery",
"", $param,
'', $sortfield, $sortorder,
'center ');
893 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
895 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
896 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
897 print $hookmanager->resPrint;
898 if (!empty($arrayfields[
'e.datec'][
'checked'])) {
899 print_liste_field_titre($arrayfields[
'e.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"e.date_creation",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
901 if (!empty($arrayfields[
'e.tms'][
'checked'])) {
902 print_liste_field_titre($arrayfields[
'e.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"e.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
904 if (!empty($arrayfields[
'e.fk_statut'][
'checked'])) {
905 print_liste_field_titre($arrayfields[
'e.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"e.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
907 if (!empty($arrayfields[
'e.billed'][
'checked'])) {
908 print_liste_field_titre($arrayfields[
'e.billed'][
'label'], $_SERVER[
"PHP_SELF"],
"e.billed",
"", $param,
'', $sortfield, $sortorder,
'center ');
910 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
914 $totalarray = array();
915 $totalarray[
'nbfield'] = 0;
916 while ($i < min($num, $limit)) {
917 $obj = $db->fetch_object(
$resql);
919 $reception->id = $obj->rowid;
920 $reception->ref = $obj->ref;
922 $companystatic->id = $obj->socid;
923 $companystatic->ref = $obj->name;
924 $companystatic->name = $obj->name;
927 print
'<tr class="oddeven">';
930 if (!empty($arrayfields[
'e.ref'][
'checked'])) {
931 print
'<td class="nowraponall">';
932 print $reception->getNomUrl(1);
935 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$reception->id;
936 print $formfile->getDocumentsLink($reception->element, $filename, $filedir);
940 $totalarray[
'nbfield']++;
945 if (!empty($arrayfields[
'e.ref_supplier'][
'checked'])) {
946 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).
'">';
950 $totalarray[
'nbfield']++;
955 if (!empty($arrayfields[
's.nom'][
'checked'])) {
956 print
'<td class="tdoverflowmax150">';
957 print $companystatic->getNomUrl(1);
960 $totalarray[
'nbfield']++;
964 if (!empty($arrayfields[
's.town'][
'checked'])) {
965 print
'<td class="nocellnopadd tdoverflowmax200" title="'.dol_escape_htmltag($obj->town).
'">';
969 $totalarray[
'nbfield']++;
973 if (!empty($arrayfields[
's.zip'][
'checked'])) {
974 print
'<td class="nocellnopadd center"">';
978 $totalarray[
'nbfield']++;
982 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
983 print
"<td>".dol_escape_htmltag($obj->state_name).
"</td>\n";
985 $totalarray[
'nbfield']++;
989 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
990 print
'<td class="center">';
995 $totalarray[
'nbfield']++;
999 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1000 print
'<td class="center">';
1001 if (count($typenArray) == 0) {
1002 $typenArray = $formcompany->typent_array(1);
1004 print $typenArray[$obj->typent_code];
1007 $totalarray[
'nbfield']++;
1012 if (!empty($arrayfields[
'e.date_delivery'][
'checked'])) {
1013 print
'<td class="center">';
1021 $totalarray[
'nbfield']++;
1025 if (!empty($arrayfields[
'l.ref'][
'checked']) || !empty($arrayfields[
'l.date_delivery'][
'checked'])) {
1026 $reception->fetchObjectLinked($reception->id, $reception->element);
1028 if (count($reception->linkedObjects[
'delivery']) > 0) {
1029 $receiving = reset($reception->linkedObjects[
'delivery']);
1032 if (!empty($arrayfields[
'l.ref'][
'checked'])) {
1035 print !empty($receiving) ? $receiving->getNomUrl($db) :
'';
1039 if (!empty($arrayfields[
'l.date_delivery'][
'checked'])) {
1041 print
'<td class="center">';
1048 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1051 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1052 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1053 print $hookmanager->resPrint;
1055 if (!empty($arrayfields[
'e.datec'][
'checked'])) {
1056 print
'<td class="center nowrap">';
1057 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour');
1060 $totalarray[
'nbfield']++;
1064 if (!empty($arrayfields[
'e.tms'][
'checked'])) {
1065 print
'<td class="center nowrap">';
1069 $totalarray[
'nbfield']++;
1073 if (!empty($arrayfields[
'e.fk_statut'][
'checked'])) {
1074 print
'<td class="right nowrap">'.$reception->LibStatut($obj->fk_statut, 5).
'</td>';
1076 $totalarray[
'nbfield']++;
1080 if (!empty($arrayfields[
'e.billed'][
'checked'])) {
1081 print
'<td class="center">'.yn($obj->billed).
'</td>';
1083 $totalarray[
'nbfield']++;
1088 print
'<td class="center">';
1089 if ($massactionbutton || $massaction) {
1092 if (in_array($obj->rowid, $arrayofselected)) {
1095 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1099 $totalarray[
'nbfield']++;
1110 foreach ($arrayfields as $key => $val) {
1111 if (!empty($val[
'checked'])) {
1115 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
1119 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1121 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1122 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
1123 print $hookmanager->resPrint;