Extended the Report Engine to better support own reports
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 8 Dec 2009 20:09:23 +0000 (20:09 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 8 Dec 2009 20:09:23 +0000 (20:09 +0000)
12 files changed:
CHANGELOG.txt
reporting/fonts/courier.php [new file with mode: 0644]
reporting/fonts/symbol.php [new file with mode: 0644]
reporting/fonts/times.php [new file with mode: 0644]
reporting/fonts/timesb.php [new file with mode: 0644]
reporting/fonts/timesbi.php [new file with mode: 0644]
reporting/fonts/timesi.php [new file with mode: 0644]
reporting/fonts/zapfdingbats.php [new file with mode: 0644]
reporting/includes/class.pdf.inc
reporting/includes/excel_report.inc
reporting/includes/pdf_report.inc
reporting/includes/tcpdf.php

index cc555176e35f3a3abb3555158d44b4bc3a57dc9e..4994d4499ddf7ee7115c42309440f0c0df0da163 100644 (file)
@@ -19,6 +19,20 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+08-Dec-2009 Tom Hallman/Joe Hunt
++ Extended the Report Engine to better support own reports
+$ /reporting/includes/class.pdf.inc
+  /reporting/includes/excel_report.inc
+  /reporting/includes/pdf_report.inc
+  /reporting/includes/tcpdf.php
+  /reporting/fonts/courier.php (new file)
+  /reporting/fonts/times.php (new file)
+  /reporting/fonts/timesb.php (new file)
+  /reporting/fonts/timesbi.php (new file)
+  /reporting/fonts/timesi.php (new file)
+  /reporting/fonts/symbol.php (new file)
+  /reporting/fonts/zapfdingbats.php (new file)
+  
 07-Dec-2009 Joe Hunt
 ! Providing use of alternative providers for exchange rates.
 $ /gl/includes/db/gl_db_rates.inc
diff --git a/reporting/fonts/courier.php b/reporting/fonts/courier.php
new file mode 100644 (file)
index 0000000..1ce3afc
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=600;
+$cw=array(0=>600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600,
+10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600,
+20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600,
+30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600,
+40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600,
+50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600,
+60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600,
+70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600,
+80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600,
+90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600,
+100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600,
+109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600,
+118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600,
+127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600,
+136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600,
+145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600,
+154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600,
+163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600,
+172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600,
+181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600,
+190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600,
+199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600,
+208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600,
+217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600,
+226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600,
+235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600,
+244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600,
+253=>600,254=>600,255=>600);
+?>
diff --git a/reporting/fonts/symbol.php b/reporting/fonts/symbol.php
new file mode 100644 (file)
index 0000000..9068a79
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=500;
+$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,
+10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,
+20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,
+30=>250,31=>250,32=>250,33=>333,34=>713,35=>500,36=>549,37=>833,38=>778,39=>439,
+40=>333,41=>333,42=>500,43=>549,44=>250,45=>549,46=>250,47=>278,48=>500,49=>500,
+50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278,
+60=>549,61=>549,62=>549,63=>444,64=>549,65=>722,66=>667,67=>722,68=>612,69=>611,
+70=>763,71=>603,72=>722,73=>333,74=>631,75=>722,76=>686,77=>889,78=>722,79=>722,
+80=>768,81=>741,82=>556,83=>592,84=>611,85=>690,86=>439,87=>768,88=>645,89=>795,
+90=>611,91=>333,92=>863,93=>333,94=>658,95=>500,96=>500,97=>631,98=>549,99=>549,
+100=>494,101=>439,102=>521,103=>411,104=>603,105=>329,106=>603,107=>549,108=>549,
+109=>576,110=>521,111=>549,112=>549,113=>521,114=>549,115=>603,116=>439,117=>576,
+118=>713,119=>686,120=>493,121=>686,122=>494,123=>480,124=>200,125=>480,126=>549,
+127=>0,128=>0,129=>0,130=>0,131=>0,132=>0,133=>0,134=>0,135=>0,136=>0,137=>0,
+138=>0,139=>0,140=>0,141=>0,142=>0,143=>0,144=>0,145=>0,146=>0,147=>0,148=>0,
+149=>0,150=>0,151=>0,152=>0,153=>0,154=>0,155=>0,156=>0,157=>0,158=>0,159=>0,
+160=>750,161=>620,162=>247,163=>549,164=>167,165=>713,166=>500,167=>753,168=>753,
+169=>753,170=>753,171=>1042,172=>987,173=>603,174=>987,175=>603,176=>400,177=>549,
+178=>411,179=>549,180=>549,181=>713,182=>494,183=>460,184=>549,185=>549,186=>549,
+187=>549,188=>1000,189=>603,190=>1000,191=>658,192=>823,193=>686,194=>795,195=>987,
+196=>768,197=>768,198=>823,199=>768,200=>768,201=>713,202=>713,203=>713,204=>713,
+205=>713,206=>713,207=>713,208=>768,209=>713,210=>790,211=>790,212=>890,213=>823,
+214=>549,215=>250,216=>713,217=>603,218=>603,219=>1042,220=>987,221=>603,222=>987,
+223=>603,224=>494,225=>329,226=>790,227=>790,228=>786,229=>713,230=>384,231=>384,
+232=>384,233=>384,234=>384,235=>384,236=>494,237=>494,238=>494,239=>494,240=>0,
+241=>329,242=>274,243=>686,244=>686,245=>686,246=>384,247=>384,248=>384,249=>384,
+250=>384,251=>384,252=>494,253=>494,254=>494,255=>0);
+?>
diff --git a/reporting/fonts/times.php b/reporting/fonts/times.php
new file mode 100644 (file)
index 0000000..8cae5a7
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=500;
+$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,
+10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,
+20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,
+30=>250,31=>250,32=>250,33=>333,34=>408,35=>500,36=>500,37=>833,38=>778,39=>180,
+40=>333,41=>333,42=>500,43=>564,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,
+50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278,
+60=>564,61=>564,62=>564,63=>444,64=>921,65=>722,66=>667,67=>667,68=>722,69=>611,
+70=>556,71=>722,72=>722,73=>333,74=>389,75=>722,76=>611,77=>889,78=>722,79=>722,
+80=>556,81=>722,82=>667,83=>556,84=>611,85=>722,86=>722,87=>944,88=>722,89=>722,
+90=>611,91=>333,92=>278,93=>333,94=>469,95=>500,96=>333,97=>444,98=>500,99=>444,
+100=>500,101=>444,102=>333,103=>500,104=>500,105=>278,106=>278,107=>500,108=>278,
+109=>778,110=>500,111=>500,112=>500,113=>500,114=>333,115=>389,116=>278,117=>500,
+118=>500,119=>722,120=>500,121=>500,122=>444,123=>480,124=>200,125=>480,126=>541,
+127=>350,128=>500,129=>350,130=>333,131=>500,132=>444,133=>1000,134=>500,135=>500,
+136=>333,137=>1000,138=>556,139=>333,140=>889,141=>350,142=>611,143=>350,144=>350,
+145=>333,146=>333,147=>444,148=>444,149=>350,150=>500,151=>1000,152=>333,153=>980,
+154=>389,155=>333,156=>722,157=>350,158=>444,159=>722,160=>250,161=>333,162=>500,
+163=>500,164=>500,165=>500,166=>200,167=>500,168=>333,169=>760,170=>276,171=>500,
+172=>564,173=>333,174=>760,175=>333,176=>400,177=>564,178=>300,179=>300,180=>333,
+181=>500,182=>453,183=>250,184=>333,185=>300,186=>310,187=>500,188=>750,189=>750,
+190=>750,191=>444,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>889,
+199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333,
+208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>564,216=>722,
+217=>722,218=>722,219=>722,220=>722,221=>722,222=>556,223=>500,224=>444,225=>444,
+226=>444,227=>444,228=>444,229=>444,230=>667,231=>444,232=>444,233=>444,234=>444,
+235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>500,242=>500,243=>500,
+244=>500,245=>500,246=>500,247=>564,248=>500,249=>500,250=>500,251=>500,252=>500,
+253=>500,254=>500,255=>500);
+?>
diff --git a/reporting/fonts/timesb.php b/reporting/fonts/timesb.php
new file mode 100644 (file)
index 0000000..68766ca
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=500;
+$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,
+10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,
+20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,
+30=>250,31=>250,32=>250,33=>333,34=>555,35=>500,36=>500,37=>1000,38=>833,39=>278,
+40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,
+50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,
+60=>570,61=>570,62=>570,63=>500,64=>930,65=>722,66=>667,67=>722,68=>722,69=>667,
+70=>611,71=>778,72=>778,73=>389,74=>500,75=>778,76=>667,77=>944,78=>722,79=>778,
+80=>611,81=>778,82=>722,83=>556,84=>667,85=>722,86=>722,87=>1000,88=>722,89=>722,
+90=>667,91=>333,92=>278,93=>333,94=>581,95=>500,96=>333,97=>500,98=>556,99=>444,
+100=>556,101=>444,102=>333,103=>500,104=>556,105=>278,106=>333,107=>556,108=>278,
+109=>833,110=>556,111=>500,112=>556,113=>556,114=>444,115=>389,116=>333,117=>556,
+118=>500,119=>722,120=>500,121=>500,122=>444,123=>394,124=>220,125=>394,126=>520,
+127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500,
+136=>333,137=>1000,138=>556,139=>333,140=>1000,141=>350,142=>667,143=>350,144=>350,
+145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000,
+154=>389,155=>333,156=>722,157=>350,158=>444,159=>722,160=>250,161=>333,162=>500,
+163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>300,171=>500,
+172=>570,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333,
+181=>556,182=>540,183=>250,184=>333,185=>300,186=>330,187=>500,188=>750,189=>750,
+190=>750,191=>500,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>1000,
+199=>722,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389,
+208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>570,216=>778,
+217=>722,218=>722,219=>722,220=>722,221=>722,222=>611,223=>556,224=>500,225=>500,
+226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444,
+235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500,
+244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556,
+253=>500,254=>556,255=>500);
+?>
diff --git a/reporting/fonts/timesbi.php b/reporting/fonts/timesbi.php
new file mode 100644 (file)
index 0000000..e2190e0
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=500;
+$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,
+10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,
+20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,
+30=>250,31=>250,32=>250,33=>389,34=>555,35=>500,36=>500,37=>833,38=>778,39=>278,
+40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,
+50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,
+60=>570,61=>570,62=>570,63=>500,64=>832,65=>667,66=>667,67=>667,68=>722,69=>667,
+70=>667,71=>722,72=>778,73=>389,74=>500,75=>667,76=>611,77=>889,78=>722,79=>722,
+80=>611,81=>722,82=>667,83=>556,84=>611,85=>722,86=>667,87=>889,88=>667,89=>611,
+90=>611,91=>333,92=>278,93=>333,94=>570,95=>500,96=>333,97=>500,98=>500,99=>444,
+100=>500,101=>444,102=>333,103=>500,104=>556,105=>278,106=>278,107=>500,108=>278,
+109=>778,110=>556,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>556,
+118=>444,119=>667,120=>500,121=>444,122=>389,123=>348,124=>220,125=>348,126=>570,
+127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500,
+136=>333,137=>1000,138=>556,139=>333,140=>944,141=>350,142=>611,143=>350,144=>350,
+145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000,
+154=>389,155=>333,156=>722,157=>350,158=>389,159=>611,160=>250,161=>389,162=>500,
+163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>266,171=>500,
+172=>606,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333,
+181=>576,182=>500,183=>250,184=>333,185=>300,186=>300,187=>500,188=>750,189=>750,
+190=>750,191=>500,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>944,
+199=>667,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389,
+208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>570,216=>722,
+217=>722,218=>722,219=>722,220=>722,221=>611,222=>611,223=>500,224=>500,225=>500,
+226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444,
+235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500,
+244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556,
+253=>444,254=>500,255=>444);
+?>
diff --git a/reporting/fonts/timesi.php b/reporting/fonts/timesi.php
new file mode 100644 (file)
index 0000000..19a5973
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=500;
+$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,
+10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,
+20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,
+30=>250,31=>250,32=>250,33=>333,34=>420,35=>500,36=>500,37=>833,38=>778,39=>214,
+40=>333,41=>333,42=>500,43=>675,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,
+50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,
+60=>675,61=>675,62=>675,63=>500,64=>920,65=>611,66=>611,67=>667,68=>722,69=>611,
+70=>611,71=>722,72=>722,73=>333,74=>444,75=>667,76=>556,77=>833,78=>667,79=>722,
+80=>611,81=>722,82=>611,83=>500,84=>556,85=>722,86=>611,87=>833,88=>611,89=>556,
+90=>556,91=>389,92=>278,93=>389,94=>422,95=>500,96=>333,97=>500,98=>500,99=>444,
+100=>500,101=>444,102=>278,103=>500,104=>500,105=>278,106=>278,107=>444,108=>278,
+109=>722,110=>500,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>500,
+118=>444,119=>667,120=>444,121=>444,122=>389,123=>400,124=>275,125=>400,126=>541,
+127=>350,128=>500,129=>350,130=>333,131=>500,132=>556,133=>889,134=>500,135=>500,
+136=>333,137=>1000,138=>500,139=>333,140=>944,141=>350,142=>556,143=>350,144=>350,
+145=>333,146=>333,147=>556,148=>556,149=>350,150=>500,151=>889,152=>333,153=>980,
+154=>389,155=>333,156=>667,157=>350,158=>389,159=>556,160=>250,161=>389,162=>500,
+163=>500,164=>500,165=>500,166=>275,167=>500,168=>333,169=>760,170=>276,171=>500,
+172=>675,173=>333,174=>760,175=>333,176=>400,177=>675,178=>300,179=>300,180=>333,
+181=>500,182=>523,183=>250,184=>333,185=>300,186=>310,187=>500,188=>750,189=>750,
+190=>750,191=>500,192=>611,193=>611,194=>611,195=>611,196=>611,197=>611,198=>889,
+199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333,
+208=>722,209=>667,210=>722,211=>722,212=>722,213=>722,214=>722,215=>675,216=>722,
+217=>722,218=>722,219=>722,220=>722,221=>556,222=>611,223=>500,224=>500,225=>500,
+226=>500,227=>500,228=>500,229=>500,230=>667,231=>444,232=>444,233=>444,234=>444,
+235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>500,242=>500,243=>500,
+244=>500,245=>500,246=>500,247=>675,248=>500,249=>500,250=>500,251=>500,252=>500,
+253=>444,254=>500,255=>444);
+?>
diff --git a/reporting/fonts/zapfdingbats.php b/reporting/fonts/zapfdingbats.php
new file mode 100644 (file)
index 0000000..d3b7c56
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+ // core font definition file for TCPDF (www.tcpdf.org)
+$type='core';
+$dw=788;
+$cw=array(0=>0,1=>0,2=>0,3=>0,4=>0,5=>0,6=>0,7=>0,8=>0,9=>0,10=>0,11=>0,12=>0,
+13=>0,14=>0,15=>0,16=>0,17=>0,18=>0,19=>0,20=>0,21=>0,22=>0,23=>0,24=>0,25=>0,
+26=>0,27=>0,28=>0,29=>0,30=>0,31=>0,32=>278,33=>974,34=>961,35=>974,36=>980,
+37=>719,38=>789,39=>790,40=>791,41=>690,42=>960,43=>939,44=>549,45=>855,46=>911,
+47=>933,48=>911,49=>945,50=>974,51=>755,52=>846,53=>762,54=>761,55=>571,56=>677,
+57=>763,58=>760,59=>759,60=>754,61=>494,62=>552,63=>537,64=>577,65=>692,66=>786,
+67=>788,68=>788,69=>790,70=>793,71=>794,72=>816,73=>823,74=>789,75=>841,76=>823,
+77=>833,78=>816,79=>831,80=>923,81=>744,82=>723,83=>749,84=>790,85=>792,86=>695,
+87=>776,88=>768,89=>792,90=>759,91=>707,92=>708,93=>682,94=>701,95=>826,96=>815,
+97=>789,98=>789,99=>707,100=>687,101=>696,102=>689,103=>786,104=>787,105=>713,
+106=>791,107=>785,108=>791,109=>873,110=>761,111=>762,112=>762,113=>759,114=>759,
+115=>892,116=>892,117=>788,118=>784,119=>438,120=>138,121=>277,122=>415,123=>392,
+124=>392,125=>668,126=>668,127=>0,128=>390,129=>390,130=>317,131=>317,132=>276,
+133=>276,134=>509,135=>509,136=>410,137=>410,138=>234,139=>234,140=>334,141=>334,
+142=>0,143=>0,144=>0,145=>0,146=>0,147=>0,148=>0,149=>0,150=>0,151=>0,152=>0,
+153=>0,154=>0,155=>0,156=>0,157=>0,158=>0,159=>0,160=>0,161=>732,162=>544,163=>544,
+164=>910,165=>667,166=>760,167=>760,168=>776,169=>595,170=>694,171=>626,172=>788,
+173=>788,174=>788,175=>788,176=>788,177=>788,178=>788,179=>788,180=>788,181=>788,
+182=>788,183=>788,184=>788,185=>788,186=>788,187=>788,188=>788,189=>788,190=>788,
+191=>788,192=>788,193=>788,194=>788,195=>788,196=>788,197=>788,198=>788,199=>788,
+200=>788,201=>788,202=>788,203=>788,204=>788,205=>788,206=>788,207=>788,208=>788,
+209=>788,210=>788,211=>788,212=>894,213=>838,214=>1016,215=>458,216=>748,217=>924,
+218=>748,219=>918,220=>927,221=>928,222=>928,223=>834,224=>873,225=>828,226=>924,
+227=>924,228=>917,229=>930,230=>931,231=>463,232=>883,233=>836,234=>836,235=>867,
+236=>867,237=>696,238=>696,239=>874,240=>0,241=>874,242=>760,243=>946,244=>771,
+245=>865,246=>771,247=>888,248=>967,249=>888,250=>831,251=>873,252=>927,253=>970,
+254=>918,255=>0);
+?>
index 0fd5aedc39b6948c16e49fa7da9dde2fba7e0aed..6eae796133ea9faa3a08533a60321a46a231e93c 100644 (file)
@@ -62,7 +62,7 @@ include_once (dirname(__FILE__).'/tcpdf.php');
 
 class Cpdf extends TCPDF {
 
-       function Cpdf($pageSize='A4', $l=array())
+       function Cpdf($pageSize='A4', $l=array(), $pageOrientation='P')
        {
                if (!isset($l['a_meta_charset']))
                        $l = array('a_meta_charset' => 'ISO-8859-1', 'a_meta_dir' => 'ltr', 'a_meta_language' => 'en_GB', 'w_page' => 'page');
@@ -70,7 +70,7 @@ class Cpdf extends TCPDF {
                $uni = ($enc == 'UTF-8' || $enc == 'GB2312' ? true : false);
                if ($uni)
                        ini_set("memory_limit", "48M");
-               $this->TCPDF('P', 'pt', $pageSize, $uni, $enc);
+               $this->TCPDF($pageOrientation, 'pt', $pageSize, $uni, $enc);
                $this->setLanguageArray($l);
                $this->setPrintHeader(false);
                $this->setPrintFooter(false);
@@ -82,16 +82,31 @@ class Cpdf extends TCPDF {
                $this->cMargin = 0;
        }
 
-       function selectFont($fontname, $style='')
+       // $fontname should be a standard PDF font (like 'times', 'helvetica' or 'courier')
+       // or one that's been installed on your system.  An empty string can also be used
+       // which will retain the font currently in use.
+       // $style is either:
+       //   * a special case string:
+       //     * bold
+       //     * italic
+       //   * or a case-insensitive string where each char represents a style choice
+       // and you can use more than one or none at all.  Possible choices:
+       //      * empty string: regular
+    //      * B: bold
+    //      * I: italic
+    //      * U: underline
+    //      * D: line trough (aka "strike through")
+       function selectFont($fontname, $style = '')
        {
-               if ($fontname != '')
-                       $fontname = basename($fontname);
+               // Parse the style - check for special cases, otherwise leave as-is
                if ($style == 'italic')
-                       $type = 'i';
+                       $style = 'i';
                elseif ($style == 'bold')
-                       $type = 'b';
-               else
-                       $type = '';
+                       $style = 'b';
+
+               // Parse the fontname
+               if ($fontname != '')
+                       $fontname = basename($fontname);
                if ($fontname == '')
                {
                        if ($this->isunicode)
@@ -120,7 +135,7 @@ class Cpdf extends TCPDF {
                        }
                        // else use built-in adobe fonts helvetica.
                }
-               $this->SetFont($fontname, $type);
+               $this->SetFont($fontname, $style);
        }
 
        function Header1()
@@ -133,17 +148,17 @@ class Cpdf extends TCPDF {
 
        function newPage()
        {
-               TCPDF::AddPage();
+               parent::AddPage();
        }
 
-       function line($x1,$y1,$x2,$y2)
+       function line($x1,$y1,$x2,$y2, $style = array())
        {
-               TCPDF::line($x1, $this->h-$y1, $x2, $this->h-$y2);
+               parent::Line($x1, $this->h-$y1, $x2, $this->h-$y2, $style);
        }
 
        function rectangle($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array())
        {
-               TCPDF::Rect($x, $this->h-$y, $w, $h, $style, $border_style, $fill_color);
+               parent::Rect($x, $this->h-$y, $w, $h, $style, $border_style, $fill_color);
        }
 
 
@@ -211,12 +226,12 @@ class Cpdf extends TCPDF {
        */
        function ellipse($x0,$y0,$r1,$r2=0,$angle=0,$nSeg=8,$astart=0,$afinish=360,$close=1,$fill=0)
        {
-               TCPDF::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg);
+               parent::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg);
        }
 
        function Stream()
        {
-               TCPDF::Output('', 'I');
+               parent::Output('', 'I');
        }
 
        function calcTextWrap($txt, $width, $spacebreak=false)
@@ -243,7 +258,7 @@ class Cpdf extends TCPDF {
                return array($txt2, $ret);
        }
 
-       function addTextWrap($xb, $yb, $w, $h, $txt, $align='left', $border=0, $fill=0, $spacebreak=false)
+       function addTextWrap($xb, $yb, $w, $h, $txt, $align='left', $border=0, $fill=0, $link = NULL, $stretch = 0, $spacebreak=false)
        {
                $ret = "";
                if (!$this->rtl)
@@ -252,47 +267,35 @@ class Cpdf extends TCPDF {
                                $align = 'R';
                        elseif ($align == 'left')
                                $align = 'L';
+                       elseif ($align == 'center')
+                               $align = 'C';
+                       elseif ($align == 'justify')
+                               $align = 'J';
                }
                else
                        $align = 'R';
-               $txt = $this->calcTextWrap($txt, $w, $spacebreak);
+
+               // If horizontal scaling was requested, check to see if we're trying to scale
+               // too much.  If so, cut back string first and then scale it.
+               $maxScaleFactor = 1.4;
+               if ($stretch == 1 || $stretch == 2)
+               $txt = $this->calcTextWrap($txt, $w * $maxScaleFactor, $spacebreak);
+               // Wrap text if stretching isn't turned on
+               else
+               $txt = $this->calcTextWrap($txt, $w, $spacebreak);
                $ret = $txt[1];
                $txt = $txt[0];
                $this->SetXY($xb, $this->h - $yb - $h);
-               $txt = TCPDF::unhtmlentities($txt);
+               $txt = parent::unhtmlentities($txt);
                if ($this->isunicode && $this->encoding != "UTF-8")
                        $txt = iconv($this->encoding, "UTF-8", $txt);
-               $this->Cell($w, $h, $txt, $border, 0, $align, $fill);
+               $this->Cell($w, $h, $txt, $border, 0, $align, $fill, $link, $stretch);
                return $ret;
        }
-/**
-* sets the colour for stroke operations
-*/
-    function setStrokeColor($r,$g,$b,$force=0)
-    {
-        TCPDF::SetDrawColor($r,$g,$b);
-    }
-/**
-* this sets the line drawing style.
-* width, is the thickness of the line in user units
-* cap is the type of cap to put on the line, values can be 'butt','round','square'
-*    where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the
-*    end of the line.
-* join can be 'miter', 'round', 'bevel'
-* dash is an array which sets the dash pattern, is a series of length values, which are the lengths of the
-*   on and off dashes.
-*   (2) represents 2 on, 2 off, 2 on , 2 off ...
-*   (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
-* phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts.
-*/
-       function setLineStyle($width=1,$cap='',$join='',$dash='',$phase=0)
-       {
-               $this->SetLineWidth($width);
-       }
 
        function Text($x, $y, $txt, $stroke=0, $clip=false)
        {
-               TCPDF::Text($x,$y, TCPDF::unhtmlentities($txt), $stroke, $clip);
+               parent::Text($x,$y, parent::unhtmlentities($txt), $stroke, $clip);
        }
 
 } // end of class
index fb7ed1be71b04b370e26c1d26eefa4e53c96a073..dde397bd8d9764bd64060c303fdd221220f26151 100644 (file)
@@ -42,7 +42,8 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
        var $row = 9999999;
        var $y;
        var $numcols;
-       
+       var $excelColWidthFactor;
+
        var $formatTitle;
        var $formatDateTime;
        var $formatDate;
@@ -53,7 +54,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
        
        var $sheet;
 
-       function FrontReport($title, $filename, $size = 'A4', $fontsize = 9)
+       function FrontReport($title, $filename, $size = 'A4', $fontsize = 9, $orientation = 'P', $margins = NULL, $excelColWidthFactor = 6.5)
        {
                global $comp_path, $dateseps, $page_security;
                if (!$_SESSION["wa_current_user"]->can_access_page($page_security))
@@ -69,6 +70,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $this->oldFontSize = 0;
                $this->y = 1;
                $this->currency = '';
+               $this->excelColWidthFactor = $excelColWidthFactor;
                $rtl = ($_SESSION['language']->dir == 'rtl');
                $this->code = strtolower($_SESSION['language']->encoding);
                $this->filename = $filename.".xls";
@@ -78,7 +80,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                //$this->setCountry(48);
                if ($this->code != "iso-8859-1")
                        $this->setVersion(8); // set biff version to 8 (0x0006 internal)
-               $this->sheet =& $this->addWorksheet($this->title);
+               $this->sheet =& $this->addWorksheet($this->worksheetNameGenerator($this->title));
                if ($this->code != "iso-8859-1")
                        $this->sheet->setInputEncoding($this->code); // set sheet encoding
                if ($rtl)
@@ -127,6 +129,16 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $this->formatHeaderLeft->setBottom(2);
                $this->formatHeaderLeft->setBottomColor('gray');
                $this->formatHeaderLeft->setAlign('vcenter');
+               $this->formatTopHeaderLeft =& $this->addFormat();
+               $this->formatTopHeaderLeft->setItalic();
+               $this->formatTopHeaderLeft->setTop(2);
+               $this->formatTopHeaderLeft->setTopColor('gray');
+               $this->formatTopHeaderLeft->setAlign('vcenter');
+               $this->formatBottomHeaderLeft =& $this->addFormat();
+               $this->formatBottomHeaderLeft->setItalic();
+               $this->formatBottomHeaderLeft->setBottom(2);
+               $this->formatBottomHeaderLeft->setBottomColor('gray');
+               $this->formatBottomHeaderLeft->setAlign('vcenter');
                $this->formatDate->setAlign($rtl ? 'right' : 'left');
                $this->formatHeaderRight =& $this->addFormat();
                $this->formatHeaderRight->setItalic();
@@ -136,11 +148,38 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $this->formatHeaderRight->setBottomColor('gray');
                $this->formatHeaderRight->setAlign('vcenter');
                $this->formatHeaderRight->setAlign('right');
+               $this->formatTopHeaderRight =& $this->addFormat();
+               $this->formatTopHeaderRight->setItalic();
+               $this->formatTopHeaderRight->setTop(2);
+               $this->formatTopHeaderRight->setTopColor('gray');
+               $this->formatTopHeaderRight->setAlign('vcenter');
+               $this->formatTopHeaderRight->setAlign('right');
+               $this->formatBottomHeaderRight =& $this->addFormat();
+               $this->formatBottomHeaderRight->setItalic();
+               $this->formatBottomHeaderRight->setBottom(2);
+               $this->formatBottomHeaderRight->setBottomColor('gray');
+               $this->formatBottomHeaderRight->setAlign('vcenter');
+               $this->formatBottomHeaderRight->setAlign('right');
                $this->formatFooter =& $this->addFormat();
                $this->formatFooter->setTop(2);
                $this->formatFooter->setTopColor('gray');
        }
        
+
+       // Check a given name to see if it's a valid Excel worksheet name,
+       // and fix if necessary
+       function worksheetNameGenerator($name)
+       {
+               // First, strip out characters which aren't allowed
+               $illegal_chars = array(':', '\\', '/', '?', '*', '[', ']');
+               for ($i = 0; $i < count($illegal_chars); $i++)
+                       $name = str_replace($illegal_chars[$i], '', $name);
+               // Now, if name is longer than 31 chars, truncate it
+               if (strlen($name) > 31)
+                       $name = substr($name, 0, 31);
+               return $name;
+       }
+       
        function NumFormat($dec) 
        {
                if (!isset($this->formatAmount[$dec]))
@@ -161,7 +200,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                return $this->formatAmount[$dec];
        }
 
-       function Font($style = 'normal')
+       function Font($fontname = '', $style = 'normal')
        {
        }
 
@@ -278,6 +317,168 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                return;
        }
 
+       // Alternate header style - primary differences are for PDFs
+       function Header3()
+       {
+               // Flag to make sure we only print the company name once
+               $companyNamePrinted = false;
+               
+               $this->y = 0;
+               $tcol = $this->numcols - 1;
+               $this->sheet->setRow($this->y, 20);
+               // Title
+               for ($i = 0; $i < $this->numcols; $i++)
+                       $this->sheet->writeBlank($this->y, $i, $this->formatTitle);
+               $this->sheet->writeString($this->y, 0, $this->title, $this->formatTitle);
+               $this->sheet->mergeCells($this->y, 0, $this->y, $tcol);
+
+               // Dimension 1 - optional
+               // - only print if available and not blank
+               if (count($this->params) > 3)
+                       if ($this->params[3]['from'] != '')
+                       {
+                               $this->NewLine();
+                               $str = $this->params[3]['text'] . ':';
+                               $this->sheet->writeString($this->y, 0, $str, $this->formatLeft);
+                               $this->sheet->writeString($this->y, 1, $this->params[3]['from'], $this->formatLeft);
+                               // Company Name - at end of this row
+                               if (!$companyNamePrinted)
+                               {
+                                       $this->sheet->writeString($this->y, $tcol-1, $this->company['coy_name'], $this->formatLeft);
+                                       $this->sheet->mergeCells($this->y, $tcol-1, $this->y, $tcol);
+                                       $companyNamePrinted = true;
+                               }
+                       }
+
+
+               // Dimension 2 - optional
+               // - only print if available and not blank
+               if (count($this->params) > 4)
+                       if ($this->params[4]['from'] != '')
+                       {
+                               $this->NewLine();
+                               $str = $this->params[4]['text'] . ':';
+                               $this->sheet->writeString($this->y, 0, $str, $this->formatLeft);
+                               $this->sheet->writeString($this->y, 1, $this->params[4]['from'], $this->formatLeft);
+                               // Company Name - at end of this row
+                               if (!$companyNamePrinted)
+                               {
+                                       $this->sheet->writeString($this->y, $tcol-1, $this->company['coy_name'], $this->formatLeft);
+                                       $this->sheet->mergeCells($this->y, $tcol-1, $this->y, $tcol);
+                                       $companyNamePrinted = true;
+                               }
+                       }
+                       
+               // Tags - optional
+               // TBD!!!               
+       
+               // Report Date - time period covered
+               // - can specify a range, or just the end date (and the report contents
+               //   should make it obvious what the beginning date is)
+               $this->NewLine();
+               $str = _("Report Date") . ':';
+               $this->sheet->writeString($this->y, 0, $str, $this->formatLeft);
+               $str = '';
+               if ($this->params[1]['from'] != '')
+                       $str = $this->params[1]['from'] . ' - ';
+               $str .= $this->params[1]['to'];
+               $this->sheet->writeString($this->y, 1, $str, $this->formatLeft);
+               // Company Name - at end of this row
+               if (!$companyNamePrinted)
+               {
+                       $this->sheet->writeString($this->y, $tcol-1, $this->company['coy_name'], $this->formatLeft);
+                       $this->sheet->mergeCells($this->y, $tcol-1, $this->y, $tcol);
+                       $companyNamePrinted = true;
+               }
+                       
+               // Timestamp of when this copy of the report was generated 
+               $this->NewLine();
+               $str = _("Generated At") . ':';
+               $this->sheet->writeString($this->y, 0, $str, $this->formatLeft);
+               $this->sheet->writeString($this->y, 1, Today() . "  ".Now(), $this->formatLeft);
+
+               // Name of the user that generated this copy of the report
+               $this->NewLine();
+               $str = _("Generated By") . ':';
+               $this->sheet->writeString($this->y, 0, $str, $this->formatLeft);
+               $str = $this->user;
+               $this->sheet->writeString($this->y, 1, $str, $this->formatLeft);
+
+               // Comments - display any user-generated comments for this copy of the report
+               if ($this->params[0] != '')
+               {
+                       $this->NewLine();
+                       $str = _("Comments") . ':';
+                       $this->sheet->writeString($this->y, 0, $str, $this->formatLeft);
+                       $this->sheet->writeString($this->y, 1, $this->params[0], $this->formatLeft);
+               }
+               $this->NewLine();
+
+               if ($this->headers2 != null)
+               {
+                       for ($i = 0, $j = 0; $i < $this->numcols; $i++)
+                       {
+                               if ($this->cols2[$j] >= $this->cols[$i] && $this->cols2[$j] <= $this->cols[$i + 1])
+                               {
+                                       if ($this->aligns2[$j] == "right")
+                                               $this->sheet->writeString($this->y, $i, $this->headers2[$j], $this->formatTopHeaderRight);
+                                       else    
+                                               $this->sheet->writeString($this->y, $i, $this->headers2[$j], $this->formatTopHeaderLeft);
+                                       $j++;   
+                               }
+                               else
+                                       $this->sheet->writeString($this->y, $i, "", $this->formatTopHeaderLeft);
+                       }               
+                       $this->NewLine();
+               }
+
+               for ($i = 0; $i < $this->numcols; $i++)
+               {
+                       if (!isset($this->headers[$i]))
+                               $header = "";
+                       else
+                               $header = $this->headers[$i];
+                       if ($this->aligns[$i] == "right")
+                               if ($this->headers2 == null)
+                                       $this->sheet->writeString($this->y, $i, $header, $this->formatHeaderRight);
+                               else
+                                       $this->sheet->writeString($this->y, $i, $header, $this->formatBottomHeaderRight);
+                       else    
+                               if ($this->headers2 == null)
+                                       $this->sheet->writeString($this->y, $i, $header, $this->formatHeaderLeft);
+                               else
+                                       $this->sheet->writeString($this->y, $i, $header, $this->formatBottomHeaderLeft);
+               }
+               $this->NewLine();
+       }
+
+       /**
+        * Format a numeric string date into something nicer looking.
+        *
+        * @param string $date Date string to be formatted.
+        * @param int $input_format Format of the input string.  Possible values are:<ul><li>0: user's default (default)</li></ul>
+        * @param int $output_format Format of the output string.  Possible values are:<ul><li>0: Month (word) Day (numeric), 4-digit Year - Example: January 1, 2000 (default)</li><li>1: Month 4-digit Year - Example: January 2000</li><li>2: Month Abbreviation 4-digit Year - Example: Jan 2000</li></ul>
+        * @access public
+        */
+       function DatePrettyPrint($date, $input_format = 0, $output_format = 0)
+       {
+               if ($date != '')
+               {
+                       $date = date2sql($date);
+                       $year = (int) (substr($date, 0, 4));
+                       $month = (int) (substr($date, 5, 2));
+                       $day = (int) (substr($date, 8, 2));
+                       if ($output_format == 0)
+                               return(date('F j, Y', mktime(12, 0, 0, $month, $day, $year)));
+                       elseif ($output_format == 1)
+                               return(date('F Y', mktime(12, 0, 0, $month, $day, $year)));
+                       elseif ($output_format == 2)
+                               return(date('M Y', mktime(12, 0, 0, $month, $day, $year)));
+               }
+               else
+                       return $date;
+       }
+               
        function AddImage($logo, $x, $y, $w, $h)
        {
                return;
@@ -293,17 +494,32 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                return;
        }
 
-       function Text($c, $txt, $n=0, $corr=0, $r=0)
+       function SetFillColor($r, $g, $b)
+       {
+               return;
+       }
+       
+       function GetCellPadding()
+       {
+               return 0;
+       }
+       
+       function SetCellPadding($pad)
+       {
+               return;
+       }
+       
+       function Text($c, $txt, $n=0, $corr=0, $r=0, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                return;
        }
 
-       function TextWrap($xpos, $ypos, $len, $str, $align = 'left')
+       function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 0)
        {
                return;
        }
 
