dolibarr/htdocs/compta/paiement/rapport.php

157 lines
4.2 KiB
PHP
Raw Normal View History

<?php
2006-12-23 10:48:26 +00:00
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2007-11-08 23:18:48 +00:00
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
2004-04-19 09:16:32 +00: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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/
2006-12-23 10:48:26 +00:00
/**
\file htdocs/compta/paiement/rapport.php
\ingroup facture
\brief Rapports de paiements
\version $Revision$
*/
2004-04-19 09:16:32 +00:00
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/rapport/pdf_paiement.class.php");
2005-10-08 19:13:58 +00:00
// S<>curit<69> acc<63>s
if (! $user->rights->facture->lire)
accessforbidden();
2006-12-23 14:34:13 +00:00
$dir = $conf->compta->dir_output.'/payments';
$socid=0;
2005-10-08 19:13:58 +00:00
if ($user->societe_id > 0)
{
2006-12-23 10:48:26 +00:00
$action = '';
$socid = $user->societe_id;
$dir = DOL_DATA_ROOT.'/private/'.$user->id.'/compta';
2005-10-08 19:13:58 +00:00
}
2004-07-26 14:17:42 +00:00
$year = $_GET["year"];
if (! $year) { $year=date("Y"); }
2004-07-26 14:17:42 +00:00
/*
* Action g<EFBFBD>n<EFBFBD>rer fichier rapport paiements
*/
2004-07-21 16:08:31 +00:00
if ($_POST["action"] == 'gen')
2004-04-19 09:16:32 +00:00
{
$rap = new pdf_paiement($db);
$rap->write_file($dir, $_POST["remonth"], $_POST["reyear"]);
2004-04-19 09:16:32 +00:00
2004-07-21 16:08:31 +00:00
$year = $_POST["reyear"];
2004-04-19 09:16:32 +00:00
}
llxHeader();
2004-04-19 09:16:32 +00:00
/*
* Affichage liste des paiements
2004-04-19 09:16:32 +00:00
*
*/
2005-10-08 19:13:58 +00:00
$titre=($year?$langs->trans("PaymentsReportsForYear",$year):$langs->trans("PaymentsReports"));
print_titre($titre);
2004-04-19 09:16:32 +00:00
// Formulaire de g<>n<EFBFBD>ration
print '<br><form method="post" action="rapport.php?year='.$year.'">';
2004-04-19 09:16:32 +00:00
print '<input type="hidden" name="action" value="gen">';
$cmonth = date("n", time());
$syear = date("Y", time());
print '<select name="remonth">';
2004-04-19 09:16:32 +00:00
for ($month = 1 ; $month < 13 ; $month++)
{
2006-12-23 10:48:26 +00:00
if ($month == $cmonth)
{
print "<option value=\"$month\" selected=\"true\">" . dolibarr_print_date(mktime(0,0,0,$month),"%B");
}
else
{
print "<option value=\"$month\">" . dolibarr_print_date(mktime(0,0,0,$month),"%B");
}
2004-04-19 09:16:32 +00:00
}
print "</select>";
print '<select name="reyear">';
for ($formyear = $syear - 2; $formyear < $syear +1 ; $formyear++)
{
if ($formyear == $syear)
{
print "<option value=\"$formyear\" selected=\"true\">".$formyear."</option>";
2004-04-19 09:16:32 +00:00
}
else
{
print "<option value=\"$formyear\">".$formyear."</option>";
2004-04-19 09:16:32 +00:00
}
}
print "</select>\n";
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
2004-04-19 09:16:32 +00:00
print '</form>';
print '<br>';
2004-04-19 09:16:32 +00:00
clearstatcache();
// Affiche lien sur autres ann<6E>es
$found=0;
if (is_dir($dir))
{
2006-12-23 10:48:26 +00:00
$handle=opendir($dir);
while (($file = readdir($handle))!==false)
2004-04-19 09:16:32 +00:00
{
2006-12-23 10:48:26 +00:00
if (is_dir($dir.'/'.$file) && ! eregi('^\.',$file))
{
$found=1;
print '<a href="rapport.php?year='.$file.'">'.$file.'</a> ';
}
2004-04-19 09:16:32 +00:00
}
}
if ($year)
{
2006-12-23 10:48:26 +00:00
if (is_dir($dir.'/'.$year))
{
$handle=opendir($dir.'/'.$year);
if ($found) print '<br>';
print '<br>';
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Reporting").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="right">'.$langs->trans("Date").'</td>';
print '</tr>';
$var=true;
while (($file = readdir($handle))!==false)
{
2006-12-23 10:48:26 +00:00
if (eregi('^payment',$file))
{
$var=!$var;
$tfile = $dir . '/'.$year.'/'.$file;
$relativepath = $year.'/'.$file;
print "<tr $bc[$var]>".'<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture_paiement&amp;file='.urlencode($relativepath).'">'.img_pdf().' '.$file.'</a></td>';
print '<td align="right">'.filesize($tfile). ' '.$langs->trans("Bytes").'</td>';
print '<td align="right">'.dolibarr_print_date(filemtime($tfile),"dayhour").'</td></tr>';
2006-12-23 10:48:26 +00:00
}
}
2006-12-23 10:48:26 +00:00
print '</table>';
}
2004-04-19 09:16:32 +00:00
}
$db->close();
2006-12-23 10:48:26 +00:00
llxFooter('$Date$ - $Revision$');
2004-04-19 09:16:32 +00:00
?>