From: Joe Hunt Date: Tue, 3 Mar 2009 14:02:36 +0000 (+0000) Subject: Preparation for Excel Writer continued X-Git-Tag: v2.4.2~19^2~1493 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=f50187b9c3095886d7fd847f635cd8763109a75e;p=fa-stable.git Preparation for Excel Writer continued --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a9d8f674..5279a8b0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,14 @@ Legend: ! -> Note $ -> Affected files +03-Mar-2009 Joe Hunt/Janusz Dobrowolski ++ Preparation for Excel Writer continued +$ /reporting/includes/ExcelWriterXML.php + /reporting/includes/ExcelWriterXML_Sheet.php + /reporting/includes/ExcelWriterXML_Style.php + /reporting/includes/excel_report.inc + /reporting all repXXX.php that are not documents + 02-Mar-2009 Joe Hunt + Preparation for report destination PDF/Printer and Excel (and Open Office Calc) $ /reporting/includes/reports_classes.inc diff --git a/reporting/includes/ExcelWriterXML.php b/reporting/includes/ExcelWriterXML.php index 0f617d50..4fa96cc9 100644 --- a/reporting/includes/ExcelWriterXML.php +++ b/reporting/includes/ExcelWriterXML.php @@ -64,7 +64,7 @@ class ExcelWriterXML function ExcelWriterXML($fileName = 'file.xml') { // Add default style - $style = $this->addStyle('Default'); + $style =& $this->addStyle('Default'); $style->name('Normal'); $style->alignVertical('Bottom'); @@ -174,7 +174,7 @@ class ExcelWriterXML * will default to "CustomStyle" + n (e.g. "CustomStyle1") * @return ExcelWriterXML_Style Reference to a new style class */ - function addStyle($id = null) + function &addStyle($id = null) { static $styleNum = 1; if (trim($id) == '') @@ -196,8 +196,8 @@ class ExcelWriterXML } $style =& new ExcelWriterXML_Style($id); - $this->styles[] = $style; - return ($style); + $this->styles[$id] = &$style; + return $style; } /** @@ -210,7 +210,7 @@ class ExcelWriterXML * will default to "Sheet" + n (e.g. "Sheet1") * @return ExcelWriterXML_Sheet Reference to a new sheet class */ - function addSheet($id = null) + function &addSheet($id = null) { static $sheetNum = 1; if (trim($id) == '') @@ -232,8 +232,8 @@ class ExcelWriterXML } $sheet =& new ExcelWriterXML_Sheet($id); - $this->sheets[] = $sheet; - return ($sheet); + $this->sheets[$id] = &$sheet; + return $sheet; } /** @@ -241,16 +241,9 @@ class ExcelWriterXML * @param string $id The sheet id to be checked * @return boolean True if the id is unique, false otherwise */ - function _checkSheetID($id){ - foreach($this->sheets as $sheet) - { - $sheetID = $sheet->getID(); - if ($id == $sheetID) + function _checkSheetID($id) { - return false; - } - } - return true; + return !isset($this->sheets[$id]); } /** @@ -260,15 +253,7 @@ class ExcelWriterXML */ function _checkStyleID($id) { - foreach($this->styles as $style) - { - $styleID = $style->getID(); - if ($id == $styleID) - { - return false; - } - } - return true; + return !isset($this->styles[$id]); } // 2009-02-28 Added by Joe Hunt, FA @@ -295,11 +280,10 @@ class ExcelWriterXML if ($this->showErrorSheet == true) { - $format = $this->addStyle('formatErrorsHeader'); + $format =& $this->addStyle('formatErrorsHeader'); $format->fontBold(); $format->bgColor('red'); } - if (!empty($this->docTitle)) $docTitle = ''.htmlspecialchars($this->docTitle).''."\r"; if (!empty($this->docSubject)) @@ -367,7 +351,7 @@ class ExcelWriterXML if ($errors == true && $this->showErrorSheet == true) { - $sheet = $this->addSheet('formatErrors'); + $sheet =& $this->addSheet('formatErrors'); $sheet->cellMerge(1,1,3,0); // Merge the first three cells across in row 1 $sheet->writeString(1,1,'Formatting Errors'); $sheet->writeString(2,1,'Type','formatErrorsHeader'); diff --git a/reporting/includes/ExcelWriterXML_Sheet.php b/reporting/includes/ExcelWriterXML_Sheet.php index 18588f1e..b29c41a5 100644 --- a/reporting/includes/ExcelWriterXML_Sheet.php +++ b/reporting/includes/ExcelWriterXML_Sheet.php @@ -281,7 +281,7 @@ class ExcelWriterXML_Sheet { if ($style != null) { - if (gettype($style) == 'object') +/* if (gettype($style) == 'object') { if (get_class($style) == 'ExcelWriterXML_Style') { @@ -294,7 +294,7 @@ class ExcelWriterXML_Sheet } } else - { +*/ { $styleID = $style; } } @@ -327,7 +327,6 @@ class ExcelWriterXML_Sheet function getSheetXML() { ksort($this->cells); - $displayRightToLeft = ($this->displayRightToLeft) ? 'ss:RightToLeft="1"' : ''; $xml = ''."\r"; diff --git a/reporting/includes/ExcelWriterXML_Style.php b/reporting/includes/ExcelWriterXML_Style.php index b188426d..8eb23d84 100644 --- a/reporting/includes/ExcelWriterXML_Style.php +++ b/reporting/includes/ExcelWriterXML_Style.php @@ -268,7 +268,7 @@ class ExcelWriterXML_Style $numberFormat = ''; - //if (empty($this->id)) + //if (empty($this->id)) //*** // throw new exception; if (!empty($this->name)){$name = 'ss:Name="'.$this->name.'"';} diff --git a/reporting/includes/excel_report.inc b/reporting/includes/excel_report.inc index a32591eb..3d543e86 100644 --- a/reporting/includes/excel_report.inc +++ b/reporting/includes/excel_report.inc @@ -15,8 +15,7 @@ include_once($path_to_root . "/reporting/includes/ExcelWriterXML.php"); include_once($path_to_root . "/admin/db/company_db.inc"); include_once($path_to_root . "/config.php"); -//class FrontReport extends ExcelWriterXML -class FrontReport +class FrontReport extends ExcelWriterXML { var $xml; var $size; @@ -27,10 +26,11 @@ class FrontReport var $title; var $filename; var $path; - var $lineHeight; var $rtl; var $code; var $bottomMargin = 0; + var $lineHeight; + var $leftMargin = 0; var $cols; var $params; @@ -44,16 +44,9 @@ class FrontReport var $currency; var $row = 9999999; var $y; + var $numcols; var $sheet; - var $formatTitle; - var $formatDateTime; - var $formatDate; - var $formatRight; - var $formatHeaderLeft; - var $formatHeaderRight; - var $formatAmount = array(); - var $formatFooter; function FrontReport($title, $filename, $size = 'A4', $fontsize = 9) { @@ -70,18 +63,18 @@ class FrontReport $this->code = $_SESSION['language']->encoding; $this->filename = $filename; $this->path = $comp_path.'/'.user_company(). '/pdf_files/'; - //$this->ExcelWriterXML($this->filename); - $this->xml = new ExcelWriterXML($this->filename); - $this->xml->setCharSet($this->code); - $this->xml->overwriteFile(); - $this->xml->showErrorSheet(true); - $this->sheet = $this->xml->addSheet($this->title); + $this->ExcelWriterXML($this->filename); + $this->setCharSet($this->code); + $this->overwriteFile(); + $this->showErrorSheet(true); + + $this->sheet =& $this->addSheet($this->title); if ($this->rtl === 'rtl') $this->sheet->displayRightToLeft(); - $this->formatTitle = $this->xml->addStyle('formatTitle'); - $this->formatTitle->fontSize('18'); - $this->formatTitle->fontBold(); - $this->formatTitle->border('Top', '2', 'darkgray'); + $formatTitle =& $this->addStyle('formatTitle'); + $formatTitle->fontSize('16'); + $formatTitle->fontBold(); + $formatTitle->border('Top', '2', 'darkgray'); $how = user_date_format(); $sep = $dateseps[user_date_sep()]; @@ -102,46 +95,48 @@ class FrontReport $dateformat_long = "yyyy{$sep}mm{$sep}dd\ \ hh:mm"; $dateformat = "yyyy{$sep}mm{$sep}dd"; } - $this->formatDateTime = $this->xml->addStyle('formatDateTime'); - $this->formatDateTime->numberFormatDateTime($dateformat_long); - $this->formatDateTime->alignHorizontal('Left'); - $this->formatDate = $this->xml->addStyle('formatDate'); - $this->formatDate->numberFormatDateTime($dateformat); - $this->formatDate->alignHorizontal('Left'); - $this->formatRight = $this->xml->addStyle('formatRight'); - $this->formatRight->alignHorizontal('Right'); + $formatDateTime =& $this->addStyle('formatDateTime'); + $formatDateTime->numberFormatDateTime($dateformat_long); + $formatDateTime->alignHorizontal('Left'); + $formatDate =& $this->addStyle('formatDate'); + $formatDate->numberFormatDateTime($dateformat); + $formatDate->alignHorizontal('Left'); + $formatRight =& $this->addStyle('formatRight'); + $formatRight->alignHorizontal('Right'); - $this->formatHeaderLeft = $this->xml->addStyle("formatHeaderLeft"); - $this->formatHeaderLeft->fontItalic(); - $this->formatHeaderLeft->border('Top', '2', 'darkgray'); - $this->formatHeaderLeft->border('Bottom', '2', 'darkgray'); - $this->formatHeaderLeft->alignVertical('Center'); - $this->formatHeaderRight = $this->xml->addStyle("formatHeaderRight"); - $this->formatHeaderRight->fontItalic(); - $this->formatHeaderRight->alignHorizontal('Right'); - $this->formatHeaderRight->border('Top', '2', 'darkgray'); - $this->formatHeaderRight->border('Bottom', '2', 'darkgray'); - $this->formatHeaderRight->alignVertical('Center'); - $tsep = $thoseps[user_tho_sep()]; - $dsep = $decseps[user_dec_sep()]; - $amountformat = "###{$tsep}###{$tsep}###{$tsep}##0"; - $this->formatAmount[0] = $this->xml->addStyle("formatAmount0"); - $this->formatAmount[0]->numberFormat($amountformat); - $this->formatAmount[0]->alignHorizontal('Right'); - $this->formatAmount[1] = $this->xml->addStyle("formatAmount1"); - $this->formatAmount[1]->numberFormat("$amountformat{$dsep}0"); - $this->formatAmount[1]->alignHorizontal('Right'); - $this->formatAmount[2] = $this->xml->addStyle("formatAmount2"); - $this->formatAmount[2]->numberFormat("$amountformat{$dsep}00"); - $this->formatAmount[2]->alignHorizontal('Right'); - $this->formatAmount[3] = $this->xml->addStyle("formatAmount3"); - $this->formatAmount[3]->numberFormat("$amountformat{$dsep}000"); - $this->formatAmount[3]->alignHorizontal('Right'); - $this->formatAmount[4] = $this->xml->addStyle("formatAmount4"); - $this->formatAmount[4]->numberFormat("$amountformat{$dsep}0000"); - $this->formatAmount[4]->alignHorizontal('Right'); - $this->formatFooter = $this->xml->addStyle("formatFooter"); - $this->formatFooter->border('Top', '2', 'darkgray'); + $formatHeaderLeft =& $this->addStyle("formatHeaderLeft"); + $formatHeaderLeft->fontItalic(); + $formatHeaderLeft->border('Top', '2', 'darkgray'); + $formatHeaderLeft->border('Bottom', '2', 'darkgray'); + $formatHeaderLeft->alignVertical('Center'); + $formatHeaderRight =& $this->addStyle("formatHeaderRight"); + $formatHeaderRight->fontItalic(); + $formatHeaderRight->alignHorizontal('Right'); + $formatHeaderRight->border('Top', '2', 'darkgray'); + $formatHeaderRight->border('Bottom', '2', 'darkgray'); + $formatHeaderRight->alignVertical('Center'); + $formatFooter =& $this->addStyle("formatFooter"); + $formatFooter->border('Top', '2', 'darkgray'); + } + + function NumFormat($dec) + { + global $thoseps,$decseps; + + $dec = (int)$dec; + $stylename = 'formatAmount'.$dec; + if (!isset($this->styles[$stylename])) + { + $tsep = $thoseps[user_tho_sep()]; + $dsep = $decseps[user_dec_sep()]; + $format = "###{$tsep}###{$tsep}###{$tsep}##0"; + if ($dec>0) + $format .= "{$dsep}".str_repeat('0',$dec); + $style =& $this->addStyle($stylename); + $style->numberFormat($format); + $style->alignHorizontal('Right'); + } + return $stylename; } function Font($style = 'normal') @@ -152,12 +147,11 @@ class FrontReport $cols2 = null, $headers2 = null, $aligns2 = null) { global $app_title, $version, $power_by, $power_url; - $this->company = get_company_prefs(); - $this->xml->docTitle($this->title); - $this->xml->docAuthor($app_title . ' ' . $version); - $this->xml->docCompany($this->company['coy_name']); - $this->xml->docManager($power_by . ' - ' . $power_url); + $this->docTitle($this->title); + $this->docAuthor($app_title . ' ' . $version); + $this->docCompany($this->company['coy_name']); + $this->docManager($power_by . ' - ' . $power_url); $year = get_current_fiscalyear(); if ($year['closed'] == 0) $how = _("Active"); @@ -173,33 +167,38 @@ class FrontReport $this->cols2 = $cols2; $this->headers2 = $headers2; $this->aligns2 = $aligns2; - for ($i = 0; $i < count($this->headers); $i++) + $this->numcols = count($this->headers); + $tcols = count($this->headers2); + if ($tcols > $this->numcols) + $this->numcols = $tcols; + for ($i = 0; $i < $this->numcols; $i++) $this->sheet->columnWidth($i+1, $this->cols[$i + 1] - $this->cols[$i]); } function Header() { $this->y = 0; + $tcol = $this->numcols - 1; $this->NewLine(); - $this->sheet->rowHeight($this->y, 22); - $this->sheet->writeString($this->y, 1, $this->title, $this->formatTitle); - $this->sheet->cellMerge($this->y, 1, count($this->headers)-1, 0); + $this->sheet->rowHeight($this->y, 20); + $this->sheet->writeString($this->y, 1, $this->title, 'formatTitle'); + $this->sheet->cellMerge($this->y, 1, $tcol, 0); $this->NewLine(); $str = _("Print Out Date") . ':'; $this->sheet->writeString($this->y, 1, $str); $date = $this->sheet->convertMysqlDateTime(date('Y-m-d H:i:s')); - $this->sheet->writeDateTime($this->y, 2, $date, $this->formatDateTime); - $this->sheet->writeString($this->y, 4, $this->company['coy_name']); - $this->sheet->cellMerge($this->y, 4, 1, 0); + $this->sheet->writeDateTime($this->y, 2, $date, 'formatDateTime'); + $this->sheet->writeString($this->y, $tcol, $this->company['coy_name']); + $this->sheet->cellMerge($this->y, $tcol, 1, 0); $this->NewLine(); $str = _("Fiscal Year") . ':'; $this->sheet->writeString($this->y, 1, $str); $str = $this->fiscal_year; $this->sheet->writeString($this->y, 2, $str); - $this->sheet->writeString($this->y, 4, $this->host); - $this->sheet->cellMerge($this->y, 4, 1, 0); + $this->sheet->writeString($this->y, $tcol, $this->host); + $this->sheet->cellMerge($this->y, $tcol, 1, 0); for ($i = 1; $i < count($this->params); $i++) { if ($this->params[$i]['from'] != '') @@ -213,8 +212,8 @@ class FrontReport $this->sheet->writeString($this->y, 2, $str); if ($i == 1) { - $this->sheet->writeString($this->y, 4, $this->user); - $this->sheet->cellMerge($this->y, 4, 1, 0); + $this->sheet->writeString($this->y, $tcol, $this->user); + $this->sheet->cellMerge($this->y, $tcol, 1, 0); } } } @@ -228,24 +227,32 @@ class FrontReport $this->NewLine(); if ($this->headers2 != null) { - $count = count($this->headers2); - for ($i = 0; $i < $count; $i++) + for ($i = 0, $j = 0; $i < $this->numcols; $i++) { - if ($this->aligns2[$i] == "right") - $this->sheet->writeString($this->y, $i + 1, $this->headers2[$i], $this->formatHeaderRight); - else - $this->sheet->writeString($this->y, $i + 1, $this->headers2[$i], $this->formatHeaderLeft); + 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 + 1, $this->headers2[$j], 'formatHeaderRight'); + else + $this->sheet->writeString($this->y, $i + 1, $this->headers2[$j], 'formatHeaderLeft'); + $j++; + } + else + $this->sheet->writeString($this->y, $i + 1, "", 'formatHeaderLeft'); } $this->NewLine(); } - $count = count($this->headers); - for ($i = 0; $i < $count; $i++) + for ($i = 0; $i < $this->numcols; $i++) { + if (!isset($this->headers[$i])) + $header = ""; + else + $header = $this->headers[$i]; if ($this->aligns[$i] == "right") - $this->sheet->writeString($this->y, $i + 1, $this->headers[$i], $this->formatHeaderRight); + $this->sheet->writeString($this->y, $i + 1, $header, 'formatHeaderRight'); else - $this->sheet->writeString($this->y, $i + 1, $this->headers[$i], $this->formatHeaderLeft); + $this->sheet->writeString($this->y, $i + 1, $header, 'formatHeaderLeft'); } $this->NewLine(); } @@ -283,7 +290,7 @@ class FrontReport function TextCol($c, $n, $txt, $corr=0, $r=0) { if ($this->aligns[$c] == 'right') - $this->sheet->writeString($this->y, $c + 1, $txt, $this->formatRight); + $this->sheet->writeString($this->y, $c + 1, $txt, 'formatRight'); else $this->sheet->writeString($this->y, $c + 1, $txt); if ($n - $c > 1) @@ -294,7 +301,7 @@ class FrontReport { if (!is_numeric($txt)) $txt = 0; - $this->sheet->writeNumber($this->y, $c + 1, $txt, $this->formatAmount[$dec]); + $this->sheet->writeNumber($this->y, $c + 1, $txt, $this->NumFormat($dec)); } function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0) @@ -302,7 +309,7 @@ class FrontReport if (!$conv) $txt = date2sql($txt); $date = $this->sheet->convertMysqlDate($txt); - $this->sheet->writeDate($this->y, $c + 1, $date, $this->formatDate); + $this->sheet->writeDateTime($this->y, $c + 1, $date, 'formatDate'); } function TextCol2($c, $n, $txt, $corr=0, $r=0) @@ -340,8 +347,8 @@ class FrontReport function End($email=0, $subject=null, $myrow=null, $doctype = 0) { global $comp_path; - $this->sheet->cellMerge($this->y, 1, count($this->headers) - 1, 0); - $this->sheet->writeString($this->y, 1, "", $this->formatFooter); + $this->sheet->cellMerge($this->y, 1, $this->numcols - 1, 0); + $this->sheet->writeString($this->y, 1, "", 'formatFooter'); $dir = $comp_path.'/'.user_company(). '/pdf_files'; //save the file @@ -349,14 +356,14 @@ class FrontReport { mkdir ($dir,0777); } - // do not use standard filenames or your sensitive company data - // are world readable - //$fname = $dir.'/'.uniqid('').'.xml'; - $fname = $dir.'/'."test".'.xml'; - $this->xml->writeData($fname); if(in_ajax()) { global $Ajax; + // do not use standard filenames or your sensitive company data + // are world readable + //$fname = $dir.'/'.uniqid('').'.xml'; + $fname = $dir.'/'."test".'.xml'; + $this->writeData($fname); if (user_rep_popup()) $Ajax->popup($fname); // when embeded pdf viewer used else @@ -364,8 +371,8 @@ class FrontReport } else { - $this->xml->sendHeaders(); - $this->xml->writeData(); + $this->sendHeaders(); + $this->writeData(); } // first have a look through the directory, // and remove old temporary pdfs diff --git a/reporting/rep101.php b/reporting/rep101.php index cb178908..74a1ba4a 100644 --- a/reporting/rep101.php +++ b/reporting/rep101.php @@ -54,12 +54,21 @@ function print_customer_balances() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $to = $_POST['PARAM_0']; $fromcust = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "CustomerBalances.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "CustomerBalances.pdf"; + } if ($fromcust == reserved_words::get_all_numeric()) $from = _('All'); @@ -87,7 +96,7 @@ function print_customer_balances() 2 => array('text' => _('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => '')); - $rep = new FrontReport(_('Customer Balances'), "CustomerBalances.pdf", user_pagesize()); + $rep = new FrontReport(_('Customer Balances'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -121,10 +130,9 @@ function print_customer_balances() $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['reference']); - $date = sql2date($trans['tran_date']); - $rep->TextCol(2, 3, $date); + $rep->DateCol(2, 3, $trans['tran_date'], true); if ($trans['type'] == 10) - $rep->TextCol(3, 4, sql2date($trans['due_date'])); + $rep->DateCol(3, 4, $trans['due_date'], true); $item[0] = $item[1] = 0.0; if ($convert) $rate = $trans['rate']; @@ -135,15 +143,15 @@ function print_customer_balances() if ($trans['TotalAmount'] > 0.0) { $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); - $rep->TextCol(4, 5, number_format2($item[0], $dec)); + $rep->AmountCol(4, 5, $item[0], $dec); } else { $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec); - $rep->TextCol(5, 6, number_format2($item[1], $dec)); + $rep->AmountCol(5, 6, $item[1], $dec); } $item[2] = round2($trans['Allocated'] * $rate, $dec); - $rep->TextCol(6, 7, number_format2($item[2], $dec)); + $rep->AmountCol(6, 7, $item[2], $dec); /* if ($trans['type'] == 10) $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; @@ -154,7 +162,7 @@ function print_customer_balances() $item[3] = $item[0] + $item[1] - $item[2]; else $item[3] = $item[0] - $item[1] + $item[2]; - $rep->TextCol(7, 8, number_format2($item[3], $dec)); + $rep->AmountCol(7, 8, $item[3], $dec); for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; @@ -165,7 +173,7 @@ function print_customer_balances() $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); for ($i = 0; $i < 4; $i++) - $rep->TextCol($i + 4, $i + 5, number_format2($total[$i], $dec)); + $rep->AmountCol($i + 4, $i + 5, $total[$i], $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); } @@ -173,8 +181,9 @@ function print_customer_balances() $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < 4; $i++) - $rep->TextCol($i + 4, $i + 5, number_format2($grandtotal[$i], $dec)); + $rep->AmountCol($i + 4, $i + 5, $grandtotal[$i], $dec); $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep102.php b/reporting/rep102.php index cbb8df42..797f9bc7 100644 --- a/reporting/rep102.php +++ b/reporting/rep102.php @@ -25,7 +25,6 @@ include_once($path_to_root . "/gl/includes/gl_db.inc"); //---------------------------------------------------------------------------------------------------- -// trial_inquiry_controls(); print_aged_customer_analysis(); function get_invoices($costomer_id, $to) @@ -69,14 +68,23 @@ function print_aged_customer_analysis() { global $comp_path, $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $to = $_POST['PARAM_0']; $fromcust = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $summaryOnly = $_POST['PARAM_3']; $graphics = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "AgedCustomerAnalysis.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "AgedCustomerAnalysis.pdf"; + } if ($graphics) { include_once($path_to_root . "/reporting/includes/class.graphic.inc"); @@ -121,7 +129,7 @@ function print_aged_customer_analysis() if ($convert) $headers[2] = _('Currency'); - $rep = new FrontReport(_('Aged Customer Analysis'), "AgedCustomerAnalysis.pdf", user_pagesize()); + $rep = new FrontReport(_('Aged Customer Analysis'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -140,11 +148,11 @@ function print_aged_customer_analysis() if (!$convert && $currency != $myrow['curr_code']) continue; $rep->fontSize += 2; - $rep->TextCol(0, 3, $myrow['name']); + $rep->TextCol(0, 2, $myrow['name']); if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); - $rep->TextCol(2, 4, $myrow['curr_code']); + $rep->TextCol(2, 3, $myrow['curr_code']); } else $rate = 1.0; @@ -157,13 +165,13 @@ function print_aged_customer_analysis() $total[2] += ($custrec["Overdue1"]-$custrec["Overdue2"]); $total[3] += $custrec["Overdue2"]; $total[4] += $custrec["Balance"]; - $str = array(number_format2(($custrec["Balance"] - $custrec["Due"]),$dec), - number_format2(($custrec["Due"]-$custrec["Overdue1"]),$dec), - number_format2(($custrec["Overdue1"]-$custrec["Overdue2"]) ,$dec), - number_format2($custrec["Overdue2"],$dec), - number_format2($custrec["Balance"],$dec)); + $str = array($custrec["Balance"] - $custrec["Due"], + $custrec["Due"]-$custrec["Overdue1"], + $custrec["Overdue1"]-$custrec["Overdue2"], + $custrec["Overdue2"], + $custrec["Balance"]); for ($i = 0; $i < count($str); $i++) - $rep->TextCol($i + 3, $i + 4, $str[$i]); + $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); $rep->NewLine(1, 2); if (!$summaryOnly) { @@ -176,7 +184,7 @@ function print_aged_customer_analysis() $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name'], -2); $rep->TextCol(1, 2, $trans['reference'], -2); - $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2); + $rep->DateCol(2, 3, $trans['tran_date'], true, -2); if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) { $trans['Balance'] *= -1; @@ -186,13 +194,13 @@ function print_aged_customer_analysis() } foreach ($trans as $i => $value) $trans[$i] *= $rate; - $str = array(number_format2(($trans["Balance"] - $trans["Due"]),$dec), - number_format2(($trans["Due"]-$trans["Overdue1"]),$dec), - number_format2(($trans["Overdue1"]-$trans["Overdue2"]) ,$dec), - number_format2($trans["Overdue2"],$dec), - number_format2($trans["Balance"],$dec)); + $str = array($trans["Balance"] - $trans["Due"], + $trans["Due"]-$trans["Overdue1"], + $trans["Overdue1"]-$trans["Overdue2"], + $trans["Overdue2"], + $trans["Balance"]); for ($i = 0; $i < count($str); $i++) - $rep->TextCol($i + 3, $i + 4, $str[$i]); + $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); } $rep->Line($rep->row - 8); $rep->NewLine(2); @@ -208,7 +216,7 @@ function print_aged_customer_analysis() $rep->fontSize -= 2; for ($i = 0; $i < count($total); $i++) { - $rep->TextCol($i + 3, $i + 4, number_format2($total[$i], $dec)); + $rep->AmountCol($i + 3, $i + 4, $total[$i], $dec); if ($graphics && $i < count($total) - 1) { $pg->y[$i] = abs($total[$i]); @@ -238,6 +246,7 @@ function print_aged_customer_analysis() $rep->Header(); $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep103.php b/reporting/rep103.php index 548f88a2..c4b9723c 100644 --- a/reporting/rep103.php +++ b/reporting/rep103.php @@ -25,7 +25,6 @@ include_once($path_to_root . "/gl/includes/gl_db.inc"); //---------------------------------------------------------------------------------------------------- -// trial_inquiry_controls(); print_customer_details_listing(); function get_customer_details_for_report($area=0, $salesid=0) @@ -96,14 +95,23 @@ function print_customer_details_listing() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $from = $_POST['PARAM_0']; $area = $_POST['PARAM_1']; $folk = $_POST['PARAM_2']; $more = $_POST['PARAM_3']; $less = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "CustomerDetailsListing.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "CustomerDetailsListing.pdf"; + } $dec = 0; @@ -145,7 +153,7 @@ function print_customer_details_listing() 3 => array('text' => _('Sales Folk'), 'from' => $salesfolk, 'to' => ''), 4 => array('text' => _('Activity'), 'from' => $morestr, 'to' => $lessstr)); - $rep = new FrontReport(_('Customer Details Listing'), "CustomerDetailsListing.pdf", user_pagesize()); + $rep = new FrontReport(_('Customer Details Listing'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); diff --git a/reporting/rep104.php b/reporting/rep104.php index 988114ae..ecd2c967 100644 --- a/reporting/rep104.php +++ b/reporting/rep104.php @@ -69,14 +69,23 @@ function print_price_listing() { global $comp_path, $path_to_root, $pic_height, $pic_width; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $currency = $_POST['PARAM_0']; $category = $_POST['PARAM_1']; $salestype = $_POST['PARAM_2']; $pictures = $_POST['PARAM_3']; $showGP = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "PriceListing.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "PriceListing.pdf"; + } $dec = user_price_dec(); @@ -145,7 +154,7 @@ function print_price_listing() $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $price = get_price($myrow['stock_id'], $currency, $salestype); - $rep->TextCol(2, 3, number_format2($price, $dec)); + $rep->AmountCol(2, 3, $price, $dec); if ($showGP) { $price2 = get_price($myrow['stock_id'], $home_curr, $salestype); @@ -199,11 +208,11 @@ function print_price_listing() $rep->TextCol(0, 1, $myrow['kit_code']); $rep->TextCol(1, 2, $myrow['kit_name']); $price = get_kit_price($myrow['kit_code'], $currency, $salestype); - $rep->TextCol(2, 3, number_format2($price, $dec)); + $rep->AmountCol(2, 3, $price, $dec); $rep->NewLine(0, 1); } $rep->Line($rep->row - 4); - + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep105.php b/reporting/rep105.php index 7a0222a7..d19c438c 100644 --- a/reporting/rep105.php +++ b/reporting/rep105.php @@ -26,7 +26,6 @@ include_once($path_to_root . "/inventory/includes/db/items_category_db.inc"); //---------------------------------------------------------------------------------------------------- -// trial_inquiry_controls(); print_order_status_list(); //---------------------------------------------------------------------------------------------------- @@ -72,14 +71,23 @@ function print_order_status_list() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $backorder = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "OrderStatusListing.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "OrderStatusListing.pdf"; + } if ($category == reserved_words::get_all_numeric()) $category = 0; @@ -117,7 +125,7 @@ function print_order_status_list() $cols2 = $cols; $aligns2 = $aligns; - $rep = new FrontReport(_('Order Status Listing'), "OrderStatusListing.pdf", user_pagesize()); + $rep = new FrontReport(_('Order Status Listing'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); @@ -145,8 +153,8 @@ function print_order_status_list() $rep->TextCol(1, 2, get_customer_name($myrow['debtor_no'])); $rep->TextCol(2, 3, get_branch_name($myrow['branch_code'])); $rep->TextCol(3, 4, $myrow['customer_ref']); - $rep->TextCol(4, 5, sql2date($myrow['ord_date'])); - $rep->TextCol(5, 6, sql2date($myrow['delivery_date'])); + $rep->DateCol(4, 5, $myrow['ord_date'], true); + $rep->DateCol(5, 6, $myrow['delivery_date'], true); $rep->TextCol(6, 7, $myrow['from_stk_loc']); $rep->NewLine(2); $orderno = $myrow['order_no']; @@ -154,9 +162,9 @@ function print_order_status_list() $rep->TextCol(0, 1, $myrow['stk_code']); $rep->TextCol(1, 2, $myrow['description']); $dec = get_qty_dec($myrow['stk_code']); - $rep->TextCol(2, 3, number_format2($myrow['quantity'], $dec)); - $rep->TextCol(3, 4, number_format2($myrow['qty_sent'], $dec)); - $rep->TextCol(4, 5, number_format2($myrow['quantity'] - $myrow['qty_sent'], $dec)); + $rep->AmountCol(2, 3, $myrow['quantity'], $dec); + $rep->AmountCol(3, 4, $myrow['qty_sent'], $dec); + $rep->AmountCol(4, 5, $myrow['quantity'] - $myrow['qty_sent'], $dec); if ($myrow['quantity'] - $myrow['qty_sent'] > 0) { $rep->Font('italic'); diff --git a/reporting/rep106.php b/reporting/rep106.php index 71fa3474..1b891f45 100644 --- a/reporting/rep106.php +++ b/reporting/rep106.php @@ -60,12 +60,21 @@ function print_salesman_list() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $summary = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "SalesmanListing.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "SalesmanListing.pdf"; + } if ($summary == 0) $sum = _("No"); @@ -91,7 +100,7 @@ function print_salesman_list() $cols2 = $cols; $aligns2 = $aligns; - $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing.pdf", user_pagesize()); + $rep = new FrontReport(_('Salesman Listing'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); @@ -116,17 +125,16 @@ function print_salesman_list() $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); - $rep->TextCol(5, 6, number_format2($subtotal, $dec)); - $rep->TextCol(6, 7, number_format2($subprov, $dec)); + $rep->AmountCol(5, 6, $subtotal, $dec); + $rep->AmountCol(6, 7, $subprov, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); - //$rep->Line($rep->row); } $rep->TextCol(0, 2, $myrow['salesman_code']." ".$myrow['salesman_name']); $rep->TextCol(2, 3, $myrow['salesman_phone']); $rep->TextCol(3, 4, $myrow['salesman_email']); $rep->TextCol(4, 5, number_format2($myrow['provision'], user_percent_dec()) ." %"); - $rep->TextCol(5, 6, number_format2($myrow['break_pt'], $dec)); + $rep->AmountCol(5, 6, $myrow['break_pt'], $dec); $rep->TextCol(6, 7, number_format2($myrow['provision2'], user_percent_dec()) ." %"); $rep->NewLine(2); $salesman = $myrow['salesman_code']; @@ -135,7 +143,6 @@ function print_salesman_list() $subtotal = 0; $subprov = 0; } - $date = sql2date($myrow['tran_date']); $rate = $myrow['rate']; $amt = $myrow['InvoiceTotal'] * $rate; if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) @@ -148,9 +155,9 @@ function print_salesman_list() $rep->TextCol(1, 2, $myrow['DebtorName']); $rep->TextCol(2, 3, $myrow['br_name']); $rep->TextCol(3, 4, $myrow['contact_name']); - $rep->TextCol(4, 5, $date); - $rep->TextCol(5, 6, number_format2($amt, $dec)); - $rep->TextCol(6, 7, number_format2($prov, $dec)); + $rep->DateCol(4, 5, $myrow['tran_date'], true); + $rep->AmountCol(5, 6, $amt, $dec); + $rep->AmountCol(6, 7, $prov, $dec); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + (2 * $rep->lineHeight)) { @@ -166,20 +173,20 @@ function print_salesman_list() $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); - $rep->TextCol(5, 6, number_format2($subtotal, $dec)); - $rep->TextCol(6, 7, number_format2($subprov, $dec)); + $rep->AmountCol(5, 6, $subtotal, $dec); + $rep->AmountCol(6, 7, $subprov, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); - //$rep->Line($rep->row); $total += $subtotal; $provtotal += $subprov; } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; - $rep->TextCol(5, 6, number_format2($total, $dec)); - $rep->TextCol(6, 7, number_format2($provtotal, $dec)); + $rep->AmountCol(5, 6, $total, $dec); + $rep->AmountCol(6, 7, $provtotal, $dec); $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep201.php b/reporting/rep201.php index 775f04af..ba247392 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -53,12 +53,21 @@ function print_supplier_balances() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $to = $_POST['PARAM_0']; $fromsupp = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "SupplierBalances.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "SupplierBalances.pdf"; + } if ($fromsupp == reserved_words::get_all_numeric()) $from = _('All'); @@ -86,7 +95,7 @@ function print_supplier_balances() 2 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''), 3 => array( 'text' => _('Currency'),'from' => $currency, 'to' => '')); - $rep = new FrontReport(_('Supplier Balances'), "SupplierBalances.pdf", user_pagesize()); + $rep = new FrontReport(_('Supplier Balances'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -121,28 +130,26 @@ function print_supplier_balances() $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['reference']); - $date = sql2date($trans['tran_date']); - $rep->TextCol(2, 3, $date); + $rep->DateCol(2, 3, $trans['tran_date'], true); if ($trans['type'] == 20) - $rep->TextCol(3, 4, sql2date($trans['due_date'])); + $rep->DateCol(3, 4, $trans['due_date'], true); $item[0] = $item[1] = 0.0; if ($convert) - //$rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date); $rate = $trans['rate']; else $rate = 1.0; if ($trans['TotalAmount'] > 0.0) { $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); - $rep->TextCol(4, 5, number_format2($item[0], $dec)); + $rep->AmountCol(4, 5, $item[0], $dec); } else { $item[1] = round2(abs($trans['TotalAmount']) * $rate, $dec); - $rep->TextCol(5, 6, number_format2($item[1], $dec)); + $rep->AmountCol(5, 6, $item[1], $dec); } $item[2] = round2($trans['Allocated'] * $rate, $dec); - $rep->TextCol(6, 7, number_format2($item[2], $dec)); + $rep->AmountCol(6, 7, $item[2], $dec); /* if ($trans['type'] == 20) $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; @@ -153,7 +160,7 @@ function print_supplier_balances() $item[3] = $item[0] + $item[1] - $item[2]; else $item[3] = $item[0] - $item[1] + $item[2]; - $rep->TextCol(7, 8, number_format2($item[3], $dec)); + $rep->AmountCol(7, 8, $item[3], $dec); for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; @@ -165,7 +172,7 @@ function print_supplier_balances() $rep->TextCol(0, 3, _('Total')); for ($i = 0; $i < 4; $i++) { - $rep->TextCol($i + 4, $i + 5, number_format2($total[$i], $dec)); + $rep->AmountCol($i + 4, $i + 5, $total[$i], $dec); $total[$i] = 0.0; } $rep->Line($rep->row - 4); @@ -175,8 +182,9 @@ function print_supplier_balances() $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < 4; $i++) - $rep->TextCol($i + 4, $i + 5,number_format2($grandtotal[$i], $dec)); + $rep->AmountCol($i + 4, $i + 5,$grandtotal[$i], $dec); $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep202.php b/reporting/rep202.php index ae0e287c..b193f5c7 100644 --- a/reporting/rep202.php +++ b/reporting/rep202.php @@ -70,14 +70,23 @@ function print_aged_supplier_analysis() { global $comp_path, $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $to = $_POST['PARAM_0']; $fromsupp = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $summaryOnly = $_POST['PARAM_3']; $graphics = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "AgedSupplierAnalysis.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "AgedSupplierAnalysis.pdf"; + } if ($graphics) { include_once($path_to_root . "/reporting/includes/class.graphic.inc"); @@ -122,7 +131,7 @@ function print_aged_supplier_analysis() if ($convert) $headers[2] = _('currency'); - $rep = new FrontReport(_('Aged Supplier Analysis'), "AgedSupplierAnalysis.pdf", user_pagesize()); + $rep = new FrontReport(_('Aged Supplier Analysis'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -148,11 +157,11 @@ function print_aged_supplier_analysis() if (!$convert && $currency != $myrow['curr_code']) continue; $rep->fontSize += 2; - $rep->TextCol(0, 3, $myrow['name']); + $rep->TextCol(0, 2, $myrow['name']); if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); - $rep->TextCol(2, 4, $myrow['curr_code']); + $rep->TextCol(2, 3, $myrow['curr_code']); } else $rate = 1.0; @@ -165,13 +174,13 @@ function print_aged_supplier_analysis() $total[2] += ($supprec["Overdue1"]-$supprec["Overdue2"]); $total[3] += $supprec["Overdue2"]; $total[4] += $supprec["Balance"]; - $str = array(number_format2(($supprec["Balance"] - $supprec["Due"]),$dec), - number_format2(($supprec["Due"]-$supprec["Overdue1"]),$dec), - number_format2(($supprec["Overdue1"]-$supprec["Overdue2"]) ,$dec), - number_format2($supprec["Overdue2"],$dec), - number_format2($supprec["Balance"],$dec)); + $str = array($supprec["Balance"] - $supprec["Due"], + $supprec["Due"]-$supprec["Overdue1"], + $supprec["Overdue1"]-$supprec["Overdue2"], + $supprec["Overdue2"], + $supprec["Balance"]); for ($i = 0; $i < count($str); $i++) - $rep->TextCol($i + 3, $i + 4, $str[$i]); + $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); $rep->NewLine(1, 2); if (!$summaryOnly) { @@ -187,13 +196,13 @@ function print_aged_supplier_analysis() $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2); foreach ($trans as $i => $value) $trans[$i] *= $rate; - $str = array(number_format2(($trans["Balance"] - $trans["Due"]),$dec), - number_format2(($trans["Due"]-$trans["Overdue1"]),$dec), - number_format2(($trans["Overdue1"]-$trans["Overdue2"]) ,$dec), - number_format2($trans["Overdue2"],$dec), - number_format2($trans["Balance"],$dec)); + $str = array($trans["Balance"] - $trans["Due"], + $trans["Due"]-$trans["Overdue1"], + $trans["Overdue1"]-$trans["Overdue2"], + $trans["Overdue2"], + $trans["Balance"]); for ($i = 0; $i < count($str); $i++) - $rep->TextCol($i + 3, $i + 4, $str[$i]); + $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); } $rep->Line($rep->row - 8); $rep->NewLine(2); @@ -209,13 +218,14 @@ function print_aged_supplier_analysis() $rep->fontSize -= 2; for ($i = 0; $i < count($total); $i++) { - $rep->TextCol($i + 3, $i + 4, number_format2($total[$i], $dec)); + $rep->AmountCol($i + 3, $i + 4, $total[$i], $dec); if ($graphics && $i < count($total) - 1) { $pg->y[$i] = abs($total[$i]); } } $rep->Line($rep->row - 8); + $rep->NewLine(); if ($graphics) { global $decseps, $graph_skin; diff --git a/reporting/rep203.php b/reporting/rep203.php index b483f655..078c7c08 100644 --- a/reporting/rep203.php +++ b/reporting/rep203.php @@ -59,12 +59,21 @@ function print_payment_report() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $to = $_POST['PARAM_0']; $fromsupp = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "PaymentReport.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "PaymentReport.pdf"; + } if ($fromsupp == reserved_words::get_all_numeric()) $from = _('All'); @@ -135,18 +144,18 @@ function print_payment_report() $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['supp_reference']); if ($trans['type'] == 20) - $rep->TextCol(2, 3, sql2date($trans['due_date'])); + $rep->DateCol(2, 3, $trans['due_date'], true); else - $rep->TextCol(2, 3, sql2date($trans['tran_date'])); + $rep->DateCol(2, 3, $trans['tran_date'], true); if ($trans['type'] != 20) { $trans['TranTotal'] = -$trans['TranTotal']; $trans['Balance'] = -$trans['Balance']; } $item[0] = $trans['TranTotal'] * $rate; - $rep->TextCol(6, 7, number_format2($item[0], $dec)); + $rep->AmountCol(6, 7, $item[0], $dec); $item[1] = $trans['Balance'] * $rate; - $rep->TextCol(7, 8, number_format2($item[1], $dec)); + $rep->AmountCol(7, 8, $item[1], $dec); for ($i = 0; $i < 2; $i++) { $total[$i] += $item[$i]; @@ -158,7 +167,7 @@ function print_payment_report() $rep->TextCol(0, 3, _('Total')); for ($i = 0; $i < 2; $i++) { - $rep->TextCol($i + 6, $i + 7, number_format2($total[$i], $dec)); + $rep->AmountCol($i + 6, $i + 7, $total[$i], $dec); $total[$i] = 0.0; } $rep->Line($rep->row - 4); @@ -168,8 +177,9 @@ function print_payment_report() $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < 2; $i++) - $rep->TextCol($i + 6, $i + 7,number_format2($grandtotal[$i], $dec)); + $rep->AmountCol($i + 6, $i + 7,$grandtotal[$i], $dec); $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep204.php b/reporting/rep204.php index 6f63e3b6..120bbbc0 100644 --- a/reporting/rep204.php +++ b/reporting/rep204.php @@ -63,10 +63,19 @@ function print_outstanding_GRN() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $fromsupp = $_POST['PARAM_0']; $comments = $_POST['PARAM_1']; + $destination = $_POST['PARAM_2']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "OutstandingGRN.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "OutstandingGRN.pdf"; + } if ($fromsupp == reserved_words::get_all_numeric()) $from = _('All'); @@ -84,7 +93,7 @@ function print_outstanding_GRN() $params = array( 0 => $comments, 1 => array('text' => _('Supplier'), 'from' => $from, 'to' => '')); - $rep = new FrontReport(_('Outstanding GRNs Report'), "OutstandingGRN.pdf", user_pagesize()); + $rep = new FrontReport(_('Outstanding GRNs Report'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -104,7 +113,7 @@ function print_outstanding_GRN() { $rep->NewLine(2); $rep->TextCol(0, 7, _('Total')); - $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec)); + $rep->AmountCol(7, 8, $SuppTot_Val, $dec); $rep->Line($rep->row - 2); $rep->NewLine(3); $SuppTot_Val = 0; @@ -116,13 +125,13 @@ function print_outstanding_GRN() $rep->TextCol(0, 1, $GRNs['id']); $rep->TextCol(1, 2, $GRNs['order_no']); $rep->TextCol(2, 3, $GRNs['item_code'] . '-' . $GRNs['description']); - $rep->TextCol(3, 4, number_format2($GRNs['qty_recd'], $dec2)); - $rep->TextCol(4, 5, number_format2($GRNs['quantity_inv'], $dec2)); + $rep->AmountCol(3, 4, $GRNs['qty_recd'], $dec2); + $rep->AmountCol(4, 5, $GRNs['quantity_inv'], $dec2); $QtyOstg = $GRNs['qty_recd'] - $GRNs['quantity_inv']; $Value = ($GRNs['qty_recd'] - $GRNs['quantity_inv']) * $GRNs['std_cost_unit']; - $rep->TextCol(5, 6, number_format2($QtyOstg, $dec2)); - $rep->TextCol(6, 7, number_format2($GRNs['std_cost_unit'], $dec)); - $rep->TextCol(7, 8, number_format2($Value, $dec)); + $rep->AmountCol(5, 6, $QtyOstg, $dec2); + $rep->AmountCol(6, 7, $GRNs['std_cost_unit'], $dec); + $rep->AmountCol(7, 8, $Value, $dec); $Tot_Val += $Value; $SuppTot_Val += $Value; @@ -132,15 +141,16 @@ function print_outstanding_GRN() { $rep->NewLine(); $rep->TextCol(0, 7, _('Total')); - $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec)); + $rep->AmountCol(7, 8, $SuppTot_Val, $dec); $rep->Line($rep->row - 2); $rep->NewLine(3); $SuppTot_Val = 0; } $rep->NewLine(2); $rep->TextCol(0, 7, _('Grand Total')); - $rep->TextCol(7, 8, number_format2($Tot_Val, $dec)); + $rep->AmountCol(7, 8, $Tot_Val, $dec); $rep->Line($rep->row - 2); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep301.php b/reporting/rep301.php index bf189355..96424ec3 100644 --- a/reporting/rep301.php +++ b/reporting/rep301.php @@ -68,12 +68,21 @@ function print_inventory_valuation_report() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $category = $_POST['PARAM_0']; $location = $_POST['PARAM_1']; $detail = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "InventoryValReport.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "InventoryValReport.pdf"; + } $dec = user_price_dec(); @@ -101,7 +110,7 @@ function print_inventory_valuation_report() 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => _('Location'), 'from' => $loc, 'to' => '')); - $rep = new FrontReport(_('Inventory Valuation Report'), "InventoryValReport.pdf", user_pagesize()); + $rep = new FrontReport(_('Inventory Valuation Report'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -121,7 +130,7 @@ function print_inventory_valuation_report() $rep->NewLine(2, 3); $rep->TextCol(0, 4, _('Total')); } - $rep->Textcol(4, 5, number_format2($total, $dec)); + $rep->AmountCol(4, 5, $total, $dec); if ($detail) { $rep->Line($rep->row - 2); @@ -142,9 +151,9 @@ function print_inventory_valuation_report() $rep->fontsize -= 2; $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); - $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], get_qty_dec($trans['stock_id']))); - $rep->TextCol(3, 4, number_format2($trans['UnitCost'], $dec)); - $rep->TextCol(4, 5, number_format2($trans['ItemTotal'], $dec)); + $rep->AmountCol(2, 3, $trans['QtyOnHand'], get_qty_dec($trans['stock_id'])); + $rep->AmountCol(3, 4, $trans['UnitCost'], $dec); + $rep->AmountCol(4, 5, $trans['ItemTotal'], $dec); $rep->fontsize += 2; } $total += $trans['ItemTotal']; @@ -155,7 +164,7 @@ function print_inventory_valuation_report() $rep->NewLine(2, 3); $rep->TextCol(0, 4, _('Total')); } - $rep->Textcol(4, 5, number_format2($total, $dec)); + $rep->Amountcol(4, 5, $total, $dec); if ($detail) { $rep->Line($rep->row - 2); @@ -163,8 +172,9 @@ function print_inventory_valuation_report() } $rep->NewLine(2, 1); $rep->TextCol(0, 4, _('Grand Total')); - $rep->TextCol(4, 5, number_format2($grandtotal, $dec)); + $rep->AmountCol(4, 5, $grandtotal, $dec); $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep302.php b/reporting/rep302.php index d40e4038..41bc978c 100644 --- a/reporting/rep302.php +++ b/reporting/rep302.php @@ -147,11 +147,20 @@ function print_inventory_planning() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $category = $_POST['PARAM_0']; $location = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; + $destination = $_POST['PARAM_3']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "InventoryPlanning.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "InventoryPlanning.pdf"; + } if ($category == reserved_words::get_all_numeric()) $category = 0; @@ -185,7 +194,7 @@ function print_inventory_planning() 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => _('Location'), 'from' => $loc, 'to' => '')); - $rep = new FrontReport(_('Inventory Planning Report'), "InventoryPlanning.pdf", user_pagesize()); + $rep = new FrontReport(_('Inventory Planning Report'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -219,26 +228,27 @@ function print_inventory_planning() $dec = get_qty_dec($trans['stock_id']); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); - $rep->TextCol(2, 3, number_format2($period['prd0'], $dec)); - $rep->TextCol(3, 4, number_format2($period['prd1'], $dec)); - $rep->TextCol(4, 5, number_format2($period['prd2'], $dec)); - $rep->TextCol(5, 6, number_format2($period['prd3'], $dec)); - $rep->TextCol(6, 7, number_format2($period['prd4'], $dec)); + $rep->AmountCol(2, 3, $period['prd0'], $dec); + $rep->AmountCol(3, 4, $period['prd1'], $dec); + $rep->AmountCol(4, 5, $period['prd2'], $dec); + $rep->AmountCol(5, 6, $period['prd3'], $dec); + $rep->AmountCol(6, 7, $period['prd4'], $dec); $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']); $IdealStockHolding = $MaxMthSales * 3; - $rep->TextCol(7, 8, number_format2($IdealStockHolding, $dec)); + $rep->AmountCol(7, 8, $IdealStockHolding, $dec); - $rep->TextCol(8, 9, number_format2($trans['qty_on_hand'], $dec)); - $rep->TextCol(9, 10, number_format2($custqty, $dec)); - $rep->TextCol(10, 11, number_format2($suppqty, $dec)); + $rep->AmountCol(8, 9, $trans['qty_on_hand'], $dec); + $rep->AmountCol(9, 10, $custqty, $dec); + $rep->AmountCol(10, 11, $suppqty, $dec); $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty; if ($SuggestedTopUpOrder < 0.0) $SuggestedTopUpOrder = 0.0; - $rep->TextCol(11, 12, number_format2($SuggestedTopUpOrder, $dec)); + $rep->AmountCol(11, 12, $SuggestedTopUpOrder, $dec); } $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep303.php b/reporting/rep303.php index 285dd726..302051f1 100644 --- a/reporting/rep303.php +++ b/reporting/rep303.php @@ -107,13 +107,22 @@ function print_stock_check() { global $comp_path, $path_to_root, $pic_height, $pic_width; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $category = $_POST['PARAM_0']; $location = $_POST['PARAM_1']; $pictures = $_POST['PARAM_2']; $check = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; + $destination = $_POST['PARAM_5']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "StockCheckSheet.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "StockCheckSheet.pdf"; + } if ($category == reserved_words::get_all_numeric()) $category = 0; @@ -152,7 +161,7 @@ function print_stock_check() else $user_comp = ""; - $rep = new FrontReport(_('Stock Check Sheets'), "StockCheckSheet.pdf", user_pagesize()); + $rep = new FrontReport(_('Stock Check Sheets'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -184,17 +193,17 @@ function print_stock_check() $dec = get_qty_dec($trans['stock_id']); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); - $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], $dec)); + $rep->AmountCol(2, 3, $trans['QtyOnHand'], $dec); if ($check) { $rep->TextCol(3, 4, "_________"); - $rep->TextCol(4, 5, number_format2($demandqty, $dec)); - $rep->TextCol(5, 6, number_format2($trans['QtyOnHand'] - $demandqty, $dec)); + $rep->AmountCol(4, 5, $demandqty, $dec); + $rep->AmountCol(5, 6, $trans['QtyOnHand'] - $demandqty, $dec); } else { - $rep->TextCol(3, 4, number_format2($demandqty, $dec)); - $rep->TextCol(4, 5, number_format2($trans['QtyOnHand'] - $demandqty, $dec)); + $rep->AmountCol(3, 4, $demandqty, $dec); + $rep->AmountCol(4, 5, $trans['QtyOnHand'] - $demandqty, $dec); } if ($pictures) { @@ -211,6 +220,7 @@ function print_stock_check() } } $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep304.php b/reporting/rep304.php index 38b0dce2..5ac7f6b5 100644 --- a/reporting/rep304.php +++ b/reporting/rep304.php @@ -106,14 +106,23 @@ function print_inventory_sales() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $detail = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "InventorySalesReport.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "InventorySalesReport.pdf"; + } $dec = user_price_dec(); @@ -165,9 +174,9 @@ function print_inventory_sales() $rep->NewLine(2, 3); $rep->TextCol(0, 2, _('Total')); } - $rep->TextCol(2, 3, number_format2($total, $dec)); - $rep->TextCol(3, 4, number_format2($total1, $dec)); - $rep->Textcol(4, 5, number_format2($total2, $dec)); + $rep->AmountCol(2, 3, $total, $dec); + $rep->AmountCol(3, 4, $total1, $dec); + $rep->AmountCol(4, 5, $total2, $dec); if ($detail) { $rep->Line($rep->row - 2); @@ -192,9 +201,9 @@ function print_inventory_sales() $rep->fontsize -= 2; $rep->TextCol(0, 1, $stock_id); $rep->TextCol(1, 2, $stock_desc); - $rep->TextCol(2, 3, number_format2($amt, $dec)); - $rep->TextCol(3, 4, number_format2($cost, $dec)); - $rep->TextCol(4, 5, number_format2($cb, $dec)); + $rep->AmountCol(2, 3, $amt, $dec); + $rep->AmountCol(3, 4, $cost, $dec); + $rep->AmountCol(4, 5, $cb, $dec); $rep->fontsize += 2; } $amt = $cost = $cb = 0; @@ -222,17 +231,17 @@ function print_inventory_sales() $rep->fontsize -= 2; $rep->TextCol(0, 1, $stock_id); $rep->TextCol(1, 2, $stock_desc); - $rep->TextCol(2, 3, number_format2($amt, $dec)); - $rep->TextCol(3, 4, number_format2($cost, $dec)); - $rep->TextCol(4, 5, number_format2($cb, $dec)); + $rep->AmountCol(2, 3, $amt, $dec); + $rep->AmountCol(3, 4, $cost, $dec); + $rep->AmountCol(4, 5, $cb, $dec); $rep->fontsize += 2; $rep->NewLine(2, 3); $rep->TextCol(0, 2, _('Total')); } - $rep->TextCol(2, 3, number_format2($total, $dec)); - $rep->TextCol(3, 4, number_format2($total1, $dec)); - $rep->Textcol(4, 5, number_format2($total2, $dec)); + $rep->AmountCol(2, 3, $total, $dec); + $rep->AmountCol(3, 4, $total1, $dec); + $rep->AmountCol(4, 5, $total2, $dec); if ($detail) { $rep->Line($rep->row - 2); @@ -240,11 +249,12 @@ function print_inventory_sales() } $rep->NewLine(2, 1); $rep->TextCol(0, 2, _('Grand Total')); - $rep->TextCol(2, 3, number_format2($grandtotal, $dec)); - $rep->TextCol(3, 4, number_format2($grandtotal1, $dec)); - $rep->Textcol(4, 5, number_format2($grandtotal2, $dec)); + $rep->AmountCol(2, 3, $grandtotal, $dec); + $rep->AmountCol(3, 4, $grandtotal1, $dec); + $rep->AmountCol(4, 5, $grandtotal2, $dec); $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep401.php b/reporting/rep401.php index 7db56ed3..3c8fed88 100644 --- a/reporting/rep401.php +++ b/reporting/rep401.php @@ -56,11 +56,20 @@ function print_bill_of_material() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $frompart = $_POST['PARAM_0']; $topart = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; + $destination = $_POST['PARAM_3']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "BillOfMaterial.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "BillOfMaterial.pdf"; + } $cols = array(0, 50, 305, 375, 445, 515); @@ -71,7 +80,7 @@ function print_bill_of_material() $params = array( 0 => $comments, 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart)); - $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial.pdf", user_pagesize()); + $rep = new FrontReport(_('Bill of Material Listing'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -104,9 +113,10 @@ function print_bill_of_material() $wc = get_work_centre($trans['workcentre_added']); $rep->TextCol(2, 3, get_location_name($trans['loc_code'])); $rep->TextCol(3, 4, $wc['name']); - $rep->TextCol(4, 5, number_format2($trans['quantity'], $dec)); + $rep->AmountCol(4, 5, $trans['quantity'], $dec); } $rep->Line($rep->row - 4); + $rep->NewLine(); $rep->End(); } diff --git a/reporting/rep501.php b/reporting/rep501.php index 5c2b2422..9694b7a3 100644 --- a/reporting/rep501.php +++ b/reporting/rep501.php @@ -71,13 +71,21 @@ function print_dimension_summary() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $fromdim = $_POST['PARAM_0']; $todim = $_POST['PARAM_1']; $showbal = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; - + $destination = $_POST['PARAM_4']; + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "DimensionSummary.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "DimensionSummary.pdf"; + } $cols = array(0, 50, 210, 250, 320, 395, 465, 515); @@ -88,7 +96,7 @@ function print_dimension_summary() $params = array( 0 => $comments, 1 => array('text' => _('Dimension'), 'from' => $fromdim, 'to' => $todim)); - $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary.pdf", user_pagesize()); + $rep = new FrontReport(_('Dimension Summary'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -100,8 +108,8 @@ function print_dimension_summary() $rep->TextCol(0, 1, $trans['reference']); $rep->TextCol(1, 2, $trans['name']); $rep->TextCol(2, 3, $trans['type_']); - $rep->TextCol(3, 4, $trans['date_']); - $rep->TextCol(4, 5, $trans['due_date']); + $rep->DateCol(3, 4, $trans['date_'], true); + $rep->DateCol(4, 5, $trans['due_date'], true); if ($trans['closed']) $str = _('Yes'); else @@ -110,7 +118,7 @@ function print_dimension_summary() if ($showbal) { $balance = getYTD($trans['id']); - $rep->TextCol(6, 7, number_format2($balance, 0)); + $rep->AmountCol(6, 7, $balance, 0); } $rep->NewLine(1, 2); } diff --git a/reporting/rep601.php b/reporting/rep601.php index 32a83f51..7bbd8ef2 100644 --- a/reporting/rep601.php +++ b/reporting/rep601.php @@ -57,15 +57,24 @@ function print_bank_transactions() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - - $rep = new FrontReport(_('Bank Statement'), "BankStatement.pdf", user_pagesize()); - $acc = $_POST['PARAM_0']; $from = $_POST['PARAM_1']; $to = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "BankStatement.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "BankStatement.pdf"; + } + $rep = new FrontReport(_('Bank Statement'), $filename, user_pagesize()); $dec = user_price_dec(); $cols = array(0, 90, 110, 170, 225, 350, 400, 460, 520); @@ -97,9 +106,9 @@ function print_bank_transactions() $rep->TextCol(0, 3, $act); $rep->TextCol(3, 5, _('Opening Balance')); if ($prev_balance > 0.0) - $rep->TextCol(5, 6, number_format2(abs($prev_balance), $dec)); + $rep->AmountCol(5, 6, abs($prev_balance), $dec); else - $rep->TextCol(6, 7, number_format2(abs($prev_balance), $dec)); + $rep->AmountCol(6, 7, abs($prev_balance), $dec); $rep->Font(); $total = $prev_balance; $rep->NewLine(2); @@ -112,13 +121,13 @@ function print_bank_transactions() $rep->TextCol(0, 1, systypes::name($myrow["type"])); $rep->TextCol(1, 2, $myrow['trans_no']); $rep->TextCol(2, 3, $myrow['ref']); - $rep->TextCol(3, 4, sql2date($myrow["trans_date"])); + $rep->DateCol(3, 4, $myrow["trans_date"], true); $rep->TextCol(4, 5, payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"], false)); if ($myrow['amount'] > 0.0) - $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec)); + $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); else - $rep->TextCol(6, 7, number_format2(abs($myrow['amount']), $dec)); - $rep->TextCol(7, 8, number_format2($total, $dec)); + $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); + $rep->AmountCol(7, 8, $total, $dec); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { @@ -131,9 +140,9 @@ function print_bank_transactions() $rep->Font('bold'); $rep->TextCol(3, 5, _("Ending Balance")); if ($total > 0.0) - $rep->TextCol(5, 6, number_format2(abs($total), $dec)); + $rep->AmountCol(5, 6, abs($total), $dec); else - $rep->TextCol(6, 7, number_format2(abs($total), $dec)); + $rep->AmountCol(6, 7, abs($total), $dec); $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); diff --git a/reporting/rep702.php b/reporting/rep702.php index bd3434b1..263672f2 100644 --- a/reporting/rep702.php +++ b/reporting/rep702.php @@ -35,12 +35,22 @@ function print_list_of_journal_entries() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $systype = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; + if (isset($destination) && $destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "JournalEntries.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "JournalEntries.pdf"; + } + $dec = user_price_dec(); $cols = array(0, 100, 240, 300, 400, 460, 520, 580); @@ -55,7 +65,7 @@ function print_list_of_journal_entries() 2 => array('text' => _('Type'), 'from' => systypes::name($systype), 'to' => '')); - $rep = new FrontReport(_('List of Journal Entries'), "JournalEntries.pdf", user_pagesize()); + $rep = new FrontReport(_('List of Journal Entries'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -79,7 +89,7 @@ function print_list_of_journal_entries() $typeno = $myrow['type_no']; $TransName = systypes::name($myrow['type']); $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']); - $rep->TextCol(2, 3, sql2date($myrow['tran_date'])); + $rep->DateCol(2, 3, $myrow['tran_date'], true); $coms = payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]); $memo = get_comments_string($myrow['type'], $myrow['type_no']); if ($memo != '') @@ -96,9 +106,9 @@ function print_list_of_journal_entries() $rep->TextCol(2, 3, $dim_str); $rep->TextCol(3, 4, $myrow['memo_']); if ($myrow['amount'] > 0.0) - $rep->TextCol(4, 5, number_format2(abs($myrow['amount']), $dec)); + $rep->AmountCol(4, 5, abs($myrow['amount']), $dec); else - $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec)); + $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); $rep->NewLine(1, 2); } $rep->Line($rep->row + 4); diff --git a/reporting/rep704.php b/reporting/rep704.php index 0b9a5b31..192cc523 100644 --- a/reporting/rep704.php +++ b/reporting/rep704.php @@ -34,9 +34,6 @@ function print_GL_transactions() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - - $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions.pdf", user_pagesize()); $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; @@ -49,16 +46,30 @@ function print_GL_transactions() $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; + $destination = $_POST['PARAM_7']; } else if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; } else { $comments = $_POST['PARAM_4']; + $destination = $_POST['PARAM_5']; + } + if (isset($destination) && $destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "GLAccountTransactions.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "GLAccountTransactions.pdf"; } + $rep = new FrontReport(_('GL Account Transactions'), $filename, user_pagesize()); $dec = user_price_dec(); $cols = array(0, 70, 90, 140, 210, 280, 340, 400, 450, 510, 570); @@ -71,7 +82,7 @@ function print_GL_transactions() if ($dim == 2) $headers = array(_('Type'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); - else if ($dim == 1) + elseif ($dim == 1) $headers = array(_('Type'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); else @@ -130,9 +141,9 @@ function print_GL_transactions() $rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']); $rep->TextCol(3, 5, _('Opening Balance')); if ($prev_balance > 0.0) - $rep->TextCol(6, 7, number_format2(abs($prev_balance), $dec)); + $rep->AmountCol(6, 7, abs($prev_balance), $dec); else - $rep->TextCol(7, 8, number_format2(abs($prev_balance), $dec)); + $rep->AmountCol(7, 8, abs($prev_balance), $dec); $rep->Font(); $total = $prev_balance; $rep->NewLine(2); @@ -144,16 +155,16 @@ function print_GL_transactions() $rep->TextCol(0, 1, systypes::name($myrow["type"])); $rep->TextCol(1, 2, $myrow['type_no']); - $rep->TextCol(2, 3, sql2date($myrow["tran_date"])); + $rep->DateCol(2, 3, $myrow["tran_date"], true); if ($dim >= 1) $rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id'])); if ($dim > 1) $rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id'])); $rep->TextCol(5, 6, payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"], false)); if ($myrow['amount'] > 0.0) - $rep->TextCol(6, 7, number_format2(abs($myrow['amount']), $dec)); + $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); else - $rep->TextCol(7, 8, number_format2(abs($myrow['amount']), $dec)); + $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); $rep->TextCol(8, 9, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) @@ -167,9 +178,9 @@ function print_GL_transactions() $rep->Font('bold'); $rep->TextCol(3, 5, _("Ending Balance")); if ($total > 0.0) - $rep->TextCol(6, 7, number_format2(abs($total), $dec)); + $rep->AmountCol(6, 7, abs($total), $dec); else - $rep->TextCol(7, 8, number_format2(abs($total), $dec)); + $rep->AmountCol(7, 8, abs($total), $dec); $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); diff --git a/reporting/rep706.php b/reporting/rep706.php index e2ceaf35..34fc0cba 100644 --- a/reporting/rep706.php +++ b/reporting/rep706.php @@ -61,7 +61,7 @@ function print_balance_sheet() $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } - if (isset($destination) && $destination) + if ($destination) { include_once($path_to_root . "/reporting/includes/excel_report.inc"); $filename = "BalanceSheet.xml"; diff --git a/reporting/rep708.php b/reporting/rep708.php index 120558b5..322a1247 100644 --- a/reporting/rep708.php +++ b/reporting/rep708.php @@ -64,7 +64,6 @@ function print_trial_balance() { global $path_to_root; - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; @@ -77,15 +76,28 @@ function print_trial_balance() $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; + $destination = $_POST['PARAM_7']; } else if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; + $destination = $_POST['PARAM_6']; } else { $comments = $_POST['PARAM_4']; + $destination = $_POST['PARAM_5']; + } + if ($destination) + { + include_once($path_to_root . "/reporting/includes/excel_report.inc"); + $filename = "TrialBalance.xml"; + } + else + { + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "TrialBalance.pdf"; } $dec = user_price_dec(); @@ -128,7 +140,7 @@ function print_trial_balance() 1 => array('text' => _('Period'),'from' => $from, 'to' => $to)); } - $rep = new FrontReport(_('Trial Balance'), "TrialBalance.pdf", user_pagesize()); + $rep = new FrontReport(_('Trial Balance'), $filename, user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); @@ -154,26 +166,26 @@ function print_trial_balance() if ($balances != 0) { if ($prev['balance'] >= 0.0) - $rep->TextCol(2, 3, number_format2($prev['balance'], $dec)); + $rep->AmountCol(2, 3, $prev['balance'], $dec); else - $rep->TextCol(3, 4, number_format2(abs($prev['balance']), $dec)); + $rep->AmountCol(3, 4, abs($prev['balance']), $dec); if ($curr['balance'] >= 0.0) - $rep->TextCol(4, 5, number_format2($curr['balance'], $dec)); + $rep->AmountCol(4, 5, $curr['balance'], $dec); else - $rep->TextCol(5, 6, number_format2(abs($curr['balance']), $dec)); + $rep->AmountCol(5, 6, abs($curr['balance']), $dec); if ($tot['balance'] >= 0.0) - $rep->TextCol(6, 7, number_format2($tot['balance'], $dec)); + $rep->AmountCol(6, 7, $tot['balance'], $dec); else - $rep->TextCol(7, 8, number_format2(abs($tot['balance']), $dec)); + $rep->AmountCol(7, 8, abs($tot['balance']), $dec); } else { - $rep->TextCol(2, 3, number_format2($prev['debit'], $dec)); - $rep->TextCol(3, 4, number_format2($prev['credit'], $dec)); - $rep->TextCol(4, 5, number_format2($curr['debit'], $dec)); - $rep->TextCol(5, 6, number_format2($curr['credit'], $dec)); - $rep->TextCol(6, 7, number_format2($tot['debit'], $dec)); - $rep->TextCol(7, 8, number_format2($tot['credit'], $dec)); + $rep->AmountCol(2, 3, $prev['debit'], $dec); + $rep->AmountCol(3, 4, $prev['credit'], $dec); + $rep->AmountCol(4, 5, $curr['debit'], $dec); + $rep->AmountCol(5, 6, $curr['credit'], $dec); + $rep->AmountCol(6, 7, $tot['debit'], $dec); + $rep->AmountCol(7, 8, $tot['credit'], $dec); $pdeb += $prev['debit']; $pcre += $prev['credit']; $cdeb += $curr['debit']; @@ -204,30 +216,31 @@ function print_trial_balance() if ($balances == 0) { $rep->TextCol(0, 2, _("Total")); - $rep->TextCol(2, 3, number_format2($pdeb, $dec)); - $rep->TextCol(3, 4, number_format2($pcre, $dec)); - $rep->TextCol(4, 5, number_format2($cdeb, $dec)); - $rep->TextCol(5, 6, number_format2($ccre, $dec)); - $rep->TextCol(6, 7, number_format2($tdeb, $dec)); - $rep->TextCol(7, 8, number_format2($tcre, $dec)); + $rep->AmountCol(2, 3, $pdeb, $dec); + $rep->AmountCol(3, 4, $pcre, $dec); + $rep->AmountCol(4, 5, $cdeb, $dec); + $rep->AmountCol(5, 6, $ccre, $dec); + $rep->AmountCol(6, 7, $tdeb, $dec); + $rep->AmountCol(7, 8, $tcre, $dec); $rep->NewLine(); } $rep->TextCol(0, 2, _("Ending Balance")); if ($pbal >= 0.0) - $rep->TextCol(2, 3, number_format2($pbal, $dec)); + $rep->AmountCol(2, 3, $pbal, $dec); else - $rep->TextCol(3, 4, number_format2(abs($pbal), $dec)); + $rep->AmountCol(3, 4, abs($pbal), $dec); if ($cbal >= 0.0) - $rep->TextCol(4, 5, number_format2($cbal, $dec)); + $rep->AmountCol(4, 5, $cbal, $dec); else - $rep->TextCol(5, 6, number_format2(abs($cbal), $dec)); + $rep->AmountCol(5, 6, abs($cbal), $dec); if ($tbal >= 0.0) - $rep->TextCol(6, 7, number_format2($tbal, $dec)); + $rep->AmountCol(6, 7, $tbal, $dec); else - $rep->TextCol(7, 8, number_format2(abs($tbal), $dec)); + $rep->AmountCol(7, 8, abs($tbal), $dec); + $rep->NewLine(); - $rep->Line($rep->row - 6); + $rep->Line($rep->row); $rep->End(); } diff --git a/reporting/rep709.php b/reporting/rep709.php index 668021b2..0bf72dbe 100644 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@ -76,17 +76,17 @@ function print_tax_report() { global $path_to_root, $trans_dir; - - include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - - $rep = new FrontReport(_('Tax Report'), "TaxReport.pdf", user_pagesize()); - $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $summaryOnly = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; + + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + $filename = "TaxReport.pdf"; + $dec = user_price_dec(); + $rep = new FrontReport(_('Tax Report'), $filename, user_pagesize()); if ($summaryOnly == 1) $summary = _('Summary Only'); else @@ -129,13 +129,13 @@ function print_tax_report() { $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['memo']); - $rep->TextCol(2, 3, sql2date($trans['tran_date'])); + $rep->DateCol(2, 3, $trans['tran_date'], true); $rep->TextCol(3, 4, $trans['name']); $rep->TextCol(4, 5, $trans['br_name']); - $rep->TextCol(5, 6, number_format2($trans['net_amount'], $dec)); - $rep->TextCol(6, 7, number_format2($trans['rate'], $dec)); - $rep->TextCol(7, 8, number_format2($trans['amount'], $dec)); + $rep->AmountCol(5, 6, $trans['net_amount'], $dec); + $rep->AmountCol(6, 7, $trans['rate'], $dec); + $rep->AmountCol(7, 8, $trans['amount'], $dec); $rep->NewLine(); @@ -176,11 +176,11 @@ function print_tax_report() $tx = getTaxInfo($id); $rep->TextCol(0, 1, $tx['name'] . " " . number_format2($tx['rate'], $dec) . "%"); - $rep->TextCol(1, 2, number_format2($sum['out'], $dec)); - $rep->TextCol(2, 3,number_format2($sum['taxout'], $dec)); - $rep->TextCol(3, 4, number_format2($sum['in'], $dec)); - $rep->TextCol(4, 5,number_format2($sum['taxin'], $dec)); - $rep->TextCol(5, 6, number_format2($sum['taxout']+$sum['taxin'], $dec)); + $rep->AmountCol(1, 2, $sum['out'], $dec); + $rep->AmountCol(2, 3, $sum['taxout'], $dec); + $rep->AmountCol(3, 4, $sum['in'], $dec); + $rep->AmountCol(4, 5, $sum['taxin'], $dec); + $rep->AmountCol(5, 6, $sum['taxout']+$sum['taxin'], $dec); $taxtotal += $sum['taxout']+$sum['taxin']; $rep->NewLine(); } @@ -189,7 +189,7 @@ function print_tax_report() $rep->NewLine(); $rep->Line($rep->row + $rep->lineHeight); $rep->TextCol(3, 5, _("Total payable or refund")); - $rep->TextCol(5, 6, number_format2($taxtotal, $dec)); + $rep->AmountCol(5, 6, $taxtotal, $dec); $rep->Line($rep->row - 5); $rep->Font(); $rep->NewLine(); diff --git a/reporting/reports_main.php b/reporting/reports_main.php index e7c4b7bc..9eff484c 100644 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@ -322,8 +322,7 @@ $reports->addReport(_('General Ledger'),709,_('Ta&x Report'), array( new ReportParam(_('Start Date'),'DATEBEGINTAX'), new ReportParam(_('End Date'),'DATEENDTAX'), new ReportParam(_('Summary Only'),'YES_NO'), - new ReportParam(_('Comments'),'TEXTBOX'), - new ReportParam(_('Destination'),'DESTINATION'))); + new ReportParam(_('Comments'),'TEXTBOX'))); echo "