noalyss Version-9
Public Member Functions
Print_Ledger_Simple Class Reference

this class extends PDF and let you export the detailled printing of any ledgers More...

+ Inheritance diagram for Print_Ledger_Simple:
+ Collaboration diagram for Print_Ledger_Simple:

Public Member Functions

 __construct ($p_cn, Acc_Ledger $p_jrn, $p_from, $p_to, $p_filter_operation)
 
 export ()
 export the ledger in PDF More...
 
 Footer ()
 write the Footer More...
 
 Header ()
 write the header of each page More...
 
 setDossierInfo ($dossier="n/a")
 
- Public Member Functions inherited from Print_Ledger
 __construct (\Database $p_cn, $orientation, $unit, $format, Acc_Ledger $p_ledger, $p_from, $p_to, $p_filter_operation)
 integer parm_periode.p_id , end periode; More...
 
 get_filter_operation ()
 
 get_from ()
 
 get_ledger ()
 
 get_to ()
 
 set_filter_operation ($filter_operation)
 Filter the operations ,. More...
 
 set_from ($from)
 
 set_ledger ($ledger)
 
 set_to ($to)
 
- Public Member Functions inherited from PDF
 __construct (Database $p_cn, $orientation='P', $unit='mm', $format='A4')
 
 Footer ()
 
 get_tiers ($p_jr_id, $p_jrn_type)
 retrieve the client name and quick_code More...
 
 Header ()
 
 set_filter_operation ($filter_operation)
 
 setDossierInfo ($dossier="n/a")
 
- Public Member Functions inherited from PDF_Core
 __construct ( $orientation='P', $unit='mm', $format='A4')
 
 get_margin_bottom ()
 
 get_margin_left ()
 
 get_margin_right ()
 
 get_margin_top ()
 
 get_orientation ()
 
 get_page_size ()
 
 get_unit ()
 
 is_fill ($p_step)
 If the step is even then return 1 and set the backgroup color to blue , otherwise returns 0, and set the background color to white It is use to compute alternated colored row , it the parameter fill in write_cell and cell. More...
 
 line_new ($p_step=null)
 Print all the cell stored and call Ln (new line) More...
 
 LongLine ($w, $h, $txt, $border=0, $align='', $fill=false)
 
 write_cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
 

Additional Inherited Members

- Static Public Member Functions inherited from Print_Ledger
static available_ledger ($get_from_periode)
 find all the active ledger for the exerice of the periode and readable by the current user @global type $g_user More...
 
static factory (Database $cn, $p_type_export, Acc_Ledger $p_ledger, $p_from, $p_to, $p_filter_operation)
 Create an object Print_Ledger* depending on $p_type_export ( 0 => accounting 1-> one row per operation 2-> detail of item) More...
 
- Data Fields inherited from PDF
 $cn = null
 
 $date = ""
 
 $dossier = "n/a"
 
 $own = null
 
 $soc = ""
 
- Protected Member Functions inherited from Print_Ledger
 build_filter_operation ()
 Build a SQL clause to filter operation depending if they are paid, unpaid or no filter. More...
 
- Protected Member Functions inherited from PDF_Core
 print_row ()
 print the current array of cell and reset it , if different colors are set on the same row you have to print it before changing More...
 
- Protected Attributes inherited from Print_Ledger
 $filter_operation
 

Detailed Description

this class extends PDF and let you export the detailled printing of any ledgers

Definition at line 33 of file print_ledger_simple.class.php.

Constructor & Destructor Documentation

◆ __construct()

Print_Ledger_Simple::__construct (   $p_cn,
Acc_Ledger  $p_jrn,
  $p_from,
  $p_to,
  $p_filter_operation 
)

Definition at line 35 of file print_ledger_simple.class.php.

