26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/intracommreport/class/intracommreport.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29 require_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 $sall = 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');
53 if (empty($page) || $page == -1) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
67 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'intracommreportlist';
68 if ((
string) $type ==
'1') {
69 $contextpage =
'DESlist';
if ($search_type ==
'') {
73 if ((
string) $type ==
'0') {
74 $contextpage =
'DEBlist';
if ($search_type ==
'') {
81 $hookmanager->initHooks(array(
'intracommreportlist'));
98 if (!empty($canvas)) {
99 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
100 $objcanvas =
new Canvas($db, $action);
101 $objcanvas->getCanvas(
'product',
'list', $canvas);
112 $fieldstosearchall = array(
114 'pfi.ref_fourn'=>
"RefSupplier",
115 'i.label'=>
"ProductLabel",
116 'i.description'=>
"Description",
123 $arrayfields = array(
124 'i.ref' => array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
125 'i.label' => array(
'label'=>$langs->trans(
"Label"),
'checked'=>1),
126 'i.fk_product_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>0,
'enabled'=>(
isModEnabled(
"product") &&
isModEnabled(
"service"))),
145 if ($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->rights->intracommreport->read;
154 $permissiontodelete = $user->rights->intracommreport->delete;
161 if (
GETPOST(
'cancel',
'alpha')) {
165 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
169 $parameters = array();
170 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
175 if (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';
210 $title = $langs->trans(
'IntracommReportList'.$type);
212 $sql =
'SELECT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity';
221 $parameters = array();
222 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
223 $sql .= preg_replace(
'/^,/',
'', $hookmanager->resPrint);
224 $sql = preg_replace(
'/,\s*$/',
'', $sql);
225 $sql .= $hookmanager->resPrint;
229 $sql .=
' FROM '.MAIN_DB_PREFIX.
'intracommreport as i';
231 $sql .=
' WHERE i.entity IN ('.getEntity(
'intracommreport').
')';
236 if (
dol_strlen($search_type) && $search_type !=
'-1') {
237 if ($search_type == 1) {
238 $sql .=
" AND i.type = 1";
240 $sql .=
" AND i.type = 0";
258 $parameters = array();
259 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
260 $sql .= $hookmanager->resPrint;
262 $sql .=
" GROUP BY i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity";
272 $parameters = array();
273 $reshook = $hookmanager->executeHooks(
'printFieldSelect', $parameters);
274 $sql .= $hookmanager->resPrint;
279 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
281 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
282 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
283 $resql = $db->query($sqlforcount);
285 $objforcount = $db->fetch_object(
$resql);
299 $sql .= $db->order($sortfield, $sortorder);
301 $sql .= $db->plimit($limit + 1, $offset);
304 $resql = $db->query($sql);
310 $num = $db->num_rows(
$resql);
312 $helpurl =
'EN:Module_IntracommReport|FR:Module_ProDouane';
320 $arrayofselected = is_array($toselect) ? $toselect : array();
324 $param .=
'&mode='.urlencode($mode);
326 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
327 $param .=
'&contextpage='.urlencode($contextpage);
329 if ($limit > 0 && $limit != $conf->liste_limit) {
330 $param .=
'&limit='.urlencode($limit);
333 $param .=
"&sall=".urlencode($sall);
336 $param =
"&search_ref=".urlencode($search_ref);
339 $param .=
"&search_label=".urlencode($search_label);
341 if ($optioncss !=
'') {
342 $param .=
'&optioncss='.urlencode($optioncss);
345 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
347 $parameters = array();
348 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object);
349 $param .= $hookmanager->resPrint;
352 $arrayofmassactions = array(
353 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
357 if (!empty($permissiontodelete)) {
358 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
360 if (in_array($massaction, array(
'presend',
'predelete'))) {
361 $arrayofmassactions = array();
363 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
366 if ($user->rights->intracommreport->write) {
367 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"NewDeclaration"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/intracommreport/card.php?action=create&type='.$type);
370 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formulaire">';
371 if ($optioncss !=
'') {
372 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
374 print
'<input type="hidden" name="token" value="'.newToken().
'">';
375 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
376 print
'<input type="hidden" name="action" value="list">';
377 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
378 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
379 print
'<input type="hidden" name="page" value="'.$page.
'">';
380 print
'<input type="hidden" name="type" value="'.$type.
'">';
381 if (empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
382 print
'<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).
'">';
385 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'intracommreport', 0, $newcardbutton,
'', $limit);
387 $topicmail =
"Information";
388 $modelmail =
"product";
390 $trackid =
'prod'.$object->id;
391 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
394 foreach ($fieldstosearchall as $key => $val) {
395 $fieldstosearchall[$key] = $langs->trans($val);
397 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
400 $parameters = array();
401 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
402 if (empty($reshook)) {
403 $moreforfilter .= $hookmanager->resPrint;
405 $moreforfilter = $hookmanager->resPrint;
408 if ($moreforfilter) {
409 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
410 print $moreforfilter;
414 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
415 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
416 if ($massactionbutton) {
417 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
420 print
'<div class="div-table-responsive">';
421 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
424 print
'<tr class="liste_titre_filter">';
425 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
426 print
'<td class="liste_titre left">';
427 print
'<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).
'">';
430 if (!empty($arrayfields[
'i.label'][
'checked'])) {
431 print
'<td class="liste_titre left">';
432 print
'<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).
'">';
437 if (!empty($arrayfields[
'customerorsupplier'][
'checked'])) {
438 print
'<td class="liste_titre maxwidthonsmartphone center">';
440 print
'<input type="hidden" name="type" value="'.$type.
'">';
442 print $formcompany->selectProspectCustomerType($search_type,
'search_type',
'search_type',
'list');
443 print
'</select></td>';
446 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
447 print
'<td class="liste_titre left">';
448 $array = array(
'-1'=>
' ',
'0'=>$langs->trans(
'Product'),
'1'=>$langs->trans(
'Service'));
449 print
$form->selectarray(
'search_type', $array, $search_type);
458 $parameters = array(
'arrayfields'=>$arrayfields);
459 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
460 print $hookmanager->resPrint;
462 if (!empty($arrayfields[
'i.datec'][
'checked'])) {
463 print
'<td class="liste_titre">';
467 if (!empty($arrayfields[
'i.tms'][
'checked'])) {
468 print
'<td class="liste_titre">';
471 print
'<td class="liste_titre center maxwidthsearch">';
472 $searchpicto =
$form->showFilterButtons();
478 print
'<tr class="liste_titre">';
479 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
480 print_liste_field_titre($arrayfields[
'i.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"i.ref",
"", $param,
"", $sortfield, $sortorder);
482 if (!empty($arrayfields[
'i.label'][
'checked'])) {
483 print_liste_field_titre($arrayfields[
'i.label'][
'label'], $_SERVER[
"PHP_SELF"],
"i.label",
"", $param,
"", $sortfield, $sortorder);
485 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
486 print_liste_field_titre($arrayfields[
'i.fk_product_type'][
'label'], $_SERVER[
"PHP_SELF"],
"i.fk_product_type",
"", $param,
"", $sortfield, $sortorder);
494 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
495 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
496 print $hookmanager->resPrint;
497 if (!empty($arrayfields[
'i.datec'][
'checked'])) {
498 print_liste_field_titre($arrayfields[
'i.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"i.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
500 if (!empty($arrayfields[
'i.tms'][
'checked'])) {
501 print_liste_field_titre($arrayfields[
'i.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"i.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
504 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
511 $totalarray = array();
512 while ($i < min($num, $limit)) {
513 $obj = $db->fetch_object(
$resql);
515 $intracommreport_static->id = $obj->rowid;
516 $intracommreport_static->ref = $obj->ref;
517 $intracommreport_static->ref_fourn = $obj->ref_supplier;
518 $intracommreport_static->label = $obj->label;
519 $intracommreport_static->type = $obj->fk_product_type;
520 $intracommreport_static->status_buy = $obj->tobuy;
521 $intracommreport_static->status = $obj->tosell;
522 $intracommreport_static->status_batch = $obj->tobatch;
523 $intracommreport_static->entity = $obj->entity;
525 print
'<tr class="oddeven">';
528 if (!empty($arrayfields[
'i.ref'][
'checked'])) {
529 print
'<td class="tdoverflowmax200">';
530 print $intracommreport_static->getNomUrl(1);
533 $totalarray[
'nbfield']++;
537 if (!empty($arrayfields[
'i.label'][
'checked'])) {
538 print
'<td class="tdoverflowmax200">'.dol_trunc($obj->label, 80).
'</td>';
540 $totalarray[
'nbfield']++;
544 if (!empty($arrayfields[
'i.fk_product_type'][
'checked'])) {
545 print
'<td>'.$obj->fk_product_type.
'</td>';
547 $totalarray[
'nbfield']++;
551 print
'<td class="nowrap center">';
552 if ($massactionbutton || $massaction) {
554 if (in_array($obj->rowid, $arrayofselected)) {
557 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
561 $totalarray[
'nbfield']++;
571 foreach ($arrayfields as $key => $val) {
572 if (!empty($val[
'checked'])) {
576 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)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.