nouveau fichier
This commit is contained in:
parent
0aa6deab5c
commit
6136a642bc
199
htdocs/comm/action/rapport/index.php
Normal file
199
htdocs/comm/action/rapport/index.php
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
* Copyright (C) 2003 Éric Seigne <erics@rycks.com>
|
||||||
|
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* 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$
|
||||||
|
* $Source$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
require("./pre.inc.php");
|
||||||
|
|
||||||
|
require("../../../contact.class.php");
|
||||||
|
require("../../../cactioncomm.class.php");
|
||||||
|
require("../../../actioncomm.class.php");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sécurité accés client
|
||||||
|
*/
|
||||||
|
if ($user->societe_id > 0)
|
||||||
|
{
|
||||||
|
$action = '';
|
||||||
|
$socid = $user->societe_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET["action"] == 'pdf')
|
||||||
|
{
|
||||||
|
$cat = new CommActionRapport($db, $_GET["month"], $_GET["year"]);
|
||||||
|
$cat->generate($_GET["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($action=='delete_action')
|
||||||
|
{
|
||||||
|
$actioncomm = new ActionComm($db);
|
||||||
|
$actioncomm->delete($actionid);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($action=='add_action')
|
||||||
|
{
|
||||||
|
$contact = new Contact($db);
|
||||||
|
$contact->fetch($contactid);
|
||||||
|
|
||||||
|
$actioncomm = new ActionComm($db);
|
||||||
|
|
||||||
|
if ($actionid == 5)
|
||||||
|
{
|
||||||
|
$actioncomm->date = $db->idate(mktime($heurehour,$heuremin,0,$remonth,$reday,$reyear));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$actioncomm->date = $date;
|
||||||
|
}
|
||||||
|
$actioncomm->type = $actionid;
|
||||||
|
$actioncomm->contact = $contactid;
|
||||||
|
|
||||||
|
$actioncomm->societe = $socid;
|
||||||
|
$actioncomm->note = $note;
|
||||||
|
|
||||||
|
$actioncomm->add($user);
|
||||||
|
|
||||||
|
$societe = new Societe($db);
|
||||||
|
$societe->fetch($socid);
|
||||||
|
|
||||||
|
|
||||||
|
$todo = new TodoComm($db);
|
||||||
|
$todo->date = mktime(12,0,0,$remonth, $reday, $reyear);
|
||||||
|
|
||||||
|
$todo->libelle = $todo_label;
|
||||||
|
|
||||||
|
$todo->societe = $societe->id;
|
||||||
|
$todo->contact = $contactid;
|
||||||
|
|
||||||
|
$todo->note = $todo_note;
|
||||||
|
|
||||||
|
$todo->add($user);
|
||||||
|
|
||||||
|
$webcal = new Webcal();
|
||||||
|
|
||||||
|
$webcal->heure = $heurehour . $heuremin . '00';
|
||||||
|
$webcal->duree = ($dureehour * 60) + $dureemin;
|
||||||
|
|
||||||
|
if ($actionid == 5) {
|
||||||
|
$libelle = "Rendez-vous avec ".$contact->fullname;
|
||||||
|
$libelle .= "\n" . $todo->libelle;
|
||||||
|
} else {
|
||||||
|
$libelle = $todo->libelle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$webcal->add($user, $todo->date, $societe->nom, $libelle);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Liste
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($page == -1) { $page = 0 ; }
|
||||||
|
$limit = $conf->liste_limit;
|
||||||
|
$offset = $limit * $page ;
|
||||||
|
if ($sortorder == "")
|
||||||
|
{
|
||||||
|
$sortorder="DESC";
|
||||||
|
}
|
||||||
|
if ($sortfield == "")
|
||||||
|
{
|
||||||
|
$sortfield="a.datea";
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 .= " GROUP BY date_format(a.datea, '%m/%Y') ";
|
||||||
|
$sql .= " ORDER BY date_format(a.datea, '%Y %m') DESC";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( $db->query($sql) )
|
||||||
|
{
|
||||||
|
$num = $db->num_rows();
|
||||||
|
|
||||||
|
print_barre_liste("Liste des actions commerciales réalisées ou à faire", $page, $PHP_SELF,'',$sortfield,$sortorder,'',$num);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>Date</td>';
|
||||||
|
print '<td align="center">Nombre</td>';
|
||||||
|
print '<td>Action</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
$var=True;
|
||||||
|
while ($i < min($num,$limit))
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object( $i);
|
||||||
|
|
||||||
|
$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&month='.$obj->month.'&year='.$obj->year.'">'.img_file_new().'</a></td>';
|
||||||
|
|
||||||
|
$root = DOL_DOCUMENT_ROOT;
|
||||||
|
$dir = "/document/rapport/comm/actions/";
|
||||||
|
$name = "rapport-action-".$obj->month."-".$obj->year.".pdf";
|
||||||
|
$file = $root . $dir . $name;
|
||||||
|
$url = $dir . $name;
|
||||||
|
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
print '<td ><a href="'.DOL_URL_ROOT.$url.'">'.img_pdf().'</a></td>';
|
||||||
|
print '<td>'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
|
||||||
|
print '<td>'.filesize($file). ' bytes</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</tr>\n";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
print "</table>";
|
||||||
|
$db->free();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $db->error() . ' ' . $sql ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||||
|
?>
|
||||||
50
htdocs/comm/action/rapport/pre.inc.php
Normal file
50
htdocs/comm/action/rapport/pre.inc.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* 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$
|
||||||
|
* $Source$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
require("../../../main.inc.php");
|
||||||
|
require("./rapport.pdf.php");
|
||||||
|
|
||||||
|
function llxHeader($head = "", $urlp = "") {
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
top_menu($head);
|
||||||
|
|
||||||
|
$menu = new Menu();
|
||||||
|
|
||||||
|
$menu->add(DOL_URL_ROOT."/comm/action/", "Actions");
|
||||||
|
|
||||||
|
$menu->add_submenu(DOL_URL_ROOT."/comm/action/?time=today", "Aujourd'hui");
|
||||||
|
|
||||||
|
$menu->add(DOL_URL_ROOT."/comm/clients.php", "Clients");
|
||||||
|
|
||||||
|
$menu->add_submenu(DOL_URL_ROOT."/comm/contact.php", "Contacts");
|
||||||
|
|
||||||
|
$menu->add(DOL_URL_ROOT."/comm/propal.php", "Propales");
|
||||||
|
|
||||||
|
$menu->add(DOL_URL_ROOT."/projet/index.php", "Projets");
|
||||||
|
|
||||||
|
left_menu($menu->liste);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
174
htdocs/comm/action/rapport/rapport.pdf.php
Normal file
174
htdocs/comm/action/rapport/rapport.pdf.php
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* or see http://www.gnu.org/
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* $Source$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
require (DOL_DOCUMENT_ROOT ."/includes/fpdf/fpdf_indexes.php");
|
||||||
|
require (DOL_DOCUMENT_ROOT ."/includes/fpdf/fpdf_html.php");
|
||||||
|
|
||||||
|
Class CommActionRapport {
|
||||||
|
|
||||||
|
Function CommActionRapport($db=0, $month, $year)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
$this->description = "";
|
||||||
|
$this->date_edition = strftime("%d %B %Y", time());
|
||||||
|
$this->month = $month;
|
||||||
|
$this->year = $year;
|
||||||
|
}
|
||||||
|
|
||||||
|
Function generate($socid = 0, $catid = 0)
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$dir = DOL_DOCUMENT_ROOT . "/document/rapport/";
|
||||||
|
|
||||||
|
if (! file_exists($dir))
|
||||||
|
{
|
||||||
|
umask(0);
|
||||||
|
if (! mkdir($dir, 0755))
|
||||||
|
{
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = DOL_DOCUMENT_ROOT . "/document/rapport/comm/";
|
||||||
|
|
||||||
|
if (! file_exists($dir))
|
||||||
|
{
|
||||||
|
umask(0);
|
||||||
|
if (! mkdir($dir, 0755))
|
||||||
|
{
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = DOL_DOCUMENT_ROOT . "/document/rapport/comm/actions/";
|
||||||
|
|
||||||
|
if (! file_exists($dir))
|
||||||
|
{
|
||||||
|
umask(0);
|
||||||
|
if (! mkdir($dir, 0755))
|
||||||
|
{
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $dir . "rapport-action-".$this->month."-".$this->year.".pdf";
|
||||||
|
|
||||||
|
if (file_exists($dir))
|
||||||
|
{
|
||||||
|
$pdf=new PDF_html('P','mm','A4');
|
||||||
|
$pdf->Open();
|
||||||
|
|
||||||
|
$pdf->SetTitle("Rapport Commercial");
|
||||||
|
$pdf->SetSubject("Rapport Commercial");
|
||||||
|
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||||
|
$pdf->SetAuthor("Rodolphe Quiedeville");
|
||||||
|
|
||||||
|
$pdf->SetFillColor(220,220,220);
|
||||||
|
|
||||||
|
$pdf->SetFont('Arial','', 9);
|
||||||
|
|
||||||
|
// $nbpage = $this->_cover($pdf);
|
||||||
|
$nbpage = $this->_pages($pdf);
|
||||||
|
|
||||||
|
$pdf->Close();
|
||||||
|
|
||||||
|
$pdf->Output($file);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function _cover(&$pdf)
|
||||||
|
{
|
||||||
|
$pdf->AddPage();
|
||||||
|
$pdf->SetAutoPageBreak(false);
|
||||||
|
$pdf->SetFont('Arial','',40);
|
||||||
|
$pdf->SetXY (10, 80);
|
||||||
|
$pdf->MultiCell(190, 20, "Rapport Commercial", 0, 'C', 0);
|
||||||
|
|
||||||
|
$pdf->SetFont('Arial','',30);
|
||||||
|
$pdf->SetXY (10, 140);
|
||||||
|
$pdf->MultiCell(190, 20, "Edition du ".$this->date_edition, 0, 'C', 0);
|
||||||
|
|
||||||
|
|
||||||
|
$pdf->SetXY (10, 170);
|
||||||
|
$pdf->SetFont('Arial','B',18);
|
||||||
|
$pdf->MultiCell(190, 15, "Rodolphe Quiédeville <rq@lolix.org>", 0, 'C');
|
||||||
|
$pdf->SetFont('Arial','B',16);
|
||||||
|
$pdf->MultiCell(190, 15, "Tél : +33 (0) 6 13 79 63 41", 0, 'C');
|
||||||
|
|
||||||
|
$pdf->SetFont('Arial','',10);
|
||||||
|
$pdf->SetXY (10, 277);
|
||||||
|
$pdf->MultiCell(190, 10, "http://www.lafrere.com/", 1, 'C', 1);
|
||||||
|
|
||||||
|
$pdf->Rect(10, 10, 190, 277);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function _pages(&$pdf)
|
||||||
|
{
|
||||||
|
$pdf->AddPage();
|
||||||
|
$pdf->SetAutoPageBreak(true);
|
||||||
|
|
||||||
|
$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";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
|
||||||
|
$sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid";
|
||||||
|
|
||||||
|
$sql .= " AND date_format(a.datea, '%m') = ".$this->month;
|
||||||
|
$sql .= " AND date_format(a.datea, '%Y') = ".$this->year;
|
||||||
|
|
||||||
|
$sql .= " ORDER BY a.datea DESC";
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($i);
|
||||||
|
$y = $pdf->GetY();
|
||||||
|
$pdf->SetFont('Arial','',11);
|
||||||
|
$pdf->SetXY(10, $y);
|
||||||
|
$pdf->MultiCell(40, 8, $obj->societe, 0, 'L', 0);
|
||||||
|
$pdf->SetXY(50,$y);
|
||||||
|
$pdf->MultiCell(40, 8, $obj->libelle, 0, 'L', 0);
|
||||||
|
$pdf->SetXY(90,$y);
|
||||||
|
$pdf->MultiCell(110, 8, $obj->note, 0, 'L', 0);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf->Rect(10, 10, 190, 277);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user