36 {
37
38 parent::__construct($p_cn,'L', 'mm', 'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
39
40 $this->a_Tva=$this->get_ledger()->existing_vat();
41 foreach($this->a_Tva as $line_tva)
42 {
43 //initialize Amount TVA
44 $tmp1=$line_tva['tva_id'];
45 $this->rap_tva[$tmp1]=0;
46 }
47 $this->rap_other_tax=0;
48 $this->jrn_type=$p_jrn->get_type();
49 //----------------------------------------------------------------------
50 /* report
51 *
52 * get rappel to initialize amount rap_xx
53 *the easiest way is to compute sum from quant_
54 */
55 $from_periode=$this->get_from();
56 $this->previous=$this->get_ledger()->previous_amount($from_periode);
57 $this->other_tax_previous=$this->get_ledger()->previous_other_tax($from_periode);
58
59 /* initialize the amount to report */
60 foreach($this->previous['tva'] as $line_tva)
61 {
62 //initialize Amount TVA
63 $tmp1=$line_tva['tva_id'];
64 $this->rap_tva[$tmp1]=$line_tva['sum_vat'];
65 }
66
67 $this->rap_htva=$this->previous['price'];
68 $this->rap_tvac=bcadd($this->previous['price'],$this->previous['vat']);
69 $this->rap_tvac=bcadd($this->rap_tvac,$this->previous['tva_nd']);
70 $this->rap_tvac=bcsub($this->rap_tvac,$this->previous['tva_np']);
71 $this->rap_tvac=bcsub($this->rap_tvac,$this->previous['reversed']);
72 $this->rap_priv=$this->previous['priv'];
73 $this->rap_nd=$this->previous['tva_nd'];
74 $this->rap_tva_np=$this->previous['tva_np'];
75 $this->flag_other_tax=false;
76
77 if ($this->jrn_type == 'ACH' || $this->jrn_type=='VEN') {
78 $periode=new Periode($p_cn,$p_from);
79 $first_date=$periode->first_day();
80 $periode=new Periode($p_cn,$p_to);
81 $last_date=$periode->last_day();
82
83 $count=$this->cn->get_value("
84 select count(*)
85 from jrn_tax join jrnx using (j_id)
86 join jrn on (j_grpt=jr_grpt_id) where
87 j_date >= to_date($1,'DD.MM.YYYY')
88 and j_date <= to_date($2,'DD.MM.YYYY')
89 and j_jrn_def=$3",
90 array($first_date,$last_date,$p_jrn->id));
91 if ($count>0) { $this->flag_other_tax=true;}
92 }
93 }
$input_from cn
Definition: balance.inc.php:66
For the periode tables parm_periode and jrn_periode.
$count

References $count, $from_periode, $p_jrn, $periode, cn, Print_Ledger\get_from(), and Print_Ledger\get_ledger().

+ Here is the call graph for this function:

Member Function Documentation

◆ export()

Print_Ledger_Simple::export ( )

export the ledger in PDF

Definition at line 253 of file print_ledger_simple.class.php.

254 {
255 bcscale(4);
256 $ledger=$this->get_ledger();
257 $ledger_history=Acc_Ledger_History::factory($this->cn,
258 array($ledger->id),
259 $this->get_from(),
260 $this->get_to(),
261 'D',
262 $this->get_filter_operation());
263 $ledger_history->get_row();
264 $a_jrn=$ledger_history->get_data();
265
266 if ( $a_jrn == null ) return;
267
268 // Count the number of VAT cols
269 $flag_tva=(count($this->a_Tva) > 4)?true:false;
270
271 // Prepare the query for reconcile date
272 $prepared_query=new Prepared_Query($ledger->db);
273 $prepared_query->prepare_reconcile_date();
274
275 for ( $i=0;$i<count($a_jrn);$i++)
276 {
277 /* initialize tva */
278 for ($f=0;$f<count($this->a_Tva);$f++)
279 {
280 $l=$this->a_Tva[$f]['tva_id'];
281 $atva_amount[$l]=0;
282 }
283
284 // retrieve info from ledger
285 $aAmountVat=$ledger->vat_operation($a_jrn[$i]['jr_grpt_id']);
286
287 // put vat into array
288 for ($f=0;$f<count($aAmountVat);$f++)
289 {
290 $l=$aAmountVat[$f]['tva_id'];
291 $atva_amount[$l]=bcadd($atva_amount[$l],$aAmountVat[$f]['sum_vat']);
292 $this->tp_tva[$l]=bcadd($this->tp_tva[$l],$aAmountVat[$f]['sum_vat']);
293 $this->rap_tva[$l]=bcadd($this->rap_tva[$l],$aAmountVat[$f]['sum_vat']);
294
295 }
296 $row=$a_jrn[$i];
297 $ret_reconcile=$ledger->db->execute('reconcile_date',array($row['jr_id']));
298 $this->LongLine(15,5,($row['jr_pj_number']),0);
299 $this->write_cell(10,5,$row['str_date_short'],0,0);
300 $this->write_cell(13,5,$row['jr_internal'],0,0);
301 list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type);
302 $this->LongLine(40,5,"[".$qc."]".$name,0,'L');
303
304 if ( !$flag_tva ) {
305 $this->LongLine(65,5,mb_substr($row['jr_comment'],0,150),0,'L');
306 }
307
308 /* get other amount (without vat, total vat included, private, ND */
309 $other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
310
311 $this->write_cell(15,5,nbm($other['price']),0,0,'R');
312
313 if ( $ledger_history->get_ledger_type() !='VEN')
314 {
315 $this->write_cell(15,5,nbm($other['priv']),0,0,'R');
316 $this->write_cell(15,5,nbm($other['tva_nd']),0,0,'R');
317 }
318
319 $this->write_cell(15,5,nbm($other['tva_np']),0,0,'R');
320
321 foreach ($atva_amount as $row_atva_amount)
322 {
323 $this->write_cell(15, 5, nbm($row_atva_amount), 0, 0, 'R');
324 }
325
326 $l_tvac=bcadd($other['price'], bcsub($other['vat'],$other['tva_np']));
327 $l_tvac=bcadd($l_tvac,$other['tva_nd']);
328 $l_tvac=bcadd($l_tvac,$a_jrn[$i]['other_tax_amount']);
329 if ($this->flag_other_tax) {
330 $this->write_cell(15, 5, nbm($a_jrn[$i]['other_tax_amount']), 0, 0, 'R');
331 }
332 $this->write_cell(15,5,nbm($l_tvac),0,0,'R');
333 $this->line_new(2);
334 // Add the payment information on another row
336 $str_payment="";
337 if ($max > 0) {
338 $this->write_cell(15,5, _("Payé par"));
339 $sep="";
340 for ($e=0;$e<$max;$e++) {
342 $msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]".$row['qcode_name']:$row['jr_internal'];
343 $str_payment=$row['jr_date'].$msg.$sep;
344 $sep=' , ';
345 }
346 $this->write_cell (120,5,$str_payment);
347 }
348
349
350 $this->line_new(3);
351 // Total page
352 $this->tp_htva=bcadd($this->tp_htva,$other['price']);
353 $this->tp_tvac=bcadd($this->tp_tvac,$other['price']);
354 $this->tp_tvac=bcadd($this->tp_tvac,$other['vat']);
355 $this->tp_tvac=bcadd($this->tp_tvac,$other['tva_nd']);
356 $this->tp_tvac=bcsub($this->tp_tvac,$other['tva_np']);
357 $this->tp_tva_np=bcadd($this->tp_tva_np,$other['tva_np']);
358 $this->tp_priv=bcadd($this->tp_priv,$other['priv']);
359 $this->tp_nd=bcadd($this->tp_nd,$other['tva_nd']);
360
361
362 // Total report
363 $this->rap_htva=bcadd($this->rap_htva,$other['price']);
364 $this->rap_tvac=bcadd($this->rap_tvac,$other['price']);
365 $this->rap_tvac=bcadd($this->rap_tvac,$other['vat']);
366 $this->rap_tvac=bcsub($this->rap_tvac,$other['tva_np']);
367 $this->rap_tvac=bcadd($this->rap_tvac,$other['tva_nd']);
368 $this->rap_priv=bcadd($this->rap_priv,$other['priv']);
369 $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
370 $this->rap_tva_np=bcadd($this->rap_tva_np,$other['tva_np']);
371
372 if ($this->flag_other_tax) {
373 $this->tp_other_tax = bcadd($this->tp_other_tax, $a_jrn[$i]['other_tax_amount']);
374 $this->rap_other_tax = bcadd($this->rap_other_tax, $a_jrn[$i]['other_tax_amount']);
375 }
376
377 }
378 }
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
static factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode, $p_paid)
Build the right object.
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
line_new($p_step=null)
Print all the cell stored and call Ln (new line)
LongLine($w, $h, $txt, $border=0, $align='', $fill=false)
write_cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
get_tiers($p_jr_id, $p_jrn_type)
retrieve the client name and quick_code
Definition: pdf.class.php:84
contains prepared query used in different classes of the application
$ledger
concerned Ledger

