MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mpdfreport.class
Ir para a documentação deste ficheiro.
1
<?php
2
10
class
MPDFReportColumn
extends
MGridColumn
11
{
15
public
$name
;
16
17
35
function
__construct
(
$name
,
$title
=
''
,
$align
=
'left'
,
$nowrap
=
false
,
$width
=0,
$visible
=
true
,
$options
=
null
,
$order
=
false
, $filter=
false
)
36
{
37
parent::__construct(
$title
,
$align
,
$nowrap
,
$width
,
$visible
,
$options
,
$order
, $filter);
38
$this->name =
$name
;
39
}
40
48
function
Generate
()
49
{
50
}
51
}
52
57
class
MPDFReportControl
extends
MGridControl
58
{
62
public
$name
;
63
64
80
function
__construct
(
$name
,
$control
,
$title
=
''
,
$align
=
'left'
,
$nowrap
=
false
,
$width
=0,
$visible
=
true
)
81
{
82
parent::__construct(
$control
,
$title
,
$align
,
$nowrap
,
$width
,
$visible
);
83
$this->name =
$name
;
84
}
85
93
function
Generate
()
94
{
95
}
96
}
97
105
class
MPDFReport
extends
MGrid
106
{
110
var
$options
;
111
115
var
$rawdata
;
116
120
var
$slot
;
121
125
var
$ezpdf
;
// ezPdfReport object
126
130
var
$pdf
;
// MCezPdf object
131
135
var
$y
;
136
137
150
function
__construct
(
$data
,
$columns
,
$pageLength
=1,
$index
=0)
151
{ global
$MIOLO
, $state,
$page
;
152
153
$this->
SetPDF
(
new
ezPDFReport
(
'2'
));
154
parent::__construct(
$data
,
$columns
,
''
,
$pageLength
,
$index
);
155
$this->slot = array();
156
$this->rawdata = NULL;
157
$this->
InitializeOptions
();
158
$this->
SetWidth
(100);
159
}
160
168
function
InitializeOptions
()
169
{
170
$this->options[
'showLines'
] = 0;
171
$this->options[
'showHeadings'
] = 1;
172
$this->options[
'showTableTitle'
] = 1;
173
$this->options[
'shaded'
] = 1;
174
$this->options[
'shadeCol'
] = array(0.8,0.8,0.8);
175
$this->options[
'shadeCol2'
] = array(0.7,0.7,0.7);
176
$this->options[
'fontSize'
] = 10;
177
$this->options[
'textCol'
] = array(0,0,0);
178
$this->options[
'titleFontSize'
] = 14;
179
$this->options[
'rowGap'
] = 2;
180
$this->options[
'colGap'
] = 5;
181
$this->options[
'lineCol'
] = array(0,0,0);
182
$this->options[
'xPos'
] =
'center'
;
183
$this->options[
'xOrientation'
] =
'center'
;
184
$this->options[
'width'
] = 0;
185
$this->options[
'maxWidth'
] = 596;
186
$this->options[
'minRowSpace'
] = -100;
187
$this->options[
'innerLineThickness'
] = 1;
188
$this->options[
'outerLineThickness'
] = 1;
189
$this->options[
'protectRows'
] = 1;
190
}
191
202
function
SetOption
($option, $value)
203
{
204
$this->options[$option] = $value;
205
}
206
216
function
SetPDF
(
$pdf
)
217
{
218
$this->ezpdf =
$pdf
;
219
$this->pdf =
$pdf
->pdf;
220
}
221
229
function
GetPDF
()
230
{
231
return
$this->ezpdf
;
232
}
233
243
function
SetWidth
(
$width
)
244
{
245
$width
= $this->pdf->getWidthFromPercent(
$width
);
246
$this->
SetOption
(
'width'
,
$width
);
247
}
248
258
function
AddColumn
($column)
259
{
260
$this->columns[$column->name] = $column;
261
$this->columns[$column->name]->width = $this->pdf->getWidthFromPercent($column->width);
262
$this->columns[$column->name]->index = count($this->columns);
263
}
264
274
function
SetColumns
(
$columns
)
275
{
276
$this->columns = NULL;
277
if
(
$columns
!= NULL)
278
{
279
if
(! is_array(
$columns
) )
$columns
= array(
$columns
);
280
foreach
(
$columns
as $k=>$c)
281
{
282
$this->columns[$c->name] = $c;
283
$this->columns[$c->name]->width = $this->pdf->getWidthFromPercent($c->width);
284
$this->columns[$c->name]->index = $k;
285
}
286
}
287
}
288
296
function
GetPage
()
297
{
298
if
(count($this->rawdata))
299
{
300
return
array_slice($this->rawdata,$this->pn->idxFirst,$this->pn->gridCount);
301
}
302
}
303
311
function
GenerateReportHeader
()
312
{
313
return
NULL;
314
}
315
323
function
GeneratePageHeader
()
324
{
325
return
NULL;
326
}
327
335
function
GeneratePageFooter
()
336
{
337
return
NULL;
338
}
339
347
function
GenerateHeader
()
348
{
349
$header
[] = $this->
GenerateReportHeader
();
350
$header
[] = $this->
GeneratePageHeader
();
351
return
$header
;
352
}
353
361
function
GenerateColumnsHeading
($tbl)
362
{
363
$tbl = array();
364
$p = 0;
365
// generate column headings
366
foreach
( $this->columns as $k=>$col )
367
{
368
if
(( !$col->visible ) || ( !$col->title ))
continue
;
369
$colTitle = $col->title;
370
$tbl[
"$col->name"
] = $colTitle;
371
}
372
return
$tbl;
373
}
374
386
function
GenerateColumns
($tbl, $row = NULL, $i = NULL)
387
{ global
$MIOLO
;
388
389
$cntRow = count($row);
390
foreach
($this->columns as $k=>$col)
391
{
392
if
(( !$col->title ) || ( !$col->visible ))
continue
;
393
$control = clone $col->basecontrol;
// clonning
394
if
($col->className ==
'pdfreportcolumn'
)
395
{
396
$value = $row[$col->index];
397
$col->value = $value;
398
if
( $col->options )
399
{
400
$value = $col->options[$value];
401
if
( $this->showid )
402
{
403
$value .=
" ($row[$k])"
;
404
}
405
}
406
// by default, we align numbers to the right and text to the left
407
$c = substr($value,0,1);
408
if
( ! $col->align && ( $c ==
'-'
|| ( $c >=
'0'
&& $c <=
'9'
) ) )
409
{
410
$col->align =
'right'
;
411
}
412
if
($col->href !=
''
)
413
{
414
$href
= $col->href;
415
for
( $r=0; $r<$cntRow; $r++ )
416
$href
= str_replace(
"#$r#"
,trim($row[$r]),
$href
);
417
$href
= str_replace(
'#?#'
,$value,
$href
);
418
$control->href =
$href
;
419
$control->action =
$href
;
420
$control->label = $value;
421
}
422
$control->value = $value;
423
}
424
elseif ($col->className ==
'pdfreportcontrol'
)
425
{
426
$control->Generate();
427
}
428
else
429
{
430
$MIOLO
->Error(
"ERROR: Unknown column class '{$col->className}'!"
);
431
}
432
$tbl[$i][$col->name] = $control;
433
}
434
}
435
436
function
&
GenerateEmptyMsg
()
437
{
438
$tbl =
new
SimpleTable
(
''
);
439
$tbl->attributes[
'table'
] =
"cellspacing=\"0\" cellpadding=\"2\" border=\"0\" class=\"gridAttention\" align=\"center\" width=\"100%\""
;
440
$tbl->attributes[
'row'
][0] =
"class=\"gridAttention\" align=\"center\""
;
441
$tbl->cell[0][0] =
new
Text
(
''
,$this->emptyMsg);
442
$tbl->cell[0][0]->SetClass(
'gridAttention'
);
443
return
$tbl;
444
}
445
453
function
GenerateTableData
()
454
{
455
if
( $this->HasErrors() )
456
{
457
$this->GenerateErrors();
458
}
459
$tblData = array();
460
if
( $this->data)
461
{
462
// generate data rows
463
foreach
( $this->data as $i=>$row )
464
{
465
if
(isset($this->rowmethod)){
466
call_user_func($this->rowmethod, $row, $this->columns, $this->slot, $this);
467
}
468
$this->
GenerateColumns
($tblData, $row, $i);
469
470
}
// foreach row
471
}
// if
472
foreach
($tblData as $r=>$row)
473
foreach
($row as $c=>$cell)
474
$data
[$r][$c] = $cell->value;
475
return
$data
;
476
}
477
485
function
GeneratePageTitle
()
486
{
487
$this->pdf->ezText($this->title,$this->options[
'titleFontSize'
],array(
'justification'
=>
'center'
));
488
$this->pdf->ezSetDy($this->pdf->getFontDecender($this->options[
'titleFontSize'
]));
489
}
490
500
function
GenerateBody
(
$data
=
null
)
501
{
502
$titles = $this->
GenerateColumnsHeading
();
503
$cols = array();
504
foreach
( $this->columns as $k=>$col )
505
{
506
if
(( !$col->visible ) || ( !$col->title ))
continue
;
507
$cols[$col->name] = array(
'justification'
=>$col->align,
'width'
=>$col->width);
508
}
509
$this->options[
'cols'
] = $cols;
510
if
($this->options[
'showTableTitle'
])
511
$title
=
$this->title
;
512
else
513
{
514
$this->
GeneratePageTitle
();
515
$title
=
''
;
516
}
517
$this->y = $this->pdf->ezTable(
$data
,$titles,
$title
,$this->options);
518
}
519
527
function
GenerateFooter
()
528
{
529
if
(!$this->data)
530
$footer
[] = $this->
GenerateEmptyMsg
();
531
$footer
[] = $this->
GeneratePageFooter
();
532
$footer
[] = $this->GenerateReportFooter();
533
return
$footer
;
534
}
535
543
function
GenerateReport
()
544
{
545
$this->pdf->ezSetMargins(30,30,30,30);
546
$this->rawdata = $this->
GenerateTableData
();
547
if
($this->pageLength)
548
{
549
$this->pn =
new
MGridNavigator
($this->pageLength, $this->rowCount,
''
);
550
}
551
else
$this->pn =
null
;
552
for
(
$page
=1;
$page
<=$this->pn->pageCount;
$page
++)
553
{
554
$this->pn->SetPageNumber(
$page
);
555
$this->
GeneratePageHeader
();
556
$this->
GenerateBody
($this->
GetPage
());
557
$this->
GeneratePageFooter
();
558
if
(
$page
!= $this->pn->pageCount) $this->pdf->ezNewPage();
559
}
560
}
561
569
function
PageBreak
()
570
{
571
if
(!$this->
break
)
572
{
573
$this->pdf->ezNewPage();
574
$this->
break
=
true
;
575
}
576
}
577
585
function
ClearPageBreak
()
586
{
587
$this->
break
=
false
;
588
}
589
602
function
SetTrigger
($trigger, $class, $module, $param)
603
{
604
$this->pdf->SetTrigger($trigger, $class, $module, $param);
605
}
606
616
function
SetOutput
($value=
''
)
617
{
618
$this->ezpdf->SetOutput();
619
}
620
628
function
Execute
()
629
{
630
$this->ezpdf->Execute();
631
}
632
640
function
Generate
()
641
{
642
$this->
GenerateReport
();
643
$this->
SetOutput
();
644
$this->
Execute
();
645
}
646
647
}
648
?>
MComponent\$page
$page
Definição
mcomponent.class:12
MControl\$visible
$visible
Definição
mcontrol.class:95
MGridColumn
Definição
gridcontrols.class:15
MGridColumn\$options
$options
Definição
gridcontrols.class:19
MGridColumn\$align
$align
Definição
gridcontrols.class:20
MGridColumn\$nowrap
$nowrap
Definição
gridcontrols.class:21
MGridColumn\$order
$order
Definição
gridcontrols.class:23
MGridColumn\$width
$width
Definição
gridcontrols.class:22
MGridColumn\$title
$title
Definição
gridcontrols.class:17
MGridControl
Definição
gridcontrols.class:384
MGridControl\$control
$control
Definição
gridcontrols.class:388
MGridNavigator
Definição
mgridnavigator.class:7
MGrid
Definição
gridcontrols.class:739
MGrid\$columns
$columns
Definição
gridcontrols.class:750
MGrid\$index
$index
Definição
gridcontrols.class:761
MGrid\$header
$header
Definição
gridcontrols.class:774
MGrid\$width
$width
Definição
gridcontrols.class:759
MGrid\$pageLength
$pageLength
Definição
gridcontrols.class:753
MGrid\$data
$data
Definição
gridcontrols.class:746
MGrid\$footer
$footer
Definição
gridcontrols.class:773
MGrid\$title
$title
Definição
gridcontrols.class:740
MGrid\$href
$href
Definição
gridcontrols.class:755
MPDFReportColumn
Definição
mpdfreport.class:11
MPDFReportColumn\Generate
Generate()
Definição
mpdfreport.class:48
MPDFReportColumn\$name
$name
Definição
mpdfreport.class:15
MPDFReportColumn\__construct
__construct($name, $title='', $align='left', $nowrap=false, $width=0, $visible=true, $options=null, $order=false, $filter=false)
Definição
mpdfreport.class:35
MPDFReportControl
Definição
mpdfreport.class:58
MPDFReportControl\Generate
Generate()
Definição
mpdfreport.class:93
MPDFReportControl\__construct
__construct($name, $control, $title='', $align='left', $nowrap=false, $width=0, $visible=true)
Definição
mpdfreport.class:80
MPDFReportControl\$name
$name
Definição
mpdfreport.class:62
MPDFReport
Definição
mpdfreport.class:106
MPDFReport\$options
$options
Definição
mpdfreport.class:110
MPDFReport\GetPage
GetPage()
Definição
mpdfreport.class:296
MPDFReport\GeneratePageTitle
GeneratePageTitle()
Definição
mpdfreport.class:485
MPDFReport\SetOption
SetOption($option, $value)
Definição
mpdfreport.class:202
MPDFReport\GenerateTableData
GenerateTableData()
Definição
mpdfreport.class:453
MPDFReport\SetColumns
SetColumns($columns)
Definição
mpdfreport.class:274
MPDFReport\PageBreak
PageBreak()
Definição
mpdfreport.class:569
MPDFReport\GeneratePageHeader
GeneratePageHeader()
Definição
mpdfreport.class:323
MPDFReport\$slot
$slot
Definição
mpdfreport.class:120
MPDFReport\SetOutput
SetOutput($value='')
Definição
mpdfreport.class:616
MPDFReport\GenerateHeader
GenerateHeader()
Definição
mpdfreport.class:347
MPDFReport\GeneratePageFooter
GeneratePageFooter()
Definição
mpdfreport.class:335
MPDFReport\Generate
Generate()
Definição
mpdfreport.class:640
MPDFReport\AddColumn
AddColumn($column)
Definição
mpdfreport.class:258
MPDFReport\GenerateReport
GenerateReport()
Definição
mpdfreport.class:543
MPDFReport\GenerateColumns
GenerateColumns($tbl, $row=NULL, $i=NULL)
Definição
mpdfreport.class:386
MPDFReport\GenerateReportHeader
GenerateReportHeader()
Definição
mpdfreport.class:311
MPDFReport\GenerateEmptyMsg
& GenerateEmptyMsg()
Definição
mpdfreport.class:436
MPDFReport\$y
$y
Definição
mpdfreport.class:135
MPDFReport\SetWidth
SetWidth($width)
Definição
mpdfreport.class:243
MPDFReport\$ezpdf
$ezpdf
Definição
mpdfreport.class:125
MPDFReport\SetPDF
SetPDF($pdf)
Definição
mpdfreport.class:216
MPDFReport\$pdf
$pdf
Definição
mpdfreport.class:130
MPDFReport\GetPDF
GetPDF()
Definição
mpdfreport.class:229
MPDFReport\InitializeOptions
InitializeOptions()
Definição
mpdfreport.class:168
MPDFReport\$rawdata
$rawdata
Definição
mpdfreport.class:115
MPDFReport\GenerateFooter
GenerateFooter()
Definição
mpdfreport.class:527
MPDFReport\ClearPageBreak
ClearPageBreak()
Definição
mpdfreport.class:585
MPDFReport\GenerateBody
GenerateBody($data=null)
Definição
mpdfreport.class:500
MPDFReport\GenerateColumnsHeading
GenerateColumnsHeading($tbl)
Definição
mpdfreport.class:361
MPDFReport\__construct
__construct($data, $columns, $pageLength=1, $index=0)
Definição
mpdfreport.class:150
MPDFReport\SetTrigger
SetTrigger($trigger, $class, $module, $param)
Definição
mpdfreport.class:602
MPDFReport\Execute
Execute()
Definição
mpdfreport.class:628
SimpleTable
Definição
compatibility.class:178
Text
Definição
compatibility.class:152
ezPDFReport
Definição
compatibility.class:61
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
classes
ui
reports
mpdfreport.class
Gerado por
1.10.0