-       function TextCol($c, $n, $txt, $corr=0, $r=0)
+       function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                if ($this->aligns[$c] == 'right')
                        $this->sheet->writeString($this->y, $c, $txt, $this->formatRight);
@@ -313,14 +529,21 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                        $this->sheet->mergeCells($this->y, $c, $this->y, $n - 1);
        }
 
-       function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0) 
+       function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) 
+       { 
+               if (!is_numeric($txt))
+                       $txt = 0;
+               $this->sheet->writeNumber($this->y, $c, $txt, $this->NumFormat($dec)); 
+       }
+       
+       function AmountCol2($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $amount_locale = NULL, $amount_format = NULL) 
        { 
                if (!is_numeric($txt))
                        $txt = 0;
                $this->sheet->writeNumber($this->y, $c, $txt, $this->NumFormat($dec)); 
        }
        
-       function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0) 
+       function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0
        {
                if (!$conv)
                        $txt = date2sql($txt);
@@ -329,23 +552,62 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $this->sheet->writeNumber($this->y, $c, $date, $this->formatDate);
        }
 
-       function TextCol2($c, $n, $txt, $corr=0, $r=0)
+       function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                $this->sheet->writeString($this->y, $c, $txt, $this->formatLeft);
                if ($n - $c > 1)
                        $this->sheet->mergeCells($this->y, $c, $this->y, $n - 1);
        }
 
