Fix: impossible de tlcharger rapport actions

Fix: Page suivante-prcdente actions
This commit is contained in:
Laurent Destailleur 2006-05-14 02:51:11 +00:00
parent 6641850aef
commit 17b6a4c588
4 changed files with 94 additions and 51 deletions

View File

@ -25,7 +25,7 @@
/**
\file htdocs/comm/action/rapport/index.php
\ingroup commercial
\brief Page accueil des rapports des actions commerciales
\brief Page accueil des rapports des actions
\version $Revision$
*/
@ -33,6 +33,9 @@ require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
$page = $_GET["page"];
$sortfield=$_GET["sortfield"];
$sortorder=$_GET["sortorder"];
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
@ -42,47 +45,50 @@ if (! $sortfield) $sortfield="a.datea";
// Sécurité accés client
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
$action = '';
$socid = $user->societe_id;
}
if ($_GET["action"] == 'pdf')
{
$cat = new CommActionRapport($db, $_GET["month"], $_GET["year"]);
$cat->generate($_GET["id"]);
}
/*
* Actions
*/
if ($_GET["action"] == 'builddoc')
{
$cat = new CommActionRapport($db, $_GET["month"], $_GET["year"]);
$cat->generate($_GET["id"]);
}
if ($action=='delete_action')
{
$actioncomm = new ActionComm($db);
$actioncomm->delete($actionid);
$actioncomm = new ActionComm($db);
$actioncomm->delete($actionid);
}
llxHeader();
/*
* Liste
* Affichage liste
*/
llxHeader();
$sql = "SELECT count(*) as cc, date_format(a.datea, '%m/%Y') as df";
$sql.= ", date_format(a.datea, '%m') as month";
$sql.= ", date_format(a.datea, '%Y') as year";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " WHERE percent = 100";
$sql.= " GROUP BY date_format(a.datea, '%m/%Y') ";
$sql.= " ORDER BY a.datea DESC";
$sql.= $db->plimit($limit+1,$offset);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
print_barre_liste($langs->trans("DoneAndToDoActions"), $page, "index.php",'',$sortfield,$sortorder,'',$num);
print_barre_liste($langs->trans("DoneActions"), $page, "index.php",'',$sortfield,$sortorder,'',$num);
$i = 0;
print '<table class="noborder" width="100%">';
@ -97,34 +103,36 @@ if ($resql)
$var=true;
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print "<td>$obj->df</td>\n";
print '<td align="center">'.$obj->cc.'</td>';
print '<td><a href="index.php?action=pdf&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_file_new().'</a></td>';
$name = "rapport-action-".$obj->month."-".$obj->year.".pdf";
$relativepath="comm/actions/" .$name;
$file = $conf->commercial->dir_output . "/comm/actions/" .$name;
if (file_exists($file))
$obj=$db->fetch_object($resql);
if ($obj)
{
print '<td align="center"><a href="'.DOL_URL_ROOT.'/document.php?file='.urlencode($relativepath).'&modulepart=actionscomm">'.img_pdf().'</a></td>';
print '<td align="center">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '<td align="center">'.filesize($file). ' '.$langs->trans("Bytes").'</td>';
$var=!$var;
print "<tr $bc[$var]>";
print "<td>$obj->df</td>\n";
print '<td align="center">'.$obj->cc.'</td>';
print '<td><a href="index.php?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_file_new().'</a></td>';
$name = "rapport-action-".$obj->month."-".$obj->year.".pdf";
$relativepath= $name;
$file = $conf->commercial->dir_output . "/actions/" .$name;
if (file_exists($file))
{
print '<td align="center"><a href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a></td>';
print '<td align="center">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '<td align="center">'.filesize($file). ' '.$langs->trans("Bytes").'</td>';
}
else {
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
}
print "</tr>\n";
}
else {
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
}
print "</tr>\n";
$i++;
}
print "</table>";

View File

@ -40,6 +40,12 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/fpdf/fpdf_html.php");
class CommActionRapport
{
var $db;
var $description;
var $date_edition;
var $year;
var $month;
var $title;
var $subject;
@ -50,7 +56,7 @@ class CommActionRapport
$this->db = $db;
$this->description = "";
$this->date_edition = dolibarr_print_date(time(),"%d %B %Y");
$this->date_edition = time();
$this->month = $month;
$this->year = $year;
@ -62,9 +68,17 @@ class CommActionRapport
{
global $user,$conf,$langs;
$dir = $conf->commercial->dir_output."/comm/actions";
$dir = $conf->commercial->dir_output."/actions";
$file = $dir . "/rapport-action-".$this->month."-".$this->year.".pdf";
create_exdir($dir);
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (file_exists($dir))
{
@ -78,8 +92,6 @@ class CommActionRapport
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9);
// $nbpage = $this->_cover($pdf);
$nbpage = $this->_pages($pdf);
@ -106,7 +118,7 @@ class CommActionRapport
$pdf->SetFont('Arial','',30);
$pdf->SetXY (10, 140);
$pdf->MultiCell(190, 20, $langs->trans("Date").': '.$this->date_edition, 0, 'C', 0);
$pdf->MultiCell(190, 20, $langs->trans("Date").': '.dolibarr_print_date($this->date_edition,"%d %B %Y"), 0, 'C', 0);
$pdf->SetXY (10, 170);
$pdf->SetFont('Arial','B',18);
@ -134,7 +146,7 @@ class CommActionRapport
$pdf->SetXY(5, $pdf->GetY());
$pdf->MultiCell(80, 2, $this->title, 0, 'L', 0);
$pdf->SetFont('Arial','',9);
$pdf->SetFont('Arial','',8);
$y=$pdf->GetY()+1;
$sql = "SELECT s.nom as societe, s.idp as socidp, s.client, a.id,".$this->db->pdate("a.datea")." as da, a.datea, c.libelle, u.code, a.fk_contact, a.note, a.percent as percent";

View File

@ -191,13 +191,24 @@ if ($modulepart)
if ($modulepart == 'actions')
{
$user->getrights('commercial');
//if ($user->rights->commercial->lire) // Ce droit n'existe pas encore
//if ($user->rights->commercial->actions->lire) // Ce droit n'existe pas encore
//{
$accessallowed=1;
//}
$original_file=$conf->actionscomm->dir_output.'/'.$original_file;
}
// Wrapping pour les actions
if ($modulepart == 'actionsreport')
{
$user->getrights('commercial');
//if ($user->rights->commercial->actions->lire) // Ce droit n'existe pas encore
//{
$accessallowed=1;
//}
$original_file = $conf->commercial->dir_output."/actions/".$original_file;
}
// Wrapping pour les produits et services
if ($modulepart == 'produit')
{
@ -246,7 +257,7 @@ dolibarr_syslog("document.php download $original_file $filename content-type=$ty
if (! file_exists($original_file))
{
dolibarr_print_error(0,$langs->trans("FileDoesNotExist",$original_file));
dolibarr_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
exit;
}

View File

@ -201,11 +201,23 @@ if ($modulepart)
}
// Limite accès si droits non corrects
if (! $accessallowed) { accessforbidden(); }
if (! $accessallowed)
{
accessforbidden();
}
// Ouvre et renvoi fichier
clearstatcache();
$filename = basename($original_file);
if (! file_exists($original_file)) { dolibarr_print_error(0,$langs->trans("FileDoesNotExist",$original_file)); exit; }
dolibarr_syslog("viewimage.php download $original_file $filename content-type=$type");
if (! file_exists($original_file))
{
dolibarr_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
exit;
}
// Les drois sont ok et fichier trouvé
if ($type)