diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index f2c88d7a217..403c4b28eae 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -119,7 +119,7 @@ if ($action == 'add' && $permissiontoadd) { $object->label = trim($label); $object->type = trim($exporttype); $object->type_declaration = $type_declaration; - $object->subscription = (int) $subscription; + //$object->subscription = (int) $subscription; // Fill array 'array_options' with data from add form // $ret = $extrafields->setOptionalsFromPost($extralabels, $object); diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index 18e6e0ecc84..88788f7070e 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -47,17 +47,29 @@ class IntracommReport extends CommonObject */ public $fk_element = 'fk_intracommreport'; - /** - * @var string declaration number - */ - public $declaration_number; - /** * 0 = No test on entity, 1 = Test with field entity, 2 = Test with link by societe * @var int */ public $ismultientitymanaged = 1; + public $picto = 'intracommreport'; + + + public $label; // ref ??? + + public $period; + + public $declaration; + + /** + * @var string declaration number + */ + public $declaration_number; + + public $type_declaration; // deb or des + + /** * DEB - Product */ @@ -73,6 +85,7 @@ class IntracommReport extends CommonObject 'expedition'=>'Expédition' ); + /** * Constructor * diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index 7f0e896a447..db93d14b4c7 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -144,21 +144,14 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); // Security check if ($search_type == '0') { $result = restrictedArea($user, 'produit', '', '', '', '', '', 0); - - $permissiontoread = $user->rights->produit->lire; - $permissiontodelete = $user->rights->produit->supprimer; } elseif ($search_type == '1') { $result = restrictedArea($user, 'service', '', '', '', '', '', 0); - - $permissiontoread = $user->rights->service->lire; - $permissiontodelete = $user->rights->service->supprimer; } else { $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0); - - $permissiontoread = $user->rights->produit->lire; - $permissiontodelete = $user->rights->produit->supprimer; } +$permissiontoread = $user->rights->intracommreport->read; +$permissiontodelete = $user->rights->intracommreport->delete; /* @@ -216,25 +209,21 @@ $formother = new FormOther($db); $title = $langs->trans('IntracommReportList'.$type); -$sql = 'SELECT DISTINCT i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity'; +$sqlfields = 'i.rowid, i.type_declaration, i.type_export, i.periods, i.mode, i.entity'; +$sql = 'SELECT '.$sqlfields; /* // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } */ - // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= ' FROM '.MAIN_DB_PREFIX.'intracommreport as i'; - // if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."intracommreport_extrafields as ef on (i.rowid = ef.fk_object)"; - $sql .= ' WHERE i.entity IN ('.getEntity('intracommreport').')'; - if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } @@ -279,281 +268,315 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} -if ($resql) { - $num = $db->num_rows($resql); +$num = $db->num_rows($resql); - $arrayofselected = is_array($toselect) ? $toselect : array(); +$helpurl = 'EN:Module_IntracommReport|FR:Module_ProDouane'; +llxHeader('', $title, $helpurl, ''); - $helpurl = 'EN:Module_IntracommReport|FR:Module_ProDouane'; - llxHeader('', $title, $helpurl, ''); +// Displays product removal confirmation +if (GETPOST('delreport')) { + setEventMessages($langs->trans("IntracommReportDeleted", GETPOST('delreport')), null, 'mesgs'); +} - // Displays product removal confirmation - if (GETPOST('delreport')) { - setEventMessages($langs->trans("IntracommReportDeleted", GETPOST('delreport')), null, 'mesgs'); - } +$arrayofselected = is_array($toselect) ? $toselect : array(); - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - if ($sall) { - $param .= "&sall=".urlencode($sall); - } - if ($search_ref) { - $param = "&search_ref=".urlencode($search_ref); - } - if ($search_label) { - $param .= "&search_label=".urlencode($search_label); - } +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($sall) { + $param .= "&sall=".urlencode($sall); +} +if ($search_ref) { + $param = "&search_ref=".urlencode($search_ref); +} +if ($search_label) { + $param .= "&search_label=".urlencode($search_label); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// List of mass actions available +$arrayofmassactions = array( + 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if (!empty($permissiontodelete)) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - // List of mass actions available - $arrayofmassactions = array( - 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>$langs->trans("PDFMerge"), - //'presend'=>$langs->trans("SendByMail"), - ); - if ($user->rights->intracommreport->delete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); - } - if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); - } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); +$newcardbutton = ''; +if ($user->rights->intracommreport->write) { + $newcardbutton .= dolGetButtonTitle($langs->trans("NewDeclaration"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&type='.$type); +} - $newcardbutton = ''; - if ($user->rights->intracommreport->write) { - $newcardbutton .= dolGetButtonTitle($langs->trans("NewDeclaration"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&type='.$type); - } +print '
'; + // End of page llxFooter(); $db->close();