References $e, $f, $i, $l, Print_Ledger\$ledger, $max, $msg, $name, $other, $ret_reconcile, $row, $sep, cn, Acc_Ledger_History\factory(), DatabaseCore\fetch_array(), Print_Ledger\get_ledger(), PDF\get_tiers(), PDF_Core\line_new(), PDF_Core\LongLine(), nbm(), DatabaseCore\num_row(), and PDF_Core\write_cell().

+ Here is the call graph for this function:

◆ Footer()

Print_Ledger_Simple::Footer ( )

write the Footer

Reimplemented from PDF.

Definition at line 187 of file print_ledger_simple.class.php.

188 {
189 //Position at 3 cm from bottom
190 $this->SetY(-20);
191 /* write reporting */
192 $flag_tva=(count($this->a_Tva) > 4)?true:false;
193 if ( ! $flag_tva)
194 $this->Cell(143,6,'Total page ','T',0,'R'); /* HTVA */
195 else
196 $this->Cell(78,6,'Total page ','T',0,'R'); /* HTVA */
197
198 $this->Cell(15,6,nbm($this->tp_htva),'T',0,'R'); /* HTVA */
199 if ( $this->jrn_type !='VEN')
200 {
201 $this->Cell(15,6,nbm($this->tp_priv),'T',0,'R'); /* prive */
202 $this->Cell(15,6,nbm($this->tp_nd),'T',0,'R'); /* Tva ND */
203 }
204 $this->Cell(15,6,nbm($this->tp_tva_np),'T',0,'R'); /* Tva Unpaid */
205 foreach($this->a_Tva as $line_tva)
206 {
207 $l=$line_tva['tva_id'];
208 $this->Cell(15,6,nbm($this->tp_tva[$l]),'T',0,'R');
209 }
210 if ($this->flag_other_tax) {
211 $this->Cell(15, 6, nbm($this->tp_other_tax), 'T', 0, 'R'); /* Tvac */
212 }
213 $this->Cell(15,6,nbm($this->tp_tvac),'T',0,'R'); /* Tvac */
214 $this->Ln(2);
215 $flag_tva=(count($this->a_Tva) > 4)?true:false;
216
217 if ( ! $flag_tva)
218 $this->Cell(143,6,'report',0,0,'R');
219 else
220 $this->Cell(78,6,'report',0,0,'R');
221
222 $this->Cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
223 if ( $this->jrn_type !='VEN')
224 {
225 $this->Cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
226 $this->Cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
227 }
228 $this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R'); /* Tva ND */
229
230 foreach($this->a_Tva as $line_tva)
231 {
232 $l=$line_tva['tva_id'];
233 $this->Cell(15,6,nbm($this->rap_tva[$l]),0,0,'R');
234 }
235 if ($this->flag_other_tax) {
236 $this->Cell(15, 6, nbm($this->rap_other_tax), 0, 0, 'R'); /* Other tax */
237 }
238 $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
239 $this->Ln(2);
240
241 //Arial italic 8
242 $this->SetFont('Arial', 'I', 8);
243 //Page number
244 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
245 // Created by NOALYSS
246 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
247 }

