27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
33$langs->loadLangs(array(
'intracommreport'));
36$action =
GETPOST(
'action',
'alpha');
37$massaction =
GETPOST(
'massaction',
'alpha');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$toselect =
GETPOST(
'toselect',
'array');
42$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
43$search_ref =
GETPOST(
"search_ref",
'alpha');
44$search_type =
GETPOST(
"search_type",
'int');
45$optioncss =
GETPOST(
'optioncss',
'alpha');
50$diroutputmassaction = $conf->product->dir_output.
'/temp/massgeneration/'.$user->id;
53$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
54$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
56if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
60$offset = $limit * $page;
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'intracommreportlist';
72if ((
string) $type ==
'1') {
73 $contextpage =
'DESlist';
74 if ($search_type ==
'') {
78if ((
string) $type ==
'0') {
79 $contextpage =
'DEBlist';
80 if ($search_type ==
'') {
87$hookmanager->initHooks(array(
'intracommreportlist'));
104if (!empty($canvas)) {
105 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
106 $objcanvas =
new Canvas($db, $action);
107 $objcanvas->getCanvas(
'product',
'list', $canvas);
111$fieldstosearchall = array(
113 'pfi.ref_fourn' =>
"RefSupplier",
114 'i.label' =>
"ProductLabel",
115 'i.description' =>
"Description",
123 'i.ref' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
124 'i.label' => array(
'label' => $langs->trans(
"Label"),
'checked' => 1),
125 'i.fk_product_type' => array(
'label' => $langs->trans(
"Type"),
'checked' => 0,
'enabled' => (isModEnabled(
"product") && isModEnabled(
"service"))),
142'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
145if ($search_type ==
'0') {
146 $result =
restrictedArea($user,
'produit',
'',
'',
'',
'',
'', 0);
147} elseif ($search_type ==
'1') {
148 $result =
restrictedArea($user,
'service',
'',
'',
'',
'',
'', 0);
150 $result =
restrictedArea($user,
'produit|service',
'',
'',
'',
'',
'', 0);
153$permissiontoread = $user->hasRight(
'intracommreport',
'read');
154$permissiontodelete = $user->hasRight(
'intracommreport',
'delete');
161if (
GETPOST(
'cancel',
'alpha')) {
165if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
169$parameters = array();
170$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
175if (empty($reshook)) {
177 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
180 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
186 $show_childproducts =
'';
187 $search_array_options = array();
191 $objectclass =
'Product';
192 if ((
string) $search_type ==
'1') {
193 $objectlabel =
'Services';
195 if ((
string) $search_type ==
'0') {
196 $objectlabel =
'Products';
199 $uploaddir = $conf->product->dir_output;
200 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
211$title = $langs->trans(
'IntracommReportList'.$type);
212$helpurl =
'EN:Module_IntracommReport|FR:Module_ProDouane';
216$sql =
'SELECT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
218if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
219 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
220 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
224$parameters = array();
225$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
226$sql .= $hookmanager->resPrint;
227$sql = preg_replace(
'/,\s*$/',
'', $sql);
228$sql .= $hookmanager->resPrint;
232$sql .=
' FROM '.MAIN_DB_PREFIX.
'intracommreport as i';
234$sql .=
' WHERE i.entity IN ('.getEntity(
'intracommreport').
')';
236 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
239if (
dol_strlen($search_type) && $search_type !=
'-1') {
240 if ($search_type == 1) {
241 $sql .=
" AND i.type = 1";
243 $sql .=
" AND i.type = 0";
261$parameters = array();
262$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
263$sql .= $hookmanager->resPrint;
265$sql .=
" GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity";
282$nbtotalofrecords =
'';
285 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
286 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
287 $resql = $db->query($sqlforcount);
289 $objforcount = $db->fetch_object($resql);
290 $nbtotalofrecords = $objforcount->nbtotalofrecords;
295 if (($page * $limit) > $nbtotalofrecords) {
303$sql .= $db->order($sortfield, $sortorder);
305 $sql .= $db->plimit($limit + 1, $offset);
308$resql = $db->query($sql);
314$num = $db->num_rows($resql);
327$arrayofselected = is_array($toselect) ? $toselect : array();
331 $param .=
'&mode='.urlencode($mode);
333if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
334 $param .=
'&contextpage='.urlencode($contextpage);
336if ($limit > 0 && $limit != $conf->liste_limit) {
337 $param .=
'&limit='.((int) $limit);
340 $param .=
"&search_all=".urlencode($search_all);
343 $param =
"&search_ref=".urlencode($search_ref);
346 $param .=
"&search_label=".urlencode($search_label);
348if ($optioncss !=
'') {
349 $param .=
'&optioncss='.urlencode($optioncss);
352include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
354$parameters = array(
'param' => &$param);
355$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
356$param .= $hookmanager->resPrint;
359$arrayofmassactions = array(
360 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
364if (!empty($permissiontodelete)) {
365 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
367if (in_array($massaction, array(
'presend',
'predelete'))) {
368 $arrayofmassactions = array();
370$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
373if ($user->hasRight(
'intracommreport',
'write')) {
374 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"NewDeclaration"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/intracommreport/card.php?action=create&type='.$type);
377print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">';
378if ($optioncss !=
'') {
379 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
381print
'<input type="hidden" name="token" value="'.newToken().
'">';
382print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
383print
'<input type="hidden" name="action" value="list">';
384print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
385print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
386print
'<input type="hidden" name="page" value="'.$page.
'">';
387print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
388print
'<input type="hidden" name="page_y" value="">';
389print
'<input type="hidden" name="mode" value="'.$mode.
'">';
390print
'<input type="hidden" name="type" value="'.$type.
'">';
391if (empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
392 print
'<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
395print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'intracommreport', 0, $newcardbutton,
'', $limit);
397$topicmail =
"Information";
398$modelmail =
"product";
400$trackid =
'prod'.$object->id;
401include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
405 foreach ($fieldstosearchall as $key => $val) {
406 $fieldstosearchall[$key] = $langs->trans($val);
407 $setupstring .= $key.
"=".$val.
";";
409 print
'<!-- Search done like if INTRACOMM_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
410 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
413$parameters = array();
414$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
415if (!isset($moreforfilter)) {
418if (empty($reshook)) {
419 $moreforfilter .= $hookmanager->resPrint;
421 $moreforfilter = $hookmanager->resPrint;
424if (!empty($moreforfilter)) {
425 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
426 print $moreforfilter;
427 $parameters = array();
428 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
429 print $hookmanager->resPrint;
433$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
434$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
435$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
436$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
438print
'<div class="div-table-responsive">';
439print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
443print
'<tr class="liste_titre_filter">';
446 print
'<td class="liste_titre center maxwidthsearch">';
447 $searchpicto = $form->showFilterButtons(
'left');
451if (!empty($arrayfields[
'i.ref'][
'checked'])) {
452 print
'<td class="liste_titre left">';
453 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
456if (!empty($arrayfields[
'i.label'][
'checked'])) {
457 print
'<td class="liste_titre left">';
458 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
463if (!empty($arrayfields[
'customerorsupplier'][
'checked'])) {
464 print
'<td class="liste_titre maxwidthonsmartphone center">';
466 print
'<input type="hidden" name="type" value="'.$type.
'">';
468 print $formcompany->selectProspectCustomerType($search_type,
'search_type',
'search_type',
'list');
469 print
'</select></td>';
472if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
473 print
'<td class="liste_titre left">';
474 $array = array(
'-1' =>
' ',
'0' => $langs->trans(
'Product'),
'1' => $langs->trans(
'Service'));
475 print $form->selectarray(
'search_type', $array, $search_type);
484$parameters = array(
'arrayfields' => $arrayfields);
485$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
486print $hookmanager->resPrint;
488if (!empty($arrayfields[
'i.datec'][
'checked'])) {
489 print
'<td class="liste_titre">';
493if (!empty($arrayfields[
'i.tms'][
'checked'])) {
494 print
'<td class="liste_titre">';
499 print
'<td class="liste_titre center maxwidthsearch">';
500 $searchpicto = $form->showFilterButtons();
507$totalarray = array();
508$totalarray[
'nbfield'] = 0;
512print
'<tr class="liste_titre">';
515 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
516 $totalarray[
'nbfield']++;
518if (!empty($arrayfields[
'i.ref'][
'checked'])) {
519 print_liste_field_titre($arrayfields[
'i.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"i.ref",
"", $param,
"", $sortfield, $sortorder);
520 $totalarray[
'nbfield']++;
522if (!empty($arrayfields[
'i.label'][
'checked'])) {
523 print_liste_field_titre($arrayfields[
'i.label'][
'label'], $_SERVER[
"PHP_SELF"],
"i.label",
"", $param,
"", $sortfield, $sortorder);
524 $totalarray[
'nbfield']++;
526if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
527 print_liste_field_titre($arrayfields[
'i.fk_product_type'][
'label'], $_SERVER[
"PHP_SELF"],
"i.fk_product_type",
"", $param,
"", $sortfield, $sortorder);
528 $totalarray[
'nbfield']++;
536$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
537$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
538print $hookmanager->resPrint;
539if (!empty($arrayfields[
'i.datec'][
'checked'])) {
540 print_liste_field_titre($arrayfields[
'i.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"i.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
541 $totalarray[
'nbfield']++;
543if (!empty($arrayfields[
'i.tms'][
'checked'])) {
544 print_liste_field_titre($arrayfields[
'i.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"i.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
545 $totalarray[
'nbfield']++;
549 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
550 $totalarray[
'nbfield']++;
558$savnbfield = $totalarray[
'nbfield'];
559$totalarray = array();
560$totalarray[
'nbfield'] = 0;
561$imaxinloop = ($limit ? min($num, $limit) : $num);
562while ($i < $imaxinloop) {
563 $obj = $db->fetch_object($resql);
568 $intracommreport_static->id = $obj->rowid;
569 $intracommreport_static->ref = $obj->ref;
570 $intracommreport_static->ref_fourn = $obj->ref_supplier;
571 $intracommreport_static->label = $obj->label;
572 $intracommreport_static->type = $obj->fk_product_type;
573 $intracommreport_static->status_buy = $obj->tobuy;
574 $intracommreport_static->status = $obj->tosell;
575 $intracommreport_static->status_batch = $obj->tobatch;
576 $intracommreport_static->entity = $obj->entity;
578 if ($mode ==
'kanban') {
580 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
581 print
'<div class="box-flex-container kanban">';
585 if ($massactionbutton || $massaction) {
587 if (in_array(
$object->id, $arrayofselected)) {
591 print
$object->getKanbanView(
'', array(
'selected' => $selected));
592 if ($i == ($imaxinloop - 1)) {
599 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
603 print
'<td class="nowrap center">';
604 if ($massactionbutton || $massaction) {
606 if (in_array(
$object->id, $arrayofselected)) {
609 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
613 $totalarray[
'nbfield']++;
618 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
619 print
'<td class="tdoverflowmax200">';
620 print $intracommreport_static->getNomUrl(1);
623 $totalarray[
'nbfield']++;
627 if (!empty($arrayfields[
'i.label'][
'checked'])) {
628 print
'<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).
'</td>';
630 $totalarray[
'nbfield']++;
634 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
635 print
'<td>'.$obj->fk_product_type.
'</td>';
637 $totalarray[
'nbfield']++;
642 print
'<td class="nowrap center">';
643 if ($massactionbutton || $massaction) {
645 if (in_array($obj->rowid, $arrayofselected)) {
649 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
652 $totalarray[
'nbfield']++;
665 foreach ($arrayfields as $key => $val) {
666 if (!empty($val[
'checked'])) {
670 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage intracomm report.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.