NEW Start to introduce search filters on dictionnaries for vat list

This commit is contained in:
Laurent Destailleur 2016-10-03 13:42:27 +02:00
parent 7967c80179
commit fc65d5fb79
4 changed files with 156 additions and 96 deletions

View File

@ -73,6 +73,9 @@ $offset = $listlimit * $page ;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$search_country_id = GETPOST('search_country_id','int');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('admin')); $hookmanager->initHooks(array('admin'));
@ -577,6 +580,16 @@ if ($id == 10)
} }
/*
* Actions
*/
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
{
$search_country_id = '';
}
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd') || GETPOST('actionmodify')) if (GETPOST('actionadd') || GETPOST('actionmodify'))
{ {
@ -921,6 +934,13 @@ if ($id)
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id]; $sql=$tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_id;
}
if ($sortfield) if ($sortfield)
{ {
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
@ -946,6 +966,7 @@ if ($id)
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// Form to add a new line // Form to add a new line
@ -1034,9 +1055,11 @@ if ($id)
} }
if ($id == 4) print '<td></td>'; if ($id == 4) print '<td></td>';
print '<td colspan="4">'; print '<td>';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>'; print '</td>';
print '<td style="min-width: 26px;"></td>';
print '<td style="min-width: 26px;"></td>';
print '</tr>'; print '</tr>';
// Line to enter new values // Line to enter new values
@ -1101,8 +1124,6 @@ if ($id)
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
} }
print '</form>';
// List of available values in database // List of available values in database
@ -1113,23 +1134,28 @@ if ($id)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=true; $var=true;
if ($num)
{ $param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit)
{ {
print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">'; print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], '&id='.$id, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
} }
// Title of lines // Title of lines
print '<tr class="liste_titre">'; print '<tr class="liste_titre liste_titre_add">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield=1; // Par defaut $showfield=1; // By defaut
$align="left"; $align="left";
$sortable=1; $sortable=1;
$valuetoshow=''; $valuetoshow='';
@ -1140,7 +1166,7 @@ if ($id)
$align=$tmp['align']; $align=$tmp['align'];
$sortable=$tmp['sortable']; $sortable=$tmp['sortable'];
*/ */
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
@ -1190,17 +1216,49 @@ if ($id)
// Affiche nom du champ // Affiche nom du champ
if ($showfield) if ($showfield)
{ {
print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
} }
} }
// Favorite - Only activated on country dictionary // Favorite - Only activated on country dictionary
if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"),0,$_SERVER["PHP_SELF"],"favorite",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
// Title line with search boxes
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value)
{
$showfield=1; // By defaut
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
if ($showfield)
{
if ($value == 'country')
{
print '<td>';
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>';
}
else
{
print '<td></td>';
}
}
}
if ($id == 4) print '<td></td>';
print '<td></td>';
print '<td class="liste_titre" colspan="2" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print '</tr>';
if ($num)
{
// Lines with values // Lines with values
while ($i < $num) while ($i < $num)
{ {
@ -1417,7 +1475,9 @@ if ($id)
$canbemodified=$iserasable; $canbemodified=$iserasable;
if ($obj->code == 'RECEP') $canbemodified=1; if ($obj->code == 'RECEP') $canbemodified=1;
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?urlencode($obj->code):'').'&amp;id='.$id.'&amp;'; $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
if ($param) $url .= '&'.$param;
$url.='&';
// Favorite // Favorite
// Only activated on country dictionary // Only activated on country dictionary

View File

@ -2396,7 +2396,7 @@ table.liste, table.noborder, table.formdoc, div.noborder {
-webkit-border-radius: 0.2em; -webkit-border-radius: 0.2em;
border-radius: 0.2em;*/ border-radius: 0.2em;*/
} }
.liste_titre_add td, .liste_titre_add .tagtd .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd
{ {
border-top-width: 2px; border-top-width: 2px;
border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);

View File

@ -2274,7 +2274,7 @@ table.noborder tr, div.noborder form {
min-height: 26px; min-height: 26px;
} }
.liste_titre_add td, .liste_titre_add .tagtd .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd
{ {
border-top-width: 2px; border-top-width: 2px;
border-top-color: rgb(<?php echo $colortopbordertitle1 ?>); border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);