diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php
index 6a54412c161..0001ea1a5a6 100644
--- a/htdocs/comm/action/rapport/index.php
+++ b/htdocs/comm/action/rapport/index.php
@@ -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 '
';
@@ -97,34 +103,36 @@ if ($resql)
$var=true;
while ($i < min($num,$limit))
{
- $obj = $db->fetch_object($resql);
-
- $var=!$var;
-
- print "";
-
- print "| $obj->df | \n";
- print ''.$obj->cc.' | ';
-
- print ''.img_file_new().' | ';
-
- $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 ''.img_pdf().' | ';
- print ''.strftime("%d %b %Y %H:%M:%S",filemtime($file)).' | ';
- print ''.filesize($file). ' '.$langs->trans("Bytes").' | ';
+ $var=!$var;
+ print "
";
+
+ print "| $obj->df | \n";
+ print ''.$obj->cc.' | ';
+
+ print ''.img_file_new().' | ';
+
+ $name = "rapport-action-".$obj->month."-".$obj->year.".pdf";
+ $relativepath= $name;
+ $file = $conf->commercial->dir_output . "/actions/" .$name;
+
+ if (file_exists($file))
+ {
+ print ''.img_pdf().' | ';
+ print ''.strftime("%d %b %Y %H:%M:%S",filemtime($file)).' | ';
+ print ''.filesize($file). ' '.$langs->trans("Bytes").' | ';
+ }
+ else {
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ }
+
+ print "
\n";
}
- else {
- print ' | ';
- print ' | ';
- print ' | ';
- }
-
- print "\n";
$i++;
}
print "
";
diff --git a/htdocs/comm/action/rapport/rapport.pdf.php b/htdocs/comm/action/rapport/rapport.pdf.php
index 1eb4c4bf932..42a3abfa950 100644
--- a/htdocs/comm/action/rapport/rapport.pdf.php
+++ b/htdocs/comm/action/rapport/rapport.pdf.php
@@ -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";
diff --git a/htdocs/document.php b/htdocs/document.php
index b6a9e21bf71..4935b2aaf85 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -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;
}
diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php
index c63dd9910a0..fabd350f39f 100644
--- a/htdocs/viewimage.php
+++ b/htdocs/viewimage.php
@@ -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)