References $l, and nbm().

+ Here is the call graph for this function:

◆ Header()

Print_Ledger_Simple::Header ( )

write the header of each page

Reimplemented from PDF.

Definition at line 102 of file print_ledger_simple.class.php.

103 {
104 //Arial bold 12
105 $this->SetFont('DejaVu', 'B', 12);
106 //Title
107 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
108 //Line break
109 $this->Ln(20);
110 $this->SetFont('DejaVu', 'B', 8);
111 /* column header */
112 //----------------------------------------------------------------------
113 // Show column header, if $flag_tva is false then display vat as column
114 foreach($this->a_Tva as $line_tva)
115 {
116 //initialize Amount TVA
117 $tmp1=$line_tva['tva_id'];
118 $this->rap_tva[$tmp1]=(isset($this->rap_tva[$tmp1]))?$this->rap_tva[$tmp1]:0;
119 }
120 $this->Cell(15,6,_('Pièce'));
121 $this->Cell(10,6,_('Date'));
122 $this->Cell(13,6,_('ref'));
123 if ( $this->jrn_type=='ACH')
124 $this->Cell(40,6,_('Client'));
125 else
126 $this->Cell(40,6,_('Fournisseur'));
127
128 $flag_tva=(count($this->a_Tva) > 4)?true:false;
129 if ( !$flag_tva ) $this->Cell(65,6,_('Description'));
130
131 $this->Cell(15,6,_('HTVA'),0,0,'R');
132 if ( $this->jrn_type=='ACH')
133 {
134 $this->Cell(15,6,_('Priv/DNA'),0,0,'R');
135 $this->Cell(15,6,_('TVA ND'),0,0,'R');
136 }
137 $this->Cell(15,6,_('TVA NP'),0,0,'R'); // Unpaid TVA --> autoliquidation, NPR
138 foreach($this->a_Tva as $line_tva)
139 {
140 $this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
141 }
142 if ($this->flag_other_tax) {
143 $this->Cell(15,6,'Autre Tx',0,0,'R');
144
145 }
146 $this->Cell(15,6,'TVAC',0,0,'R');
147 $this->Ln(5);
148
149 $this->SetFont('DejaVu','',6);
150 // page Header
151 if ( ! $flag_tva)
152 $this->Cell(143,6,'report',0,0,'R');
153 else
154 $this->Cell(78,6,'report',0,0,'R');
155 $this->Cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
156 if ( $this->jrn_type != 'VEN')
157 {
158 $this->Cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
159 $this->Cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
160 }
161 $this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R'); /* Tva ND */
162 foreach($this->rap_tva as $line_tva)
163 $this->Cell(15,6,nbm($line_tva),0,0,'R');
164 if ($this->flag_other_tax) {
165 $this->Cell(15, 6, nbm($this->rap_other_tax), 0, 0, 'R'); /* Other tax */
166 }
167 $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
168
169 $this->Ln(6);
170 //total page
171 $this->tp_htva=0.0;
172 $this->tp_tvac=0.0;
173 $this->tp_priv=0;
174 $this->tp_nd=0;
175 $this->tp_tva_np=0;
176 $this->tp_other_tax=0;
177 foreach($this->a_Tva as $line_tva)
178 {
179 //initialize Amount TVA
180 $tmp1=$line_tva['tva_id'];
181 $this->tp_tva[$tmp1]=0.0;
182 }
183 }

References nbm().

+ Here is the call graph for this function:

◆ setDossierInfo()

Print_Ledger_Simple::setDossierInfo (   $dossier = "n/a")

Reimplemented from PDF.

Definition at line 95 of file print_ledger_simple.class.php.

96 {
97 $this->dossier = dossier::name()." ".$dossier;
98 }
$from_poste name
$dossier
Definition: pdf.class.php:38

References PDF\$dossier, and name.


The documentation for this class was generated from the following file: