/[dolibarr]/dolibarr/htdocs/telephonie/pdf/pdfdetail_nodet.modules.php
ViewVC logotype

Diff of /dolibarr/htdocs/telephonie/pdf/pdfdetail_nodet.modules.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by rodolphe, Mon Apr 25 09:15:58 2005 UTC revision 1.5 by rodolphe, Thu Nov 24 12:45:53 2005 UTC
# Line 44  class pdfdetail_nodet { Line 44  class pdfdetail_nodet {
44     *     *
45     *     *
46     */     */
   
47    function write_pdf_file($factel, $ligne)    function write_pdf_file($factel, $ligne)
48      {    {
49        $xpdf = 0;
50        $this->_write_pdf_file($factel, $ligne, $xpdf, 0);
51      }
52    
53      function _write_pdf_file($factel, $ligne, &$pdf, $output)
54        {
55        $fac = new Facture($this->db,"",$factel->fk_facture);        $fac = new Facture($this->db,"",$factel->fk_facture);
56        $fac->fetch($factel->fk_facture);          $fac->fetch($factel->fk_facture);  
57        $fac->fetch_client();        $fac->fetch_client();
# Line 58  class pdfdetail_nodet { Line 62  class pdfdetail_nodet {
62    
63        if (defined("FAC_OUTPUTDIR"))        if (defined("FAC_OUTPUTDIR"))
64          {          {
65            $dir = FAC_OUTPUTDIR . "/" . $fac->ref . "/" ;            $dir  = FAC_OUTPUTDIR . "/" . $fac->ref . "/" ;
   
66            $file = $dir . $fac->ref . "-$ligne-detail.pdf";            $file = $dir . $fac->ref . "-$ligne-detail.pdf";
67    
68            if (strlen($objlignetel->code_analytique) > 0)            if (strlen($objlignetel->code_analytique) > 0)
# Line 77  class pdfdetail_nodet { Line 80  class pdfdetail_nodet {
80                  }                  }
81              }              }
82    
83            if (file_exists($dir))            if (file_exists($dir) OR $output)
84              {              {
85                  if ($output == 0)
86                    {
87                      $pdf = new pdfdetail_standard_modeles('P','mm','A4');
88                    }
89    
90                $this->pdf = new pdfdetail_standard_modeles('P','mm','A4');                $pdf->fac = $fac;
   
               $this->pdf->fac = $fac;  
91    
92                $this->pdf->factel = $this->factel;                $pdf->factel = $this->factel;
93    
94                $this->pdf->client_nom     = $fac->client->nom;                $pdf->client_nom     = $fac->client->nom;
95                $this->pdf->client_adresse = $fac->client->adresse;                $pdf->client_adresse = $fac->client->adresse;
96                $this->pdf->client_cp      = $fac->client->cp;                $pdf->client_cp      = $fac->client->cp;
97                $this->pdf->client_ville   = $fac->client->ville;                $pdf->client_ville   = $fac->client->ville;
98    
99                $this->pdf->ligne = $ligne;                $pdf->ligne = $ligne;
100    
101                $this->pdf->year  = $this->year;                $pdf->year  = $this->year;
102                $this->pdf->month = $this->month;                $pdf->month = $this->month;
103    
104                $this->pdf->ligne_ville = '';                $pdf->ligne_ville = '';
105                if ($objlignetel->code_analytique)                if ($objlignetel->code_analytique)
106                  {                  {
107                    $soca = new Societe($this->db);                    $soca = new Societe($this->db);
108                    $soca->fetch($objlignetel->client_id);                    $soca->fetch($objlignetel->client_id);
109    
110                    $this->pdf->ligne = $ligne . " (".$objlignetel->code_analytique.")";                    $pdf->ligne = $ligne . " (".$objlignetel->code_analytique.")";
111                    $this->pdf->ligne_ville = $soca->ville;                    $pdf->ligne_ville = $soca->ville;
112                  }                  }
113    
114                $this->pdf->AliasNbPages();                $pdf->AliasNbPages();
115                $this->pdf->Open();                if ($output == 0)
116                    {
117                $this->pdf->SetTitle($fac->ref);                    $pdf->Open();
               $this->pdf->SetSubject("Facture détaillée");  
               $this->pdf->SetCreator("Dolibarr");  
               $this->pdf->SetAuthor("");  
   
               $this->pdf->SetMargins(10, 10, 10);  
   
               $this->pdf->SetAutoPageBreak(1, 24);  
118    
119                $this->pdf->SetLineWidth(0.1);                    $pdf->SetTitle($fac->ref);
120                      $pdf->SetSubject("Facture détaillée");
121                      $pdf->SetCreator("Dolibarr");
122                      $pdf->SetAuthor("");
123                      
124                      $pdf->SetMargins(10, 10, 10);
125                    }
126                  $pdf->SetAutoPageBreak(1, 24);
127                  $pdf->SetLineWidth(0.1);
128    
129                $this->pdf->tab_top = 53;                $pdf->tab_top = 53;
130                $this->pdf->tab_height = 222;                $pdf->tab_height = 222;
131    
132                /*                /*
133                 *                 *
                *  
134                 */                 */
135                  $pdf->FirstPage = 1;
136                  $pdf->AddPage();
137                  $this->Header($pdf);
138    
139                $this->pdf->FirstPage = 1;                $pdf->SetFillColor(230,230,230);
               $this->pdf->AddPage();  
   
               $this->pdf->SetFillColor(230,230,230);  
   
140                /*                /*
141                 * Détails des comm                 * Détails des comm
142                 *                 *
143                 */                 */
144    
145                $this->pdf->SetFont('Arial','', 12);                $pdf->SetFont('Arial','', 12);
146                                        
147                $Y = $this->pdf->tab_top + 4;                $Y = $pdf->tab_top + 4;
148                $this->pdf->SetXY(10, $Y);                $pdf->SetXY(10, $Y);
149                $this->pdf->MultiCell(100, 4, "Détails de vos communications", 0,'L',0);                $pdf->MultiCell(100, 4, "Détails de vos communications", 0,'L',0);
150    
151                $this->pdf->SetFont('Arial','', 9);                $pdf->SetFont('Arial','', 9);
152    
153                $Y = $this->pdf->GetY();                $Y = $pdf->GetY();
154    
155                $this->pdf->SetXY(140, $Y);                $pdf->SetXY(140, $Y);
156                $this->pdf->MultiCell(20, 4, "Durée", 0,'R',0);                $pdf->MultiCell(20, 4, "Durée", 0,'R',0);
157    
158                $this->pdf->SetXY(160, $Y);                $pdf->SetXY(160, $Y);
159                $this->pdf->MultiCell(20, 4, "Nb appels", 0,'R',0);                $pdf->MultiCell(20, 4, "Nb appels", 0,'R',0);
160    
161                $this->pdf->SetXY(180, $Y);                $pdf->SetXY(180, $Y);
162                $this->pdf->MultiCell(20, 4, "Coût", 0,'R',0);                $pdf->MultiCell(20, 4, "Coût", 0,'R',0);
163    
164                $sql = "SELECT count(*) as cc, sum(t.cout_vente) as cout_vente, sum(t.duree) as duree, t.dest";                $sql = "SELECT count(*) as cc, sum(t.cout_vente) as cout_vente, sum(t.duree) as duree, t.dest";
165                $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as t ";                $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as t ";
# Line 175  class pdfdetail_nodet { Line 179  class pdfdetail_nodet {
179                    $num = $this->db->num_rows($resql);                    $num = $this->db->num_rows($resql);
180                    $i = 0;                    $i = 0;
181    
182                    $this->pdf->SetFont('Arial','', 9);                                $pdf->SetFont('Arial','', 9);          
183                    $var = 0;                    $var = 0;
184                    $line_height = 4;                    $line_height = 4;
185    
# Line 188  class pdfdetail_nodet { Line 192  class pdfdetail_nodet {
192                        $obj = $this->db->fetch_object($i);                        $obj = $this->db->fetch_object($i);
193                        $var=!$var;                        $var=!$var;
194                                    
195                        $Y = $this->pdf->GetY();                        $Y = $pdf->GetY();
196                
197                        $this->pdf->SetXY(10, $Y);                        $pdf->SetXY(10, $Y);
198                        $this->pdf->MultiCell(100, $line_height, $obj->dest, 0,'L',$var);                        $pdf->MultiCell(100, $line_height, $obj->dest, 0,'L',$var);
199    
200                        if ($Y > $this->pdf->GetY())                        if ($Y > $pdf->GetY())
201                          $Y = $this->pdf->GetY() - $line_height;                          $Y = $pdf->GetY() - $line_height;
202    
203    
204                        $h = floor($obj->duree / 3600);                        $h = floor($obj->duree / 3600);
# Line 217  class pdfdetail_nodet { Line 221  class pdfdetail_nodet {
221                              }                              }
222                          }                          }
223                                                
224                        $this->pdf->SetXY(110, $Y);                        $pdf->SetXY(110, $Y);
225                        $this->pdf->MultiCell(50, $line_height,$dt, 0,'R',$var);                        $pdf->MultiCell(50, $line_height,$dt, 0,'R',$var);
226                                                
227                        $this->pdf->SetXY(160, $Y);                        $pdf->SetXY(160, $Y);
228                        $this->pdf->MultiCell(20, $line_height,$obj->cc, 0,'R',$var);                        $pdf->MultiCell(20, $line_height,$obj->cc, 0,'R',$var);
229    
230                        $this->pdf->SetXY(180, $Y);                        $pdf->SetXY(180, $Y);
231                        $this->pdf->MultiCell(20, $line_height,sprintf("%01.3f",$obj->cout_vente), 0,'R',$var);                        $pdf->MultiCell(20, $line_height,sprintf("%01.3f",$obj->cout_vente), 0,'R',$var);
232    
233                        array_push($graph_values, $obj->cc);                        array_push($graph_values, $obj->cc);
234                        array_push($graph_values_duree, $obj->duree);                        array_push($graph_values_duree, $obj->duree);
# Line 265  class pdfdetail_nodet { Line 269  class pdfdetail_nodet {
269                                
270                $var=!$var;                $var=!$var;
271    
272                $this->pdf->SetXY(10, $Y + $line_height);                $pdf->SetXY(10, $Y + $line_height);
273                $this->pdf->MultiCell(100, $line_height,"Total : ", 0,'R',$var);                $pdf->MultiCell(100, $line_height,"Total : ", 0,'R',$var);
274    
275                $this->pdf->SetXY(110, $Y + $line_height);                $pdf->SetXY(110, $Y + $line_height);
276                $this->pdf->MultiCell(50, $line_height,$dt, 0,'R',$var);                $pdf->MultiCell(50, $line_height,$dt, 0,'R',$var);
277    
278                $this->pdf->SetXY(160, $Y + $line_height);                $pdf->SetXY(160, $Y + $line_height);
279                $this->pdf->MultiCell(20, $line_height,$total_nb, 0,'R',$var);                $pdf->MultiCell(20, $line_height,$total_nb, 0,'R',$var);
280                                
281                $this->pdf->SetXY(180, $Y + $line_height);                $pdf->SetXY(180, $Y + $line_height);
282                $this->pdf->MultiCell(20, $line_height,sprintf("%01.3f",$total_cout), 0,'R',$var);                $pdf->MultiCell(20, $line_height,sprintf("%01.3f",$total_cout), 0,'R',$var);
283    
284    
285                /*                /*
# Line 283  class pdfdetail_nodet { Line 287  class pdfdetail_nodet {
287                 *                 *
288                 */                 */
289    
290                $this->pdf->SetFont('Arial','', 12);                $pdf->SetFont('Arial','', 12);
291                                        
292                $Y = $this->pdf->GetY() + 10;                $Y = $pdf->GetY() + 10;
293                $this->pdf->SetXY(10, $Y);                $pdf->SetXY(10, $Y);
294                $this->pdf->MultiCell(100, 4, "TOP 10 des numéros appelés en coût", 0,'L',0);                $pdf->MultiCell(100, 4, "TOP 10 des numéros appelés en coût", 0,'L',0);
295    
296                $this->pdf->SetFont('Arial','', 9);                $pdf->SetFont('Arial','', 9);
297    
298                $Y = $this->pdf->GetY();                $Y = $pdf->GetY();
299                $this->pdf->SetXY(10, $Y);                $pdf->SetXY(10, $Y);
300                $this->pdf->MultiCell(150, 4, "Destination", 0,'L',0);                $pdf->MultiCell(150, 4, "Destination", 0,'L',0);
301    
302                $this->pdf->SetXY(140, $Y);                $pdf->SetXY(140, $Y);
303                $this->pdf->MultiCell(20, 4, "Durée", 0,'R',0);                $pdf->MultiCell(20, 4, "Durée", 0,'R',0);
304    
305                $this->pdf->SetXY(160, $Y);                $pdf->SetXY(160, $Y);
306                $this->pdf->MultiCell(20, 4, "Nb appels", 0,'R',0);                $pdf->MultiCell(20, 4, "Nb appels", 0,'R',0);
307    
308                $this->pdf->SetXY(180, $Y);                $pdf->SetXY(180, $Y);
309                $this->pdf->MultiCell(20, 4, "Coût", 0,'R',0);                $pdf->MultiCell(20, 4, "Coût", 0,'R',0);
310    
311                $sql = "SELECT count(*) as cc, sum(t.cout_vente) as cout_vente, sum(t.duree) as duree, t.numero, t.dest";                $sql = "SELECT count(*) as cc, sum(t.cout_vente) as cout_vente, sum(t.duree) as duree, t.numero, t.dest";
312                $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as t ";                $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as t ";
# Line 315  class pdfdetail_nodet { Line 319  class pdfdetail_nodet {
319                  {                  {
320                    $num = $this->db->num_rows();                    $num = $this->db->num_rows();
321    
322                    $this->pdf->SetFont('Arial','', 9);                    $pdf->SetFont('Arial','', 9);
323                                        
324                    $i = 0;                    $i = 0;
325                    $var = 0;                    $var = 0;
# Line 326  class pdfdetail_nodet { Line 330  class pdfdetail_nodet {
330                        $obj = $this->db->fetch_object($i);                        $obj = $this->db->fetch_object($i);
331                        $var=!$var;                        $var=!$var;
332                                    
333                        $Y = $this->pdf->GetY();                        $Y = $pdf->GetY();
334                
335                        $this->pdf->SetXY(10, $Y);                        $pdf->SetXY(10, $Y);
336                        $this->pdf->MultiCell(80, $line_height, $obj->dest, 0,'L',$var);                        $pdf->MultiCell(80, $line_height, $obj->dest, 0,'L',$var);
337    
338                        if ($Y > $this->pdf->GetY())                        if ($Y > $pdf->GetY())
339                          $Y = $this->pdf->GetY() - $line_height;                          $Y = $pdf->GetY() - $line_height;
340    
341                        $this->pdf->SetXY(90, $Y);                        $pdf->SetXY(90, $Y);
342                        $this->pdf->MultiCell(30, $line_height, $obj->numero, 0,'L',$var);                        $pdf->MultiCell(30, $line_height, $obj->numero, 0,'L',$var);
343    
344                        $h = floor($obj->duree / 3600);                        $h = floor($obj->duree / 3600);
345                        $m = floor(($obj->duree - ($h * 3600)) / 60);                        $m = floor(($obj->duree - ($h * 3600)) / 60);
# Line 357  class pdfdetail_nodet { Line 361  class pdfdetail_nodet {
361                              }                              }
362                          }                          }
363    
364                        $this->pdf->SetXY(120, $Y);                        $pdf->SetXY(120, $Y);
365                        $this->pdf->MultiCell(40, $line_height,$dt, 0,'R',$var);                        $pdf->MultiCell(40, $line_height,$dt, 0,'R',$var);
366    
367                        $this->pdf->SetXY(160, $Y);                        $pdf->SetXY(160, $Y);
368                        $this->pdf->MultiCell(20, $line_height,$obj->cc, 0,'R',$var);                        $pdf->MultiCell(20, $line_height,$obj->cc, 0,'R',$var);
369    
370                        $this->pdf->SetXY(180, $Y);                        $pdf->SetXY(180, $Y);
371                        $this->pdf->MultiCell(20, $line_height,sprintf("%01.3f",$obj->cout_vente), 0,'R',$var);                        $pdf->MultiCell(20, $line_height,sprintf("%01.3f",$obj->cout_vente), 0,'R',$var);
372    
373                        $i++;                        $i++;
374                      }                      }
# Line 400  class pdfdetail_nodet { Line 404  class pdfdetail_nodet {
404    
405                $handle = $graph->Stroke($file_graph);                $handle = $graph->Stroke($file_graph);
406    
407                $this->pdf->Image($file_graph, 11, ($this->pdf->GetY() + 10), 0, 0, 'JPG');                $pdf->Image($file_graph, 11, ($pdf->GetY() + 10), 0, 0, 'JPG');
408    
409                /*                /*
410                 *                 *
411                 */                 */
412                              if ($output == 0)
413                $this->pdf->Close();                  {
414                                    $pdf->Close();              
415                $this->pdf->Output($file);                    $pdf->Output($file);
416                      dolibarr_syslog("Write $file");
417                    }
418                $this->filename = $file;                $this->filename = $file;
419    
               dolibarr_syslog("Write $file");  
