26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
32$langs->loadLangs(array(
'intracommreport'));
35$action =
GETPOST(
'action',
'alpha');
36$massaction =
GETPOST(
'massaction',
'alpha');
37$show_files =
GETPOST(
'show_files',
'int');
38$confirm =
GETPOST(
'confirm',
'alpha');
39$toselect =
GETPOST(
'toselect',
'array');
41$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
42$search_ref =
GETPOST(
"search_ref",
'alpha');
43$search_type =
GETPOST(
"search_type",
'int');
44$optioncss =
GETPOST(
'optioncss',
'alpha');
47$diroutputmassaction = $conf->product->dir_output.
'/temp/massgeneration/'.$user->id;
49$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
53if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
57$offset = $limit * $page;
68$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'intracommreportlist';
69if ((
string) $type ==
'1') {
70 $contextpage =
'DESlist';
if ($search_type ==
'') {
74if ((
string) $type ==
'0') {
75 $contextpage =
'DEBlist';
if ($search_type ==
'') {
82$hookmanager->initHooks(array(
'intracommreportlist'));
100 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
101 $objcanvas =
new Canvas($db, $action);
102 $objcanvas->getCanvas(
'product',
'list', $canvas);
113$fieldstosearchall = array(
115 'pfi.ref_fourn'=>
"RefSupplier",
116 'i.label'=>
"ProductLabel",
117 'i.description'=>
"Description",
125 'i.ref' => array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
126 'i.label' => array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
127 'i.fk_product_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>0,
'enabled'=>(isModEnabled(
"product") && isModEnabled(
"service"))),
146if ($search_type ==
'0') {
147 $result =
restrictedArea($user,
'produit',
'',
'',
'',
'',
'', 0);
148} elseif ($search_type ==
'1') {
149 $result =
restrictedArea($user,
'service',
'',
'',
'',
'',
'', 0);
151 $result =
restrictedArea($user,
'produit|service',
'',
'',
'',
'',
'', 0);
154$permissiontoread = $user->rights->intracommreport->read;
155$permissiontodelete = $user->rights->intracommreport->delete;
162if (
GETPOST(
'cancel',
'alpha')) {
166if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
170$parameters = array();
171$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176if (empty($reshook)) {
178 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
181 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
187 $show_childproducts =
'';
188 $search_array_options = array();
192 $objectclass =
'Product';
193 if ((
string) $search_type ==
'1') {
194 $objectlabel =
'Services';
196 if ((
string) $search_type ==
'0') {
197 $objectlabel =
'Products';
200 $uploaddir = $conf->product->dir_output;
201 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
212$title = $langs->trans(
'IntracommReportList'.$type);
213$helpurl =
'EN:Module_IntracommReport|FR:Module_ProDouane';
217$sql =
'SELECT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
219if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
220 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
221 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
225$parameters = array();
226$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
227$sql .= $hookmanager->resPrint;
228$sql = preg_replace(
'/,\s*$/',
'', $sql);
229$sql .= $hookmanager->resPrint;
233$sql .=
' FROM '.MAIN_DB_PREFIX.
'intracommreport as i';
235$sql .=
' WHERE i.entity IN ('.getEntity(
'intracommreport').
')';
237 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
240if (
dol_strlen($search_type) && $search_type !=
'-1') {
241 if ($search_type == 1) {
242 $sql .=
" AND i.type = 1";
244 $sql .=
" AND i.type = 0";
262$parameters = array();
263$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
264$sql .= $hookmanager->resPrint;
266$sql .=
" GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity";
283$nbtotalofrecords =
'';
286 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
287 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
288 $resql = $db->query($sqlforcount);
290 $objforcount = $db->fetch_object($resql);
291 $nbtotalofrecords = $objforcount->nbtotalofrecords;
296 if (($page * $limit) > $nbtotalofrecords) {
304$sql .= $db->order($sortfield, $sortorder);
306 $sql .= $db->plimit($limit + 1, $offset);
309$resql = $db->query($sql);
315$num = $db->num_rows($resql);
328$arrayofselected = is_array($toselect) ? $toselect : array();
332 $param .=
'&mode='.urlencode($mode);
334if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
335 $param .=
'&contextpage='.urlencode($contextpage);
337if ($limit > 0 && $limit != $conf->liste_limit) {
338 $param .=
'&limit='.((int) $limit);
341 $param .=
"&search_all=".urlencode($search_all);
344 $param =
"&search_ref=".urlencode($search_ref);
347 $param .=
"&search_label=".urlencode($search_label);
349if ($optioncss !=
'') {
350 $param .=
'&optioncss='.urlencode($optioncss);
353include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
355$parameters = array();
356$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
357$param .= $hookmanager->resPrint;
360$arrayofmassactions = array(
361 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
365if (!empty($permissiontodelete)) {
366 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
368if (in_array($massaction, array(
'presend',
'predelete'))) {
369 $arrayofmassactions = array();
371$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
374if ($user->rights->intracommreport->write) {
375 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"NewDeclaration"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/intracommreport/card.php?action=create&type='.$type);
378print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">';
379if ($optioncss !=
'') {
380 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
382print
'<input type="hidden" name="token" value="'.newToken().
'">';
383print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
384print
'<input type="hidden" name="action" value="list">';
385print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
386print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
387print
'<input type="hidden" name="page" value="'.$page.
'">';
388print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
389print
'<input type="hidden" name="page_y" value="">';
390print
'<input type="hidden" name="mode" value="'.$mode.
'">';
391print
'<input type="hidden" name="type" value="'.$type.
'">';
392if (empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
393 print
'<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
396print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'intracommreport', 0, $newcardbutton,
'', $limit);
398$topicmail =
"Information";
399$modelmail =
"product";
401$trackid =
'prod'.$object->id;
402include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
406 foreach ($fieldstosearchall as $key => $val) {
407 $fieldstosearchall[$key] = $langs->trans($val);
408 $setupstring .= $key.
"=".$val.
";";
410 print
'<!-- Search done like if INTRACOMM_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
411 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
414$parameters = array();
415$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
416if (empty($reshook)) {
417 $moreforfilter .= $hookmanager->resPrint;
419 $moreforfilter = $hookmanager->resPrint;
422if (!empty($moreforfilter)) {
423 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
424 print $moreforfilter;
425 $parameters = array();
426 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
427 print $hookmanager->resPrint;
431$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
432$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
433$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
435print
'<div class="div-table-responsive">';
436print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
440print
'<tr class="liste_titre_filter">';
443 print
'<td class="liste_titre center maxwidthsearch">';
444 $searchpicto = $form->showFilterButtons(
'left');
448if (!empty($arrayfields[
'i.ref'][
'checked'])) {
449 print
'<td class="liste_titre left">';
450 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
453if (!empty($arrayfields[
'i.label'][
'checked'])) {
454 print
'<td class="liste_titre left">';
455 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
460if (!empty($arrayfields[
'customerorsupplier'][
'checked'])) {
461 print
'<td class="liste_titre maxwidthonsmartphone center">';
463 print
'<input type="hidden" name="type" value="'.$type.
'">';
465 print $formcompany->selectProspectCustomerType($search_type,
'search_type',
'search_type',
'list');
466 print
'</select></td>';
469if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
470 print
'<td class="liste_titre left">';
471 $array = array(
'-1'=>
' ',
'0'=>$langs->trans(
'Product'),
'1'=>$langs->trans(
'Service'));
472 print $form->selectarray(
'search_type', $array, $search_type);
481$parameters = array(
'arrayfields'=>$arrayfields);
482$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
483print $hookmanager->resPrint;
485if (!empty($arrayfields[
'i.datec'][
'checked'])) {
486 print
'<td class="liste_titre">';
490if (!empty($arrayfields[
'i.tms'][
'checked'])) {
491 print
'<td class="liste_titre">';
496 print
'<td class="liste_titre center maxwidthsearch">';
497 $searchpicto = $form->showFilterButtons();
504$totalarray = array();
505$totalarray[
'nbfield'] = 0;
509print
'<tr class="liste_titre">';
512 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
513 $totalarray[
'nbfield']++;
515if (!empty($arrayfields[
'i.ref'][
'checked'])) {
516 print_liste_field_titre($arrayfields[
'i.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"i.ref",
"", $param,
"", $sortfield, $sortorder);
517 $totalarray[
'nbfield']++;
519if (!empty($arrayfields[
'i.label'][
'checked'])) {
520 print_liste_field_titre($arrayfields[
'i.label'][
'label'], $_SERVER[
"PHP_SELF"],
"i.label",
"", $param,
"", $sortfield, $sortorder);
521 $totalarray[
'nbfield']++;
523if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
524 print_liste_field_titre($arrayfields[
'i.fk_product_type'][
'label'], $_SERVER[
"PHP_SELF"],
"i.fk_product_type",
"", $param,
"", $sortfield, $sortorder);
525 $totalarray[
'nbfield']++;
533$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
534$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
535print $hookmanager->resPrint;
536if (!empty($arrayfields[
'i.datec'][
'checked'])) {
537 print_liste_field_titre($arrayfields[
'i.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"i.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
538 $totalarray[
'nbfield']++;
540if (!empty($arrayfields[
'i.tms'][
'checked'])) {
541 print_liste_field_titre($arrayfields[
'i.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"i.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
542 $totalarray[
'nbfield']++;
546 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
547 $totalarray[
'nbfield']++;
555$savnbfield = $totalarray[
'nbfield'];
556$totalarray = array();
557$totalarray[
'nbfield'] = 0;
558$imaxinloop = ($limit ? min($num, $limit) : $num);
559while ($i < $imaxinloop) {
560 $obj = $db->fetch_object($resql);
565 $intracommreport_static->id = $obj->rowid;
566 $intracommreport_static->ref = $obj->ref;
567 $intracommreport_static->ref_fourn = $obj->ref_supplier;
568 $intracommreport_static->label = $obj->label;
569 $intracommreport_static->type = $obj->fk_product_type;
570 $intracommreport_static->status_buy = $obj->tobuy;
571 $intracommreport_static->status = $obj->tosell;
572 $intracommreport_static->status_batch = $obj->tobatch;
573 $intracommreport_static->entity = $obj->entity;
575 if ($mode ==
'kanban') {
577 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
578 print
'<div class="box-flex-container kanban">';
581 if ($massactionbutton || $massaction) {
583 if (in_array($object->id, $arrayofselected)) {
587 print $object->getKanbanView(
'', array(
'selected' => in_array($object->id, $arrayofselected)));
588 if ($i == ($imaxinloop - 1)) {
595 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
599 print
'<td class="nowrap center">';
600 if ($massactionbutton || $massaction) {
602 if (in_array($object->id, $arrayofselected)) {
605 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
609 $totalarray[
'nbfield']++;
614 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
615 print
'<td class="tdoverflowmax200">';
616 print $intracommreport_static->getNomUrl(1);
619 $totalarray[
'nbfield']++;
623 if (!empty($arrayfields[
'i.label'][
'checked'])) {
624 print
'<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).
'</td>';
626 $totalarray[
'nbfield']++;
630 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
631 print
'<td>'.$obj->fk_product_type.
'</td>';
633 $totalarray[
'nbfield']++;
638 print
'<td class="nowrap center">';
639 if ($massactionbutton || $massaction) {
641 if (in_array($obj->rowid, $arrayofselected)) {
645 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
648 $totalarray[
'nbfield']++;
661 foreach ($arrayfields as $key => $val) {
662 if (!empty($val[
'checked'])) {
666 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
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)
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
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.
print_barre_liste($titre, $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.
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.