-       function TextColLines($c, $n, $txt, $corr=0, $r=0)
+       function TextColLines($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                return;
        }
 
-       function TextWrapLines($c, $width, $txt, $align='left')
+       function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                return;
        }
 
+       /**
+        * Crude text wrap calculator based on PDF version.
+        */
+       function TextWrapCalc($txt, $width, $spacebreak=false)
+       {
+               // Assume an average character width
+               $avg_char_width = 5;
+               $ret = "";
+               $txt2 = $txt;
+               $w = strlen($txt) * $avg_char_width;
+               if ($w > $width && $w > 0 && $width != 0)
+               {
+                       $n = strlen($txt);
+                       $k = intval($n * $width / $w);
+                       if ($k > 0 && $k < $n)
+                       {
+                               $txt2 = substr($txt, 0, $k);
+                               if ($spacebreak && (($pos = strrpos($txt2, " ")) !== false))
+                               {
+                                       $txt2 = substr($txt2, 0, $pos);
+                                       $ret = substr($txt, $pos+1);
+                               }
+                               else
+                                       $ret = substr($txt, $k);
+                       }
+               }
+               return array($txt2, $ret);
+       }
+
+       function SetLineStyle($style)
+       {
+               return;
+       }
+
+       function SetLineWidth($width)
+       {
+               return;
+       }
+       
        function LineTo($from, $row, $to, $row2)
        {
                return;
@@ -356,7 +618,12 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                return;
        }
 
