[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/12: Problem read README.export-PDF
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/12: Problem read README.export-PDF |
Date: |
Mon, 25 Jan 2016 22:58:35 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 69efdd1cb3853f01f685aa30188d0f51b94d943b
Author: Dany De Bontridder <address@hidden>
Date: Sat Dec 19 04:32:53 2015 +0100
Problem read README.export-PDF
---
README.export-pdf | 3 +
include/class/class_print_ledger_fin.php | 6 +-
include/export/export_fiche_detail_pdf.php | 4 +-
include/lib/class_pdf.php | 142 ++++++++++++++++++++++-----
4 files changed, 123 insertions(+), 32 deletions(-)
diff --git a/README.export-pdf b/README.export-pdf
new file mode 100644
index 0000000..8d155a4
--- /dev/null
+++ b/README.export-pdf
@@ -0,0 +1,3 @@
+Remplacer PDF::Cell par PDF::write_cell
+Remplacer PDF::ln par PDF::line_new
+
diff --git a/include/class/class_print_ledger_fin.php
b/include/class/class_print_ledger_fin.php
index e7976bb..b8bbbb4 100644
--- a/include/class/class_print_ledger_fin.php
+++ b/include/class/class_print_ledger_fin.php
@@ -100,15 +100,15 @@ class Print_Ledger_Financial extends PDF
for ( $i=0;$i<count($a_jrn);$i++)
{
$row=$a_jrn[$i];
- $this->LongLine(15,5,$row['pj']);
+ $this->Cell(15,5,$row['pj']);
$this->Cell(10,5,$row['date_fmt']);
$this->Cell(15,5,$row['internal']);
$name=$this->ledger->get_tiers($this->jrn_type,$row['id']);
- $this->LongLine(40,5,$name,0,'L');
+ $this->Cell(40,5,$name,0,'L');
- $this->LongLine(80,5,$row['comment'],0,'L');
+ $this->Cell(80,5,$row['comment'],0,'L');
$amount=$this->cn->get_value('select qf_amount from quant_fin
where jr_id=$1',array( $row['id']));
$this->Cell(20,5,sprintf('%s',nbm($amount)),0,0,'R');
$this->Ln(5);
diff --git a/include/export/export_fiche_detail_pdf.php
b/include/export/export_fiche_detail_pdf.php
index 3ca91d7..3652482 100644
--- a/include/export/export_fiche_detail_pdf.php
+++ b/include/export/export_fiche_detail_pdf.php
@@ -132,7 +132,7 @@ for ($e=0;$e<count($array);$e++)
$progress=bcadd($progress,$delta);
$date=shrink_date($row['j_date_fmt']);
- $pdf->LongLine($size[$l],6,$date,0,$align[$l]);
+ $pdf->Cell($size[$l],6,$date,0,0,$align[$l]);
$l++;
if ( $row['jr_pj_number'] == '')
$pdf->Cell($size[$l],6,"",0,0,$align[$l]);
@@ -140,7 +140,7 @@ for ($e=0;$e<count($array);$e++)
$pdf->Cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
$l++;
-
$pdf->LongLine($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,$align[$l]);
+
$pdf->Cell($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l]);
$l++;
$pdf->LongLine($size[$l],6,($row['description'].'('.$row['jr_internal'].")"),0,$align[$l]);
diff --git a/include/lib/class_pdf.php b/include/lib/class_pdf.php
index 69ab52e..5d3ee92 100644
--- a/include/lib/class_pdf.php
+++ b/include/lib/class_pdf.php
@@ -24,7 +24,30 @@
*/
require_once NOALYSS_INCLUDE.'/tfpdf/tfpdf.php';
-
+class Cellule {
+ var $width;
+ var $height;
+ var $text;
+ var $new_line;
+ var $border;
+ var $align;
+ var $fill;
+ var $link;
+ var $type;
+ function __construct($w,$h,$txt,$border,$ln,$align,$fill,$link,$type)
+ {
+ $this->width=$w ;
+ $this->height=$h ;
+ $this->text=$txt;
+ $this->border=$border;
+ $this->new_line=$ln;
+ $this->align=$align;
+ $this->fill=$fill;
+ $this->link=$link;
+ $this->type=$type;
+ return $this;
+ }
+}
class PDF extends TFPDF
{
@@ -33,6 +56,7 @@ class PDF extends TFPDF
var $soc = "";
var $dossier = "n/a";
var $date = "";
+ private $cells=array();
public function __construct ($p_cn = null, $orientation = 'P', $unit =
'mm', $format = 'A4')
{
@@ -52,6 +76,7 @@ class PDF extends TFPDF
$this->own = new own($this->cn);
$this->soc = $this->own->MY_NAME;
$this->date = date('d.m.Y');
+ $this->cells=array();
}
function setDossierInfo($dossier = "n/a")
@@ -64,9 +89,9 @@ class PDF extends TFPDF
//Arial bold 12
$this->SetFont('DejaVu', 'B', 12);
//Title
- $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
+ parent::Cell(0,10,$this->dossier, 'B', 0, 'C');
//Line break
- $this->Ln(20);
+ parent::Ln(20);
}
function Footer()
{
@@ -75,37 +100,100 @@ class PDF extends TFPDF
//Arial italic 8
$this->SetFont('Arial', '', 8);
//Page number
- $this->Cell(0,8,'Date '.$this->date." - Page
".$this->PageNo().'/{nb}',0,0,'C');
- $this->Ln(3);
+ parent::Cell(0,8,'Date '.$this->date." - Page
".$this->PageNo().'/{nb}',0,0,'C');
+ parent::Ln(3);
// Created by NOALYSS
- $this->Cell(0,8,'Created by NOALYSS, online on
http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
+ parent::Cell(0,8,'Created by NOALYSS, online on
http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
}
- function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='',
$fill=false, $link='')
+ private function check_page_add()
{
- $txt = str_replace("\\", "", $txt);
- return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
- }
- function LongLine($w,$h,$txt,$border=0,$align='',$fill=false)
- {
- $x_m=$this->GetX();
+ // break on page
+ $size=count($this->cells);
+ for ($i=0;$i < $size ; $i++)
+ {
+ if ($this->cells[$i]->type == 'M' )
+ {
+ $y=$this->GetY();
+ if ( $y > ($this->h - $this->bMargin-20))
+ return true;
+ }
+ }
+ return false;
+ }
+ private function print_row()
+ {
+ static $e=0;
+ $e++;
+ if ( $e == 73 ) xdebug_break ();
+ //if ( $this->check_page_add() == true ) $this->AddPage ();
+ $this->bigger=0;
+ $size=count($this->cells);
+ if ($size == 0 )return;
+ for ($i=0;$i < $size ; $i++)
+ {
+ $this->cells[$i]->text= str_replace("\\", "",
$this->cells[$i]->text);
+
+ switch ($this->cells[$i]->type)
+ {
+ case "M":
+ $x_m=$this->GetX();
$y_m=$this->GetY();
- $txt = str_replace("\\", "", $txt);
- if ( $y_m > ($this->h-$this->bMargin-10 )) {
- $this->AddPage ();
- $y_m=$this->GetY();
-
- }
- $this->MultiCell($w,$h,$txt,$border,$align,$fill);
- $x_m=$x_m+$w;
+ parent::MultiCell(
+ $this->cells[$i]->width,
+ $this->cells[$i]->height,
+ $this->cells[$i]->text,
+ $this->cells[$i]->border,
+ $this->cells[$i]->align,
+ $this->cells[$i]->fill
+ );
+ $x_m=$x_m+$this->cells[$i]->width;
$tmp=$this->GetY()-$y_m;
if ( $tmp > $this->bigger) $this->bigger=$tmp;
$this->SetXY($x_m,$y_m);
- }
- function Ln($p_step=null){
- if ( $this->bigger==0) parent::Ln($p_step);
- parent::Ln($this->bigger);
- $this->bigger=0;
- }
+ break;
+
+ case "C":
+
+ $this->Cell( $this->cells[$i]->width,
+ $this->cells[$i]->height,
+ $this->cells[$i]->text,
+ $this->cells[$i]->border,
+ $this->cells[$i]->new_line,
+ $this->cells[$i]->align,
+ $this->cells[$i]->fill,
+ $this->cells[$i]->link);
+ break;
+
+ default:
+ break;
+ }
+ }
+ $this->cells=array();
+ }
+ function add_cell(Cellule $Ce)
+ {
+ $size=count($this->cells);
+ $this->cells[$size]=$Ce;
+
+ }
+ function write_cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='',
$fill=false, $link='')
+ {
+ $this->add_cell(new
Cellule($w,$h,$txt,$border,$ln,$align,$fill,$link,'C'));
+
+ }
+ function LongLine($w,$h,$txt,$border=0,$align='',$fill=false)
+ {
+ $this->add_cell(new Cellule($w,$h,$txt,$border,0,$align,$fill,'','M'));
+
+ }
+ function Ln($p_step=null){
+ $this->print_row();
+ if ( $this->bigger==0)
+ parent::Ln($p_step);
+ else
+ parent::Ln($this->bigger);
+ $this->bigger=0;
+ }
/**
address@hidden retrieve the client name and quick_code
address@hidden $p_jr_id jrn.jr_id
- [Noalyss-commit] [noalyss] branch master updated (8f47684 -> 01d9cf0), Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 05/12: Update comment for belong_ledger, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 01/12: Problem read README.export-PDF,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 07/12: Debugging info to remove, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 03/12: Task #3 - Problem avec export PDF depuis COMPTA/PRINT/PRINTJRN Cannot remove a shared note, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 04/12: #1251 : impression PDF Les Headers et Footer ne doivent pas utiliser write_celle et ln, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 10/12: Compute the height of a MultiCell and check is a page must be added, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 06/12: Update unit-test to new structure, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 12/12: Merge branch 'rel6912-export-pdf', Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 11/12: Fix problem with PDF and the empty page due a wrong page break, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 02/12: #1251 impression PDF Remove function Cell that fct cannot be overloaded Change Cell by write_cell change ln by print_row, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 09/12: HTML doc, Dany De Bontridder, 2016/01/25
- [Noalyss-commit] [noalyss] 08/12: update doc, Dany De Bontridder, 2016/01/25