2004-10-19 22:35:36 +02:00
|
|
|
<?php
|
2006-12-23 11:48:26 +01:00
|
|
|
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2014-01-30 11:44:31 +01:00
|
|
|
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
2004-04-19 11:16:32 +02: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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-04-19 11:16:32 +02: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-03 02:45:22 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-04-19 11:16:32 +02:00
|
|
|
*/
|
2008-10-28 21:05:23 +01:00
|
|
|
|
2006-12-23 11:48:26 +01:00
|
|
|
/**
|
2009-01-09 23:46:41 +01:00
|
|
|
* \file htdocs/compta/paiement/rapport.php
|
|
|
|
|
* \ingroup facture
|
|
|
|
|
* \brief Payment reports page
|
2008-10-28 21:05:23 +01:00
|
|
|
*/
|
2004-12-28 16:02:48 +01:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
2004-07-25 19:43:23 +02:00
|
|
|
|
2009-01-09 23:46:41 +01:00
|
|
|
// Security check
|
2011-12-13 01:10:07 +01:00
|
|
|
if (! $user->rights->facture->lire) accessforbidden();
|
|
|
|
|
|
|
|
|
|
$action=GETPOST('action');
|
2004-07-25 19:43:23 +02:00
|
|
|
|
2006-09-13 20:56:30 +02:00
|
|
|
$socid=0;
|
2008-10-28 21:05:23 +01:00
|
|
|
if ($user->societe_id > 0)
|
2005-10-08 21:13:58 +02:00
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
$action = '';
|
|
|
|
|
$socid = $user->societe_id;
|
2005-10-08 21:13:58 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-30 11:44:31 +01:00
|
|
|
$dir = $conf->facture->dir_output.'/payments';
|
|
|
|
|
if (! $user->rights->societe->client->voir || $socid) $dir.='/private/'.$user->id; // If user has no permission to see all, output dir is specific to user
|
|
|
|
|
|
2004-07-26 16:17:42 +02:00
|
|
|
$year = $_GET["year"];
|
2004-12-28 16:16:49 +01:00
|
|
|
if (! $year) { $year=date("Y"); }
|
2004-07-26 16:17:42 +02:00
|
|
|
|
2009-01-09 23:46:41 +01:00
|
|
|
|
2004-12-28 16:02:48 +01:00
|
|
|
/*
|
2009-01-09 23:46:41 +01:00
|
|
|
* Actions
|
2004-12-28 16:02:48 +01:00
|
|
|
*/
|
2009-01-09 23:46:41 +01:00
|
|
|
|
2011-12-13 01:10:07 +01:00
|
|
|
if ($action == 'builddoc')
|
2004-04-19 11:16:32 +02:00
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
$rap = new pdf_paiement($db);
|
|
|
|
|
|
|
|
|
|
$outputlangs = $langs;
|
2013-10-14 16:12:07 +02:00
|
|
|
if (GETPOST('lang_id'))
|
2010-12-15 19:15:08 +01:00
|
|
|
{
|
|
|
|
|
$outputlangs = new Translate("",$conf);
|
2013-09-06 13:25:45 +02:00
|
|
|
$outputlangs->setDefaultLang(GETPOST('lang_id'));
|
2010-12-15 19:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We save charset_output to restore it because write_file can change it if needed for
|
|
|
|
|
// output format that does not support UTF8.
|
|
|
|
|
$sav_charset_output=$outputlangs->charset_output;
|
|
|
|
|
if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0)
|
|
|
|
|
{
|
|
|
|
|
$outputlangs->charset_output=$sav_charset_output;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$outputlangs->charset_output=$sav_charset_output;
|
|
|
|
|
dol_print_error($db,$obj->error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$year = $_POST["reyear"];
|
2004-04-19 11:16:32 +02:00
|
|
|
}
|
|
|
|
|
|
2008-10-28 21:05:23 +01:00
|
|
|
|
2009-01-09 23:46:41 +01:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
2008-10-28 21:05:23 +01:00
|
|
|
|
2011-12-13 01:10:07 +01:00
|
|
|
$formother=new FormOther($db);
|
|
|
|
|
|
2006-08-04 21:05:34 +02:00
|
|
|
llxHeader();
|
|
|
|
|
|
2005-10-08 21:13:58 +02:00
|
|
|
$titre=($year?$langs->trans("PaymentsReportsForYear",$year):$langs->trans("PaymentsReports"));
|
2009-01-09 23:50:58 +01:00
|
|
|
print_fiche_titre($titre);
|
2004-04-19 11:16:32 +02:00
|
|
|
|
2009-06-29 20:16:21 +02:00
|
|
|
// Formulaire de generation
|
2009-01-09 23:52:45 +01:00
|
|
|
print '<form method="post" action="rapport.php?year='.$year.'">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2009-06-29 20:16:21 +02:00
|
|
|
print '<input type="hidden" name="action" value="builddoc">';
|
2010-12-20 23:07:04 +01:00
|
|
|
$cmonth = GETPOST("remonth")?GETPOST("remonth"):date("n", time());
|
|
|
|
|
$syear = GETPOST("reyear")?GETPOST("reyear"):date("Y", time());
|
2008-10-28 21:05:23 +01:00
|
|
|
|
2011-12-13 01:10:07 +01:00
|
|
|
print $formother->select_month($cmonth,'remonth');
|
|
|
|
|
|
|
|
|
|
print $formother->select_year($syear,'reyear');
|
2004-04-19 11:16:32 +02:00
|
|
|
|
2006-08-04 21:05:34 +02:00
|
|
|
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
|
2004-04-19 11:16:32 +02:00
|
|
|
print '</form>';
|
2006-08-04 21:05:34 +02:00
|
|
|
print '<br>';
|
2004-12-28 16:16:49 +01:00
|
|
|
|
2004-04-19 11:16:32 +02:00
|
|
|
clearstatcache();
|
|
|
|
|
|
2011-03-07 03:11:38 +01:00
|
|
|
// Show link on other years
|
2009-02-10 23:07:31 +01:00
|
|
|
$linkforyear=array();
|
2006-08-04 21:05:34 +02:00
|
|
|
$found=0;
|
|
|
|
|
if (is_dir($dir))
|
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
$handle=opendir($dir);
|
|
|
|
|
if (is_resource($handle))
|
|
|
|
|
{
|
|
|
|
|
while (($file = readdir($handle))!==false)
|
|
|
|
|
{
|
2011-03-07 03:11:38 +01:00
|
|
|
if (is_dir($dir.'/'.$file) && ! preg_match('/^\./',$file) && is_numeric($file))
|
2010-12-15 19:15:08 +01:00
|
|
|
{
|
|
|
|
|
$found=1;
|
|
|
|
|
$linkforyear[]=$file;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-19 11:16:32 +02:00
|
|
|
}
|
2009-01-09 23:50:58 +01:00
|
|
|
asort($linkforyear);
|
|
|
|
|
foreach($linkforyear as $cursoryear)
|
|
|
|
|
{
|
2010-12-15 19:15:08 +01:00
|
|
|
print '<a href="rapport.php?year='.$cursoryear.'">'.$cursoryear.'</a> ';
|
2009-01-09 23:50:58 +01:00
|
|
|
}
|
2004-04-19 11:16:32 +02:00
|
|
|
|
|
|
|
|
if ($year)
|
|
|
|
|
{
|
2010-12-15 19:15:08 +01: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;
|
|
|
|
|
if (is_resource($handle))
|
|
|
|
|
{
|
|
|
|
|
while (($file = readdir($handle))!==false)
|
|
|
|
|
{
|
|
|
|
|
if (preg_match('/^payment/i',$file))
|
|
|
|
|
{
|
|
|
|
|
$var=!$var;
|
|
|
|
|
$tfile = $dir . '/'.$year.'/'.$file;
|
|
|
|
|
$relativepath = $year.'/'.$file;
|
2013-04-20 20:30:18 +02:00
|
|
|
print "<tr ".$bc[$var].">".'<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=facture_paiement&file='.urlencode($relativepath).'">'.img_pdf().' '.$file.'</a></td>';
|
2010-12-15 19:15:08 +01:00
|
|
|
print '<td align="right">'.dol_print_size(dol_filesize($tfile)).'</td>';
|
|
|
|
|
print '<td align="right">'.dol_print_date(dol_filemtime($tfile),"dayhour").'</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-19 00:49:40 +01:00
|
|
|
closedir($handle);
|
2010-12-15 19:15:08 +01:00
|
|
|
}
|
|
|
|
|
print '</table>';
|
|
|
|
|
}
|
2004-04-19 11:16:32 +02:00
|
|
|
}
|
2006-12-23 11:48:26 +01:00
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2011-12-13 01:10:07 +01:00
|
|
|
|
|
|
|
|
$db->close();
|
2004-04-19 11:16:32 +02:00
|
|
|
?>
|