-       function NewLine($l=1, $np=0)
+       function UnderlineCell($c, $r = 0, $type = 1, $linewidth = 0, $style = array())
+       {
+               return;
+       }
+       
+       function NewLine($l=1, $np=0, $h=NULL)
        {
                $this->y += $l;
        }
@@ -397,7 +664,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
        function px2units($px) // XLS app conversion. Not bulletproof.
        {
                $excel_column_width_factor = 256;
-               $unit_offset_length = 6.5;
+               $unit_offset_length = $this->excelColWidthFactor;
                return ($px / $unit_offset_length);
        }       
 
index 944b4c28509d38ba5078e93ddbbd7a26e6d57d13..2e1654d192390b9d57fa841e2a7c1fd8afcdf23e 100644 (file)
@@ -41,14 +41,16 @@ class FrontReport extends Cpdf
        var $headers2;
        var $aligns2;
        var $cols2;
-       var $companyCol;
-       var $titleCol;
        var $pageNumber;
        var $fontSize;
        var $oldFontSize;
        var $currency;
+       var $companyLogoEnable;  // select whether to use a company logo graphic in some header templates
+       var $footerEnable;  // select whether to print a page footer or not
+       var $footerText;  // store user-generated footer text
+       var $headerFunc;  // store the name of the currently selected header function
 
-       function FrontReport($title, $filename, $size = 'A4', $fontsize = 9)
+       function FrontReport($title, $filename, $size = 'A4', $fontsize = 9, $orientation = 'P', $margins = NULL, $excelColWidthFactor = NULL)
        {
                global $page_security;
                if (!$_SESSION["wa_current_user"]->can_access_page($page_security))
@@ -57,74 +59,131 @@ class FrontReport extends Cpdf
                        end_page();
                        exit;
                }
-               switch ($size)
+               // Page margins - if user-specified, use those.  Otherwise, use defaults below.
+               if (isset($margins))
+               {
+                       $this->topMargin = $margins['top'];
+                       $this->bottomMargin = $margins['bottom'];
+                       $this->leftMargin = $margins['left'];
+                       $this->rightMargin = $margins['right'];
+               }
+               // Page orientation - P: portrait, L: landscape
+               $orientation = strtoupper($orientation);
+               // Page size name
+               switch (strtoupper($size))
                {
                        default:
                  case 'A4':
-                 case 'a4':
-                         $this->pageWidth=595;
-                         $this->pageHeight=842;
-                         $this->topMargin=40;
-                         $this->bottomMargin=30;
-                         $this->leftMargin=40;
-                         $this->rightMargin=30;
-                         break;
-                 case 'A4_Landscape':
-                         $this->pageWidth=842;
-                         $this->pageHeight=595;
-                         $this->topMargin=30;
-                         $this->bottomMargin=30;
-                         $this->leftMargin=40;
-                         $this->rightMargin=30;
+                         // Portrait
+                         if ($orientation == 'P')
+                         {
+                                 $this->pageWidth=595;
+                                 $this->pageHeight=842;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=40;
+                                         $this->bottomMargin=30;
+                                         $this->leftMargin=40;
+                                         $this->rightMargin=30;
+                                 }
+                         }
+                         // Landscape
+                         else
+                         {
+                                 $this->pageWidth=842;
+                                 $this->pageHeight=595;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=30;
+                                         $this->bottomMargin=30;
+                                         $this->leftMargin=40;
+                                         $this->rightMargin=30;
+                                 }
+                         }
                          break;
                   case 'A3':
-                         $this->pageWidth=842;
-                         $this->pageHeight=1190;
-                         $this->topMargin=50;
-                         $this->bottomMargin=50;
-                         $this->leftMargin=50;
-                         $this->rightMargin=40;
-                         break;
-                  case 'A3_landscape':
-                         $this->pageWidth=1190;
-                         $this->pageHeight=842;
-                         $this->topMargin=50;
-                         $this->bottomMargin=50;
-                         $this->leftMargin=50;
-                         $this->rightMargin=40;
+                         // Portrait
+                         if ($orientation == 'P')
+                         {
+                                 $this->pageWidth=842;
+                                 $this->pageHeight=1190;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=50;
+                                         $this->bottomMargin=50;
+                                         $this->leftMargin=50;
+                                         $this->rightMargin=40;
+                                 }
+                         }
+                         // Landscape
+                         else
+                         {
+                                 $this->pageWidth=1190;
+                                 $this->pageHeight=842;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=50;
+                                         $this->bottomMargin=50;
+                                         $this->leftMargin=50;
+                                         $this->rightMargin=40;
+                                 }
+                         }
                          break;
-                  case 'letter':
-                  case 'Letter':
-                         $this->pageWidth=612;
-                         $this->pageHeight=792;
-                         $this->topMargin=30;
-                         $this->bottomMargin=30;
-                         $this->leftMargin=30;
-                         $this->rightMargin=25;
+                  case 'LETTER':
+                         // Portrait
+                         if ($orientation == 'P')
+                         {
+                                 $this->pageWidth=612;
+                                 $this->pageHeight=792;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=30;
+                                         $this->bottomMargin=30;
+                                         $this->leftMargin=30;
+                                         $this->rightMargin=25;
+                                 }
+                         }
+                         // Landscape
+                         else
+                         {
+                                 $this->pageWidth=792;
+                                 $this->pageHeight=612;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=30;
+                                         $this->bottomMargin=30;
+                                         $this->leftMargin=30;
+                                         $this->rightMargin=25;
+                                 }
+                         }
                          break;
-                  case 'letter_landscape':
-                         $this->pageWidth=792;
-                         $this->pageHeight=612;
-                         $this->topMargin=30;
-                         $this->bottomMargin=30;
-                         $this->leftMargin=30;
-                         $this->rightMargin=25;
-                         break;
-                  case 'legal':
-                         $this->pageWidth=612;
-                         $this->pageHeight=1008;
-                         $this->topMargin=50;
-                         $this->bottomMargin=40;
-                         $this->leftMargin=30;
-                         $this->rightMargin=25;
-                         break;
-                  case 'legal_landscape':
-                         $this->pageWidth=1008;
-                         $this->pageHeight=612;
-                         $this->topMargin=50;
-                         $this->bottomMargin=40;
-                         $this->leftMargin=30;
-                         $this->rightMargin=25;
+                  case 'LEGAL':
+                         // Portrait
+                         if ($orientation == 'P')
+                         {
+                                 $this->pageWidth=612;
+                                 $this->pageHeight=1008;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=50;
+                                         $this->bottomMargin=40;
+                                         $this->leftMargin=30;
+                                         $this->rightMargin=25;
+                                 }
+                         }
+                         // Landscape
+                         else
+                         {
+                                 $this->pageWidth=1008;
+                                 $this->pageHeight=612;
+                                 if (!isset($margins))
+                                 {
+                                         $this->topMargin=50;
+                                         $this->bottomMargin=40;
+                                         $this->leftMargin=30;
+                                         $this->rightMargin=25;
+                                 }
+                         }
                          break;
                }
                $this->size = array(0, 0, $this->pageWidth, $this->pageHeight);
