From: <tim...@us...> - 2010-08-18 19:26:35
|
Revision: 3695 http://web-erp.svn.sourceforge.net/web-erp/?rev=3695&view=rev Author: tim_schofield Date: 2010-08-18 19:26:27 +0000 (Wed, 18 Aug 2010) Log Message: ----------- Pak Ricard: Revised report writer with the ability for more fields Modified Paths: -------------- trunk/doc/Change.log.html trunk/reportwriter/FormMaker.php trunk/reportwriter/ReportMaker.php trunk/reportwriter/WriteForm.inc trunk/reportwriter/WriteReport.inc trunk/reportwriter/admin/RCFunctions.inc trunk/reportwriter/admin/ReportCreator.php trunk/reportwriter/admin/defaults.php trunk/reportwriter/admin/forms/ReportsFieldSetup.html trunk/reportwriter/admin/forms/ReportsID.html trunk/reportwriter/admin/forms/ReportsPageSetup.html trunk/reportwriter/install/ReportListForm.php trunk/reportwriter/install/ReportListLinks.php trunk/reportwriter/languages/en_US/reports.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/doc/Change.log.html 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>18/08/10 Pak Ricard: Revised report writer with the ability for more fields</p> <p>18/08/10 Paul Thursby: PO_Items.php - Eliminate query; Moves the ONE field into a query above this point.</p> <p>15/08/10 Phil: Decided to have contracts as part of orders module since not really enough links to warrant a new module changes to index.php WWW_Users.php and sql upgrade. <p>15/08/10 Phil: New script for ContractCosting.php comparison of contract costs budgeted vs incurred. Lot of work on contracts Modified: trunk/reportwriter/FormMaker.php =================================================================== --- trunk/reportwriter/FormMaker.php 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/reportwriter/FormMaker.php 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,18 +1,16 @@ <?php +/* $Revision: 1.3 $ */ -/* $Id$ */ - $DirectoryLevelsDeep = 1; $PathPrefix = '../'; $PageSecurity = 1; // set security level for webERP require($PathPrefix . 'includes/session.inc'); // TBD The followiung line needs to be replace when more translations are available -$ReportLanguage = 'en_US'; // default language file -define('DBReports','reports'); // name of the databse holding the main report information (ReportID) +$ReportLanguage = 'en_US'; // default language file +define('DBReports','reports'); // name of the databse holding the main report information (ReportID) define('DBRptFields','reportfields'); // name of the database holding the report fields -// Javier -// define('FPDF_FONTPATH','../fonts/'); // FPDF path to fonts directory +define('FPDF_FONTPATH','../fonts/'); // FPDF path to fonts directory define('DefRptPath',$PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/reportwriter/'); // path to default reports // Fetch necessary include files - Host application specific (webERP) require_once($PathPrefix . 'includes/DateFunctions.inc'); @@ -100,9 +98,7 @@ } } // else use default settings, i.e. no overrides // All done with setup, build the form -// Javier -// require($PathPrefix . 'includes/fpdf.php'); // FPDF class to generate reports - require($PathPrefix . 'includes/class.pdf.php'); // Cpdf TCPDF class to generate reports + require($PathPrefix . 'includes/fpdf.php'); // FPDF class to generate reports require('WriteForm.inc'); // build the pdf pages (this function exits the script if successful; otherwise returns with error) $success = BuildPDF($ReportID, $Prefs); // build and output form, should not return from this function @@ -237,4 +233,4 @@ return $CriteriaString; } -?> +?> \ No newline at end of file Modified: trunk/reportwriter/ReportMaker.php =================================================================== --- trunk/reportwriter/ReportMaker.php 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/reportwriter/ReportMaker.php 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,7 +1,5 @@ <?php - -/* $Id$ */ - +/* $Revision: 1.7 $ */ $DirectoryLevelsDeep =1; $PathPrefix = '../'; $PageSecurity = 1; // set security level for webERP @@ -11,8 +9,7 @@ define('DBReports','reports'); // name of the databse holding the main report information (ReportID) define('DBRptFields','reportfields'); // name of the database holding the report fields -// Javier -// define('FPDF_FONTPATH','../fonts/'); // FPDF path to fonts directory +define('FPDF_FONTPATH','../fonts/'); // FPDF path to fonts directory // Fetch necessary include files - Host application specific (webERP) require($PathPrefix . 'includes/session.inc'); @@ -134,9 +131,7 @@ case RPT_BTN_EXPPDF: $Prefs = ReadPostData($ReportID, $Prefs); // include the necessary files to build report -// Javier -// require($PathPrefix . 'includes/fpdf.php'); // FPDF class to generate reports - require($PathPrefix . 'includes/class.pdf.php'); // Cpdf TCPDF class to generate reports + require($PathPrefix . 'includes/fpdf.php'); // FPDF class to generate reports require('WriteReport.inc'); $ReportData = ''; $success = BuildSQL($Prefs); @@ -257,7 +252,10 @@ return $FieldListings; } -function ChangeSequence($ReportID, $SeqNum, $EntryType, $UpDown) { +function ChangeSequence($ReportID, + $SeqNum, + $EntryType, + $UpDown) { global $db; // find the id of the row to move $sql = "SELECT id FROM ".DBRptFields." @@ -476,7 +474,19 @@ col5width = ".$_POST['Col5Width'].", col6width = ".$_POST['Col6Width'].", col7width = ".$_POST['Col7Width'].", - col8width = ".$_POST['Col8Width']." + col8width = ".$_POST['Col8Width'].", + col9width = ".$_POST['Col9Width'].", + col10width = ".$_POST['Col10Width'].", + col11width = ".$_POST['Col11Width'].", + col12width = ".$_POST['Col12Width'].", + col13width = ".$_POST['Col13Width'].", + col14width = ".$_POST['Col14Width'].", + col15width = ".$_POST['Col15Width'].", + col16width = ".$_POST['Col16Width'].", + col17width = ".$_POST['Col17Width'].", + col18width = ".$_POST['Col18Width'].", + col19width = ".$_POST['Col19Width'].", + col20width = ".$_POST['Col20Width'].", WHERE id =".$ReportID.";"; $Result=DB_query($sql,$db,'','',false,true); return true; @@ -553,4 +563,4 @@ $Rtn['result'] = 'success'; return $Rtn; } -?> +?> \ No newline at end of file Modified: trunk/reportwriter/WriteForm.inc =================================================================== --- trunk/reportwriter/WriteForm.inc 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/reportwriter/WriteForm.inc 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,8 +1,16 @@ <?php +// for compatability with extended char sets +if ($_SESSION['Language']=='zh_CN'){ + include($PathPrefix . 'includes/FPDF_Chinese.php'); +} elseif ($_SESSION['Language']=='ja_JP'){ + include($PathPrefix . 'includes/FPDF_Japanese.php'); +} elseif ($_SESSION['Language']=='ko_KR'){ + include($PathPrefix . 'includes/FPDF_Korean.php'); +} else { + class PDF_Language extends FPDF { } +} -/* $Id$ */ - -class PDF extends Cpdf { +class PDF extends PDF_Language { var $y0; // current y position var $x0; // current x position var $pageY; // y value of bottom of page less bottom margin @@ -12,10 +20,7 @@ global $Prefs; define('RowSpace',2); // define separation between the heading rows $PaperSize = explode(':',$Prefs['papersize']); -// $this->PDF_Language($Prefs['paperorientation'], 'mm', $PaperSize[0]); This was the calling used -// __construct($DocOrientation='P', $DocUnits='mm', $DocPaper='A4'); This is the actual contructor - parent::__construct($Prefs['paperorientation'], 'mm', $PaperSize[0]); - + $this->PDF_Language($Prefs['paperorientation'], 'mm', $PaperSize[0]); if ($Prefs['paperorientation']=='P') { // Portrait - calculate max page height $this->pageY = $PaperSize[2]-$Prefs['marginbottom']; } else { // Landscape @@ -23,12 +28,19 @@ } $this->SetMargins($Prefs['marginleft'], $Prefs['margintop'], $Prefs['marginright']); $this->SetAutoPageBreak(0, $Prefs['marginbottom']); + $this->SetFont('Helvetica'); $this->SetDrawColor(128,0,0); $this->SetLineWidth(.35); // 1 point -// Javier $this->SetFont('Helvetica'); + + if ($_SESSION['Language']=='zh_CN'){ + $this->AddBig5Font(); + } elseif ($_SESSION['Language']=='ja_JP'){ + $this->AddSJISFont(); + } elseif ($_SESSION['Language']=='ko_KR'){ + $this->AddUHCFont(); + } } - function Header() { // prints all static information on the page global $FieldListings, $FieldValues; $i=0; // set sequence to pull data fields should be sorted by seqnum @@ -79,10 +91,7 @@ $Params['BoxHeight'] = '20'; } $this->SetXY($Params['LineXStrt'],$Params['LineYStrt']); - -// Javier $this->SetFont('Helvetica', '', '10'); - $this->SetFont('', '', '10'); - + $this->SetFont('Helvetica','','10'); $this->SetTextColor(255,0,0); $this->SetDrawColor(255,0,0); $this->SetLineWidth(0.35); @@ -140,11 +149,7 @@ function FormText($Params) { if (!isset($Params['LineXStrt'])) return; // don't do anything if data array has not been set $this->SetXY($Params['LineXStrt'],$Params['LineYStrt']); - -// Javier: CJK don't have the choice to select a font -// $this->SetFont($Params['Font'],'',$Params['FontSize']); - $this->SetFont('', '', $Params['FontSize']); - + $this->SetFont($Params['Font'],'',$Params['FontSize']); if ($Params['Color']=='2') $RGB=$Params['FontRed'].':'.$Params['FontGreen'].':'.$Params['FontBlue']; else $RGB=$Params['FontColor']; $FC = explode(':',$RGB); @@ -221,11 +226,7 @@ if ($Params['Seq'][$Col]['TblShow']) { $this->SetLeftMargin($NextXPos); $this->SetXY($NextXPos, $this->y0); - -// Javier: CJK don't have the choice to select a font -// $this->SetFont($Params['Seq'][$Col]['Font'], '', $Params['Seq'][$Col]['FontSize']); - $this->SetFont('', '', $Params['Seq'][$Col]['FontSize']); - + $this->SetFont($Params['Seq'][$Col]['Font'],'',$Params['Seq'][$Col]['FontSize']); $TC = explode(':',$Params['Seq'][$Col]['FontColor']); $this->SetTextColor($TC[0],$TC[1],$TC[2]); $CellHeight = ($Params['Seq'][$Col]['FontSize']+RowSpace)*0.35; @@ -597,11 +598,9 @@ } } // Add additional headers needed for MSIE and send page - -// Javier: TCPDF sends its own http header -/* header('Pragma: cache'); + header('Pragma: cache'); header('Cache-Control: public, must-revalidate, max-age=0'); -*/ $pdf->Output($Prefs['reportname'].'.pdf','D'); + $pdf->Output($Prefs['reportname'].'.pdf','D'); exit(); // needs to be here to properly render the pdf file. } @@ -617,4 +616,4 @@ } } -?> +?> \ No newline at end of file Modified: trunk/reportwriter/WriteReport.inc =================================================================== --- trunk/reportwriter/WriteReport.inc 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/reportwriter/WriteReport.inc 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,283 +1,277 @@ -<?php +<?PHP +// for compatability with extended char sets +if ($_SESSION['Language']=='zh_CN'){ + include($PathPrefix . 'includes/FPDF_Chinese.php'); +} elseif ($_SESSION['Language']=='ja_JP'){ + include($PathPrefix . 'includes/FPDF_Japanese.php'); +} elseif ($_SESSION['Language']=='ko_KR'){ + include($PathPrefix . 'includes/FPDF_Korean.php'); +} else { + class PDF_Language extends FPDF { } +} -/* $Id$ */ +class PDF extends PDF_Language { -class PDF extends Cpdf { +var $y0; // current y position +var $x0; // current x position +var $pageY; // y value of bottom of page less bottom margin - var $y0; // current y position - var $x0; // current x position - var $pageY; // y value of bottom of page less bottom margin +function PDF() { + global $Prefs; + $PaperSize = explode(':',$Prefs['papersize']); + $this->PDF_Language($Prefs['paperorientation'], 'mm', $PaperSize[0]); + if ($Prefs['paperorientation']=='P') { // Portrait - calculate max page height + $this->pageY = $PaperSize[2]-$Prefs['marginbottom']; + } else { // Landscape + $this->pageY = $PaperSize[1]-$Prefs['marginbottom']; + } + $this->SetMargins($Prefs['marginleft'], $Prefs['margintop'], $Prefs['marginright']); + $this->SetAutoPageBreak(0, $Prefs['marginbottom']); + $this->SetFont($Prefs['coynamefont']); + $this->SetDrawColor(128,0,0); + $this->SetLineWidth(.35); // 1 point + $this->AliasNbPages(); + $this->AddPage(); - function PDF() { - global $Prefs; - $PaperSize = explode(':',$Prefs['papersize']); -// $this->PDF_Language($Prefs['paperorientation'], 'mm', $PaperSize[0]); -// __construct($DocOrientation='P', $DocUnits='mm', $DocPaper='A4'); - parent::__construct($Prefs['paperorientation'], 'mm', $PaperSize[0]); - - if ($Prefs['paperorientation']=='P') { // Portrait - calculate max page height - $this->pageY = $PaperSize[2]-$Prefs['marginbottom']; - } else { // Landscape - $this->pageY = $PaperSize[1]-$Prefs['marginbottom']; - } - $this->SetMargins($Prefs['marginleft'], $Prefs['margintop'], $Prefs['marginright']); - $this->SetAutoPageBreak(0, $Prefs['marginbottom']); - $this->SetDrawColor(128,0,0); - $this->SetLineWidth(.35); // 1 point - $this->AliasNbPages(); - $this->AddPage(); -// Javier $this->SetFont($Prefs['coynamefont']); + if ($_SESSION['Language']=='zh_CN'){ + $this->AddBig5Font(); + } elseif ($_SESSION['Language']=='zh_HK'){ + $this->AddCIDFont(); + } elseif ($_SESSION['Language']=='ja_JP'){ + $this->AddSJISFont(); + } elseif ($_SESSION['Language']=='ko_KR'){ + $this->AddUHCFont(); } +} - - function Header() { - global $Prefs, $Heading, $Seq; - define(RowSpace,2); // define separation between the heading rows - - if ($Prefs['coynameshow']) { // Show the company name - -// Javier: $this->SetFont($Prefs['coynamefont'], 'B', $Prefs['coynamefontsize']); - $this->SetFont('', 'B', $Prefs['coynamefontsize']); - - $Colors = explode(':',$Prefs['coynamefontcolor']); - $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); - $CellHeight = ($Prefs['coynamefontsize']+RowSpace)*0.35; - $this->Cell(0,$CellHeight,$_SESSION['CompanyRecord']['coyname'],0,1,$Prefs['coynamealign']); - } - if ($Prefs['title1show']) { // Set title 1 heading - -// Javier $this->SetFont($Prefs['title1font'], '', $Prefs['title1fontsize']); - $this->SetFont('', '', $Prefs['title1fontsize']); - $Colors = explode(':',$Prefs['title1fontcolor']); - $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); - $CellHeight = ($Prefs['title1fontsize']+RowSpace)*0.35; - $this->Cell(0,$CellHeight,$this->SubTitle($Prefs['title1desc']),0,1,$Prefs['title1fontalign']); - } - - if ($Prefs['title2show']) { // Set Title 2 heading -// Javier $this->SetFont($Prefs['title2font'], '', $Prefs['title2fontsize']); - $this->SetFont('', '', $Prefs['title2fontsize']); - $Colors = explode(':',$Prefs['title2fontcolor']); - $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); - $CellHeight = ($Prefs['title2fontsize']+RowSpace)*0.35; - $this->Cell(0,$CellHeight,$this->SubTitle($Prefs['title2desc']),0,1,$Prefs['title2fontalign']); - } - // Set the filter heading - -// Javier $this->SetFont($Prefs['filterfont'], '', $Prefs['filterfontsize']); - $this->SetFont('', '', $Prefs['filterfontsize']); - - $Colors = explode(':',$Prefs['filterfontcolor']); +function Header() { + global $Prefs, $Heading, $Seq; + define(RowSpace,2); // define separation between the heading rows + if ($Prefs['coynameshow']) { // Show the company name + $this->SetFont($Prefs['coynamefont'],'B',$Prefs['coynamefontsize']); + $Colors = explode(':',$Prefs['coynamefontcolor']); $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); - $CellHeight = ($Prefs['filterfontsize']+RowSpace)*0.35; // convert points to mm - $this->MultiCell(0,$CellHeight,$Prefs['filterdesc'],'B',1,$Prefs['filterfontalign']); - $this->y0=$this->GetY(); // set y position after report headings before column titles - // Set the table header - -// Javier $this->SetFont($Prefs['datafont'],'',$Prefs['datafontsize']); - $this->SetFont('','',$Prefs['datafontsize']); - - $Colors = explode(':',$Prefs['datafontcolor']); + $CellHeight = ($Prefs['coynamefontsize']+RowSpace)*0.35; + $this->Cell(0,$CellHeight,$_SESSION['CompanyRecord']['coyname'],0,1,$Prefs['coynamealign']); + } + if ($Prefs['title1show']) { // Set title 1 heading + $this->SetFont($Prefs['title1font'],'',$Prefs['title1fontsize']); + $Colors = explode(':',$Prefs['title1fontcolor']); $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); - $this->SetDrawColor(128,0,0); - $this->SetLineWidth(.35); // 1 point - $CellHeight = ($Prefs['datafontsize']+RowSpace)*0.35; - // fetch the column widths and put into array to match the columns of data - $CellXPos[0] = $Prefs['marginleft']; - for ($x=1; $x<=8; $x++) $CellXPos[$x] = $CellXPos[$x-1] + $Prefs['col'.$x.'width']; - // Fetch the column break array - foreach ($Seq as $Temp) if ($Temp['break']) $ColBreak[] = true; else $ColBreak[] = false; - // See if we need to truncate the data - if ($Prefs['TruncListings']['params']=='1') $trunc=true; else $trunc=false; - // Ready to draw the column titles in the header - $maxY = $this->y0; // set to track the tallest column - $col = 1; - $LastY = $this->y0; - foreach ($Heading as $key=>$value) { - $this->SetLeftMargin($CellXPos[$col-1]); - $this->SetX($CellXPos[$col-1]); - $this->SetY($LastY); - // truncate data if selected - if ($trunc) $value=$this->TruncData($value, $Prefs['col'.$col.'width']); - $this->MultiCell($CellXPos[$col]-$CellXPos[$col-1],$CellHeight,$value); - if ($ColBreak[$key]) { - $col++; - $LastY = $this->y0; - } else $LastY = $this->GetY(); - if ($this->GetY()>$maxY) $maxY = $this->GetY(); // check for new col max height - } - // Draw a bottom line for the end of the heading - $this->SetLeftMargin($CellXPos[0]); - $this->SetX($CellXPos[0]); - $this->SetY($this->y0); - $this->Cell(0,$maxY-$this->y0,' ','B'); - $this->y0=$maxY+0.35; + $CellHeight = ($Prefs['title1fontsize']+RowSpace)*0.35; + $this->Cell(0,$CellHeight,$this->SubTitle($Prefs['title1desc']),0,1,$Prefs['title1fontalign']); } - - function SubTitle($Title) { - global $Prefs; - // substitutes a command string with current information - $Title=preg_replace('/%date%/', date('Y-m-d',time()), $Title); - $Title=preg_replace('/%reportname%/', $Prefs['reportname'], $Title); - return $Title; + if ($Prefs['title2show']) { // Set Title 2 heading + $this->SetFont($Prefs['title2font'],'',$Prefs['title2fontsize']); + $Colors = explode(':',$Prefs['title2fontcolor']); + $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); + $CellHeight = ($Prefs['title2fontsize']+RowSpace)*0.35; + $this->Cell(0,$CellHeight,$this->SubTitle($Prefs['title2desc']),0,1,$Prefs['title2fontalign']); } - - function Footer() { - //Position at 1.5 cm from bottom - $this->SetY(-15); - //Arial italic 8 - -// Javier $this->SetFont('Helvetica', '', 8); - $this->SetFont('','', 8); - - $this->SetTextColor(0); - //Page number - $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); + // Set the filter heading + $this->SetFont($Prefs['filterfont'],'',$Prefs['filterfontsize']); + $Colors = explode(':',$Prefs['filterfontcolor']); + $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); + $CellHeight = ($Prefs['filterfontsize']+RowSpace)*0.35; // convert points to mm + $this->MultiCell(0,$CellHeight,$Prefs['filterdesc'],'B',1,$Prefs['filterfontalign']); + $this->y0=$this->GetY(); // set y position after report headings before column titles + // Set the table header + $this->SetFont($Prefs['datafont'],'',$Prefs['datafontsize']); + $Colors = explode(':',$Prefs['datafontcolor']); + $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); + $this->SetDrawColor(128,0,0); + $this->SetLineWidth(.35); // 1 point + $CellHeight = ($Prefs['datafontsize']+RowSpace)*0.35; + // fetch the column widths and put into array to match the columns of data + $CellXPos[0] = $Prefs['marginleft']; + for ($x=1; $x<=20; $x++) $CellXPos[$x] = $CellXPos[$x-1] + $Prefs['col'.$x.'width']; + // Fetch the column break array + foreach ($Seq as $Temp) if ($Temp['break']) $ColBreak[] = true; else $ColBreak[] = false; + // See if we need to truncate the data + if ($Prefs['TruncListings']['params']=='1') $trunc=true; else $trunc=false; + // Ready to draw the column titles in the header + $maxY = $this->y0; // set to track the tallest column + $col = 1; + $LastY = $this->y0; + foreach ($Heading as $key=>$value) { + $this->SetLeftMargin($CellXPos[$col-1]); + $this->SetX($CellXPos[$col-1]); + $this->SetY($LastY); + // truncate data if selected + if ($trunc) $value=$this->TruncData($value, $Prefs['col'.$col.'width']); + $this->MultiCell($CellXPos[$col]-$CellXPos[$col-1],$CellHeight,$value); + if ($ColBreak[$key]) { + $col++; + $LastY = $this->y0; + } else $LastY = $this->GetY(); + if ($this->GetY()>$maxY) $maxY = $this->GetY(); // check for new col max height } + // Draw a bottom line for the end of the heading + $this->SetLeftMargin($CellXPos[0]); + $this->SetX($CellXPos[0]); + $this->SetY($this->y0); + $this->Cell(0,$maxY-$this->y0,' ','B'); + $this->y0=$maxY+0.35; +} - function ReportTable($Data) { - global $Prefs, $Seq; +function SubTitle($Title) { + global $Prefs; + // substitutes a command string with current information + $Title=preg_replace('/%date%/', date('Y-m-d',time()), $Title); + $Title=preg_replace('/%reportname%/', $Prefs['reportname'], $Title); + return $Title; +} - $FillColor = array(224, 235, 255); +function Footer() { + //Position at 1.5 cm from bottom + $this->SetY(-15); + //Arial italic 8 + $this->SetFont('Helvetica','',8); + $this->SetTextColor(0); + //Page number + $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); +} -// Javier $this->SetFont($Prefs['datafont'], '', $Prefs['datafontsize']); - $this->SetFont('','', $Prefs['datafontsize']); +function ReportTable($Data) { + global $Prefs, $Seq; - $this->SetFillColor($FillColor[0],$FillColor[1],$FillColor[2]); - $Colors = explode(':',$Prefs['datafontcolor']); - $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); - $CellHeight = ($Prefs['datafontsize']+RowSpace)*0.35; - // Fetch the column widths and put into array to match the columns of data - $CellXPos[0] = $Prefs['marginleft']; - for ($x=1; $x<=8; $x++) $CellXPos[$x] = $CellXPos[$x-1] + $Prefs['col'.$x.'width']; - // Fetch the column break array - foreach ($Seq as $Temp) { - if ($Temp['break']){ - $ColBreak[] = true; - } else { - $ColBreak[] = false; - } - } - // See if we need to truncate the data - if ($Prefs['TruncListings']['params']=='1') { - $trunc=true; + $FillColor = array(224, 235, 255); + $this->SetFont($Prefs['datafont'],'',$Prefs['datafontsize']); + $this->SetFillColor($FillColor[0],$FillColor[1],$FillColor[2]); + $Colors = explode(':',$Prefs['datafontcolor']); + $this->SetTextColor($Colors[0], $Colors[1], $Colors[2]); + $CellHeight = ($Prefs['datafontsize']+RowSpace)*0.35; + // Fetch the column widths and put into array to match the columns of data + $CellXPos[0] = $Prefs['marginleft']; + for ($x=1; $x<=20; $x++) $CellXPos[$x] = $CellXPos[$x-1] + $Prefs['col'.$x.'width']; + // Fetch the column break array + foreach ($Seq as $Temp) { + if ($Temp['break']){ + $ColBreak[] = true; } else { - $trunc=false; + $ColBreak[] = false; } - // Ready to draw the column data - $fill=false; - $NeedTop='No'; - $MaxRowHt = 0; //track the tallest row to estimate page breaks - foreach($Data as $myrow) { - $Action = array_shift($myrow); - $todo = explode(':',$Action); // contains a letter of the date type and title/groupname - switch ($todo[0]) { - case "r": // Report Total - case "g": // Group Total - // Draw a fill box - if ($this->y0+(2*$MaxRowHt)>$this->pageY) { - // Fill the end of the report with white space - $this->SetLeftMargin($CellXPos[0]); - $this->SetX($CellXPos[0]); - $this->SetY($this->y0); - $this->SetFillColor(255); - $this->Cell(0,$this->pageY-$this->y0,'','',0,'L',1); - $this->AddPage(); - $MaxRowHt=0; - } + } + // See if we need to truncate the data + if ($Prefs['TruncListings']['params']=='1') { + $trunc=true; + } else { + $trunc=false; + } + // Ready to draw the column data + $fill=false; + $NeedTop='No'; + $MaxRowHt = 0; //track the tallest row to estimate page breaks + foreach($Data as $myrow) { + $Action = array_shift($myrow); + $todo = explode(':',$Action); // contains a letter of the date type and title/groupname + switch ($todo[0]) { + case "r": // Report Total + case "g": // Group Total + // Draw a fill box + if ($this->y0+(2*$MaxRowHt)>$this->pageY) { + // Fill the end of the report with white space $this->SetLeftMargin($CellXPos[0]); $this->SetX($CellXPos[0]); $this->SetY($this->y0); - $this->SetFillColor(240); - $this->Cell(0,$this->pageY-$this->y0,'',$brdr,0,'L',1); - // Add total heading + $this->SetFillColor(255); + $this->Cell(0,$this->pageY-$this->y0,'','',0,'L',1); + $this->AddPage(); + $MaxRowHt=0; + } + $this->SetLeftMargin($CellXPos[0]); + $this->SetX($CellXPos[0]); + $this->SetY($this->y0); + $this->SetFillColor(240); + $this->Cell(0,$this->pageY-$this->y0,'',$brdr,0,'L',1); + // Add total heading + $this->SetLeftMargin($CellXPos[0]); + $this->SetX($CellXPos[0]); + $this->SetY($this->y0); + if ($todo[0]=='g') $Desc = 'Group'; else $Desc = 'Report'; + $this->Cell(0,$CellHeight,$Desc.' Total For: '.$todo[1],1,1,'C'); + $this->y0=$this->GetY()+0.35; + $NeedTop = 'Next'; + $fill=false; // set so totals data will not be filled + // now fall into the 'd' case to show the data + case "d": // data element + default: + // figure out if a border needs to be drawn for total separation + // and fill color (draws an empty box over the row just written with the fill color) + $brdr = 0; + if ($NeedTop=='Yes') { + $brdr='T'; + $fill=false; // set so first data after total will not be filled + $NeedTop='No'; + } elseif ($NeedTop=='Next') { + $brdr='LR'; + $NeedTop='Yes'; + } + // Draw a fill box + if (($this->y0+$MaxRowHt)>$this->pageY) { + // Fill the end of the report with white space $this->SetLeftMargin($CellXPos[0]); $this->SetX($CellXPos[0]); $this->SetY($this->y0); - if ($todo[0]=='g') $Desc = 'Group'; else $Desc = 'Report'; - $this->Cell(0,$CellHeight,$Desc.' Total For: '.$todo[1],1,1,'C'); - $this->y0=$this->GetY()+0.35; - $NeedTop = 'Next'; - $fill=false; // set so totals data will not be filled - // now fall into the 'd' case to show the data - case "d": // data element - default: - // figure out if a border needs to be drawn for total separation - // and fill color (draws an empty box over the row just written with the fill color) - $brdr = 0; - if ($NeedTop=='Yes') { - $brdr='T'; - $fill=false; // set so first data after total will not be filled - $NeedTop='No'; - } elseif ($NeedTop=='Next') { - $brdr='LR'; - $NeedTop='Yes'; - } - // Draw a fill box - if (($this->y0+$MaxRowHt)>$this->pageY) { - // Fill the end of the report with white space - $this->SetLeftMargin($CellXPos[0]); - $this->SetX($CellXPos[0]); - $this->SetY($this->y0); - $this->SetFillColor(255); - $this->Cell(0,$this->pageY-$this->y0,'','',0,'L',1); - $this->AddPage(); - $MaxRowHt=0; - } - $this->SetLeftMargin($CellXPos[0]); - $this->SetX($CellXPos[0]); - $this->SetY($this->y0); - if ($fill) $this->SetFillColor($FillColor[0],$FillColor[1],$FillColor[2]); else $this->SetFillColor(255); - $this->Cell(0,$this->pageY-$this->y0,'',$brdr,0,'L',1); - // fill in the data - $maxY = $this->y0; // set to current top of row - $col = 1; - $LastY = $this->y0; - foreach ($myrow as $key=>$value) { - $this->SetLeftMargin($CellXPos[$col-1]); - $this->SetX($CellXPos[$col-1]); - $this->SetY($LastY); - // truncate data if necessary - if ($trunc) $value=$this->TruncData($value, $Prefs['col'.$col.'width']); - $this->MultiCell($CellXPos[$col]-$CellXPos[$col-1],$CellHeight,$value,0); - if ($ColBreak[$key]) { - $col++; - $LastY = $this->y0; - } else $LastY = $this->GetY(); - if ($this->GetY()>$maxY) $maxY = $this->GetY(); - } - $this->SetLeftMargin($CellXPos[0]); // restore left margin - break; - } - $ThisRowHt=$maxY-$this->y0; // seee how tall this row was - if ($ThisRowHt>$MaxRowHt) $MaxRowHt = $ThisRowHt; // keep that largest row so far to track pagination - $this->y0=$maxY; // set y position to largest value for next row - $fill=!$fill; + $this->SetFillColor(255); + $this->Cell(0,$this->pageY-$this->y0,'','',0,'L',1); + $this->AddPage(); + $MaxRowHt=0; + } + $this->SetLeftMargin($CellXPos[0]); + $this->SetX($CellXPos[0]); + $this->SetY($this->y0); + if ($fill) $this->SetFillColor($FillColor[0],$FillColor[1],$FillColor[2]); else $this->SetFillColor(255); + $this->Cell(0,$this->pageY-$this->y0,'',$brdr,0,'L',1); + // fill in the data + $maxY = $this->y0; // set to current top of row + $col = 1; + $LastY = $this->y0; + foreach ($myrow as $key=>$value) { + $this->SetLeftMargin($CellXPos[$col-1]); + $this->SetX($CellXPos[$col-1]); + $this->SetY($LastY); + // truncate data if necessary + if ($trunc) $value=$this->TruncData($value, $Prefs['col'.$col.'width']); + $this->MultiCell($CellXPos[$col]-$CellXPos[$col-1],$CellHeight,$value,0); + if ($ColBreak[$key]) { + $col++; + $LastY = $this->y0; + } else $LastY = $this->GetY(); + if ($this->GetY()>$maxY) $maxY = $this->GetY(); + } + $this->SetLeftMargin($CellXPos[0]); // restore left margin + break; } - // Fill the end of the report with white space - $this->SetLeftMargin($CellXPos[0]); - $this->SetX($CellXPos[0]); - $this->SetY($this->y0); - $this->SetFillColor(255); - $this->Cell(0,$this->pageY-$this->y0,'','T',0,'L',1); - } + $ThisRowHt=$maxY-$this->y0; // seee how tall this row was + if ($ThisRowHt>$MaxRowHt) $MaxRowHt = $ThisRowHt; // keep that largest row so far to track pagination + $this->y0=$maxY; // set y position to largest value for next row + $fill=!$fill; + } + // Fill the end of the report with white space + $this->SetLeftMargin($CellXPos[0]); + $this->SetX($CellXPos[0]); + $this->SetY($this->y0); + $this->SetFillColor(255); + $this->Cell(0,$this->pageY-$this->y0,'','T',0,'L',1); +} - function TruncData($strData, $ColWidth) { - $percent=0.90; //percent to truncate from max to account for proportional spacing - $CurWidth = $this->GetStringWidth($strData); - if ($CurWidth>($ColWidth*.90)) { // then it needs to be truncated - // for now we'll do an approximation based on averages and scale to 90% of the width to allow for variance - // A better aproach would be an recursive call to this function until the string just fits. - $NumChars = strlen($strData); - // Reduce the string by 1-$percent and retest - $strData = $this->TruncData(substr($strData, 0, ($ColWidth/$CurWidth)*$NumChars*$percent), $ColWidth); - } - return $strData; +function TruncData($strData, $ColWidth) { + $percent=0.90; //percent to truncate from max to account for proportional spacing + $CurWidth = $this->GetStringWidth($strData); + if ($CurWidth>($ColWidth*.90)) { // then it needs to be truncated + // for now we'll do an approximation based on averages and scale to 90% of the width to allow for variance + // A better aproach would be an recursive call to this function until the string just fits. + $NumChars = strlen($strData); + // Reduce the string by 1-$percent and retest + $strData = $this->TruncData(substr($strData, 0, ($ColWidth/$CurWidth)*$NumChars*$percent), $ColWidth); } + return $strData; +} - function Stream($FileName) { - $this->Output($FileName,'D'); - } +function Stream($FileName) { + $this->Output($FileName,'D'); +} } // end class @@ -600,22 +594,18 @@ function GeneratePDFFile($Data, $Prefs) { $pdf=new PDF(); $pdf->ReportTable($Data); -// Javier: TCPDF flush buffers so this actually would produce the pdf creation -/* $pdfcode = $pdf->output(); + $pdfcode = $pdf->output(); $len = strlen($pdfcode); -*/ $ReportName = ReplaceNonAllowedCharacters($Prefs['reportname']) .'.pdf'; + $ReportName = ReplaceNonAllowedCharacters($Prefs['reportname']) .'.pdf'; -// Javier: TCPDF sends its own http header -/* header('Content-type: application/pdf'); + header('Content-type: application/pdf'); header('Content-Length: ' . $len); header('Content-Disposition: inline; filename="' . $ReportName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); -*/ -// $pdf->Stream($ReportName); - $pdf->OutputD($ReportName); - $pdf->__destruct(); + + $pdf->Stream($ReportName); exit(); // needs to be here to properly render the pdf file. } @@ -623,7 +613,7 @@ function ReplaceNonAllowedCharacters ($String) { $DodgyCharactersArray = array('"',' ', '&',"'"); $ContainsDodgyCharacters = true; - while ($ContainsDodgyCharacters == true) { + while ($ContainsDodgyCharacters == true){ $ContainsDodgyCharacters = false; //assume all dodgy characters are replaced on the last pass @@ -637,4 +627,4 @@ } return $String; } -?> +?> \ No newline at end of file Modified: trunk/reportwriter/admin/RCFunctions.inc =================================================================== --- trunk/reportwriter/admin/RCFunctions.inc 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/reportwriter/admin/RCFunctions.inc 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,5 +1,5 @@ <?php -/* $Id$*/ +/* $Revision: 1.9 $ */ // Include functions needed for ReportCreator.php function PrepStep($StepNum) { @@ -7,44 +7,44 @@ switch ($StepNum) { case '1': // home form with form listings default: - $FormParams['title'] = RPT_RPRBLDR.RPT_STEP1; - $FormParams['heading'] = RPT_ADMIN; + $FormParams['title'] = RPT_RPRBLDR.RPT_STEP1; + $FormParams['heading'] = RPT_ADMIN; $FormParams['IncludePage'] = 'forms/ReportsHome.html'; break; case '2': // id, copy, new report name form - $FormParams['title'] = RPT_RPRBLDR.RPT_STEP2; + $FormParams['title'] = RPT_RPRBLDR.RPT_STEP2; $FormParams['heading'] = RPT_RPTID; $FormParams['IncludePage'] = 'forms/ReportsID.html'; break; case '3': // page setup form - $FormParams['title'] = RPT_RPRBLDR.RPT_STEP3; + $FormParams['title'] = RPT_RPRBLDR.RPT_STEP3; $FormParams['heading'] = RPT_RPTFRM; $FormParams['IncludePage'] = 'forms/ReportsPageSetup.html'; break; case '4': // db setup form - $FormParams['title'] = RPT_RPRBLDR.RPT_STEP4; + $FormParams['title'] = RPT_RPRBLDR.RPT_STEP4; $FormParams['heading'] = RPT_RPTFRM; $FormParams['IncludePage'] = 'forms/ReportsDBSetup.html'; break; case '5': // field setup form - $FormParams['title'] = RPT_RPRBLDR.RPT_STEP5; + $FormParams['title'] = RPT_RPRBLDR.RPT_STEP5; $FormParams['heading'] = RPT_RPTFRM; $FormParams['IncludePage'] = 'forms/ReportsFieldSetup.html'; break; case 'prop': // Form field properties form global $Params; // we need the form type from the Params variable to load the correct form - $FormParams['title'] = RPT_RPRBLDR.RPT_BTN_PROP; + $FormParams['title'] = RPT_RPRBLDR.RPT_BTN_PROP; $FormParams['heading'] = RPT_RPTFRM; $FormParams['IncludePage'] = 'forms/TplFrm'.$Params['index'].'.html'; break; case '6': // criteria setup form - $FormParams['title'] = RPT_RPRBLDR.RPT_STEP6; + $FormParams['title'] = RPT_RPRBLDR.RPT_STEP6; $FormParams['heading'] = RPT_RPTFRM; $FormParams['IncludePage'] = 'forms/ReportsCritSetup.html'; break; case 'imp': // import form - $FormParams['title'] = RPT_RPRBLDR.RPT_RPTIMPORT; - $FormParams['heading'] = RPT_RPTIMPORT; + $FormParams['title'] = RPT_RPRBLDR.RPT_RPTIMPORT; + $FormParams['heading'] = RPT_RPTIMPORT; $FormParams['IncludePage'] = 'forms/ReportsImport.html'; break; } // end switch $StepNum @@ -53,26 +53,26 @@ function RetrieveReports() { global $db, $ReportGroups, $FormGroups; - + $OutputString = ''; foreach ($ReportGroups as $key=>$GName) { $OutputString .= '<tr bgcolor="#CCCCCC"><td colspan="2" align="center">'.$GName.'</td></tr>'; $OutputString .= '<tr><td align="center">'.RPT_REPORTS.'</td><td align="center">'.RPT_FORMS.'</td></tr>'; $OutputString .= '<tr><td width="250" valign="top">'; - $sql= "SELECT id, reportname FROM ".DBReports." - WHERE defaultreport='1' AND reporttype='rpt' AND groupname='".$key."' + $sql= "SELECT id, reportname FROM ".DBReports." + WHERE defaultreport='1' AND reporttype='rpt' AND groupname='".$key."' ORDER BY reportname"; $Result=DB_query($sql,$db,'','',false,true); while ($Temp = DB_fetch_array($Result)) $OutputString .= '<input type="radio" name="ReportID" value="'.$Temp['id'].'">'.$Temp['reportname'].'<br>'; - $sql= "SELECT id, reportname FROM ".DBReports." - WHERE defaultreport='0' AND reporttype='rpt' AND groupname='".$key."' + $sql= "SELECT id, reportname FROM ".DBReports." + WHERE defaultreport='0' AND reporttype='rpt' AND groupname='".$key."' ORDER BY reportname"; $Result=DB_query($sql,$db,'','',false,true); if (DB_num_rows($Result)>0) $OutputString .= '<u>'.RPT_CUSTRPT.'</u><br>'; while ($Temp = DB_fetch_array($Result)) $OutputString .= '<input type="radio" name="ReportID" value="'.$Temp['id'].'">'.$Temp['reportname'].'<br>'; $OutputString .= '</td>'.chr(10).'<td width="250" valign="top">'; - $sql= "SELECT id, groupname, reportname FROM ".DBReports." - WHERE defaultreport='1' AND reporttype='frm' + $sql= "SELECT id, groupname, reportname FROM ".DBReports." + WHERE defaultreport='1' AND reporttype='frm' ORDER BY groupname, reportname"; $Result=DB_query($sql,$db,'','',false,true); $FormList = ''; @@ -97,13 +97,13 @@ function RetrieveFields($EntryType) { global $db, $ReportID; $FieldListings['fields'] = ''; - $sql= "SELECT * FROM ".DBRptFields." + $sql= "SELECT * FROM ".DBRptFields." WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' ORDER BY seqnum"; $Result=DB_query($sql,$db,'','',false,true); if (DB_num_rows($Result)>0) { - while ($FieldValues = DB_fetch_array($Result)) { - $FieldListings['lists'][] = $FieldValues; + while ($FieldValues = DB_fetch_array($Result)) { + $FieldListings['lists'][] = $FieldValues; } } // set the form field defaults @@ -120,7 +120,7 @@ function UpdatePageFields($ReportID) { global $db, $Type; // For both reports and forms start sql string - $sql = "UPDATE ".DBReports." SET + $sql = "UPDATE ".DBReports." SET papersize = '".$_POST['PaperSize']."', paperorientation = '".$_POST['PaperOrientation']."', margintop = ".$_POST['MarginTop'].", @@ -168,7 +168,19 @@ col5width = ".$_POST['Col5Width'].", col6width = ".$_POST['Col6Width'].", col7width = ".$_POST['Col7Width'].", - col8width = ".$_POST['Col8Width']; + col8width = ".$_POST['Col8Width'].", + col9width = ".$_POST['Col9Width'].", + col10width = ".$_POST['Col10Width'].", + col11width = ".$_POST['Col11Width'].", + col12width = ".$_POST['Col12Width'].", + col13width = ".$_POST['Col13Width'].", + col14width = ".$_POST['Col14Width'].", + col15width = ".$_POST['Col15Width'].", + col16width = ".$_POST['Col16Width'].", + col17width = ".$_POST['Col17Width'].", + col18width = ".$_POST['Col18Width'].", + col19width = ".$_POST['Col19Width'].", + col20width = ".$_POST['Col20Width']; } $sql .=" WHERE id =".$ReportID.";"; $Result=DB_query($sql,$db,'','',false,true); @@ -177,7 +189,7 @@ function UpdateCritFields($ReportID, $DateString) { global $db, $Type; - $sql = "UPDATE ".DBRptFields." SET + $sql = "UPDATE ".DBRptFields." SET reportid = '".$ReportID."', entrytype = 'dateselect', fieldname = '".DB_escape_string($_POST['DateField'])."', @@ -187,7 +199,7 @@ $Result=DB_query($sql,$db,'','',false,true); if ($Type<>'frm') { // then write specifics for a report // write the truncate long descriptions choice - $sql = "UPDATE ".DBRptFields." SET + $sql = "UPDATE ".DBRptFields." SET reportid = '".$ReportID."', entrytype = 'trunclong', params = '".$_POST['TruncLongDesc']."', @@ -196,7 +208,7 @@ $Result=DB_query($sql,$db,'','',false,true); } else { // it's a form update the page break info // write the form page break fieldname - $sql = "UPDATE ".DBRptFields." SET + $sql = "UPDATE ".DBRptFields." SET reportid = '".$ReportID."', entrytype = 'grouplist', seqnum = 1, @@ -220,15 +232,15 @@ if ($_POST['Table6']) $strTable .= ' INNER JOIN '.DB_escape_string($_POST['Table6']).' ON '.DB_escape_string($_POST['Table6Criteria']); // $sql = "SELECT * FROM ".$strTable." LIMIT 1"; - for ($i=0;$i<6;$i++) { - if ($_POST['Table'.$i]) { + for ($i=0;$i<6;$i++) { + if (isset($_POST['Table'.$i]) and $_POST['Table'.$i]) { $sql = "SHOW TABLES WHERE Tables_in_".$_SESSION['DatabaseName']."='".$_POST['Table'.$i]."'"; $Result=DB_query($sql,$db,'','',false,false); if (DB_num_rows($Result)==0) return false; } // if we have a row, sql was valid } - $sql = "UPDATE ".DBReports." SET + $sql = "UPDATE ".DBReports." SET table1 = '".DB_escape_string($_POST['Table1'])."', table2 = '".DB_escape_string($_POST['Table2'])."', table2criteria = '".DB_escape_string($_POST['Table2Criteria'])."', @@ -250,7 +262,7 @@ if (!isset($_POST['Visible'])) $_POST['Visible'] = '0'; if (!isset($_POST['ColumnBreak'])) $_POST['ColumnBreak'] = '0'; if (!isset($_POST['Params'])) $Params = '0'; else $Params = $_POST['Params']; - $sql = "UPDATE ".DBRptFields." SET + $sql = "UPDATE ".DBRptFields." SET fieldname = '".DB_escape_string($_POST['FieldName'])."', displaydesc = '".DB_escape_string($_POST['DisplayDesc'])."', visible = '".$_POST['Visible']."', @@ -265,14 +277,14 @@ function ChangeSequence($SeqNum, $EntryType, $UpDown) { global $db, $ReportID; // find the id of the row to move - $sql = "SELECT id FROM ".DBRptFields." + $sql = "SELECT id FROM ".DBRptFields." WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' AND seqnum = ".$SeqNum.";"; $Result=DB_query($sql,$db,'','',false,true); $myrow = DB_fetch_row($Result); $OrigID = $myrow[0]; if ($UpDown=='up') $NewSeqNum = $SeqNum-1; else $NewSeqNum = $SeqNum+1; // first move affected sequence to seqnum, then seqnum to new position - $sql = "UPDATE ".DBRptFields." SET seqnum='".$SeqNum."' + $sql = "UPDATE ".DBRptFields." SET seqnum='".$SeqNum."' WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' AND seqnum = ".$NewSeqNum.";"; $Result=DB_query($sql,$db,'','',false,true); $sql = "UPDATE ".DBRptFields." SET seqnum='".$NewSeqNum."' WHERE id = ".$OrigID.";"; @@ -285,8 +297,8 @@ global $db, $ReportID, $Type; if (!$SeqNum) $SeqNum = 999; // set sequence to max if not entered // read the sequence numbers for the given EntryType - $sql = "SELECT id FROM ".DBRptFields." - WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' + $sql = "SELECT id FROM ".DBRptFields." + WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' ORDER BY seqnum;"; $Result=DB_query($sql,$db,'','',false,true); while ($FieldID = DB_fetch_array($Result)) { $IDList[] = $FieldID['id']; } @@ -301,7 +313,7 @@ if (!isset($_POST['Visible'])) $Visible = '0'; else $Visible = $_POST['Visible']; if (!isset($_POST['ColumnBreak'])) $ColumnBreak = '0'; else $ColumnBreak = $_POST['ColumnBreak']; if (!isset($_POST['Params'])) { - $Params = '0'; + $Params = '0'; } elseif ($Type=='frm' AND $EntryType=='fieldlist') { $EntryIndex['index'] = $_POST['Params']; $Params = serialize($EntryIndex); @@ -320,12 +332,12 @@ // This function removes a sequence field and fills the sequence hole left behind global $db, $ReportID; // delete the sequence number from the list - $sql = "DELETE FROM ".DBRptFields." + $sql = "DELETE FROM ".DBRptFields." WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' AND seqnum = ".$SeqNum.";"; $Result=DB_query($sql,$db,'','',false,true); // read in the remaining sequences and re-number - $sql = "SELECT id FROM ".DBRptFields." - WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' + $sql = "SELECT id FROM ".DBRptFields." + WHERE reportid = ".$ReportID." AND entrytype = '".$EntryType."' ORDER BY seqnum;"; $Result=DB_query($sql,$db,'','',false,true); while ($FieldID = DB_fetch_array($Result)) { $IDList[] = $FieldID['id']; } @@ -342,7 +354,7 @@ // This function creates a hole in the sequencing to allow inserting new form table field data $SeqNum = $_POST['TblSeqNum']; if (!$SeqNum) $SeqNum = count($Params['Seq'])+1; // set sequence to last entry if not entered - if (isset($Params['Seq'][$SeqNum-1]) AND $Insert=='insert') { + if (isset($Params['Seq'][$SeqNum-1]) AND $Insert=='insert') { // then the sequence number exists make a hole for this insert for ($j=count($Params['Seq']); $j>=$SeqNum; $j--) { $Params['Seq'][$j] = $Params['Seq'][$j-1]; // move the array element down one @@ -359,7 +371,7 @@ $Params['Seq'][$SeqNum-1]['FontAlign'] = $_POST['FontAlign']; $Params['Seq'][$SeqNum-1]['FontColor'] = $_POST['FontColor']; $Params['Seq'][$SeqNum-1]['TblColWidth'] = $_POST['TblColWidth']; - if (!isset($_POST['TblShow'])) $Params['Seq'][$SeqNum-1]['TblShow'] = '0'; + if (!isset($_POST['TblShow'])) $Params['Seq'][$SeqNum-1]['TblShow'] = '0'; else $Params['Seq'][$SeqNum-1]['TblShow'] = '1'; return true; } @@ -396,7 +408,7 @@ $Params['FontAlign'] = $Params['Seq'][$i-1]['FontAlign']; $Params['FontColor'] = $Params['Seq'][$i-1]['FontColor']; $Params['TblColWidth'] = $Params['Seq'][$i-1]['TblColWidth']; - $Params['TblShow'] = $Params['Seq'][$i-1]['TblShow']; + $Params['TblShow'] = $Params['Seq'][$i-1]['TblShow']; return 'edit'; } if (isset($_POST['rm'.$i.'_x'])) { // sequence rm[i] was pressed, delete the entry @@ -419,9 +431,9 @@ if (strlen($Description)<1) return false; else return true; } // fetch the table values to build sql - $sql = "SELECT table1, - table2, table2criteria, - table3, table3criteria, + $sql = "SELECT table1, + table2, table2criteria, + table3, table3criteria, table4, table4criteria, table5, table5criteria, table6, table6criteria @@ -492,7 +504,7 @@ while ($DefRpt = readdir($dh)) { $pinfo = pathinfo(DefRptPath.$DefRpt); $Ext = strtoupper($pinfo['extension']); - if ($Ext=='JPG' OR $Ext=='JPEG' OR $Ext=='PNG') { + if ($Ext=='JPG' OR $Ext=='JPEG' OR $Ext=='PNG') { if ($Default==$pinfo['basename']) $checked=' selected'; else $checked = ''; $OptionList .= '<option value="'.$pinfo['basename'].'"'.$checked.'> '.$pinfo['basename'].'</option>'; } @@ -521,7 +533,7 @@ } elseif (!is_uploaded_file($_FILES['imagefile']['tmp_name'])) { // file uploaded $Rtn['message'] = RPT_IMP_ERMSG10; } elseif (strpos($_FILES['imagefile']['type'],'image')===false) { // not an imsge file extension - $Rtn['message'] = RPT_IMP_ERMSG6; + $Rtn['message'] = RPT_IMP_ERMSG6; } elseif ($_FILES['imagefile']['size']==0) { // report contains no data, error $Rtn['message'] = RPT_IMP_ERMSG7; } else { // passed all error checking, save the image @@ -588,7 +600,7 @@ for ($i=0; $i<count($FieldData); $i++) $CSVOutput .= $FieldData[$i].$crlf; $CSVOutput .= $crlf; $CSVOutput .= '/* End of Export File */'.$crlf; - // export the file + // export the file $FileSize = strlen($CSVOutput); header("Content-type: application/txt"); header("Content-disposition: attachment; filename=".preg_replace('/ /','',$ReportName).".rpt.txt; size=".$FileSize); @@ -596,7 +608,7 @@ header('Pragma: cache'); header('Cache-Control: public, must-revalidate, max-age=0'); print $CSVOutput; - exit(); + exit(); } function ImportReport($RptName) { @@ -625,7 +637,7 @@ } if ($Rtn['result']=='error') return $Rtn; } - + $Title1Desc = ''; // Initialize to null, not used for forms $Title2Desc = ''; foreach ($arrSQL as $sql) { // find the report translated reportname and title information @@ -637,7 +649,7 @@ if ($RptName=='') $RptName = $ReportName; // then no report was entered use reportname from file $sql= "SELECT id FROM ".DBReports." WHERE reportname='".DB_escape_string($RptName)."';"; $Result=DB_query($sql,$db,'','',false,true); - if (DB_num_rows($Result)>0) { // the report name already exists, error + if (DB_num_rows($Result)>0) { // the report name already exists, error $Rtn['result'] = 'error'; $Rtn['message'] = RPT_REPDUP; return $Rtn; @@ -656,13 +668,13 @@ $Rtn['message'] = RPT_IMP_ERMSG8; return $Rtn; } - // fetch the id of the row inserted + // fetch the id of the row inserted $ReportID = DB_Last_Insert_ID($db,DBReports,'id'); // update the translated report name and title fields into the newly imported report - $sql = "UPDATE ".DBReports." SET - reportname = '".$RptName."', - title1desc = '".$Title1Desc."', - title2desc = '".$Title2Desc."' + $sql = "UPDATE ".DBReports." SET + reportname = '".$RptName."', + title1desc = '".$Title1Desc."', + title2desc = '".$Title2Desc."' WHERE id = ".$ReportID.";"; $Result=DB_query($sql,$db,'','',false,true); foreach ($arrSQL as $sql) { // fetch the translations for the field descriptions @@ -682,7 +694,7 @@ if ($FieldID<>0) { // A field was successfully written update the report id if (isset($Language[$FldIndex])) $DispSQL = "displaydesc='".$Language[$FldIndex]."', "; else $DispSQL = ''; - $tsql = "UPDATE ".DBRptFields." SET ".$DispSQL." reportid='".$ReportID."' + $tsql = "UPDATE ".DBRptFields." SET ".$DispSQL." reportid='".$ReportID."' WHERE id=".$FieldID.";"; $Result=DB_query($tsql,$db,'','',false,true); } @@ -698,9 +710,9 @@ $sql = "SELECT table".$Table." FROM ".DBReports." WHERE id='".$ReportID."'"; $Result=DB_query($sql,$db,'','',false,true); $myrow = DB_fetch_row($Result); - + $TableList = ''; - + $Result=DB_show_tables($db); while ($mytable=DB_fetch_row($Result)) { @@ -717,7 +729,7 @@ FROM ".DBReports." WHERE id='".$ReportID."'"; $Result=DB_query($sql,$db,'','',false,true); $myrow = DB_fetch_row($Result); - $LinkList = ''; $j = 0; + $LinkList = ''; $j = 0; /* Get list of link tables from foreign keys */ for ($i = 0; $i < $Table; $i++) { @@ -749,11 +761,11 @@ function CreateLinkEqList($ReportID,$Table) { global $db; - $sql = "SELECT table1, - table2, table2criteria, - table3, table3criteria, - table4, table4criteria, - table5, table5criteria, + $sql = "SELECT table1, + table2, table2criteria, + table3, table3criteria, + table4, table4criteria, + table5, table5criteria, table6, table6criteria FROM ".DBReports." WHERE id='".$ReportID."'"; $Result=DB_query($sql,$db,'','',false,true); Modified: trunk/reportwriter/admin/ReportCreator.php =================================================================== --- trunk/reportwriter/admin/ReportCreator.php 2010-08-18 17:27:18 UTC (rev 3694) +++ trunk/reportwriter/admin/ReportCreator.php 2010-08-18 19:26:27 UTC (rev 3695) @@ -1,13 +1,13 @@ <?php -/* $Id$*/ +/* $Revision: 1.6 $ */ /* -This script has the responsibility to gather basic information necessary to retrieve data for reports. -It is comprised of several steps designed to gather display preferences, database information, field +This script has the responsibility to gather basic information necessary to retrieve data for reports. +It is comprised of several steps designed to gather display preferences, database information, field information and filter/criteria information. The Report builder process is as follows: Step 1: (or script entry): displays the current listing of reports. Uses form ReportsHome.html as a UI. -Step 2: (action=step2): After the user has selected an option, this step is followed to enter a report +Step 2: (action=step2): After the user has selected an option, this step is followed to enter a report name and the type of report it is for grouping purposes. Step 3: Handles the page setup information. Step 4: Handles the database setup and link information. @@ -18,15 +18,13 @@ */ $DirectoryLevelsDeep = 2; -// Javier $PathPrefix = '../../'; se va un directorio mas arriba, si no funciona el cambio hay que hacerlo constante. $PathPrefix = '../../'; - $PageSecurity = 2; // set security level for webERP // Fetch necessary include files for webERP require ($PathPrefix . 'includes/session.inc'); // Initialize some constants -$ReportLanguage = 'en_US'; // default language file +$ReportLanguage = 'en_US'; // default language file define('DBReports','reports'); // name of the databse holding the main report information (ReportID) define('DBRptFields','reportfields'); // name of the database holding the report fields define ('DefRptPath',$PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/reportwriter/'); // path to default reports @@ -41,8 +39,8 @@ $usrMsg = ''; // initialize array for return messages // a valid report id needs to be passed as a post field to do anything, except create new report if (!isset($_POST['ReportID'])) { // entered for the first time or created new report - $ReportID = ''; -} else { + $ReportID = ''; +} else { $ReportID = $_POST['ReportID']; if (isset($_POST['Type'])) { // then the type was passed from the previous form $Type=$_POST['Type']; @@ -81,7 +79,7 @@ $myrow = DB_fetch_array($Result); $_POST['ReportName'] = $myrow['reportname']; // continue like copy was pushed - case RPT_BTN_COPY: // Copy a report was selected + case RPT_BTN_COPY: // Copy a report was selected $FormParams = PrepStep('2'); break; case RPT_BTN_DEL: // after confirmation, delete the report and go to the main report admin menu @@ -103,7 +101,7 @@ break; } break; // End Step 2 - + case "step3": // entered from id setup page switch ($_POST['todo']) { case RPT_BTN_REPLACE: // Erase the default report and copy a new one with the same name @@ -175,8 +173,8 @@ $sql = "UPDATE ".DBReports." SET id=".$OrigID." WHERE id=0;"; $Result=DB_query($sql,$db,'','',false,true); // Set the report name and group name per the form - $sql = "UPDATE ".DBReports." SET - reportname = '" . DB_escape_string($_POST['ReportName']) . "' + $sql = "UPDATE ".DBReports." SET + reportname = '" . DB_escape_string($_POST['ReportName']) . "' WHERE id =".$ReportID.";"; $Result=DB_query($sql,$db,'','',false,true); // fetch the fields and duplicate @@ -184,7 +182,7 @@ $Result=DB_query($sql,$db,'','',false,true); while ($temp = DB_fetch_array($Result)) $field[] = $temp; foreach ($field as $row) { - $sql = "INSERT INTO ".DBRptFields." (reportid, entrytype, seqnum, fieldname, + $sql = "INSERT INTO ".DBRptFields." (reportid, entrytype, seqnum, fieldname, displaydesc, visible, columnbreak, params) VALUES (".$ReportID.", '".$row['entrytype']."', ".$row['seqnum'].", '".$row['fieldname']."', '".$row['displaydesc']."', '".$row['visible']."', @@ -198,7 +196,7 @@ $myrow = DB_fetch_array($Result); $FormParams = PrepStep('3'); break; - + case RPT_BTN_RENAME: // Rename a report was selected, fetch the report name and update // input error check reportname, blank duplicate, bad characters, etc. if ($_POST['ReportName']=='') { // no report name was entered, error and reload form @@ -227,7 +225,7 @@ $FormParams = PrepStep('1'); } break; - + case "step4": // entered from page setup page switch ($_POST['todo']) { case RPT_BTN_UPDATE: @@ -241,7 +239,7 @@ case RPT_BTN_CONT: // fetch the report information and go to the page setup screen $success = UpdatePageFields($ReportID); // read in the data for the next form - $sql = "SELECT table1, + $sql = "SELECT table1, table2, table2criteria, table3, table3criteria, table4, table4criteria, @@ -260,7 +258,7 @@ $FormParams = PrepStep('1'); } break; - + case "step5": // entered from dbsetup page switch ($_POST['todo']) { case RPT_BTN_BACK: @@ -284,16 +282,16 @@ } } $success = UpdateDBFields($ReportID); - if (!$success OR $_POST['todo']==RPT_BTN_UPDATE) { + if (!$success OR $_POST['todo']==RPT_BTN_UPDATE) { // update fields and stay on this form if (!$success) $usrMsg[] = array('message'=>RPT_DUPDB, 'level'=>'error'); // read back in new data for next screen (will set defaults as defined in the db) - $sql = "SELECT table1, - table2, table2criteria, - table3, table3criteria, - table4, table4criteria, - table5, table5criteria, - table6, table6criteria, + $sql = "SELECT table1, + table2, table2criteria, + table3, table3criteria, + table4, table4criteria, + table5, table5criteria, + table6, table6criteria, reportname FROM ".DBReports." WHERE id='".$ReportID."'"; $Result=DB_query($sql,$db,'','',false,true); @@ -311,7 +309,7 @@ $FormParams = PrepStep('1'); } break; - + case "step6": // entered from field setup page if (!isset($_POST['todo'])) { // then a sequence image button was pushed $SeqNum = $_POST['SeqNum']; //fetch the sequence number @@ -324,9 +322,9 @@ if ($SeqNum<DB_num_rows($Result)) $success = ChangeSequence($SeqNum, 'fieldlist', 'down'); $FieldListings = RetrieveFields('fieldlist'); } elseif (isset($_POST['ed_x'])) { // the sequence edit button was pushed - // pre fill form with the field to edit and change button name + // pre fill form with the field to edit and change button name $FieldListings = RetrieveFields('fieldlist'); - $sql = "SELECT * FROM ".DBRptFields." + $sql = "SELECT * FROM ".DBRptFields." WHERE reportid = ".$ReportID." AND entrytype = 'fieldlist' AND seqnum=".$SeqNum.";"; $Result=DB_query($sql,$db,'','',false,true); $FieldListings['defaults'] = DB_fetch_array($Result); @@ -340,12 +338,12 @@ } else { switch ($_POST['todo']) { case RPT_BTN_BACK: - $sql = "SELECT table1, - table2, table2criteria, - table3, table3criteria, - table4, table4criteria, - table5, table5criteria, - table6, table6criteria, + $sql = "SELECT table1, + table2, table2criteria, + table3, table3criteria, + table4, table4criteria, + table5, table5criteria, + table6, table6criteria, reportname FROM ".DBReports." WHERE id='".$ReportID."'"; $Result=DB_query($sql,$db,'','',false,true); @@ -374,7 +372,7 @@ $reportname = $_POST['ReportName']; $FormParams = PrepStep('5'); break; - } + } if ($_POST['todo']==RPT_BTN_ADDNEW) { // add new so insert $_POST['SeqNum'] = InsertSequence($_POST['SeqNum'], 'fieldlist'); } else { // exists, so update it. @@ -390,7 +388,7 @@ case RPT_BTN_PROP: // Enter the properties of a given field // see what form needs to be loaded and load based on index stored in params variable $SeqNum = $_POST['SeqNum']; - $sql = "SELECT id, displaydesc, params FROM ".DBRptFields." + $sql = "SELECT id, displaydesc, params FROM ".DBRptFields." WHERE reportid = ".$ReportID." AND entrytype='fieldlist' AND seqnum = ".$SeqNum.";"; $Result = DB_query($sql,$db,'','',false,true); $myrow = DB_fetch_assoc($Result); @@ -419,13 +417,13 @@ } } break; - + case "step6a": // entered from properties page for fields $ButtonValue = RPT_BTN_ADDNEW; // default the field button to Add New unless overidden by the edit image pressed $reportname = $_POST['ReportName']; $SeqNum = $_POST['SeqNum']; // first fetch the original Params - $sql = "SELECT id, params FROM ".DBRptFields." + $sql = "SELECT id, params FROM ".DBRptFields." WHERE reportid = ".$ReportID." AND entrytype='fieldlist' AND seqnum = ".$SeqNum.";"; $Result = DB_query($sql,$db,'','',false... [truncated message content] |