* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/adherents/cotisations.php * \ingroup member * \brief Page de consultation et insertion d'une cotisation */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("members"); $filter=$_GET["filter"]; $statut=isset($_GET["statut"])?$_GET["statut"]:1; $search_ref=GETPOST('search_ref','alpha'); $search_lastname=GETPOST('search_lastname','alpha'); $search_login=GETPOST('search_login','alpha'); $search_note=GETPOST('search_note','alpha'); $search_account=GETPOST('search_account','int'); $search_amount=GETPOST('search_amount','alpha'); $optioncss = GETPOST('optioncss','alpha'); $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="c.dateadh"; } $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"]; // Security check $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'); // List of subscriptions $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe,"; $sql.= " c.rowid as crowid, c.cotisation,"; $sql.= " c.dateadh,"; $sql.= " c.datef,"; $sql.= " c.fk_bank as bank, c.note,"; $sql.= " b.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql.= " WHERE d.rowid = c.fk_adherent"; 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.= natural_search(array('d.firstname','d.lastname','d.societe'), $search_lastname); if ($search_login) $sql.= natural_search('c.cotisation', $search_login); if ($search_note) $sql.= natural_search('c.note', $search_note); if ($search_account > 0) $sql.= " AND b.fk_account = ".$search_account; if ($search_amount) $sql.= natural_search('c.cotisation', $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } $sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $title=$langs->trans("ListOfSubscriptions"); if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($statut != '') $param.="&statut=".$statut; if ($date_select) $param.="&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; if ($optioncss != '') $param.='&optioncss='.$optioncss; print '
'; if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); 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; } print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"c.rowid",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.note",$param,"",'align="left"',$sortfield,$sortorder); if (! empty($conf->banque->enabled)) { print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"b.fk_account",$pram,"","",$sortfield,$sortorder); } 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(''); print "\n"; // Line for filters fields print ''; print ''; print ''; print ''; print ''; if (! empty($conf->banque->enabled)) { print ''; } print ''; print ''; print ''; // Action column print ''; print "\n"; // Static objects $cotisation=new Cotisation($db); $adherent=new Adherent($db); $accountstatic=new Account($db); $var=true; $total=0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); $total+=$objp->cotisation; $cotisation->ref=$objp->crowid; $cotisation->id=$objp->crowid; $adherent->lastname=$objp->lastname; $adherent->firstname=$objp->firstname; $adherent->ref=$adherent->getFullName($langs); $adherent->id=$objp->rowid; $adherent->login=$objp->login; $var=!$var; print ""; // Ref print ''; // Lastname print ''; // Login print ''; // Libelle print ''; // Banque if (! empty($conf->banque->enabled)) { if ($objp->fk_account) { $accountstatic->id=$objp->fk_account; $accountstatic->fetch($objp->fk_account); //$accountstatic->label=$objp->label; print ''; } else { print "\n"; } } // Date start print '\n"; // Date end print '\n"; // Price print ''; print ''; print ""; $i++; } // Total $var=!$var; print ''; print "\n"; print "\n"; print "\n"; print "\n"; if (! empty($conf->banque->enabled)) { print ''; } print ''; print ''; print '\n"; print ''; print "\n"; print "
'; print ''; print ''; print ''; print ''; print $form->select_comptes($search_account, 'search_account', 0, '', 1); print '  '; print ''; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print '
'.$cotisation->getNomUrl(1).''.$adherent->getNomUrl(1).''.$adherent->login.''; print dol_trunc($objp->note,32); print ''.$accountstatic->getNomUrl(1).'"; print "'.dol_print_date($db->jdate($objp->dateadh),'day')."'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->cotisation).'
".$langs->trans("Total")."      '.price($total)."
"; print '
'; } else { dol_print_error($db); } llxFooter(); $db->close();