@@ -132,28 +191,48 @@ class FrontReport extends Cpdf
                $this->filename = $filename.".pdf";
                $this->pageNumber = 0;
                $this->endLine = $this->pageWidth - $this->rightMargin;
-               $this->companyCol = $this->endLine - 150;
-               $this->titleCol = $this->leftMargin + 100;
                $this->lineHeight = 12;
                $this->fontSize = $fontsize;
                $this->oldFontSize = 0;
                $this->row = $this->pageHeight - $this->topMargin;
                $this->currency = '';
+               $this->headerFunc = 'Header';  // default to the original header template
                $rtl = ($_SESSION['language']->dir === 'rtl' ? 'rtl' : 'ltr');
                $code = $_SESSION['language']->code;
                $enc = strtoupper($_SESSION['language']->encoding);
                // for the language array in class.pdf.inc
                $l = array('a_meta_charset' => $enc, 'a_meta_dir' => $rtl, 'a_meta_language' => $code, 'w_page' => 'page');
-               $this->Cpdf($size, $l);
+               $this->Cpdf($size, $l, $orientation);
        }
 
-       function Font($style = 'normal')
+       /*
+        * Select the font and style to use for following output until
+        * it's changed again.
+        * 
+        * $style is either:
+        *   * a special case string (for backwards compatible with older code):
+        *     * bold
+        *     * italic
+        *   * or a case-insensitive string where each char represents a style choice
+        *     and you can use more than one or none at all.  Possible choices:
+        *      * empty string: regular
+     *      * B: bold
+     *      * I: italic
+     *      * U: underline
+     *      * D: line trough (aka "strike through")
+        * $fontname should be a standard PDF font (like 'times', 'helvetica' or 'courier')
+        *   or one that's been installed on your system (see TCPDF docs for details).
+        *   An empty string can also be used which will retain the font currently in use if
+        *   you just want to change the style.
+        */
+       function Font($style = '', $fontname = '')
        {
-               $this->selectFont("", $style);
+               $this->selectFont($fontname, $style);
        }
 
        function Info($params, $cols, $headers, $aligns,
-               $cols2 = null, $headers2 = null, $aligns2 = null)
+               $cols2 = null, $headers2 = null, $aligns2 = null,
+               $companylogoenable = false, $footerenable = false, $footertext = '')
        {
                global $app_title, $version, $power_by, $power_url;
 
@@ -184,10 +263,20 @@ class FrontReport extends Cpdf
                }
                $this->headers2 = $headers2;
                $this->aligns2 = $aligns2;
+
+               // Set whether to display company logo in some header templates
+               $this->companyLogoEnable = $companylogoenable;
+               
+               // Store footer settings
+               $this->footerEnable = $footerenable;
+               $this->footerText = $footertext;        
        }
 
        function Header()
        {
+               $companyCol = $this->endLine - 150;
+               $titleCol = $this->leftMargin + 100;
+
                $this->pageNumber++;
                if ($this->pageNumber > 1)
                        $this->newPage();
@@ -200,46 +289,46 @@ class FrontReport extends Cpdf
 
                $this->fontSize += 4;
                $this->Font('bold');
-               $this->Text($this->leftMargin, $this->title, $this->companyCol);
+               $this->Text($this->leftMargin, $this->title, $companyCol);
                $this->Font();
                $this->fontSize -= 4;
-               $this->Text($this->companyCol, $this->company['coy_name']);
+               $this->Text($companyCol, $this->company['coy_name']);
                $this->row -= ($this->lineHeight + 4);
 
                $str = _("Print Out Date") . ':';
-               $this->Text($this->leftMargin, $str, $this->titleCol);
+               $this->Text($this->leftMargin, $str, $titleCol);
                $str = Today() . '   ' . Now();
                if ($this->company['time_zone'])
                        $str .= ' ' . date('O') . ' GMT';
-               $this->Text($this->titleCol, $str, $this->companyCol);
-               $this->Text($this->companyCol, $this->host);
+               $this->Text($titleCol, $str, $companyCol);
+               $this->Text($companyCol, $this->host);
 
                $this->NewLine();
                $str = _("Fiscal Year") . ':';
-               $this->Text($this->leftMargin, $str, $this->titleCol);
+               $this->Text($this->leftMargin, $str, $titleCol);
                $str = $this->fiscal_year;
-               $this->Text($this->titleCol, $str, $this->companyCol);
-               $this->Text($this->companyCol, $this->user);
+               $this->Text($titleCol, $str, $companyCol);
+               $this->Text($companyCol, $this->user);
                for ($i = 1; $i < count($this->params); $i++)
                {
                        if ($this->params[$i]['from'] != '')
                        {
                                $this->NewLine();
                                $str = $this->params[$i]['text'] . ':';
-                               $this->Text($this->leftMargin, $str, $this->titleCol);
+                               $this->Text($this->leftMargin, $str, $titleCol);
                                $str = $this->params[$i]['from'];
                                if ($this->params[$i]['to'] != '')
                                        $str .= " - " . $this->params[$i]['to'];
-                               $this->Text($this->titleCol, $str, $this->companyCol);
+                               $this->Text($titleCol, $str, $companyCol);
                        }
                }
                if ($this->params[0] != '') // Comments
                {
                        $this->NewLine();
                        $str = _("Comments") . ':';
-                       $this->Text($this->leftMargin, $str, $this->titleCol);
+                       $this->Text($this->leftMargin, $str, $titleCol);
                        $this->Font('bold');
-                       $this->Text($this->titleCol, $this->params[0], $this->endLine - 35);
+                       $this->Text($titleCol, $this->params[0], $this->endLine - 35);
                        $this->Font();
                }
                $str = _("Page") . ' ' . $this->pageNumber;
@@ -286,6 +375,262 @@ class FrontReport extends Cpdf
                $this->row = $temp;
        }
 
