From c79de819d37193ecd35bdbbad3b8f0e513980646 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 23:27:26 +0200 Subject: [PATCH] FIX Missing import_key in member list --- htdocs/adherents/list.php | 93 +++++++++++++++++++++++++++------------ htdocs/societe/list.php | 25 +++++++---- 2 files changed, 82 insertions(+), 36 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 72f75cdf4c8..ec6e7ac5f29 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2013-2015 RaphaĆ«l Doursenaud * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2018 Alexandre Spangaro @@ -63,6 +63,7 @@ $search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); $search_filter = GETPOST("search_filter", 'alpha'); $search_status = GETPOST("search_status", 'intcomma'); +$search_import_key = trim(GETPOST("search_import_key", "alpha")); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); @@ -156,7 +157,8 @@ $arrayfields = array( 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'd.birth'=>array('label'=>$langs->trans("Birthday"), 'checked'=>0, 'position'=>500), 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) + 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -213,6 +215,7 @@ if (empty($reshook)) { $search_categ = ""; $search_filter = ""; $search_status = ""; + $search_import_key = ''; $catid = ""; $sall = ""; $toselect = array(); @@ -318,7 +321,7 @@ $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,"; $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; -$sql .= " d.note_private, d.note_public,"; +$sql .= " d.note_private, d.note_public, d.import_key,"; $sql .= " s.nom,"; $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,"; $sql .= " t.libelle as type, t.subscription,"; @@ -427,6 +430,9 @@ if ($search_phone_mobile) { if ($search_country) { $sql .= " AND d.country IN (".$db->sanitize($search_country).')'; } +if ($search_import_key) { + $sql .= natural_search("d.import_key", $search_import_key); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -436,8 +442,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $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 with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -447,15 +451,20 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } 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); +} + +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } -// Add limit -$sql .= $db->plimit($limit + 1, $offset); -dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -464,6 +473,7 @@ if (!$resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { @@ -473,7 +483,8 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -llxHeader('', $title, 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +llxHeader('', $title, $help_url); if (GETPOSTISSET("search_status")) { if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED @@ -577,6 +588,9 @@ if ($search_filter && $search_filter != '-1') { if ($search_status != "" && $search_status != -3) { $param .= "&search_status=".urlencode($search_status); } +if ($search_import_key != '') { + $param .= '&search_import_key='.urlencode($search_import_key); +} if ($search_type > 0) { $param .= "&search_type=".urlencode($search_type); } @@ -603,7 +617,7 @@ if ($user->rights->societe->creer) { if ($user->rights->adherent->creer && $user->rights->user->user->creer) { $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); } -if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -669,7 +683,6 @@ if ($massactionbutton) { print '
'; print ''."\n"; - // Line for filters fields print ''; @@ -807,15 +820,24 @@ if (!empty($arrayfields['d.statut']['checked'])) { print $form->selectarray('search_status', $liststatus, $search_status, -3); print ''; } -// Action column -print ''; - +if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; +} +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + // Action column + print ''; +} print "\n"; print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); +} if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); } @@ -895,7 +917,12 @@ if (!empty($arrayfields['d.tms']['checked'])) { if (!empty($arrayfields['d.statut']['checked'])) { print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +if (!empty($arrayfields['d.import_key']['checked'])) { + print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +} print "\n"; $i = 0; @@ -936,7 +963,7 @@ while ($i < min($num, $limit)) { print ''; if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -1172,21 +1199,31 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - // Action column - print '\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!$i) { $totalarray['nbfield']++; } - print "\n"; + print ''."\n"; $i++; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 91368ec9dc7..c2ad5852842 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -678,20 +678,28 @@ $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; -$sql .= $db->order($sortfield, $sortorder); - -// Count total nb of records +// Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + if ($resql) { + $nbtotalofrecords = $db->num_rows($resql); + } 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) { @@ -701,6 +709,7 @@ if (!$resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { @@ -860,8 +869,8 @@ if (GETPOST('delsoc')) { // List of mass actions available $arrayofmassactions = array( -'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->creer) {
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + print ''; + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'.$obj->rowid.''.$obj->rowid.''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; + print $obj->import_key; + print "'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '