X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Fincludes%2Fexcel_report.inc;h=33ac54a529448ee627444c4679e9dd357a41b567;hb=a0392584696bcbc635c578921983d2ef59bc07ac;hp=4f8dbc6a2e10907c41e0e5b2f313a933b6f3c0ee;hpb=b2d74dd9702a3bedea66cc832033a21c9ed59c45;p=fa-stable.git diff --git a/reporting/includes/excel_report.inc b/reporting/includes/excel_report.inc index 4f8dbc6a..33ac54a5 100644 --- a/reporting/includes/excel_report.inc +++ b/reporting/includes/excel_report.inc @@ -11,6 +11,7 @@ ***********************************************************************/ include_once($path_to_root . "/reporting/includes/Workbook.php"); include_once($path_to_root . "/admin/db/company_db.inc"); +include_once($path_to_root . "/admin/db/fiscalyears_db.inc"); include_once($path_to_root . "/config.php"); // xls version class FrontReport extends Spreadsheet_Excel_Writer_Workbook @@ -28,6 +29,8 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook var $bottomMargin = 0; var $lineHeight; var $leftMargin = 0; + var $pageWidth; // dummy + var $rightMargin; // dummy var $cols; var $params; @@ -52,12 +55,13 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook var $formatHeaderRight; var $formatFooter; var $formatAmount = array(); + var $headerFunc; var $sheet; function FrontReport($title, $filename, $size = 'A4', $fontsize = 9, $orientation = 'P', $margins = NULL, $excelColWidthFactor = 6.5) { - global $comp_path, $dateseps, $page_security; + global $dateseps, $page_security; if (!$_SESSION["wa_current_user"]->can_access_page($page_security)) { display_error(_("The security settings on your account do not permit you to print this report")); @@ -68,7 +72,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->title = $title; $this->lineHeight = 12; $this->endLine = 760; - $this->fontSize = $fontsize; + $this->SetFontSize($fontsize); $this->oldFontSize = 0; $this->y = 0; $this->currency = ''; @@ -77,7 +81,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->code = strtolower($_SESSION['language']->encoding); $this->filename = $filename.".xls"; $this->unique_name = uniqid('').".xls"; - $this->path = $comp_path.'/'.user_company(). '/pdf_files'; + $this->path = company_path(). '/pdf_files'; $this->Spreadsheet_Excel_Writer_Workbook($this->path."/".$this->unique_name); //$this->setCountry(48); if ($this->code != "iso-8859-1") @@ -165,9 +169,16 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->formatFooter =& $this->addFormat(); $this->formatFooter->setTop(2); $this->formatFooter->setTopColor('gray'); + $this->SetHeaderType("header"); } + /* + Set header handler + */ + function SetHeaderType($name) { + $this->headerFunc = $name; + } // Check a given name to see if it's a valid Excel worksheet name, // and fix if necessary function worksheetNameGenerator($name) @@ -205,6 +216,11 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook function Font($fontname = '', $style = 'normal') { } + + function SetFontSize($size) + { + $this->fontSize = $size; + } function Info($params, $cols, $headers, $aligns, $cols2 = null, $headers2 = null, $aligns2 = null) @@ -522,6 +538,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { + $txt = html_entity_decode($txt); if ($this->aligns[$c] == 'right') $this->sheet->writeString($this->y, $c, $txt, $this->formatRight); else @@ -548,13 +565,14 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook { if (!$conv) $txt = date2sql($txt); - list($year, $mo, $day) = explode("-", $txt); + list($year, $mo, $day) = explode("-", $txt); $date = $this->ymd2date((int)$year, (int)$mo, (int)$day); $this->sheet->writeNumber($this->y, $c, $date, $this->formatDate); } function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { + $txt = html_entity_decode($txt); $this->sheet->writeString($this->y, $c, $txt, $this->formatLeft); if ($n - $c > 1) $this->sheet->mergeCells($this->y, $c, $this->y, $n - 1); @@ -628,7 +646,13 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook { $this->y += $l; } - + + function NewPage() + { + if (method_exists($this, $this->headerFunc)) // draw predefined page layout if any + $this->{$this->headerFunc}(); + } + function ymd2Date($year, $mon, $day) // XLS internal date representation is a number between 1900-01-01 and 2078-12-31 { // if we need the time part too, we have to add this value after a decimalpoint. $mo = array(0,31,28,31,30,31,30,31,31,30,31,30,31); @@ -669,8 +693,10 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook return ($px / $unit_offset_length); } - function End($email=0, $subject=null, $myrow=null, $doctype = 0) + function End($email=0, $subject='') { + global $path_to_root; + ++$this->y; for ($i = 0; $i < $this->numcols; $i++) $this->sheet->writeBlank($this->y, $i, $this->formatFooter); $this->sheet->mergeCells($this->y, 0, $this->y, $this->numcols - 1); @@ -689,7 +715,8 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook } closedir($d); } - meta_forward($_SERVER['PHP_SELF'], "xls=1&filename=$this->filename&unique=$this->unique_name"); + + meta_forward($path_to_root.'/reporting/prn_redirect.php', "xls=1&filename=$this->filename&unique=$this->unique_name"); exit(); } }