Corrections diverses sur génération des rapport de paiement.

Si on est un utilisateur externe, le fichier est généré dans un rep privé.
This commit is contained in:
Laurent Destailleur 2006-08-04 19:05:34 +00:00
parent da56232460
commit aadbf18c22
4 changed files with 172 additions and 176 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** \file htdocs/compta/paiement/rapport.php /** \file htdocs/compta/paiement/rapport.php
@ -36,11 +35,14 @@ $user->getrights("facture");
if (! $user->rights->facture->lire) if (! $user->rights->facture->lire)
accessforbidden(); accessforbidden();
$dir = $conf->compta->dir_output;
$socidp=0; $socidp=0;
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socidp = $user->societe_id; $socidp = $user->societe_id;
$dir = DOL_DATA_ROOT.'/private/'.$user->id.'/compta';
} }
@ -50,7 +52,6 @@ if (! $year) { $year=date("Y"); }
require("../../includes/modules/rapport/pdf_paiement.class.php"); require("../../includes/modules/rapport/pdf_paiement.class.php");
$dir = $conf->compta->dir_output;
/* /*
@ -64,9 +65,10 @@ if ($_POST["action"] == 'gen')
$year = $_POST["reyear"]; $year = $_POST["reyear"];
} }
llxHeader();
llxHeader();
/* /*
* Affichage liste des paiements * Affichage liste des paiements
* *
@ -80,29 +82,17 @@ print '<input type="hidden" name="action" value="gen">';
$cmonth = date("n", time()); $cmonth = date("n", time());
$syear = date("Y", time()); $syear = date("Y", time());
$strmonth[1] = "Janvier";
$strmonth[2] = "F&eacute;vrier";
$strmonth[3] = "Mars";
$strmonth[4] = "Avril";
$strmonth[5] = "Mai";
$strmonth[6] = "Juin";
$strmonth[7] = "Juillet";
$strmonth[8] = "Ao&ucirc;t";
$strmonth[9] = "Septembre";
$strmonth[10] = "Octobre";
$strmonth[11] = "Novembre";
$strmonth[12] = "D&eacute;cembre";
print '<select name="remonth">'; print '<select name="remonth">';
for ($month = 1 ; $month < 13 ; $month++) for ($month = 1 ; $month < 13 ; $month++)
{ {
if ($month == $cmonth) if ($month == $cmonth)
{ {
print "<option value=\"$month\" selected=\"true\">" . $strmonth[$month]; print "<option value=\"$month\" selected=\"true\">" . dolibarr_print_date(mktime(0,0,0,$month),"%B");
} }
else else
{ {
print "<option value=\"$month\">" . $strmonth[$month]; print "<option value=\"$month\">" . dolibarr_print_date(mktime(0,0,0,$month),"%B");
} }
} }
print "</select>"; print "</select>";
@ -121,19 +111,24 @@ for ($formyear = $syear - 2; $formyear < $syear +1 ; $formyear++)
} }
} }
print "</select>\n"; print "</select>\n";
print '<input type="submit" value="'.$langs->trans("Create").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
print '</form>'; print '</form>';
print '<br>';
clearstatcache(); clearstatcache();
if (is_dir($dir)) { // Affiche lien sur autres années
$found=0;
if (is_dir($dir))
{
$handle=opendir($dir); $handle=opendir($dir);
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (is_dir($dir.$file) && substr($file, 0, 1) <> '.') if (is_dir($dir.'/'.$file) && ! eregi('^\.',$file))
{ {
$found=1;
print '<a href="rapport.php?year='.$file.'">'.$file.'</a> '; print '<a href="rapport.php?year='.$file.'">'.$file.'</a> ';
} }
} }
@ -141,11 +136,19 @@ if (is_dir($dir)) {
if ($year) if ($year)
{ {
if (is_dir($dir.'/'.$year)) { if (is_dir($dir.'/'.$year))
{
$handle=opendir($dir.'/'.$year); $handle=opendir($dir.'/'.$year);
if ($found) print '<br>';
print '<br>'; print '<br>';
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td>Rapport</td><td align="right">'.$langs->trans("Size").'</td><td align="right">'.$langs->trans("Date").'</td></tr>'; 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; $var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -164,5 +167,5 @@ if ($year)
} }
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -278,7 +278,7 @@ if ($result)
$i++; $i++;
} }
print_barre_liste($titre ,$page, "index.php", '&amp;begin='.$begin.'&amp;view='.$_GET["view"].'&amp;userid='.$_GET["userid"], $sortfield, $sortorder,'',$num); if ($num > $limit) print_barre_liste($titre ,$page, "index.php", '&amp;begin='.$begin.'&amp;view='.$_GET["view"].'&amp;userid='.$_GET["userid"], $sortfield, $sortorder,'',$num);
print "</table>"; print "</table>";

View File

@ -142,7 +142,8 @@ if ($modulepart)
{ {
$accessallowed=1; $accessallowed=1;
} }
$original_file=$conf->compta->dir_output.'/'.$original_file; if ($user->societe_id > 0) $original_file=DOL_DATA_ROOT.'/private/'.$user->id.'/compta/'.$original_file;
else $original_file=$conf->compta->dir_output.'/'.$original_file;
} }
// Wrapping pour les exports de compta // Wrapping pour les exports de compta

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,7 +19,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
@ -43,6 +43,8 @@ class pdf_paiement
*/ */
function pdf_paiement($db=0) function pdf_paiement($db=0)
{ {
global $langs;
$this->db = $db; $this->db = $db;
$this->description = "Liste des paiements"; $this->description = "Liste des paiements";
@ -52,10 +54,10 @@ class pdf_paiement
$this->line_height = 5; $this->line_height = 5;
$this->line_per_page = 25; $this->line_per_page = 25;
$this->tab_height = 230;//$this->line_height * $this->line_per_page; $this->tab_height = 230; //$this->line_height * $this->line_per_page;
} }
function print_link() function print_link()
{ {
if (file_exists($this->file)) if (file_exists($this->file))
@ -68,13 +70,13 @@ class pdf_paiement
} }
} }
function Header(&$pdf, $page, $pages) function Header(&$pdf, $page, $pages)
{ {
$pdf->SetFont('Arial','B',12); global $langs;
$pdf->Text(10, 10, FAC_PDF_INTITULE);
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$pdf->Text(90, 10, "Liste des paiements encaissés"); $pdf->Text(90, 10, $langs->trans("PaimentsList"));
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$pdf->Text(11, 16, "Date : " . strftime("%d %b %Y", time())); $pdf->Text(11, 16, "Date : " . strftime("%d %b %Y", time()));
@ -175,37 +177,27 @@ class pdf_paiement
*/ */
function write_pdf_file($_dir, $month, $year) function write_pdf_file($_dir, $month, $year)
{ {
if (! file_exists($_dir)) global $langs;
$dir=$_dir.'/'.$year;
if (! is_dir($dir))
{ {
umask(0); $result=create_exdir($dir);
if (! mkdir($_dir, 0755)) if ($result < 0)
{ {
print "Impossible de créer $_dir !"; $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
die; return;
}
}
$_dir = $_dir . '/' . $year . '/';
if (! file_exists($_dir))
{
umask(0);
if (! mkdir($_dir, 0755))
{
print "Impossible de créer $_dir !";
die;
} }
} }
$month = substr("0".$month, strlen("0".$month)-2,2); $month = substr("0".$month, strlen("0".$month)-2,2);
$_file = $_dir . "paiements-$month-$year" . ".pdf"; $_file = $dir . "/paiements-$month-$year" . ".pdf";
$pdf = new FPDF('P','mm','A4'); $pdf = new FPDF('P','mm','A4');
$pdf->Open(); $pdf->Open();
/*
*
*/
$sql = "SELECT ".$this->db->pdate("p.datep")." as dp, f.facnumber"; $sql = "SELECT ".$this->db->pdate("p.datep")." as dp, f.facnumber";
$sql .= ", c.libelle as paiement_type, p.num_paiement"; $sql .= ", c.libelle as paiement_type, p.num_paiement";
$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount "; $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount ";
@ -225,7 +217,7 @@ class pdf_paiement
if ($result) if ($result)
{ {
$lignes = $this->db->num_rows(); $lignes = $this->db->num_rows($result);
$i = 0; $i = 0;
$var=True; $var=True;