420    
421                if(file_exists($file_graph))                if(file_exists($file_graph))
422                  {                  {
423                    unlink($file_graph);                    unlink($file_graph);
424                  }                  }
425    
426                /* Génération du tableur */                if ($output == 0)
427                    {
428                $xlsdet = new xlsdetail_nodet($this->db);                    /* Génération du tableur */
429                $xlsdet->GenerateFile($objlignetel, $fac, $factel);                    $xlsdet = new xlsdetail_nodet($this->db);
430                      $xlsdet->GenerateFile($objlignetel, $fac, $factel);
431                    }
432                return 0;                return 0;
433              }              }
434            else            else
# Line 437  class pdfdetail_nodet { Line 443  class pdfdetail_nodet {
443              return -2;              return -2;
444          }          }
445      }      }
446    
447    
448    
449    
450      /*
451       * Header
452       */
453    
454      function Header(&$pdf)
455      {
456        $pdf->SetXY(10,5);
457        
458        // 400x186
459    
460        $logo_file = DOL_DOCUMENT_ROOT."/../documents/logo.jpg";
461    
462        if (file_exists($logo_file))
463        {
464          $pdf->Image($logo_file, 10, 5, 60, 27.9, 'JPG');
465        }
466    
467        $pdf->SetTextColor(0,90,200);
468        $pdf->SetFont('Arial','',10);
469        $pdf->SetXY(11,31);
470        $pdf->MultiCell(89, 4, "Facture détaillée : ".$pdf->fac->ref);
471    
472        $pdf->SetX(11);
473        $pdf->MultiCell(89, 4, "Ligne : " . $pdf->ligne);
474    
475        $pdf->SetX(11);
476    
477        $libelle = "Du ".strftime("%d/%m/%Y",$pdf->factel->get_comm_min_date($pdf->year.$pdf->month));
478        $libelle .= " au ".strftime("%d/%m/%Y",$pdf->factel->get_comm_max_date($pdf->year.$pdf->month));
479        $pdf->MultiCell(89, 4, $libelle, 0);
480    
481        $pdf->SetX(11);
482        $pdf->MultiCell(80, 4, "Page : ". $pdf->PageNo() ."/{nb}", 0);
483    
484        // Clients spéciaux
485    
486        if ($pdf->ligne_ville)
487          {
488            $pdf->SetX(11);
489            $pdf->MultiCell(80, 4, "Agence : ". $pdf->ligne_ville, 0);
490          }
491    
492        $pdf->rect(10, 30, 95, 23);
493        
494        $pdf->SetTextColor(0,0,0);
495        $pdf->SetFont('Arial','',10);
496    
497        $pdf->SetXY(107, 31);
498    
499        $pdf->MultiCell(66,4, $pdf->client_nom);
500    
501        $pdf->SetX(107);
502        $pdf->MultiCell(86,4, $pdf->client_adresse . "\n" . $pdf->client_cp . " " . $pdf->client_ville);
503    
504        $pdf->rect(105, 30, 95, 23);
505    
506        /*
507         * On positionne le curseur pour la liste
508         */        
509        $pdf->SetXY(10,$pdf->tab_top + 6);
510        $pdf->colonne = 1;
511        $pdf->inc = 0;
512      }
513    
514      /*
515       * Footer
516       */
517    
518      function Footer(&$pdf)
519      {
520    
521        if ($pdf->FirstPage == 1)
522          {
523            $pdf->FirstPage = 0;
524          }
525        else
526          {
527    
528            $pdf->SetFont('Arial','',8);
529        
530            $pdf->Text(11, $pdf->tab_top + 3,'Date');
531            $pdf->Text(106, $pdf->tab_top + 3,'Date');
532            
533            $w = 33;
534            
535            $pdf->Text($w+1, $pdf->tab_top + 3,'Numéro');
536            $pdf->Text($w+96, $pdf->tab_top + 3,'Numéro');
537            
538            $w = 47;
539            
540            $pdf->Text($w+1, $pdf->tab_top + 3,'Destination');
541            $pdf->Text($w+96, $pdf->tab_top + 3,'Destination');
542            
543            $w = 86;
544            
545            $pdf->Text($w+1, $pdf->tab_top + 3,'Durée');
546            $pdf->Text($w+96, $pdf->tab_top + 3,'Durée');
547            
548            $w = 98;
549            
550            $pdf->Text($w+1, $pdf->tab_top + 3,'HT');
551            $pdf->Text($w+96, $pdf->tab_top + 3,'HT');
552            
553            $pdf->line(10, $pdf->tab_top + 4, 200, $pdf->tab_top + 4 );
554    
555            /* Ligne Médiane */
556    
557            $pdf->line(105, $pdf->tab_top, 105, $pdf->tab_top + $pdf->tab_height);
558            
559          }
560    
561        $pdf->Rect(10, $pdf->tab_top, 190, $pdf->tab_height);
562    
563      }
564    
565    
566    
567    
568    
569    
570    
571    
572  }  }
573  ?>  ?>

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26