[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * or see http://www.gnu.org/ 19 * 20 * $Id: rapport.pdf.php,v 1.12 2005/09/17 02:31:19 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/action/rapport/rapport.pdf.php,v $ 22 */ 23 24 /** 25 \file htdocs/comm/action/rapport/rapport.pdf.php 26 \ingroup commercial 27 \brief Fichier de generation de PDF pour les rapports d'actions 28 \version $Revision: 1.12 $ 29 */ 30 31 require_once(FPDF_PATH.'fpdf.php'); 32 require_once(DOL_DOCUMENT_ROOT ."/includes/fpdf/fpdf_indexes.php"); 33 require_once(DOL_DOCUMENT_ROOT ."/includes/fpdf/fpdf_html.php"); 34 35 36 /** 37 \class CommActionRapport 38 \brief Classe permettant la generation des rapports d'actions 39 */ 40 41 class CommActionRapport 42 { 43 var $title; 44 var $subject; 45 46 function CommActionRapport($db=0, $month, $year) 47 { 48 global $langs; 49 $langs->load("commercial"); 50 51 $this->db = $db; 52 $this->description = ""; 53 $this->date_edition = dolibarr_print_date(time(),"%d %B %Y"); 54 $this->month = $month; 55 $this->year = $year; 56 57 $this->title=$langs->trans("ActionsReport").' '.$this->year."-".$this->month; 58 $this->subject=$langs->trans("ActionsReport").' '.$this->year."-".$this->month; 59 } 60 61 function generate($socid = 0, $catid = 0) 62 { 63 global $user,$conf,$langs; 64 65 $dir = $conf->commercial->dir_output."/comm/actions"; 66 $file = $dir . "/rapport-action-".$this->month."-".$this->year.".pdf"; 67 create_exdir($dir); 68 69 if (file_exists($dir)) 70 { 71 $pdf=new PDF_html('P','mm','A4'); 72 $pdf->Open(); 73 74 $pdf->SetTitle($this->title); 75 $pdf->SetSubject($this->subject); 76 $pdf->SetCreator("Dolibarr ".DOL_VERSION); 77 $pdf->SetAuthor($user->fullname); 78 79 $pdf->SetFillColor(220,220,220); 80 81 $pdf->SetFont('Arial','', 9); 82 83 // $nbpage = $this->_cover($pdf); 84 $nbpage = $this->_pages($pdf); 85 86 $pdf->Close(); 87 88 $pdf->Output($file); 89 90 return 1; 91 } 92 } 93 94 /* 95 * 96 */ 97 function _cover(&$pdf) 98 { 99 global $user; 100 101 $pdf->AddPage(); 102 $pdf->SetAutoPageBreak(false); 103 $pdf->SetFont('Arial','',40); 104 $pdf->SetXY (10, 80); 105 $pdf->MultiCell(190, 20, $langs->trans("ActionsReport").' '.$title, 0, 'C', 0); 106 107 $pdf->SetFont('Arial','',30); 108 $pdf->SetXY (10, 140); 109 $pdf->MultiCell(190, 20, $langs->trans("Date").': '.$this->date_edition, 0, 'C', 0); 110 111 $pdf->SetXY (10, 170); 112 $pdf->SetFont('Arial','B',18); 113 $pdf->MultiCell(190, 15, $user->fullname, 0, 'C'); 114 $pdf->SetFont('Arial','B',16); 115 $pdf->MultiCell(190, 15, "Tél : +33 (0) 6 13 79 63 41", 0, 'C'); 116 117 $pdf->SetFont('Arial','',10); 118 $pdf->SetXY (10, 277); 119 $pdf->MultiCell(190, 10, "http://www.lafrere.com/", 1, 'C', 1); 120 121 $pdf->Rect(10, 10, 190, 277); 122 return 1; 123 } 124 125 /* 126 * 127 */ 128 function _pages(&$pdf) 129 { 130 $pdf->AddPage(); 131 $pdf->SetAutoPageBreak(true); 132 133 $pdf->SetFont('Arial','B',10); 134 $pdf->SetXY(5, $pdf->GetY()); 135 $pdf->MultiCell(80, 2, $this->title, 0, 'L', 0); 136 137 $pdf->SetFont('Arial','',9); 138 $y=$pdf->GetY()+1; 139 140 $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"; 141 $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"; 142 $sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid"; 143 144 $sql .= " AND date_format(a.datea, '%m') = ".$this->month; 145 $sql .= " AND date_format(a.datea, '%Y') = ".$this->year; 146 147 $sql .= " ORDER BY a.datea DESC"; 148 149 if ($this->db->query($sql)) 150 { 151 $num = $this->db->num_rows(); 152 $i = 0; 153 $y0=$y1=$y2=$y3=0; 154 155 while ($i < $num) 156 { 157 $obj = $this->db->fetch_object(); 158 159 $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3) + 1; 160 161 $pdf->SetXY(5, $y); 162 $pdf->MultiCell(22, 4, dolibarr_print_date($obj->da)."\n".dolibarr_print_date($obj->da,"%H:%m:%S"), 0, 'L', 0); 163 $y0 = $pdf->GetY(); 164 165 $pdf->SetXY(26, $y); 166 $pdf->MultiCell(40, 4, $obj->societe, 0, 'L', 0); 167 $y1 = $pdf->GetY(); 168 169 $pdf->SetXY(66,$y); 170 $pdf->MultiCell(40, 4, $obj->libelle, 0, 'L', 0); 171 $y2 = $pdf->GetY(); 172 173 $pdf->SetXY(106,$y); 174 $pdf->MultiCell(94, 4, eregi_replace('<br>',"\n",dolibarr_trunc($obj->note,150)), 0, 'L', 0); 175 $y3 = $pdf->GetY(); 176 177 $i++; 178 } 179 } 180 181 $pdf->Rect(5, 5, 200, 287); 182 return 1; 183 } 184 185 186 } 187 188 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |