Skip to content

Commit

Permalink
Paul Becker reportwriter mods.
Browse files Browse the repository at this point in the history
Add reportwriter "Prior Periods" contribution mods.

Contributed via forum:
http://www.weberp.org/forum/showthread.php?tid=8110
  • Loading branch information
TurboPT committed Mar 6, 2018
1 parent 2180bed commit 2175669
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 17 deletions.
58 changes: 52 additions & 6 deletions reportwriter/WriteReport.inc
Expand Up @@ -30,30 +30,35 @@ var $pageY; // y value of bottom of page less bottom margin
global $Prefs, $Heading, $Seq;
define(RowSpace,2); // define separation between the heading rows
if ($Prefs['coynameshow']) { // Show the company name
$this->SetFontSize($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
$this->SetFontSize($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
$this->SetFontSize($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
$this->SetFontSize($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->Cell(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->SetFontSize($Prefs['datafontsize']);
$Colors = explode(':',$Prefs['datafontcolor']);
$this->SetTextColor($Colors[0], $Colors[1], $Colors[2]);
$this->SetDrawColor(128,0,0);
Expand Down Expand Up @@ -117,6 +122,7 @@ var $pageY; // y value of bottom of page less bottom margin
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFontSize(8);
$this->SetTextColor(0);
//Page number
$this->Cell(0, 10, 'Page ' . $this->PageNo() . '/' . $this->getNumPages(), 0, 0, 'C');
Expand All @@ -125,6 +131,7 @@ var $pageY; // y value of bottom of page less bottom margin
function ReportTable($Data) {
global $Prefs, $Seq;

$this->SetFontSize($Prefs['datafontsize']);
$FillColor = array(224, 235, 255);
$this->SetFillColor($FillColor[0],$FillColor[1],$FillColor[2]);
$Colors = explode(':',$Prefs['datafontcolor']);
Expand Down Expand Up @@ -300,11 +307,15 @@ function BuildSQL($Prefs) {
// fetch date filter info
$df = $Prefs['DateListings']['fieldname'];
$Today = date('Y-m-d', time());
$ThisDay = date('d');
$ThisMonth = date('m');
$ThisYear = date('Y');
$Yesterday = $Today-1;
$LastMonth = $ThisMonth-1;
$LastYear = $ThisYear-1;
// Find total number of days in this month:
$TotalDays = cal_days_in_month(CAL_GREGORIAN, $ThisMonth, $ThisYear);
// Find total number of days in last month:
$TotalDaysLast = cal_days_in_month(CAL_GREGORIAN, $LastMonth, $ThisYear);
// Calculate date range
$DateArray=explode(':',$Prefs['DateListings']['params']);
switch ($DateArray[0]) { // based on the date choice selected
Expand Down Expand Up @@ -332,14 +343,14 @@ function BuildSQL($Prefs) {
$fildesc = ' '.RPT_DATERANGE.'='.ConvertSQLDate($Today).';';
break;
case "d": // RPT_GROUP_WEEK
$ws = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j',$t)-date('w',$t), $ThisYear));
$we = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j',$t)-date('w',$t)+6, $ThisYear));
$ws = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j')-date('w')+0, $ThisYear));
$we = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j')-date('w')+6, $ThisYear));
$d = $df.">='".$ws."'";
$d .= " AND ".$df."<='".$we."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($ws).' '.RPT_TO.' '.ConvertSQLDate($we).';';
break;
case "e": // RPT_GROUP_WTD
$ws = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j',$t)-date('w',$t), $ThisYear));
$ws = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j')-date('w'), $ThisYear));
$d = $df.">='".$ws."'";
$d .= " AND ".$df."<='".$Today."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($ws).' '.RPT_TO.' '.ConvertSQLDate($Today).';';
Expand Down Expand Up @@ -387,6 +398,41 @@ function BuildSQL($Prefs) {
$d .= " AND ".$df."<='".$Today."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($ys).' '.RPT_TO.' '.ConvertSQLDate($Today).';';
break;
case "l": // RPT_GROUP_YESTERDAY
$d = $df."='".$Yesterday."'";
$fildesc = ' '.RPT_DATERANGE.'='.ConvertSQLDate($Yesterday).';';
break;
case "m": // RPT_GROUP_LASTWEEK
$ws = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j')-date('w')-7, $ThisYear));
$we = date('Y-m-d', mktime(0,0,0, $ThisMonth, date('j')-date('w')-1, $ThisYear));
$d = $df.">='".$ws."'";
$d .= " AND ".$df."<='".$we."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($ws).' '.RPT_TO.' '.ConvertSQLDate($we).';';
break;
case "n": // RPT_GROUP_LASTMONTH
$ms = date('Y-m-d', mktime(0,0,0, $LastMonth, 1, $ThisYear));
$me = date('Y-m-d', mktime(0,0,0, $LastMonth, $TotalDaysLast, $ThisYear));
$d = $df.">='".$ms."'";
$d .= " AND ".$df."<='".$me."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($ms).' '.RPT_TO.' '.ConvertSQLDate($me).';';
break;
case "o": // RPT_GROUP_LASTQUARTER
$QtrStrt = intval(($ThisMonth-1)/3)*3-2;
$QtrEnd = intval(($ThisMonth-1)/3)*3+0;
if ( $QtrEnd == 4 OR $QtrEnd == 6 OR $QtrEnd == 9 OR $QtrEnd == 11 ) { $TotalDaysLast=30; }
$qs = date('Y-m-d', mktime(0,0,0, $QtrStrt, 1, $ThisYear));
$qe = date('Y-m-d', mktime(0,0,0, $QtrEnd, $TotalDays, $ThisYear));
$d = $df.">='".$qs."'";
$d .= " AND ".$df."<='".$qe."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($qs).' '.RPT_TO.' '.ConvertSQLDate($qe).';';
break;
case "p": // RPT_GROUP_LASTYEAR
$ys = date('Y-m-d', mktime(0,0,0, 1, 1, $LastYear));
$ye = date('Y-m-d', mktime(0,0,0, 12, 31, $LastYear));
$d = $df.">='".$ys."'";
$d .= " AND ".$df."<='".$ye."'";
$fildesc = ' '.RPT_DATERANGE.' '.RPT_FROM.' '.ConvertSQLDate($ys).' '.RPT_TO.' '.ConvertSQLDate($ye).';';
break;
}
$strDate = $d;
if ($fildesc<>'') $Prefs['filterdesc'] .= $fildesc; // update the filter description string
Expand Down Expand Up @@ -611,4 +657,4 @@ function ReplaceNonAllowedCharacters ($String) {
}
return $String;
}
?>
?>
7 changes: 6 additions & 1 deletion reportwriter/admin/defaults.php
Expand Up @@ -105,7 +105,12 @@
'h' => RPT_QUARTER,
'i' => RPT_QTD,
'j' => RPT_YEAR,
'k' => RPT_YTD);
'k' => RPT_YTD,
'l' => RPT_YESTERDAY,
'm' => RPT_LASTWEEK,
'n' => RPT_LASTMONTH,
'o' => RPT_LASTQUARTER,
'p' => RPT_LASTYEAR);

/*********************************************************************************************
Form unique defaults
Expand Down
30 changes: 21 additions & 9 deletions reportwriter/admin/forms/ReportsCritSetup.html
Expand Up @@ -13,11 +13,11 @@ <h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_C
</table>
<table width="700" align="center" border="2" cellspacing="1" cellpadding="1">
<tr bgcolor="#CCCCCC">
<td colspan="3"><div align="center"><?php echo RPT_DATEINFO; ?></div></td>
<td colspan="4"><div align="center"><?php echo RPT_DATEINFO; ?></div></td>
</tr>
<tr>
<td width="33%"><?php echo RPT_DATELIST; ?><br /><br /><?php echo RPT_DATEINST; ?></td>
<td width="33%">
<td width="25%"><?php echo RPT_DATELIST; ?><br /><br /><?php echo RPT_DATEINST; ?></td>
<td width="25%">
<?php if (mb_strpos($DateListings['displaydesc'],'a')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange1" value="a"<?php echo $Checked; ?>><?php echo $DateChoices['a']; ?><br />
<?php if (mb_strpos($DateListings['displaydesc'],'b')===false) $Checked = ''; else $Checked = ' checked'; ?>
Expand All @@ -31,7 +31,7 @@ <h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_C
<?php if (mb_strpos($DateListings['displaydesc'],'f')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange6" value="f"<?php echo $Checked; ?>><?php echo $DateChoices['f']; ?><br />
</td>
<td width="33%">
<td width="25%">
<?php if (mb_strpos($DateListings['displaydesc'],'g')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange7" value="g"<?php echo $Checked; ?>><?php echo $DateChoices['g']; ?><br />
<?php if (mb_strpos($DateListings['displaydesc'],'h')===false) $Checked = ''; else $Checked = ' checked'; ?>
Expand All @@ -43,10 +43,22 @@ <h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_C
<?php if (mb_strpos($DateListings['displaydesc'],'k')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange11" value="k"<?php echo $Checked; ?>><?php echo $DateChoices['k']; ?><br />
</td>
<td width="25%">
<?php if (mb_strpos($DateListings['displaydesc'],'l')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange12" value="l"<?php echo $Checked; ?>><?php echo $DateChoices['l']; ?><br />
<?php if (mb_strpos($DateListings['displaydesc'],'m')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange13" value="m"<?php echo $Checked; ?>><?php echo $DateChoices['m']; ?><br />
<?php if (mb_strpos($DateListings['displaydesc'],'n')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange14" value="n"<?php echo $Checked; ?>><?php echo $DateChoices['n']; ?><br />
<?php if (mb_strpos($DateListings['displaydesc'],'o')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange15" value="o"<?php echo $Checked; ?>><?php echo $DateChoices['o']; ?><br />
<?php if (mb_strpos($DateListings['displaydesc'],'p')===false) $Checked = ''; else $Checked = ' checked'; ?>
<input type="checkbox" name="DateRange16" value="p"<?php echo $Checked; ?>><?php echo $DateChoices['p']; ?><br />
</td>
</tr>
<tr>
<td><?php echo RPT_DATEDEF; ?></td>
<td colspan="2"><select name="DefDate">
<td colspan="3"><select name="DefDate">
<?php foreach($DateChoices as $key=>$value) {
if ($DateListings['params']==$key) $Selected = ' selected'; else $Selected = '';
echo '<option value="'.$key.'"'.$Selected.'>'.$value.'</option>';
Expand All @@ -55,15 +67,15 @@ <h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_C
</tr>
<tr>
<td><?php echo RPT_DATEFNAME; ?></td>
<td colspan="4">
<td colspan="3">
<select name="DateField"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
<?php echo CreateFieldList($ReportID,$DateListings['fieldname'],''); ?></select>
</td>
</tr>
<?php if ($Type<>'frm') { ?>
<tr>
<td><?php echo RPT_TRUNC; ?></td>
<td colspan="4"><p>
<td colspan="3"><p>
<?php if ($TruncListings['params']=='1') $Checked = ' checked'; else $Checked = ''; ?>
<input type="radio" name="TruncLongDesc" value="1"<?php echo $Checked; ?>><?php echo RPT_YES; ?>
<?php if ($TruncListings['params']=='0') $Checked = ' checked'; else $Checked = ''; ?>
Expand All @@ -72,7 +84,7 @@ <h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_C
<?php } else { ?>
<tr>
<td><?php echo 'Form Page Break Field (table.fieldname)'; ?></td>
<td colspan="4">
<td colspan="3">
<select name="FormBreakField"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
<?php echo CreateFieldList($ReportID,$GroupListings['lists'][0]['fieldname'],''); ?></select>
</td>
Expand Down Expand Up @@ -293,4 +305,4 @@ <h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_C
</tr>
<?php } // end foreach
} // end else ?>
</table>
</table>
9 changes: 8 additions & 1 deletion reportwriter/languages/en_US/reports.php
@@ -1,4 +1,4 @@
<?php /* Version 1.0 */
<?php

/**************************************************************************************
Locale language file for reports. This file can be broken out for apps that use
Expand Down Expand Up @@ -346,4 +346,11 @@
define('RPT_QTD',_('This Quarter To Date'));
define('RPT_YEAR',_('This Year'));
define('RPT_YTD',_('This Year To Date'));
define('RPT_YESTERDAY',_('Yesterday'));
define('RPT_LASTWEEK',_('Last Week'));
define('RPT_LASTMONTH',_('Last Month'));
define('RPT_LASTQUARTER',_('Last Quarter'));
define('RPT_LASTYEAR',_('Last Year'));


?>

0 comments on commit 2175669

Please sign in to comment.