+       // Alternate header style which also supports a simple footer
+       function Header3()
+       {
+               global $comp_path;
+
+               // Make this header the default for the current report ( used by NewLine() )
+               $this->headerFunc = 'Header3';
+               
+               // Turn off cell padding for the main report header, restoring the current setting later
+               $oldcMargin = $this->cMargin;
+               $this->SetCellPadding(0);
+
+               // Set some constants which control header item layout
+               // only set them once or the PHP interpreter gets angry
+               if ($this->pageNumber == 0)
+               {
+                       define('COMPANY_WIDTH', 150);
+                       define('LOGO_HEIGHT', 50);
+                       define('LOGO_Y_POS_ADJ_FACTOR', 0.74);
+                       define('LABEL_WIDTH', 80);
+                       define('PAGE_NUM_WIDTH', 60);
+                       define('TITLE_FONT_SIZE', 14);
+                       define('HEADER1_FONT_SIZE', 10);
+                       define('HEADER2_FONT_SIZE', 9);
+                       define('FOOTER_FONT_SIZE', 10);
+                       define('FOOTER_MARGIN', 4);
+               }
+               // Set some variables which control header item layout
+               $companyCol = $this->endLine - COMPANY_WIDTH;
+               $headerFieldCol = $this->leftMargin + LABEL_WIDTH;
+               $pageNumCol = $this->endLine - PAGE_NUM_WIDTH;
+               $footerCol = $this->leftMargin + PAGE_NUM_WIDTH; 
+               $footerRow = $this->bottomMargin - FOOTER_MARGIN;
+
+               // Calling this function generates a new PDF page after the first instance
+               $this->pageNumber++;
+               if ($this->pageNumber > 1)
+               {
+//                     // TODO: experimenting with line drawing to highlight current period
+//                     $this->SetLineWidth(1);
+//                     $this->LineTo($this->cols[3], 33, $this->cols[3], 534);
+//                     $this->LineTo($this->cols[4], 33, $this->cols[4], 534);
+//                     $this->SetLineWidth(0.1);
+                       
+                       $this->newPage();
+               }
+               $this->row = $this->pageHeight - $this->topMargin;
+
+               // Set the color of dividing lines we'll draw
+               $oldDrawColor = $this->GetDrawColor();
+               $this->SetDrawColor(128, 128, 128);
+
+               // Tell TCPDF that we want to use its alias system to track the total number of pages
+               $this->AliasNbPages();
+               
+               // Footer
+               if ($this->footerEnable)
+               {
+                       $this->Line($footerRow, 1);
+                       $prevFontSize = $this->fontSize;
+                       $this->fontSize = FOOTER_FONT_SIZE;
+                       $this->TextWrap($footerCol, $footerRow - ($this->fontSize + 1),
+                               $pageNumCol - $footerCol, $this->footerText, $align = 'center',
+                               $border = 0, $fill = 0, $link = NULL, $stretch = 1);
+                       $this->TextWrap($pageNumCol, $footerRow - ($this->fontSize + 1),
+                               PAGE_NUM_WIDTH, _("Page") . ' ' . $this->pageNumber . '/' . $this->getAliasNbPages(),
+                               $align = 'right', $border = 0, $fill = 0, $link = NULL, $stretch = 1);
+                       $this->fontSize = $prevFontSize;
+               }
+
+               //
+               // Header
+               //
+               
+               // Print gray line across the page
+               $this->Line($this->row + 8, 1);
+
+               $this->NewLine();
+
+               // Print the report title nice and big
+               $oldFontSize = $this->fontSize;
+               $this->fontSize = TITLE_FONT_SIZE;
+               $this->Font('B');
+               $this->Text($this->leftMargin, $this->title, $companyCol);
+               $this->fontSize = HEADER1_FONT_SIZE;
+
+               // Print company logo if present and requested, or else just print company name
+               if ($this->companyLogoEnable && ($this->company['coy_logo'] != ''))
+               {
+                       // Build a string specifying the location of the company logo file
+                       $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
+
+                       // Width being zero means that the image will be scaled to the specified height
+                       // keeping its aspect ratio intact.
+                       $this->AddImage($logo, $companyCol, $this->row - (LOGO_HEIGHT * LOGO_Y_POS_ADJ_FACTOR), 0, LOGO_HEIGHT);
+               }
+               else
+                       $this->Text($companyCol, $this->company['coy_name']);
+
+               // Dimension 1 - optional
+               // - only print if available and not blank
+               if (count($this->params) > 3)
+                       if ($this->params[3]['from'] != '')
+                       {
+                               $this->NewLine(1, 0, $this->fontSize + 2);
+                               $str = $this->params[3]['text'] . ':';
+                               $this->Text($this->leftMargin, $str, $headerFieldCol);
+                               $str = $this->params[3]['from'];
+                               $this->Text($headerFieldCol, $str, $companyCol);
+                       }
+
+               // Dimension 2 - optional
+               // - only print if available and not blank
+               if (count($this->params) > 4)
+                       if ($this->params[4]['from'] != '')
+                       {
+                               $this->NewLine(1, 0, $this->fontSize + 2);
+                               $str = $this->params[4]['text'] . ':';
+                               $this->Text($this->leftMargin, $str, $headerFieldCol);
+                               $str = $this->params[4]['from'];
+                               $this->Text($headerFieldCol, $str, $companyCol);
+                       }
+
+               // Tags - optional
+               // if present, it's an array of tag names
+               if (count($this->params) > 5)
+                       if ($this->params[5]['from'] != '')
+                       {
+                               $this->NewLine(1, 0, $this->fontSize + 2);
+                               $str = $this->params[5]['text'] . ':';
+                               $this->Text($this->leftMargin, $str, $headerFieldCol);
+                               $str = '';
+                               for ($i = 0; $i < count($this->params[5]['from']); $i++)
+                               {
+                                       if($i != 0)
+                                               $str .= ', ';
+                                       $str .= $this->params[5]['from'][$i];
+                               }
+                               $this->Text($headerFieldCol, $str, $companyCol);
+                       }
+
+               // Report Date - time period covered
+               // - can specify a range, or just the end date (and the report contents
+               //   should make it obvious what the beginning date is)
+               $this->NewLine(1, 0, $this->fontSize + 2);
+               $str = _("Report Period") . ':';
+               $this->Text($this->leftMargin, $str, $headerFieldCol);
+               $str = '';
+               if ($this->params[1]['from'] != '')
+                       $str = $this->params[1]['from'] . ' - ';
+               $str .= $this->params[1]['to'];
+               $this->Text($headerFieldCol, $str, $companyCol);
+
+               // Turn off Bold
+               $this->Font();
+               
+               $this->NewLine(1, 0, $this->fontSize + 1);
+
+               // Make the remaining report headings a little less important
+               $this->fontSize = HEADER2_FONT_SIZE;
+
+               // Timestamp of when this copy of the report was generated
+               $str = _("Generated At") . ':';
+               $this->Text($this->leftMargin, $str, $headerFieldCol);
+               $str = Today() . '   ' . Now();
+               if ($this->company['time_zone'])
+                       $str .= ' ' . date('O') . ' GMT';
+               $this->Text($headerFieldCol, $str, $companyCol);
+
+               // Name of the user that generated this copy of the report
+               $this->NewLine(1, 0, $this->fontSize + 1);
+               $str = _("Generated By") . ':';
+               $this->Text($this->leftMargin, $str, $headerFieldCol);
+               $str = $this->user;
+               $this->Text($headerFieldCol, $str, $companyCol);
+
+               // Display any user-generated comments for this copy of the report
+               if ($this->params[0] != '') // Comments
+               {
+                       $this->NewLine(1, 0, $this->fontSize + 1);
+                       $str = _("Comments") . ':';
+                       $this->Text($this->leftMargin, $str, $headerFieldCol);
+                       $this->Font('B');
+                       $this->Text($headerFieldCol, $this->params[0], $companyCol, 0, 0, 'left', 0, 0, $link=NULL, 1);
+                       $this->Font();
+               }
+
+               // Add page numbering to header if footer is turned off
+               if (!$this->footerEnable)
+               {
+                       $str = _("Page") . ' ' . $this->pageNumber . '/' . $this->getAliasNbPages();
+                       $this->Text($pageNumCol, $str, 0, 0, 0, 'right', 0, 0, NULL, 1);
+               }
+               
+               // Print gray line across the page
+               $this->Line($this->row - 5, 1);
+
+               // Restore font size to user-defined size
+               $this->fontSize = $oldFontSize;
+
+               // restore user-specified cell padding for column headers
+               $this->SetCellPadding($oldcMargin);
+
+               // scoot down the page a bit
+               $oldLineHeight = $this->lineHeight;
+               $this->lineHeight = $this->fontSize + 1;
+               $this->row -= ($this->lineHeight + 6);
+               $this->lineHeight = $oldLineHeight;
+
+               // Print the column headers!
+               $this->Font('I');
+               if ($this->headers2 != null)
+               {
+                       $count = count($this->headers2);
+                       for ($i = 0; $i < $count; $i++)
+                               $this->TextCol2($i, $i + 1,     $this->headers2[$i], $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1);
+                       $this->NewLine();
+               }
+               $count = count($this->headers);
+               for ($i = 0; $i < $count; $i++)
+                       $this->TextCol($i, $i + 1, $this->headers[$i], $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1);
+               $this->Font();
+
+               $this->NewLine(2);
+
+               // restore user-specified draw color
+               $this->SetDrawColor($oldDrawColor[0], $oldDrawColor[1], $oldDrawColor[2]);              
+       }
+
+       /**
+        * Format a numeric string date into something nicer looking.
+        *
+        * @param string $date Date string to be formatted.
+        * @param int $input_format Format of the input string.  Possible values are:<ul><li>0: user's default (default)</li></ul>
+        * @param int $output_format Format of the output string.  Possible values are:<ul><li>0: Month (word) Day (numeric), 4-digit Year - Example: January 1, 2000 (default)</li><li>1: Month 4-digit Year - Example: January 2000</li><li>2: Month Abbreviation 4-digit Year - Example: Jan 2000</li></ul>
+        * @access public
+        */
+       function DatePrettyPrint($date, $input_format = 0, $output_format = 0)
+       {
+               if ($date != '')
+               {
+                       $date = date2sql($date);
+                       $year = (int) (substr($date, 0, 4));
+                       $month = (int) (substr($date, 5, 2));
+                       $day = (int) (substr($date, 8, 2));
+                       if ($output_format == 0)
+                               return(date('F j, Y', mktime(12, 0, 0, $month, $day, $year)));
+                       elseif ($output_format == 1)
+                               return(date('F Y', mktime(12, 0, 0, $month, $day, $year)));
+                       elseif ($output_format == 2)
+                               return(date('M Y', mktime(12, 0, 0, $month, $day, $year)));
+               }
+               else
+                       return $date;
+       }
+
        function AddImage($logo, $x, $y, $w, $h)
        {
                if (strpos($logo, ".png") || strpos($logo, ".PNG"))
@@ -294,63 +639,108 @@ class FrontReport extends Cpdf
                        $this->addJpegFromFile($logo, $x, $y, $w, $h);
        }
 
+       // Get current draw color setting from TCPDF object; returns array of RGB numbers
+       function GetDrawColor()
+       {
+               // Convert the TCPDF stored DrawColor string into an array of strings
+               $colorFields = explode(' ', $this->DrawColor);
+
+               // Test last value: G == grayscale, single number; RG == RGB, 3 numbers
+               if ($colorFields[count($colorFields) - 1] == 'G')
+                       // Convert a grayscale string value to the equivalent RGB value
+                       $drawColor = array((float) $colorFields[0], (float) $colorFields[0], (float) $colorFields[0]);
+               else
+                       // Convert RGB string values to the a numeric array
+                       $drawColor = array((float) $colorFields[0], (float) $colorFields[1], (float) $colorFields[2]);
+               
+               return $drawColor;
+       }
+       
        function SetDrawColor($r, $g, $b)
        {
-               $this->setStrokeColor($r, $g, $b);
+               parent::SetDrawColor($r, $g, $b);
        }
 
        function SetTextColor($r, $g, $b)
        {
-               TCPDF::SetTextColor($r, $g, $b);
+               parent::SetTextColor($r, $g, $b);
        }
 
-       function Text($c, $txt, $n=0, $corr=0, $r=0)
+       /**
+     * Set the fill color for table cells.
+     * @see reporting/includes/TCPDF#SetFillColor($col1, $col2, $col3, $col4)
+     */
+       function SetFillColor($r, $g, $b)
+       {
+               parent::SetFillColor($r, $g, $b);
+       }
+
+       // Get current cell padding setting from TCPDF object
+       function GetCellPadding()
+       {
+               return $this->cMargin;
+       }
+
+       // Set desired cell padding (aka "cell margin")
+       // Seems to be just left and right margins...
+       function SetCellPadding($pad)
+       {
+               parent::SetCellPadding($pad);
+       }
+       
+       function Text($c, $txt, $n=0, $corr=0, $r=0, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                if ($n == 0)
                        $n = $this->pageWidth - $this->rightMargin;
 
-               return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, 'left');
+               return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, $align, $border, $fill, $link, $stretch);
        }
 
