From 4e6d5e1cd1d680365ffe1172ae8f6ed659293c0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 14 Feb 2015 19:10:40 +0100 Subject: [PATCH] New: Add filter fields on the subscription list --- htdocs/adherents/cotisations.php | 136 +++++++++++++++++++++++-------- htdocs/adherents/list.php | 4 +- 2 files changed, 105 insertions(+), 35 deletions(-) diff --git a/htdocs/adherents/cotisations.php b/htdocs/adherents/cotisations.php index 160f47365fa..40d34f58881 100644 --- a/htdocs/adherents/cotisations.php +++ b/htdocs/adherents/cotisations.php @@ -32,6 +32,12 @@ $langs->load("members"); $filter=$_GET["filter"]; $statut=isset($_GET["statut"])?$_GET["statut"]:1; +$search_ref=GETPOST('search_ref'); +$search_lastname=GETPOST('search_lastname'); +$search_login=GETPOST('search_login'); +$search_note=GETPOST('search_note'); +$search_account=GETPOST('search_account','int'); +$search_amount=GETPOST('search_amount','int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -43,7 +49,6 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="c.dateadh"; } -$msg=''; $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"]; // Security check @@ -54,14 +59,27 @@ $result=restrictedArea($user,'adherent','','','cotisation'); * Actions */ +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search=""; + $search_ref=""; + $search_lastname=""; + $search_firstname=""; + $search_login=""; + $search_note=""; + $search_amount=""; + $search_account=""; +} + /* * View */ +$form=new Form($db); + llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); -if ($msg) print $msg.'
'; // List of subscriptions $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe,"; @@ -77,6 +95,31 @@ if (isset($date_select) && $date_select != '') { $sql.= " AND c.dateadh LIKE '".$date_select."%'"; } +if ($search_ref) +{ + if (is_numeric($search_ref)) $sql.= " AND (c.rowid = ".$db->escape($search_ref).")"; + else $sql.=" AND 1 = 2"; // Always wrong +} +if ($search_lastname) +{ + $sql.= " AND (d.firstname LIKE '%".$db->escape($search_lastname)."%' OR d.lastname LIKE '%".$db->escape($search_lastname)."%' OR d.societe LIKE '%".$db->escape($search_lastname)."%')"; +} +if ($search_login) +{ + $sql.= " AND d.login LIKE '%".$db->escape($search_login)."%'"; +} +if ($search_note) +{ + $sql.= " AND c.note LIKE '%".$db->escape($search_note)."%'"; +} +if ($search_account > 0) +{ + $sql.= " AND b.fk_account = ".$search_account; +} +if ($search_amount) +{ + $sql.=" AND c.cotisation = ".$db->escape($search_amount); +} $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit+1, $offset); @@ -90,10 +133,23 @@ if ($result) if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; $param=""; - $param.="&statut=$statut&date_select=$date_select"; + $param.="&statut=$statut&date_select=$date_select"; + + if ($search_lastname) $param.="&search_lastname=".$search_lastname; + if ($search_login) $param.="&search_login=".$search_login; + if ($search_acount) $param.="&search_account=".$search_account; + if ($search_amount) $param.="&search_amount=".$search_amount; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num); + if ($sall) + { + print $langs->trans("Filter")." (".$langs->trans("Ref").", ".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; + } + $param=""; + $param.="&statut=$statut&date_select=$date_select"; + + print '
'; print ''; print ''; @@ -107,9 +163,47 @@ if ($result) } print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"c.dateadh",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"c.datef",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"c.cotisation",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"c.cotisation",$param,"",'colspan="2" align="right"',$sortfield,$sortorder); print "\n"; + + // Line for filters fields + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + if (! empty($conf->banque->enabled)) + { + print ''; + } + + print ''; + + print ''; + + print ''; + + print "\n"; + + // Static objects $cotisation=new Cotisation($db); $adherent=new Adherent($db); @@ -133,11 +227,6 @@ if ($result) $var=!$var; - if ($allowinsertbankafter && ! $objp->fk_account && ! empty($conf->banque->enabled) && $objp->cotisation) - { - print ""; - print ''; - } print ""; // Ref @@ -167,19 +256,6 @@ if ($result) else { print "\n"; } } @@ -191,13 +267,10 @@ if ($result) print '\n"; // Price - print ''; + print ''; print ""; - if ($allowinsertbankafter && ! $objp->fk_account && ! empty($conf->banque->enabled) && $objp->cotisation) - { - print "\n"; - } + $i++; } @@ -214,13 +287,11 @@ if ($result) } print ''; print ''; - print "\n"; + print '\n"; print "\n"; print "
'; + print ''; + print ''; + print ''; + print ''; + print $form->select_comptes($search_account, 'search_account', 0, '', 1); + print '  '; + print ''; + print ''; + print ''; + print ' '; + print ''; + print '
"; - if ($allowinsertbankafter && $objp->cotisation) - { - print ''; - print ''; - $form->select_comptes('','accountid',0,'',1); - print '
'; - $form->select_types_paiements('','paymenttypeid'); - print ''; - } - else - { - print ' '; - } print "
'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->cotisation).''.price($objp->cotisation).'
  ".price($total)."'.price($total)."
"; - print "
\n"; - - + print ''; } else { @@ -228,6 +299,5 @@ else } -$db->close(); - llxFooter(); +$db->close(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index b88a39c76af..0bb34d14153 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -233,7 +233,7 @@ if ($resql) print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); print "\n"; - // Lignes des champs de filtre + // Line for filters fields print ''; print ''; @@ -263,7 +263,7 @@ if ($resql) print ''; print ''; - print "\n"; + print "\n"; $var=True; while ($i < $num && $i < $conf->liste_limit)