dolibarr/htdocs/adherents/cotisations.php

235 lines
7.6 KiB
PHP
Raw Normal View History

<?php
2002-12-30 16:13:28 +01:00
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
2009-03-09 11:27:21 +01:00
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
2002-12-30 16:13:28 +01:00
*
* 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
2002-12-30 16:13:28 +01:00
* (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
2011-08-01 00:21:57 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2002-12-30 16:13:28 +01:00
*/
2005-04-02 22:36:17 +02:00
/**
* \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';
2005-01-12 21:53:29 +01:00
$langs->load("members");
$filter=$_GET["filter"];
$statut=isset($_GET["statut"])?$_GET["statut"]:1;
2002-12-30 16:13:28 +01:00
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
2010-11-20 14:08:44 +01:00
if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="c.dateadh"; }
2005-01-12 21:53:29 +01:00
$msg='';
$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
2002-12-30 16:13:28 +01:00
2013-01-10 08:27:12 +01:00
// Security check
$result=restrictedArea($user,'adherent','','','cotisation');
2002-12-30 16:13:28 +01:00
/*
* Actions
*/
2005-01-12 21:53:29 +01:00
2006-03-18 01:06:55 +01:00
/*
2009-08-12 14:59:14 +02:00
* View
2006-03-18 01:06:55 +01:00
*/
2002-12-30 16:13:28 +01:00
2009-08-12 14:59:14 +02:00
llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
2002-12-30 16:13:28 +01:00
if ($msg) print $msg.'<br>';
2002-12-30 16:13:28 +01:00
// Liste des cotisations
2013-02-23 15:26:39 +01:00
$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 dateadh LIKE '$date_select%'";
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
2002-12-30 16:13:28 +01:00
$result = $db->query($sql);
2009-03-09 11:27:21 +01:00
if ($result)
2002-12-30 16:13:28 +01:00
{
$num = $db->num_rows($result);
$i = 0;
2009-03-09 11:27:21 +01:00
$title=$langs->trans("ListOfSubscriptions");
if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')';
2013-07-10 23:57:18 +02:00
$param="";
$param.="&amp;statut=$statut&amp;date_select=$date_select";
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),"cotisations.php","c.rowid",$param,"","",$sortfield,$sortorder);
2013-02-23 11:11:33 +01:00
print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.lastname",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Login"),"cotisations.php","d.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"cotisations.php","c.note",$param,"",'align="left"',$sortfield,$sortorder);
2012-09-15 10:01:35 +02:00
if (! empty($conf->banque->enabled))
2002-12-30 16:13:28 +01:00
{
print_liste_field_titre($langs->trans("Account"),"cotisations.php","b.fk_account",$pram,"","",$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateEnd"),"cotisations.php","c.datef",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
// Static objects
$cotisation=new Cotisation($db);
$adherent=new Adherent($db);
$accountstatic=new Account($db);
$var=true;
$total=0;
while ($i < $num && $i < $conf->liste_limit)
{
$objp = $db->fetch_object($result);
2007-08-27 13:46:24 +02:00
$total+=$objp->cotisation;
$cotisation->ref=$objp->crowid;
$cotisation->id=$objp->crowid;
2012-01-30 10:22:50 +01:00
$adherent->lastname=$objp->lastname;
$adherent->firstname=$objp->firstname;
$adherent->ref=$adherent->getFullName($langs);
$adherent->id=$objp->rowid;
$adherent->login=$objp->login;
$var=!$var;
2012-09-15 11:21:22 +02:00
if ($allowinsertbankafter && ! $objp->fk_account && ! empty($conf->banque->enabled) && $objp->cotisation)
{
print "<form method=\"post\" action=\"cotisations.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
}
2013-06-20 09:18:12 +02:00
print "<tr ".$bc[$var].">";
2009-03-09 11:27:21 +01:00
// Ref
print '<td>'.$cotisation->getNomUrl(1).'</td>';
2013-02-23 11:11:33 +01:00
// Lastname
print '<td>'.$adherent->getNomUrl(1).'</td>';
// Login
print '<td>'.$adherent->login.'</td>';
// Libelle
print '<td>';
print dol_trunc($objp->note,32);
print '</td>';
// Banque
2012-09-15 10:01:35 +02:00
if (! empty($conf->banque->enabled))
{
if ($objp->fk_account)
{
2006-12-20 02:15:21 +01:00
$accountstatic->id=$objp->fk_account;
$accountstatic->fetch($objp->fk_account);
//$accountstatic->label=$objp->label;
print '<td>'.$accountstatic->getNomUrl(1).'</td>';
}
else
{
print "<td>";
if ($allowinsertbankafter && $objp->cotisation)
{
print '<input type="hidden" name="action" value="2bank">';
print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
$form->select_comptes('','accountid',0,'',1);
print '<br>';
$form->select_types_paiements('','paymenttypeid');
print '<input name="num_chq" type="text" class="flat" size="5">';
}
else
{
print '&nbsp;';
}
print "</td>\n";
}
}
// Date start
print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
2009-03-09 11:27:21 +01:00
// Date end
print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
// Price
print '<td align="right">'.price($objp->cotisation).'</td>';
2009-03-09 11:27:21 +01:00
print "</tr>";
2012-09-15 11:21:22 +02:00
if ($allowinsertbankafter && ! $objp->fk_account && ! empty($conf->banque->enabled) && $objp->cotisation)
{
print "</form>\n";
}
$i++;
2002-12-30 16:13:28 +01:00
}
2008-11-11 20:49:46 +01:00
// Total
$var=!$var;
print '<tr class="liste_total">';
print "<td>".$langs->trans("Total")."</td>\n";
print "<td align=\"right\">&nbsp;</td>\n";
print "<td align=\"right\">&nbsp;</td>\n";
print "<td align=\"right\">&nbsp;</td>\n";
2012-09-15 10:01:35 +02:00
if (! empty($conf->banque->enabled))
2006-03-18 01:06:55 +01:00
{
print '<td>&nbsp;</td>';
2006-03-18 01:06:55 +01:00
}
print '<td>&nbsp;</td>';
2008-11-11 20:49:46 +01:00
print '<td>&nbsp;</td>';
print "<td align=\"right\">".price($total)."</td>\n";
print "</tr>\n";
2009-03-09 11:27:21 +01:00
print "</table>";
print "<br>\n";
2002-12-30 16:13:28 +01:00
}
else
{
dol_print_error($db);
2002-12-30 16:13:28 +01:00
}
$db->close();
llxFooter();
2002-12-30 16:13:28 +01:00
?>