-       function TextWrap($xpos, $ypos, $len, $str, $align = 'left')
+       function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 0)
        {
                if ($this->fontSize != $this->oldFontSize)
                {
                        $this->SetFontSize($this->fontSize);
                        $this->oldFontSize = $this->fontSize;
                }
-               return $this->addTextWrap($xpos, $ypos, $len, $this->fontSize, $str, $align);
+               return $this->addTextWrap($xpos, $ypos, $len, $this->fontSize, $str, $align, $border, $fill, $link, $stretch);
        }
 
-       function TextCol($c, $n, $txt, $corr=0, $r=0)
+       function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
-               return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c]);
+               return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch);
        }
        
-       function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0)
+       function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
-               return $this->TextCol($c, $n, number_format2($txt, $dec), $corr, $r);
+               return $this->TextCol($c, $n, number_format2($txt, $dec), $corr, $r, $border, $fill, $link, $stretch);
        }
 
-       function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0)
+       function AmountCol2($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $amount_locale = 'en_US.UTF-8', $amount_format = '%(!.2n')
+       {
+               setlocale(LC_MONETARY, $amount_locale);
+               return $this->TextCol($c, $n, money_format($amount_format, $txt), $corr, $r, $border, $fill, $link, $stretch);
+       }
+       
+       function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                if ($conv)
                        $txt = sql2date($txt);
-               return $this->TextCol($c, $n, $txt, $corr, $r);
+               return $this->TextCol($c, $n, $txt, $corr, $r, $border, $fill, $link, $stretch);
        }
 
-       function TextCol2($c, $n, $txt, $corr=0, $r=0)
+       function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
-               return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c]);
+               return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c], $border, $fill, $link, $stretch);
        }
 
-       function TextColLines($c, $n, $txt, $corr=0, $r=0)
+       function TextColLines($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                $this->row -= $r;
-               $this->TextWrapLines($this->cols[$c], $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c]);
+               $this->TextWrapLines($this->cols[$c], $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch);
        }
 
-       function TextWrapLines($c, $width, $txt, $align='left')
+       function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0)
        {
                $str = Explode("\n", $txt);
                for ($i = 0; $i < count($str); $i++)
@@ -358,29 +748,117 @@ class FrontReport extends Cpdf
                        $l = $str[$i];
                        do
                        {
-                               $l = $this->TextWrap($c, $this->row , $width, $l, $align);
+                               $l = $this->TextWrap($c, $this->row , $width, $l, $align, $border, $fill, $link, $stretch);
                                $this->row -= $this->lineHeight;
                        }
                        while ($l != '');
                }
        }
 
+       /**
+        * Expose the underlying calcTextWrap() function in this API.
+        */
+       function TextWrapCalc($txt, $width, $spacebreak=false)
+       {
+               return $this->calcTextWrap($txt, $width, $spacebreak);
+       }
+       
+       /**
+        * Sets the line drawing style.
+        * 
+        * Takes an associative array as arg so you don't need to specify all values.
+        * 
+        * Array keys:
+        * width (float) - the thickness of the line in user units
+        * cap (string) - the type of cap to put on the line, values can be 'butt','round','square'
+        *    where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the
+        *    end of the line.
+        * join (string) - can be 'miter', 'round', 'bevel'
+        * dash (mixed) - Dash pattern. Is 0 (without dash) or string with series of length values, which are the
+        *        lengths of the on and off dashes. For example: "2" represents 2 on, 2 off, 2 on, 2 off, ...;
+        *        "2,1" is 2 on, 1 off, 2 on, 1 off, ... 
+        * phase (integer) - a modifier on the dash pattern which is used to shift the point at which the pattern starts.
+        * color (array) - draw color.  Format: array(GREY), or array(R,G,B) or array(C,M,Y,K).
+        */
+       function SetLineStyle($style)
+       {
+               parent::SetLineStyle($style);
+       }
+
+       /**
+        * Sets the line drawing width.
+        */
+       function SetLineWidth($width)
+       {
+               parent::SetLineWidth($width);
+       }
+       
        function LineTo($from, $row, $to, $row2)
        {
-               Cpdf::line($from, $row, $to, $row2);
+               parent::line($from, $row, $to, $row2);
        }
 
        function Line($row, $height = 0)
        {
-               $this->setLineStyle($height + 1);
-               Cpdf::line($this->pageWidth - $this->rightMargin, $row ,$this->leftMargin, $row);
+               $oldLineWidth = $this->GetLineWidth();
+               $this->SetLineWidth($height + 1);
+               parent::line($this->pageWidth - $this->rightMargin, $row ,$this->leftMargin, $row);
+               $this->SetLineWidth($oldLineWidth);
        }
 
-       function NewLine($l=1, $np=0)
+       /**
+       * Underlines the contents of a cell, but not the cell padding area.
+       * Primarily useful for the last line before a "totals" line.
+       * @param int $c Column number to underline.
+       * @param int $r Print the underline(s) this number of rows below the current position.  Can be negative in order to go up.
+       * @param int $type Type of underlining to draw.  Possible values are:<ul><li>1: single underline (default)</li><li>2: double underline</li></ul>
+       * @param int $linewidth Thickness of the line to draw.  Default value of zero will use the current line width defined for this document.
+       * @param array $style Line style. Array like for {@link SetLineStyle SetLineStyle}. Default value: default line style (empty array).
+       * @access public
+       * @see SetLineWidth(), SetDrawColor(), SetLineStyle()
+       */
+       function UnderlineCell($c, $r = 0, $type = 1, $linewidth = 0, $style = array())
+       {
+               // If line width was specified, save current setting so we can reset it
+               if ($linewidth != 0)
+               {
+                       $oldLineWidth = $this->GetLineWidth();
+                       $this->SetLineWidth($linewidth);
+               }
+
+               // Figure out how far down to move the line based on current font size
+               // Calculate this because printing underline directly at $this->row goes on top
+               // of the parts of characters that "hang down", like the bottom of commas &
+               // lowercase letter 'g', etc.
+               if ($this->fontSize < 10)
+                       $y_adj = 2;
+               else
+                       $y_adj = 3; 
+               parent::line($this->cols[$c] + $this->cMargin, $this->row - $r - $y_adj, $this->cols[$c + 1] - $this->cMargin, $this->row - $r - $y_adj, $style);
+
+               // Double underline, far enough below the first underline so as not to overlap
+               // the first underline (depends on current line thickness (aka "line width")
+               if ($type == 2)
+                       parent::line($this->cols[$c] + $this->cMargin, $this->row - $r - $y_adj - ($this->GetLineWidth() + 2), $this->cols[$c + 1] - $this->cMargin, $this->row - $r - $y_adj - ($this->GetLineWidth() + 2), $style);
+
+               // If line width was specified, reset it back to the original setting
+               if ($linewidth != 0)
+                       $this->SetLineWidth($oldLineWidth);
+       }
+       
+       function NewLine($l=1, $np=0, $h = NULL)
        {
-               $this->row -= ($l * $this->lineHeight);
-               if ($this->row < $this->bottomMargin + ($np * $this->lineHeight))
-                       $this->Header();
+               // If the line height wasn't specified, use the current setting
+               if ($h == NULL)
+                       $h = $this->lineHeight;
+
+               // Move one line down the page
+               $this->row -= ($l * $h);
+               // Reset the "current line height" for the new line
+               $this->curLineHeight = $this->fontSize;
+               // Check to see if we're at the bottom and should insert a page break
+               if ($this->row < $this->bottomMargin + ($np * $h))
+                       $this->{$this->headerFunc}();  // call header template chosen by current report
        }
 
        function End($email=0, $subject=null, $myrow=null, $doctype = 0)
index ba54e66a3ea08b8a96f70a25d25fb50be43c1516..06df1ad82f9af8ac4abe86916d0ddc202fd4e9d6 100644 (file)
   *    and
   *    if (!defined("K_RE_PATTERN_ARABIC"))
   * 4. Parameter $unicode in constructor renamed to $uni.
-  * 4. Header function renamed to Header1 (due to conflict with FrontReport Header)
+  * 5. Header function renamed to Header1 (due to conflict with FrontReport Header)
+  * 6. Line 6190, SetLineWidth (cast of values to avoid problem in PHP 5.2.6
   * -------------------------------------------------------------------------------
   */
 if (!defined("K_PATH_FONTS"))
@@ -6190,7 +6191,15 @@ if (!class_exists('TCPDF')) {
                function SetLineWidth($width) {
                        //Set line width
                        $this->LineWidth = $width;
-                       $this->linestyleWidth = sprintf('%.2f w', ($width * $this->k));
+                       //$this->linestyleWidth = sprintf('%.2f w', ($width * $this->k));
+                       // FrontAccounting fix
+                       // My PHP 5.2.6 environment gave an "Unsupported operand types"
+                       // error for the multiplication on the next line some of the
+                       // time when this method is called - I debugged and sometimes
+                       // the $width parameter is some sort of weird array.  I don't
+                       // understand what's going on, but casting it to a (float) seems
+                       // to "fix" the problem.  -Jason Maas, 2009/09/25
+                       $this->linestyleWidth = sprintf('%.2f w', ((float) $width * (float) $this->k));
                        $this->_out($this->linestyleWidth);
                }