From: <rc...@us...> - 2015-08-05 02:41:55
|
Revision: 7335 http://sourceforge.net/p/web-erp/reponame/7335 Author: rchacon Date: 2015-08-05 02:41:53 +0000 (Wed, 05 Aug 2015) Log Message: ----------- In AnalysisHorizontalPosition.php, modify DB_fetch_array() function because it requires only one parameter (thanks Tim). Other improvements. Modified Paths: -------------- trunk/AnalysisHorizontalPosition.php trunk/doc/Change.log Modified: trunk/AnalysisHorizontalPosition.php =================================================================== --- trunk/AnalysisHorizontalPosition.php 2015-08-04 07:40:21 UTC (rev 7334) +++ trunk/AnalysisHorizontalPosition.php 2015-08-05 02:41:53 UTC (rev 7335) @@ -1,6 +1,6 @@ <?php /* $Id: AnalysisHorizontalPosition.php 7268 2015-04-19 14:57:47Z rchacon $*/ -/* Horizontal analysis of statement of financial position. */ +/* Shows the horizontal analysis of the statement of financial position. */ function RelativeVariation($CurrentPeriod, $PreviousPeriod) { // Calculates the relative variation between current and previous periods. Uses percent in locale number format. @@ -24,37 +24,49 @@ include('includes/header.inc'); echo '<p class="page_title_text"><img alt="" src="', $RootPath, '/css/', $Theme, '/images/printer.png" title="', // Icon image. - _('Print Horizontal analysis of statement of financial position'), '" /> ', // Icon title. + _('Print Horizontal Analysis of Statement of Financial Position'), '" /> ', // Icon title. _('Horizontal Analysis of Statement of Financial Position'), '</p>';// Page title. echo '<div class="page_help_text">', _('Horizontal analysis (also known as trend analysis) is a financial statement analysis technique that shows changes in the amounts of corresponding financial statement items over a period of time. It is a useful tool to evaluate trend situations.'), '<br />', _('The statements for two periods are used in horizontal analysis. The earliest period is used as the base period. The items on the later statement are compared with items on the statement of the base period. The changes are shown both in currency (absolute variation) and percentage (relative variation).'), '<br />', _('webERP is an "accrual" based system (not a "cash based" system). Accrual systems include items when they are invoiced to the customer, and when expenses are owed based on the supplier invoice date.'), '</div>', + // Show a form to allow input of criteria for the report to show: '<form method="post" action="', htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8'), '">', '<input type="hidden" name="FormID" value="', $_SESSION['FormID'], '" />', + '<br />', '<table class="selection"> <tr> <td>', _('Select the balance date'), ':</td> <td><select required="required" name="BalancePeriodEnd">'; +/* <td><select required="required" name="ToPeriod">';*/ $periodno=GetPeriod(Date($_SESSION['DefaultDateFormat']), $db); $sql = "SELECT lastdate_in_period FROM periods WHERE periodno='".$periodno . "'"; $result = DB_query($sql); - $myrow=DB_fetch_array($result, $db); + $myrow=DB_fetch_array($result); $lastdate_in_period=$myrow[0]; $sql = "SELECT periodno, lastdate_in_period FROM periods ORDER BY periodno DESC"; $Periods = DB_query($sql); - while($myrow=DB_fetch_array($Periods,$db)) { - if( $myrow['periodno']== $periodno) { - echo '<option selected="selected" value="', $myrow['periodno'], '">', ConvertSQLDate($lastdate_in_period), '</option>'; - } else { - echo '<option value="', $myrow['periodno'], '">', ConvertSQLDate($myrow['lastdate_in_period']), '</option>'; + while($myrow=DB_fetch_array($Periods)) { + echo '<option'; + if($myrow['periodno']== $periodno) { + echo ' selected="selected"'; } + echo ' value="', $myrow['periodno'], '">', MonthAndYearFromSQLDate($myrow['lastdate_in_period']), '</option>'; } - echo '</select></td> +/* + while($myrow=DB_fetch_array($Periods)) { + echo '<option'; + if($myrow['periodno']==$DefaultToPeriod) { + echo ' selected="selected"'; + } + echo ' value="', $myrow['periodno'], '">', MonthAndYearFromSQLDate($myrow['lastdate_in_period']), '</option>'; + } +*/ + echo '</select></td> </tr> <tr> <td>', _('Detail or summary'), ':</td> @@ -64,8 +76,8 @@ </select></td> </tr> <tr> - <td>', _('Show all accounts including zero balances'), '</td> - <td><input name="ShowZeroBalances" title="', _('Check this box to display all accounts including those accounts with no balance'), '" type="checkbox" /></td> + <td>', _('Show all accounts including zero balances'), '</td> + <td><input name="ShowZeroBalances" title="', _('Check this box to display all accounts including those accounts with no balance'), '" type="checkbox" /></td> </tr> </table> <br />', // Form buttons: @@ -77,7 +89,7 @@ '</div>', '</form>'; - /*Now do the posting while the user is thinking about the period to select */ + // Now do the posting while the user is thinking about the period to select: include ('includes/GLPostings.inc'); } else { @@ -90,9 +102,36 @@ $myrow = DB_fetch_row($PrdResult); $BalanceDate = ConvertSQLDate($myrow[0]); + // Page title as IAS 1, numerals 10 and 51: + include_once('includes/CurrenciesArray.php');// Array to retrieve currency name. + echo '<div id="Report">', // Division to identify the report block. + '<p class="page_title_text"><img alt="" src="', $RootPath, '/css/', $Theme, + '/images/gl.png" title="', // Icon image. + _('Horizontal Analysis of Statement of Financial Position'), '" /> ', // Icon title. + _('Horizontal Analysis of Statement of Financial Position'), '<br />', // Page title, reporting statement. + stripslashes($_SESSION['CompanyRecord']['coyname']), '<br />', // Page title, reporting entity. + _('as at'), ' ', $BalanceDate, '<br />', // Page title, reporting period. + _('All amounts stated in'), ': ', _($CurrencyName[$_SESSION['CompanyRecord']['currencydefault']]), '</p>';// Page title, reporting presentation currency and level of rounding used. + echo '<table class="scrollable"> + <thead> + <tr>'; + if($_POST['Detail']=='Detailed') {// Detailed report: + echo '<th class="text">', _('Account'), '</th> + <th class="text">', _('Account Name'), '</th>'; + } else {// Summary report: + echo '<th class="text" colspan="2">', _('Summary'), '</th>'; + } + echo '<th class="number">', $BalanceDate, '</th> + <th class="number">', _('Last Year'), '</th> + <th class="number">', _('Absolute variation'), '</th> + <th class="number">', _('Relative variation'), '</th> + </tr> + </thead> + <tbody>';// thead used in conjunction with tbody enable scrolling of the table body independently of the header and footer. Also, when printing a large table that spans multiple pages, these elements can enable the table header to be printed at the top of each page. + // Calculate B/Fwd retained earnings: $SQL = "SELECT Sum(CASE WHEN chartdetails.period='" . $_POST['BalancePeriodEnd'] . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS accumprofitbfwd, - Sum(CASE WHEN chartdetails.period='" . ($_POST['BalancePeriodEnd'] - 12) . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lyaccumprofitbfwd + Sum(CASE WHEN chartdetails.period='" . ($_POST['BalancePeriodEnd'] - 12) . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS accumprofitbfwdly FROM chartmaster INNER JOIN accountgroups ON chartmaster.group_ = accountgroups.groupname INNER JOIN chartdetails ON chartmaster.accountcode= chartdetails.accountcode @@ -108,7 +147,7 @@ chartdetails.accountcode, chartmaster.accountname, Sum(CASE WHEN chartdetails.period='" . $_POST['BalancePeriodEnd'] . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS balancecfwd, - Sum(CASE WHEN chartdetails.period='" . ($_POST['BalancePeriodEnd'] - 12) . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lybalancecfwd + Sum(CASE WHEN chartdetails.period='" . ($_POST['BalancePeriodEnd'] - 12) . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS balancecfwdly FROM chartmaster INNER JOIN accountgroups ON chartmaster.group_ = accountgroups.groupname INNER JOIN chartdetails ON chartmaster.accountcode= chartdetails.accountcode @@ -126,58 +165,30 @@ $AccountsResult = DB_query($SQL,_('No general ledger accounts were returned by the SQL because')); - // Page title as IAS 1, numerals 10 and 51: - include_once('includes/CurrenciesArray.php');// Array to retrieve currency name. - echo '<div id="Report">', // Division to identify the report block. - '<p class="page_title_text"><img alt="" src="', $RootPath, '/css/', $Theme, - '/images/gl.png" title="', // Icon image. - _('Horizontal Analysis of Statement of Financial Position'), '" /> ', // Icon title. - _('Horizontal Analysis of Statement of Financial Position'), '<br />', // Page title, reporting statement. - stripslashes($_SESSION['CompanyRecord']['coyname']), '<br />', // Page title, reporting entity. - _('as at'), ' ', $BalanceDate, '<br />', // Page title, reporting period. - _('All amounts stated in'), ': ', _($CurrencyName[$_SESSION['CompanyRecord']['currencydefault']]), '</p>';// Page title, reporting presentation currency and level of rounding used. + $CheckTotal=0; + $CheckTotalLY=0; - echo '<table class="scrollable"> - <thead> - <tr>'; - if($_POST['Detail']=='Detailed') {// Detailed report: - echo '<th class="text">', _('Account'), '</th> - <th class="text">', _('Account Name'), '</th>'; - } else {// Summary report: - echo '<th class="text" colspan="2">', _('Summary'), '</th>'; - } - echo '<th class="number">', $BalanceDate, '</th> - <th class="number">', _('Last Year'), '</th> - <th class="number">', _('Absolute variation'), '</th> - <th class="number">', _('Relative variation'), '</th> - </tr> - </thead> - <tbody>';// thead used in conjunction with tbody enable scrolling of the table body independently of the header and footer. Also, when printing a large table that spans multiple pages, these elements can enable the table header to be printed at the top of each page. - - $k=0; //row colour counter $Section=''; - $SectionBalance = 0; - $SectionBalanceLY = 0; + $SectionBalance= 0; + $SectionBalanceLY=0; - $LYCheckTotal = 0; - $CheckTotal = 0; - - $ActGrp =''; + $ActGrp=''; $Level=0; $ParentGroups=array(); $ParentGroups[$Level]=''; $GroupTotal = array(0); - $LYGroupTotal = array(0); + $GroupTotalLY = array(0); - $j=0; //row counter + $j=0;// Row counter. + $k=0;// Row colour counter. while($myrow=DB_fetch_array($AccountsResult)) { $AccountBalance = $myrow['balancecfwd']; - $LYAccountBalance = $myrow['lybalancecfwd']; + $AccountBalanceLY = $myrow['balancecfwdly']; if($myrow['accountcode'] == $RetainedEarningsAct) { $AccountBalance += $AccumProfitRow['accumprofitbfwd']; - $LYAccountBalance += $AccumProfitRow['lyaccumprofitbfwd']; + $AccountBalanceLY += $AccumProfitRow['accumprofitbfwdly']; } if($myrow['groupname']!= $ActGrp AND $ActGrp != '') { @@ -193,15 +204,15 @@ </tr>'; } echo '<tr> - <td colspan="2"><i>', $ParentGroups[$Level], '</i></td> + <td colspan="2">', $ParentGroups[$Level], '</i></td> <td class="number">', locale_number_format($GroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($GroupTotal[$Level]-$LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', RelativeVariation($GroupTotal[$Level],$LYGroupTotal[$Level]), '</td> + <td class="number">', locale_number_format($GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', locale_number_format($GroupTotal[$Level]-$GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', RelativeVariation($GroupTotal[$Level],$GroupTotalLY[$Level]), '</td> </tr>'; - $GroupTotal[$Level] = 0; - $LYGroupTotal[$Level] = 0; - $ParentGroups[$Level] = ''; + $GroupTotal[$Level]=0; + $GroupTotalLY[$Level]=0; + $ParentGroups[$Level]=''; $Level--; $j++; } @@ -215,20 +226,19 @@ </tr>'; } echo '<tr> - <td colspan="2">', $ParentGroups[$Level], '</td> + <td class="text" colspan="2">', $ParentGroups[$Level], '</td> <td class="number">', locale_number_format($GroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($GroupTotal[$Level]-$LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', RelativeVariation($GroupTotal[$Level],$LYGroupTotal[$Level]), '</td> + <td class="number">', locale_number_format($GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', locale_number_format($GroupTotal[$Level]-$GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', RelativeVariation($GroupTotal[$Level],$GroupTotalLY[$Level]), '</td> </tr>'; - $GroupTotal[$Level] = 0; - $LYGroupTotal[$Level] = 0; - $ParentGroups[$Level] = ''; + $GroupTotal[$Level]=0; + $GroupTotalLY[$Level]=0; + $ParentGroups[$Level]=''; $j++; } } if($myrow['sectioninaccounts'] != $Section ) { - if($Section!='') { if($_POST['Detail']=='Detailed') { echo '<tr> @@ -248,7 +258,7 @@ </tr>'; } echo '<tr> - <td colspan="2"><h2>', $Sections[$Section], '</h2></td> + <td class="text" colspan="2"><h2>', $Sections[$Section], '</h2></td> <td class="number"><h2>', locale_number_format($SectionBalance,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> <td class="number"><h2>', locale_number_format($SectionBalanceLY,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> <td class="number"><h2>', locale_number_format($SectionBalance-$SectionBalanceLY,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> @@ -256,8 +266,8 @@ </tr>'; $j++; } - $SectionBalanceLY = 0; - $SectionBalance = 0; + $SectionBalance=0; + $SectionBalanceLY=0; $Section = $myrow['sectioninaccounts']; if($_POST['Detail']=='Detailed') { echo '<tr> @@ -278,37 +288,37 @@ <td colspan="6"><h3>', $myrow['groupname'], '</h3></td> </tr>'; } - $GroupTotal[$Level] = 0; - $LYGroupTotal[$Level] = 0; + $GroupTotal[$Level]=0; + $GroupTotalLY[$Level]=0; $ActGrp = $myrow['groupname']; $ParentGroups[$Level] = $myrow['groupname']; $j++; } + $SectionBalance += $AccountBalance; + $SectionBalanceLY += $AccountBalanceLY; - $SectionBalanceLY += $LYAccountBalance; - $SectionBalance += $AccountBalance; for ($i=0;$i<=$Level;$i++) { - $LYGroupTotal[$i] += $LYAccountBalance; + $GroupTotalLY[$i] += $AccountBalanceLY; $GroupTotal[$i] += $AccountBalance; } - $LYCheckTotal += $LYAccountBalance; $CheckTotal += $AccountBalance; + $CheckTotalLY += $AccountBalanceLY; if($_POST['Detail']=='Detailed') { - if(isset($_POST['ShowZeroBalances']) OR (!isset($_POST['ShowZeroBalances']) AND (round($AccountBalance,$_SESSION['CompanyRecord']['decimalplaces']) <> 0 OR round($LYAccountBalance,$_SESSION['CompanyRecord']['decimalplaces']) <> 0))) { + if(isset($_POST['ShowZeroBalances']) OR (!isset($_POST['ShowZeroBalances']) AND (round($AccountBalance,$_SESSION['CompanyRecord']['decimalplaces']) <> 0 OR round($AccountBalanceLY,$_SESSION['CompanyRecord']['decimalplaces']) <> 0))) { if($k==1) { echo '<tr class="OddTableRows">'; $k=0; } else { echo '<tr class="EvenTableRows">'; - $k++; + $k=1; } - echo '<td><a href="', $RootPath, '/GLAccountInquiry.php?Period=', $_POST['BalancePeriodEnd'], '&Account=', $myrow['accountcode'], '">', $myrow['accountcode'], '</a></td> - <td>', htmlspecialchars($myrow['accountname'],ENT_QUOTES,'UTF-8',false), '</td> + echo '<td class="text"><a href="', $RootPath, '/GLAccountInquiry.php?Period=', $_POST['BalancePeriodEnd'], '&Account=', $myrow['accountcode'], '">', $myrow['accountcode'], '</a></td> + <td class="text">', htmlspecialchars($myrow['accountname'],ENT_QUOTES,'UTF-8',false), '</td> <td class="number">', locale_number_format($AccountBalance,$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($LYAccountBalance,$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($AccountBalance-$LYAccountBalance,$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', RelativeVariation($AccountBalance,$LYAccountBalance), '</td> + <td class="number">', locale_number_format($AccountBalanceLY,$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', locale_number_format($AccountBalance-$AccountBalanceLY,$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', RelativeVariation($AccountBalance,$AccountBalanceLY), '</td> </tr>'; $j++; } @@ -327,11 +337,11 @@ </tr>'; } echo '<tr> - <td colspan="2"><i>', $ParentGroups[$Level], '</i></td> + <td colspan="2">', $ParentGroups[$Level], '</i></td> <td class="number">', locale_number_format($GroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($GroupTotal[$Level]-$LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', RelativeVariation($GroupTotal[$Level],$LYGroupTotal[$Level]), '</td> + <td class="number">', locale_number_format($GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', locale_number_format($GroupTotal[$Level]-$GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', RelativeVariation($GroupTotal[$Level],$GroupTotalLY[$Level]), '</td> </tr>'; $Level--; } @@ -347,9 +357,9 @@ echo '<tr> <td colspan="2">', $ParentGroups[$Level], '</td> <td class="number">', locale_number_format($GroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', locale_number_format($GroupTotal[$Level]-$LYGroupTotal[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> - <td class="number">', RelativeVariation($GroupTotal[$Level],$LYGroupTotal[$Level]), '</td> + <td class="number">', locale_number_format($GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', locale_number_format($GroupTotal[$Level]-$GroupTotalLY[$Level],$_SESSION['CompanyRecord']['decimalplaces']), '</td> + <td class="number">', RelativeVariation($GroupTotal[$Level],$GroupTotalLY[$Level]), '</td> </tr>'; echo '<tr> @@ -386,9 +396,9 @@ echo'<tr> <td colspan="2"><h2>', _('Check Total'), '</h2></td> <td class="number"><h2>', locale_number_format($CheckTotal,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> - <td class="number"><h2>', locale_number_format($LYCheckTotal,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> - <td class="number"><h2>', locale_number_format($CheckTotal-$LYCheckTotal,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> - <td class="number"><h2>', RelativeVariation($CheckTotal,$LYCheckTotal), '</h2></td> + <td class="number"><h2>', locale_number_format($CheckTotalLY,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> + <td class="number"><h2>', locale_number_format($CheckTotal-$CheckTotalLY,$_SESSION['CompanyRecord']['decimalplaces']), '</h2></td> + <td class="number"><h2>', RelativeVariation($CheckTotal,$CheckTotalLY), '</h2></td> </tr>'; echo '<tr> @@ -419,4 +429,4 @@ } include('includes/footer.inc'); -?> \ No newline at end of file +?> Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2015-08-04 07:40:21 UTC (rev 7334) +++ trunk/doc/Change.log 2015-08-05 02:41:53 UTC (rev 7335) @@ -1,5 +1,6 @@ webERP Change Log +05/08/15 RChacon: In AnalysisHorizontalPosition.php, modify DB_fetch_array() function because it requires only one parameter (thanks Tim). Other improvements. 04/08/15 RChacon: Add new script AnalysisHorizontalPosition.php to generate an horizontal analysis of the statement of financial position. 02/08/15 RChacon: In CustomerReceipt.php, move currency tags near currency ratesand other minor changes. 27/07/15 RChacon: In Payments.php, move currency tags near currency rates. |