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';
71 if ($search_type ==
'') {
75if ((
string) $type ==
'0') {
76 $contextpage =
'DEBlist';
77 if ($search_type ==
'') {
84$hookmanager->initHooks(array(
'intracommreportlist'));
101if (!empty($canvas)) {
102 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
103 $objcanvas =
new Canvas($db, $action);
104 $objcanvas->getCanvas(
'product',
'list', $canvas);
115$fieldstosearchall = array(
117 'pfi.ref_fourn'=>
"RefSupplier",
118 'i.label'=>
"ProductLabel",
119 'i.description'=>
"Description",
127 'i.ref' => array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
128 'i.label' => array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
129 'i.fk_product_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>0,
'enabled'=>(isModEnabled(
"product") && isModEnabled(
"service"))),
148if ($search_type ==
'0') {
149 $result =
restrictedArea($user,
'produit',
'',
'',
'',
'',
'', 0);
150} elseif ($search_type ==
'1') {
151 $result =
restrictedArea($user,
'service',
'',
'',
'',
'',
'', 0);
153 $result =
restrictedArea($user,
'produit|service',
'',
'',
'',
'',
'', 0);
156$permissiontoread = $user->rights->intracommreport->read;
157$permissiontodelete = $user->rights->intracommreport->delete;
164if (
GETPOST(
'cancel',
'alpha')) {
168if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
172$parameters = array();
173$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
178if (empty($reshook)) {
180 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
183 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
189 $show_childproducts =
'';
190 $search_array_options = array();
194 $objectclass =
'Product';
195 if ((
string) $search_type ==
'1') {
196 $objectlabel =
'Services';
198 if ((
string) $search_type ==
'0') {
199 $objectlabel =
'Products';
202 $uploaddir = $conf->product->dir_output;
203 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
214$title = $langs->trans(
'IntracommReportList'.$type);
215$helpurl =
'EN:Module_IntracommReport|FR:Module_ProDouane';
219$sql =
'SELECT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
221if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
222 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
223 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
227$parameters = array();
228$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
229$sql .= $hookmanager->resPrint;
230$sql = preg_replace(
'/,\s*$/',
'', $sql);
231$sql .= $hookmanager->resPrint;
235$sql .=
' FROM '.MAIN_DB_PREFIX.
'intracommreport as i';
237$sql .=
' WHERE i.entity IN ('.getEntity(
'intracommreport').
')';
239 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
242if (
dol_strlen($search_type) && $search_type !=
'-1') {
243 if ($search_type == 1) {
244 $sql .=
" AND i.type = 1";
246 $sql .=
" AND i.type = 0";
264$parameters = array();
265$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
266$sql .= $hookmanager->resPrint;
268$sql .=
" GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity";
285$nbtotalofrecords =
'';
288 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
289 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
290 $resql = $db->query($sqlforcount);
292 $objforcount = $db->fetch_object($resql);
293 $nbtotalofrecords = $objforcount->nbtotalofrecords;
298 if (($page * $limit) > $nbtotalofrecords) {
306$sql .= $db->order($sortfield, $sortorder);
308 $sql .= $db->plimit($limit + 1, $offset);
311$resql = $db->query($sql);
317$num = $db->num_rows($resql);
330$arrayofselected = is_array($toselect) ? $toselect : array();
334 $param .=
'&mode='.urlencode($mode);
336if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
337 $param .=
'&contextpage='.urlencode($contextpage);
339if ($limit > 0 && $limit != $conf->liste_limit) {
340 $param .=
'&limit='.((int) $limit);
343 $param .=
"&search_all=".urlencode($search_all);
346 $param =
"&search_ref=".urlencode($search_ref);
349 $param .=
"&search_label=".urlencode($search_label);
351if ($optioncss !=
'') {
352 $param .=
'&optioncss='.urlencode($optioncss);
355include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
357$parameters = array(
'param' => &$param);
358$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
359$param .= $hookmanager->resPrint;
362$arrayofmassactions = array(
363 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
367if (!empty($permissiontodelete)) {
368 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
370if (in_array($massaction, array(
'presend',
'predelete'))) {
371 $arrayofmassactions = array();
373$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
376if ($user->hasRight(
'intracommreport',
'write')) {
377 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"NewDeclaration"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/intracommreport/card.php?action=create&type='.$type);
380print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">';
381if ($optioncss !=
'') {
382 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
384print
'<input type="hidden" name="token" value="'.newToken().
'">';
385print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
386print
'<input type="hidden" name="action" value="list">';
387print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
388print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
389print
'<input type="hidden" name="page" value="'.$page.
'">';
390print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
391print
'<input type="hidden" name="page_y" value="">';
392print
'<input type="hidden" name="mode" value="'.$mode.
'">';
393print
'<input type="hidden" name="type" value="'.$type.
'">';
394if (empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
395 print
'<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
398print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'intracommreport', 0, $newcardbutton,
'', $limit);
400$topicmail =
"Information";
401$modelmail =
"product";
403$trackid =
'prod'.$object->id;
404include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
408 foreach ($fieldstosearchall as $key => $val) {
409 $fieldstosearchall[$key] = $langs->trans($val);
410 $setupstring .= $key.
"=".$val.
";";
412 print
'<!-- Search done like if INTRACOMM_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
413 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
416$parameters = array();
417$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
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$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
435$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
437print
'<div class="div-table-responsive">';
438print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
442print
'<tr class="liste_titre_filter">';
445 print
'<td class="liste_titre center maxwidthsearch">';
446 $searchpicto = $form->showFilterButtons(
'left');
450if (!empty($arrayfields[
'i.ref'][
'checked'])) {
451 print
'<td class="liste_titre left">';
452 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
455if (!empty($arrayfields[
'i.label'][
'checked'])) {
456 print
'<td class="liste_titre left">';
457 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
462if (!empty($arrayfields[
'customerorsupplier'][
'checked'])) {
463 print
'<td class="liste_titre maxwidthonsmartphone center">';
465 print
'<input type="hidden" name="type" value="'.$type.
'">';
467 print $formcompany->selectProspectCustomerType($search_type,
'search_type',
'search_type',
'list');
468 print
'</select></td>';
471if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
472 print
'<td class="liste_titre left">';
473 $array = array(
'-1'=>
' ',
'0'=>$langs->trans(
'Product'),
'1'=>$langs->trans(
'Service'));
474 print $form->selectarray(
'search_type', $array, $search_type);
483$parameters = array(
'arrayfields'=>$arrayfields);
484$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
485print $hookmanager->resPrint;
487if (!empty($arrayfields[
'i.datec'][
'checked'])) {
488 print
'<td class="liste_titre">';
492if (!empty($arrayfields[
'i.tms'][
'checked'])) {
493 print
'<td class="liste_titre">';
498 print
'<td class="liste_titre center maxwidthsearch">';
499 $searchpicto = $form->showFilterButtons();
506$totalarray = array();
507$totalarray[
'nbfield'] = 0;
511print
'<tr class="liste_titre">';
514 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
515 $totalarray[
'nbfield']++;
517if (!empty($arrayfields[
'i.ref'][
'checked'])) {
518 print_liste_field_titre($arrayfields[
'i.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"i.ref",
"", $param,
"", $sortfield, $sortorder);
519 $totalarray[
'nbfield']++;
521if (!empty($arrayfields[
'i.label'][
'checked'])) {
522 print_liste_field_titre($arrayfields[
'i.label'][
'label'], $_SERVER[
"PHP_SELF"],
"i.label",
"", $param,
"", $sortfield, $sortorder);
523 $totalarray[
'nbfield']++;
525if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
526 print_liste_field_titre($arrayfields[
'i.fk_product_type'][
'label'], $_SERVER[
"PHP_SELF"],
"i.fk_product_type",
"", $param,
"", $sortfield, $sortorder);
527 $totalarray[
'nbfield']++;
535$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
536$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
537print $hookmanager->resPrint;
538if (!empty($arrayfields[
'i.datec'][
'checked'])) {
539 print_liste_field_titre($arrayfields[
'i.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"i.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
540 $totalarray[
'nbfield']++;
542if (!empty($arrayfields[
'i.tms'][
'checked'])) {
543 print_liste_field_titre($arrayfields[
'i.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"i.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
544 $totalarray[
'nbfield']++;
548 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
549 $totalarray[
'nbfield']++;
557$savnbfield = $totalarray[
'nbfield'];
558$totalarray = array();
559$totalarray[
'nbfield'] = 0;
560$imaxinloop = ($limit ? min($num, $limit) : $num);
561while ($i < $imaxinloop) {
562 $obj = $db->fetch_object($resql);
567 $intracommreport_static->id = $obj->rowid;
568 $intracommreport_static->ref = $obj->ref;
569 $intracommreport_static->ref_fourn = $obj->ref_supplier;
570 $intracommreport_static->label = $obj->label;
571 $intracommreport_static->type = $obj->fk_product_type;
572 $intracommreport_static->status_buy = $obj->tobuy;
573 $intracommreport_static->status = $obj->tosell;
574 $intracommreport_static->status_batch = $obj->tobatch;
575 $intracommreport_static->entity = $obj->entity;
577 if ($mode ==
'kanban') {
579 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
580 print
'<div class="box-flex-container kanban">';
584 if ($massactionbutton || $massaction) {
586 if (in_array($object->id, $arrayofselected)) {
590 print $object->getKanbanView(
'', array(
'selected' => $selected));
591 if ($i == ($imaxinloop - 1)) {
598 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
602 print
'<td class="nowrap center">';
603 if ($massactionbutton || $massaction) {
605 if (in_array($object->id, $arrayofselected)) {
608 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
612 $totalarray[
'nbfield']++;
617 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
618 print
'<td class="tdoverflowmax200">';
619 print $intracommreport_static->getNomUrl(1);
622 $totalarray[
'nbfield']++;
626 if (!empty($arrayfields[
'i.label'][
'checked'])) {
627 print
'<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).
'</td>';
629 $totalarray[
'nbfield']++;
633 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
634 print
'<td>'.$obj->fk_product_type.
'</td>';
636 $totalarray[
'nbfield']++;
641 print
'<td class="nowrap center">';
642 if ($massactionbutton || $massaction) {
644 if (in_array($obj->rowid, $arrayofselected)) {
648 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
651 $totalarray[
'nbfield']++;
664 foreach ($arrayfields as $key => $val) {
665 if (!empty($val[
'checked'])) {
669 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 a 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.