diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 42ecf21c27b..ef6d6472559 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -55,17 +55,15 @@ $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; $optioncss = GETPOST('optioncss', 'alpha'); - if ($contextpage == 'poslist') { $optioncss = 'print'; } - $mode = GETPOST("mode", 'alpha'); // search fields -$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_all = trim(GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars $search_id = trim(GETPOST("search_id", "int")); @@ -163,8 +161,8 @@ if ($type == 'f') { // Initialize technical objects to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); -$hookmanager->initHooks(array('thirdpartylist')); $extrafields = new ExtraFields($db); +$hookmanager->initHooks(array($contextpage)); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -445,9 +443,8 @@ if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) { if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) { $title = $langs->trans("Suppliers"); } +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); @@ -497,6 +494,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +//$sql .= ", COUNT(rc.rowid) as anotherfield"; $sqlfields = $sql; // $sql fields to remove for count totall @@ -733,12 +732,13 @@ if (empty($reshook)) { } } $sql .= $hookmanager->resPrint; + // Add GroupBy from hooks $parameters = array('fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -// Count total nb of records with no order and no limits +// Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ @@ -752,7 +752,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -774,8 +774,6 @@ if (!$resql) { $num = $db->num_rows($resql); -$arrayofselected = is_array($toselect) ? $toselect : array(); - // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { $obj = $db->fetch_object($resql); @@ -798,9 +796,11 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ( // Output page // -------------------------------------------------------------------- -$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); + +$arrayofselected = is_array($toselect) ? $toselect : array(); + $param = ''; if (!empty($mode)) { $param .= '&mode='.urlencode($mode); @@ -811,8 +811,11 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} if ($search_all != '') { - $param = "&sall=".urlencode($search_all); + $param = "&search_all=".urlencode($search_all); } if ($search_categ_cus > 0) { $param .= '&search_categ_cus='.urlencode($search_categ_cus); @@ -929,11 +932,12 @@ if ($search_import_key != '') { if ($type != '') { $param .= '&type='.urlencode($type); } -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, $action); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; // Show delete result message if (GETPOST('delsoc')) { @@ -1043,13 +1047,15 @@ $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } + print ''."\n"; print '
| '; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; @@ -1338,9 +1343,9 @@ if (!empty($arrayfields['s.import_key']['checked'])) { print ''; print ' | '; } -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - // Action column - print ''; +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ' | '; $searchpicto = $form->showFilterButtons(); print $searchpicto; print ' | '; @@ -1354,8 +1359,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print '