25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 $langs->loadLangs(array(
'intracommreport'));
33 $action =
GETPOST(
'action',
'alpha');
34 $massaction =
GETPOST(
'massaction',
'alpha');
35 $show_files =
GETPOST(
'show_files',
'int');
36 $confirm =
GETPOST(
'confirm',
'alpha');
37 $toselect =
GETPOST(
'toselect',
'array');
39 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
40 $search_ref =
GETPOST(
"search_ref",
'alpha');
41 $search_type =
GETPOST(
"search_type",
'int');
42 $optioncss =
GETPOST(
'optioncss',
'alpha');
45 $diroutputmassaction = $conf->product->dir_output.
'/temp/massgeneration/'.$user->id;
47 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51 if (empty($page) || $page == -1) {
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
65 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'intracommreportlist';
66 if ((
string) $type ==
'1') {
67 $contextpage =
'DESlist';
if ($search_type ==
'') {
71 if ((
string) $type ==
'0') {
72 $contextpage =
'DEBlist';
if ($search_type ==
'') {
79 $hookmanager->initHooks(array(
'intracommreportlist'));
96 if (!empty($canvas)) {
97 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
98 $objcanvas =
new Canvas($db, $action);
99 $objcanvas->getCanvas(
'product',
'list', $canvas);
110 $fieldstosearchall = array(
112 'pfi.ref_fourn'=>
"RefSupplier",
113 'i.label'=>
"ProductLabel",
114 'i.description'=>
"Description",
121 $arrayfields = array(
122 'i.ref' => array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
123 'i.label' => array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
124 'i.fk_product_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>0,
'enabled'=>(!empty($conf->produit->enabled) && !empty($conf->service->enabled))),
141 if ($search_type ==
'0') {
142 $result =
restrictedArea($user,
'produit',
'',
'',
'',
'',
'', 0);
143 } elseif ($search_type ==
'1') {
144 $result =
restrictedArea($user,
'service',
'',
'',
'',
'',
'', 0);
146 $result =
restrictedArea($user,
'produit|service',
'',
'',
'',
'',
'', 0);
154 if (
GETPOST(
'cancel',
'alpha')) {
155 $action =
'list'; $massaction =
'';
157 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
161 $parameters = array();
162 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167 if (empty($reshook)) {
169 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
172 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
178 $show_childproducts =
'';
179 $search_array_options = array();
183 $objectclass =
'Product';
184 if ((
string) $search_type ==
'1') {
185 $objectlabel =
'Services';
187 if ((
string) $search_type ==
'0') {
188 $objectlabel =
'Products';
191 $permtoread = $user->rights->produit->lire;
192 $permtodelete = $user->rights->produit->supprimer;
193 $uploaddir = $conf->product->dir_output;
194 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
204 $title = $langs->trans(
'IntracommReportList'.$type);
206 $sql =
'SELECT DISTINCT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
214 $parameters = array();
215 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
216 $sql .= $hookmanager->resPrint;
218 $sql .=
' FROM '.MAIN_DB_PREFIX.
'intracommreport as i';
222 $sql .=
' WHERE i.entity IN ('.getEntity(
'intracommreport').
')';
228 if (
dol_strlen($search_type) && $search_type !=
'-1') {
229 if ($search_type == 1) {
230 $sql .=
" AND i.type = 1";
232 $sql .=
" AND i.type = 0";
250 $parameters = array();
251 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
252 $sql .= $hookmanager->resPrint;
254 $sql .=
" GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity";
264 $parameters = array();
265 $reshook = $hookmanager->executeHooks(
'printFieldSelect', $parameters);
266 $sql .= $hookmanager->resPrint;
268 $sql .= $db->order($sortfield, $sortorder);
270 $nbtotalofrecords =
'';
271 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
272 $result = $db->query($sql);
273 $nbtotalofrecords = $db->num_rows($result);
274 if (($page * $limit) > $nbtotalofrecords) {
280 $sql .= $db->plimit($limit + 1, $offset);
282 $resql = $db->query($sql);
285 $num = $db->num_rows(
$resql);
287 $arrayofselected = is_array($toselect) ? $toselect : array();
289 $helpurl =
'EN:Module_IntracommReport|FR:Module_ProDouane';
298 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
299 $param .=
'&contextpage='.urlencode($contextpage);
301 if ($limit > 0 && $limit != $conf->liste_limit) {
302 $param .=
'&limit='.urlencode($limit);
305 $param .=
"&sall=".urlencode($sall);
308 $param =
"&search_ref=".urlencode($search_ref);
311 $param .=
"&search_label=".urlencode($search_label);
315 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
318 $arrayofmassactions = array(
319 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
323 if ($user->rights->intracommreport->delete) {
324 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
326 if (in_array($massaction, array(
'presend',
'predelete'))) {
327 $arrayofmassactions = array();
329 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
332 if ($user->rights->intracommreport->write) {
333 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"NewDeclaration"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/intracommreport/card.php?action=create&type='.$type);
336 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
337 if ($optioncss !=
'') {
338 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
340 print
'<input type="hidden" name="token" value="'.newToken().
'">';
341 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
342 print
'<input type="hidden" name="action" value="list">';
343 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
344 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
345 print
'<input type="hidden" name="page" value="'.$page.
'">';
346 print
'<input type="hidden" name="type" value="'.$type.
'">';
347 if (empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
348 print
'<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
351 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'intracommreport', 0, $newcardbutton,
'', $limit);
353 $topicmail =
"Information";
354 $modelmail =
"product";
356 $trackid =
'prod'.$object->id;
357 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
360 foreach ($fieldstosearchall as $key => $val) {
361 $fieldstosearchall[$key] = $langs->trans($val);
363 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
366 $parameters = array();
367 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
368 if (empty($reshook)) {
369 $moreforfilter .= $hookmanager->resPrint;
371 $moreforfilter = $hookmanager->resPrint;
374 if ($moreforfilter) {
375 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
376 print $moreforfilter;
380 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
381 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
382 if ($massactionbutton) {
383 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
386 print
'<div class="div-table-responsive">';
387 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
390 print
'<tr class="liste_titre_filter">';
391 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
392 print
'<td class="liste_titre left">';
393 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
396 if (!empty($arrayfields[
'i.label'][
'checked'])) {
397 print
'<td class="liste_titre left">';
398 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
403 if (!empty($arrayfields[
'customerorsupplier'][
'checked'])) {
404 print
'<td class="liste_titre maxwidthonsmartphone center">';
406 print
'<input type="hidden" name="type" value="'.$type.
'">';
408 print $formcompany->selectProspectCustomerType($search_type,
'search_type',
'search_type',
'list');
409 print
'</select></td>';
412 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
413 print
'<td class="liste_titre left">';
414 $array = array(
'-1'=>
' ',
'0'=>$langs->trans(
'Product'),
'1'=>$langs->trans(
'Service'));
415 print
$form->selectarray(
'search_type', $array, $search_type);
424 $parameters = array(
'arrayfields'=>$arrayfields);
425 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
426 print $hookmanager->resPrint;
428 if (!empty($arrayfields[
'i.datec'][
'checked'])) {
429 print
'<td class="liste_titre">';
433 if (!empty($arrayfields[
'i.tms'][
'checked'])) {
434 print
'<td class="liste_titre">';
437 print
'<td class="liste_titre center maxwidthsearch">';
438 $searchpicto =
$form->showFilterButtons();
444 print
'<tr class="liste_titre">';
445 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
446 print_liste_field_titre($arrayfields[
'i.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"i.ref",
"", $param,
"", $sortfield, $sortorder);
448 if (!empty($arrayfields[
'i.label'][
'checked'])) {
449 print_liste_field_titre($arrayfields[
'i.label'][
'label'], $_SERVER[
"PHP_SELF"],
"i.label",
"", $param,
"", $sortfield, $sortorder);
451 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
452 print_liste_field_titre($arrayfields[
'i.fk_product_type'][
'label'], $_SERVER[
"PHP_SELF"],
"i.fk_product_type",
"", $param,
"", $sortfield, $sortorder);
460 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
461 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
462 print $hookmanager->resPrint;
463 if (!empty($arrayfields[
'i.datec'][
'checked'])) {
464 print_liste_field_titre($arrayfields[
'i.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"i.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
466 if (!empty($arrayfields[
'i.tms'][
'checked'])) {
467 print_liste_field_titre($arrayfields[
'i.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"i.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
470 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
477 $totalarray = array();
478 while ($i < min($num, $limit)) {
479 $obj = $db->fetch_object(
$resql);
481 $intracommreport_static->id = $obj->rowid;
482 $intracommreport_static->ref = $obj->ref;
483 $intracommreport_static->ref_fourn = $obj->ref_supplier;
484 $intracommreport_static->label = $obj->label;
485 $intracommreport_static->type = $obj->fk_product_type;
486 $intracommreport_static->status_buy = $obj->tobuy;
487 $intracommreport_static->status = $obj->tosell;
488 $intracommreport_static->status_batch = $obj->tobatch;
489 $intracommreport_static->entity = $obj->entity;
491 print
'<tr class="oddeven">';
494 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
495 print
'<td class="tdoverflowmax200">';
496 print $intracommreport_static->getNomUrl(1);
499 $totalarray[
'nbfield']++;
503 if (!empty($arrayfields[
'i.label'][
'checked'])) {
504 print
'<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).
'</td>';
506 $totalarray[
'nbfield']++;
510 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
511 print
'<td>'.$obj->fk_product_type.
'</td>';
513 $totalarray[
'nbfield']++;
517 print
'<td class="nowrap center">';
518 if ($massactionbutton || $massaction) {
520 if (in_array($obj->rowid, $arrayofselected)) {
523 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
527 $totalarray[
'nbfield']++;