3 /* $Revision: 1.13 $ */
7 include ('includes/session.inc');
8 $title = _('Profit and Loss');
9 include('includes/SQL_CommonFunctions.inc');
10 include('includes/AccountSectionsDef.inc'); // This loads the $Sections variable
13 if ($_POST['FromPeriod'] > $_POST['ToPeriod']){
14 prnMsg(_('The selected period from is actually after the period to') . '! ' . _('Please reselect the reporting period'),'error');
15 $_POST['SelectADifferentPeriod']='Select A Different Period';
18 if ((! isset($_POST['FromPeriod']) AND ! isset($_POST['ToPeriod'])) OR isset($_POST['SelectADifferentPeriod'])){
20 include('includes/header.inc');
21 echo "<FORM METHOD='POST' ACTION=" . $_SERVER['PHP_SELF'] . '?' . SID
. '>';
23 if (Date('m') > $_SESSION['YearEnd']){
24 /*Dates in SQL format */
25 $DefaultFromDate = Date ('Y-m-d', Mktime(0,0,0,$_SESSION['YearEnd'] +
2,0,Date('Y')));
27 $DefaultFromDate = Date ('Y-m-d', Mktime(0,0,0,$_SESSION['YearEnd'] +
2,0,Date('Y')-1));
30 /*Show a form to allow input of criteria for profit and loss to show */
31 echo '<CENTER><TABLE><TR><TD>'._('Select Period From').":</TD><TD><SELECT Name='FromPeriod'>";
33 $sql = 'SELECT periodno, lastdate_in_period FROM periods ORDER BY periodno DESC';
34 $Periods = DB_query($sql,$db);
37 while ($myrow=DB_fetch_array($Periods,$db)){
38 if(isset($_POST['FromPeriod']) AND $_POST['FromPeriod']!=''){
39 if( $_POST['FromPeriod']== $myrow['periodno']){
40 echo '<OPTION SELECTED VALUE=' . $myrow['periodno'] . '>' .MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
42 echo '<OPTION VALUE=' . $myrow['periodno'] . '>' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
45 if($myrow['lastdate_in_period']==$DefaultFromDate){
46 echo '<OPTION SELECTED VALUE=' . $myrow['periodno'] . '>' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
48 echo '<OPTION VALUE=' . $myrow['periodno'] . '>' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
53 echo '</SELECT></TD></TR>';
54 if (!isset($_POST['ToPeriod']) OR $_POST['ToPeriod']==''){
55 $sql = 'SELECT MAX(periodno) FROM periods';
56 $MaxPrd = DB_query($sql,$db);
57 $MaxPrdrow = DB_fetch_row($MaxPrd);
59 $DefaultToPeriod = (int) ($MaxPrdrow[0]-1);
61 $DefaultToPeriod = $_POST['ToPeriod'];
64 echo '<TR><TD>' . _('Select Period To') . ":</TD><TD><SELECT Name='ToPeriod'>";
66 $RetResult = DB_data_seek($Periods,0);
68 while ($myrow=DB_fetch_array($Periods,$db)){
70 if($myrow['periodno']==$DefaultToPeriod){
71 echo '<OPTION SELECTED VALUE=' . $myrow['periodno'] . '>' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
73 echo '<OPTION VALUE =' . $myrow['periodno'] . '>' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']);
76 echo '</SELECT></TD></TR>';
78 echo '<TR><TD>'._('Detail Or Summary').":</TD><TD><SELECT Name='Detail'>";
79 echo "<OPTION SELECTED VALUE='Summary'>"._('Summary');
80 echo "<OPTION SELECTED VALUE='Detailed'>"._('All Accounts');
81 echo '</SELECT></TD></TR>';
85 echo "<INPUT TYPE=SUBMIT Name='ShowPL' Value='"._('Show Statement of Profit and Loss')."'></CENTER>";
86 echo "<CENTER><INPUT TYPE=SUBMIT Name='PrintPDF' Value='"._('PrintPDF')."'></CENTER>";
88 /*Now do the posting while the user is thinking about the period to select */
90 include ('includes/GLPostings.inc');
92 } else if (isset($_POST['PrintPDF'])) {
94 include('includes/PDFStarter.php');
97 $pdf->addinfo('Title', _('Profit and Loss') );
98 $pdf->addinfo('Subject', _('Profit and Loss') );
101 $NumberOfMonths = $_POST['ToPeriod'] - $_POST['FromPeriod'] +
1;
103 if ($NumberOfMonths > 12){
104 include('includes/header.inc');
106 prnMsg(_('A period up to 12 months in duration can be specified') . ' - ' . _('the system automatically shows a comparative for the same period from the previous year') . ' - ' . _('it cannot do this if a period of more than 12 months is specified') . '. ' . _('Please select an alternative period range'),'error');
107 include('includes/footer.inc');
111 $sql = 'SELECT lastdate_in_period FROM periods WHERE periodno=' . $_POST['ToPeriod'];
112 $PrdResult = DB_query($sql, $db);
113 $myrow = DB_fetch_row($PrdResult);
114 $PeriodToDate = MonthAndYearFromSQLDate($myrow[0]);
117 $SQL = 'SELECT accountgroups.sectioninaccounts,
118 accountgroups.groupname,
119 accountgroups.parentgroupname,
120 chartdetails.accountcode ,
121 chartmaster.accountname,
122 Sum(CASE WHEN chartdetails.period=' . $_POST['FromPeriod'] . ' THEN chartdetails.bfwd ELSE 0 END) AS firstprdbfwd,
123 Sum(CASE WHEN chartdetails.period=' . $_POST['FromPeriod'] . ' THEN chartdetails.bfwdbudget ELSE 0 END) AS firstprdbudgetbfwd,
124 Sum(CASE WHEN chartdetails.period=' . $_POST['ToPeriod'] . ' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lastprdcfwd,
125 Sum(CASE WHEN chartdetails.period=' . ($_POST['FromPeriod'] - 12) . ' THEN chartdetails.bfwd ELSE 0 END) AS lyfirstprdbfwd,
126 Sum(CASE WHEN chartdetails.period=' . ($_POST['ToPeriod']-12) . ' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lylastprdcfwd,
127 Sum(CASE WHEN chartdetails.period=' . $_POST['ToPeriod'] . ' THEN chartdetails.bfwdbudget + chartdetails.budget ELSE 0 END) AS lastprdbudgetcfwd
128 FROM chartmaster INNER JOIN accountgroups
129 ON chartmaster.group_ = accountgroups.groupname INNER JOIN chartdetails
130 ON chartmaster.accountcode= chartdetails.accountcode
131 WHERE accountgroups.pandl=1
132 GROUP BY accountgroups.sectioninaccounts,
133 accountgroups.groupname,
134 accountgroups.parentgroupname,
135 chartdetails.accountcode,
136 chartmaster.accountname,
137 accountgroups.sequenceintb
138 ORDER BY accountgroups.sectioninaccounts,
139 accountgroups.sequenceintb,
140 accountgroups.groupname,
141 chartdetails.accountcode';
143 $AccountsResult = DB_query($SQL,$db);
144 if (DB_error_no($db) != 0) {
145 $title = _('Profit and Loss') . ' - ' . _('Problem Report') . '....';
146 include('includes/header.inc');
147 prnMsg( _('No general ledger accounts were returned by the SQL because') . ' - ' . DB_error_msg($db) );
148 echo '<BR><A HREF="' .$rootpath .'/index.php?' . SID
. '">'. _('Back to the menu'). '</A>';
152 include('includes/footer.inc');
156 include('includes/PDFProfitAndLossPageHeader.inc');
159 $SectionPrdActual = 0;
161 $SectionPrdBudget = 0;
164 $ParentGroups = array();
166 $ParentGroups[$Level]='';
167 $GrpPrdActual = array(0);
168 $GrpPrdLY = array(0);
169 $GrpPrdBudget = array(0);
171 while ($myrow = DB_fetch_array($AccountsResult)){
173 // Print heading if at end of page
174 if ($YPos < ($Bottom_Margin)){
175 include('includes/PDFProfitAndLossPageHeader.inc');
178 if ($myrow['groupname'] != $ActGrp){
180 if ($myrow['parentgroupname']!=$ActGrp){
181 while ($myrow['groupname']!=$ParentGroups[$Level] AND $Level>0) {
182 if ($_POST['Detail'] == 'Detailed'){
183 $ActGrpLabel = $ParentGroups[$Level] . ' ' . _('total');
185 $ActGrpLabel = $ParentGroups[$Level];
187 if ($Section == 1){ /*Income */
188 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel);
189 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$GrpPrdActual[$Level]),'right');
190 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$GrpPrdBudget[$Level]),'right');
191 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$GrpPrdLY[$Level]),'right');
192 $YPos -= (2 * $line_height);
194 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel);
195 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($GrpPrdActual[$Level]),'right');
196 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($GrpPrdBudget[$Level]),'right');
197 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($GrpPrdLY[$Level]),'right');
198 $YPos -= (2 * $line_height);
200 $GrpPrdLY[$Level] = 0;
201 $GrpPrdActual[$Level] = 0;
202 $GrpPrdBudget[$Level] = 0;
203 $ParentGroups[$Level] ='';
205 // Print heading if at end of page
206 if ($YPos < ($Bottom_Margin +
(2*$line_height))){
207 include('includes/PDFProfitAndLossPageHeader.inc');
210 //still need to print out the group total for the same level
211 if ($_POST['Detail'] == 'Detailed'){
212 $ActGrpLabel = $ParentGroups[$Level] . ' ' . _('total');
214 $ActGrpLabel = $ParentGroups[$Level];
216 if ($Section == 1){ /*Income */
217 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel); $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$GrpPrdActual[$Level]),'right');
218 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$GrpPrdBudget[$Level]),'right');
219 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$GrpPrdLY[$Level]),'right');
220 $YPos -= (2 * $line_height);
222 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel);
223 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($GrpPrdActual[$Level]),'right');
224 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($GrpPrdBudget[$Level]),'right');
225 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($GrpPrdLY[$Level]),'right');
226 $YPos -= (2 * $line_height);
228 $GrpPrdLY[$Level] = 0;
229 $GrpPrdActual[$Level] = 0;
230 $GrpPrdBudget[$Level] = 0;
231 $ParentGroups[$Level] ='';
236 // Print heading if at end of page
237 if ($YPos < ($Bottom_Margin +
(2 * $line_height))){
238 include('includes/PDFProfitAndLossPageHeader.inc');
241 if ($myrow['sectioninaccounts'] != $Section){
243 $pdf->selectFont('./fonts/Helvetica-Bold.afm');
246 $pdf->line($Left_Margin+
310, $YPos+
$line_height,$Left_Margin+
500, $YPos+
$line_height);
247 $pdf->line($Left_Margin+
310, $YPos,$Left_Margin+
500, $YPos);
248 if ($Section == 1) { /*Income*/
250 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,$Sections[$Section]);
251 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$SectionPrdActual),'right');
252 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$SectionPrdBudget),'right');
253 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$SectionPrdLY),'right');
254 $YPos -= (2 * $line_height);
256 $TotalIncome = -$SectionPrdActual;
257 $TotalBudgetIncome = -$SectionPrdBudget;
258 $TotalLYIncome = -$SectionPrdLY;
260 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,$Sections[$Section]);
261 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($SectionPrdActual),'right');
262 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($SectionPrdBudget),'right');
263 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($SectionPrdLY),'right');
264 $YPos -= (2 * $line_height);
266 if ($Section == 2){ /*Cost of Sales - need sub total for Gross Profit*/
267 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,_('Gross Profit'));
268 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($TotalIncome - $SectionPrdActual),'right');
269 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($TotalBudgetIncome - $SectionPrdBudget),'right');
270 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($TotalLYIncome - $SectionPrdLY),'right');
271 $pdf->line($Left_Margin+
310, $YPos+
$line_height,$Left_Margin+
500, $YPos+
$line_height);
272 $pdf->line($Left_Margin+
310, $YPos,$Left_Margin+
500, $YPos);
273 $YPos -= (2 * $line_height);
275 if ($TotalIncome != 0){
276 $PrdGPPercent = 100 *($TotalIncome - $SectionPrdActual) / $TotalIncome;
280 if ($TotalBudgetIncome != 0){
281 $BudgetGPPercent = 100 * ($TotalBudgetIncome - $SectionPrdBudget) / $TotalBudgetIncome;
283 $BudgetGPPercent = 0;
285 if ($TotalLYIncome != 0){
286 $LYGPPercent = 100 * ($TotalLYIncome - $SectionPrdLY) / $TotalLYIncome;
290 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,_('Gross Profit Percent'));
291 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($PrdGPPercent,1) . '%','right');
292 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($BudgetGPPercent,1) . '%','right');
293 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($LYGPPercent,1). '%','right');
294 $YPos -= (2 * $line_height);
298 $SectionPrdActual = 0;
299 $SectionPrdBudget = 0;
301 $Section = $myrow['sectioninaccounts'];
303 if ($_POST['Detail'] == 'Detailed'){
304 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,$Sections[$myrow['sectioninaccounts']]);
305 $YPos -= (2 * $line_height);
308 $pdf->selectFont('./fonts/Helvetica.afm');
311 if ($myrow['groupname'] != $ActGrp){
312 if ($myrow['parentgroupname']==$ActGrp AND $ActGrp !=''){ //adding another level of nesting
315 $ActGrp = $myrow['groupname'];
316 $ParentGroups[$Level]=$ActGrp;
317 if ($_POST['Detail'] == 'Detailed'){
319 $pdf->selectFont('./fonts/Helvetica-Bold.afm');
320 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,$myrow['groupname']);
321 $YPos -= (2 * $line_height);
323 $pdf->selectFont('./fonts/Helvetica.afm');
327 $AccountPeriodActual = $myrow['lastprdcfwd'] - $myrow['firstprdbfwd'];
328 $AccountPeriodLY = $myrow['lylastprdcfwd'] - $myrow['lyfirstprdbfwd'];
329 $AccountPeriodBudget = $myrow['lastprdbudgetcfwd'] - $myrow['firstprdbudgetbfwd'];
330 $PeriodProfitLoss +
= $AccountPeriodActual;
331 $PeriodBudgetProfitLoss +
= $AccountPeriodBudget;
332 $PeriodLYProfitLoss +
= $AccountPeriodLY;
334 for ($i=0;$i<=$Level;$i++
){
335 $GrpPrdLY[$i] +
=$AccountPeriodLY;
336 $GrpPrdActual[$i] +
=$AccountPeriodActual;
337 $GrpPrdBudget[$i] +
=$AccountPeriodBudget;
341 $SectionPrdLY +
=$AccountPeriodLY;
342 $SectionPrdActual +
=$AccountPeriodActual;
343 $SectionPrdBudget +
=$AccountPeriodBudget;
345 if ($_POST['Detail'] == _('Detailed')) {
346 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,$myrow['accountcode']);
347 $LeftOvers = $pdf->addTextWrap($Left_Margin+
60,$YPos,190,$FontSize,$myrow['accountname']);
348 if ($Section == 1) { /*Income*/
349 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$AccountPeriodActual),'right');
350 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$AccountPeriodBudget),'right');
351 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$AccountPeriodLY),'right');
353 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($AccountPeriodActual),'right');
354 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($AccountPeriodBudget),'right');
355 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($AccountPeriodLY),'right');
357 $YPos -= $line_height;
364 if ($myrow['parentgroupname']!=$ActGrp){
366 while ($myrow['groupname']!=$ParentGroups[$Level] AND $Level>0) {
367 if ($_POST['Detail'] == 'Detailed'){
368 $ActGrpLabel = $ParentGroups[$Level] . ' ' . _('total');
370 $ActGrpLabel = $ParentGroups[$Level];
372 if ($Section == 1){ /*Income */
373 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel);
374 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$GrpPrdActual[$Level]),'right');
375 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$GrpPrdBudget[$Level]),'right');
376 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$GrpPrdLY[$Level]),'right');
377 $YPos -= (2 * $line_height);
379 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel);
380 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($GrpPrdActual[$Level]),'right');
381 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($GrpPrdBudget[$Level]),'right');
382 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($GrpPrdLY[$Level]),'right');
383 $YPos -= (2 * $line_height);
385 $GrpPrdLY[$Level] = 0;
386 $GrpPrdActual[$Level] = 0;
387 $GrpPrdBudget[$Level] = 0;
388 $ParentGroups[$Level] ='';
390 // Print heading if at end of page
391 if ($YPos < ($Bottom_Margin +
(2*$line_height))){
392 include('includes/PDFProfitAndLossPageHeader.inc');
395 //still need to print out the group total for the same level
396 if ($_POST['Detail'] == 'Detailed'){
397 $ActGrpLabel = $ParentGroups[$Level] . ' ' . _('total');
399 $ActGrpLabel = $ParentGroups[$Level];
401 if ($Section == 1){ /*Income */
402 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel); $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$GrpPrdActual[$Level]),'right');
403 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$GrpPrdBudget[$Level]),'right');
404 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$GrpPrdLY[$Level]),'right');
405 $YPos -= (2 * $line_height);
407 $LeftOvers = $pdf->addTextWrap($Left_Margin +
($Level*10),$YPos,200 -($Level*10),$FontSize,$ActGrpLabel);
408 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($GrpPrdActual[$Level]),'right');
409 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($GrpPrdBudget[$Level]),'right');
410 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($GrpPrdLY[$Level]),'right');
411 $YPos -= (2 * $line_height);
413 $GrpPrdLY[$Level] = 0;
414 $GrpPrdActual[$Level] = 0;
415 $GrpPrdBudget[$Level] = 0;
416 $ParentGroups[$Level] ='';
419 // Print heading if at end of page
420 if ($YPos < ($Bottom_Margin +
(2*$line_height))){
421 include('includes/PDFProfitAndLossPageHeader.inc');
425 $pdf->selectFont('./fonts/Helvetica-Bold.afm');
426 $pdf->line($Left_Margin+
310, $YPos+
10,$Left_Margin+
500, $YPos+
10);
427 $pdf->line($Left_Margin+
310, $YPos,$Left_Margin+
500, $YPos);
429 if ($Section == 1) { /*Income*/
430 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,$Sections[$Section]);
431 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$SectionPrdActual),'right');
432 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$SectionPrdBudget),'right');
433 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$SectionPrdLY),'right');
434 $YPos -= (2 * $line_height);
436 $TotalIncome = -$SectionPrdActual;
437 $TotalBudgetIncome = -$SectionPrdBudget;
438 $TotalLYIncome = -$SectionPrdLY;
440 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,$Sections[$Section]);
441 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($SectionPrdActual),'right');
442 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($SectionPrdBudget),'right');
443 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($SectionPrdLY),'right');
444 $YPos -= (2 * $line_height);
446 if ($Section == 2){ /*Cost of Sales - need sub total for Gross Profit*/
447 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,_('Gross Profit'));
448 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format($TotalIncome - $SectionPrdActual),'right');
449 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format($TotalBudgetIncome - $SectionPrdBudget),'right');
450 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format($TotalLYIncome - $SectionPrdLY),'right');
451 $YPos -= (2 * $line_height);
453 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(100*($TotalIncome - $SectionPrdActual)/$TotalIncome,1) . '%','right');
454 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(100*($TotalBudgetIncome - $SectionPrdBudget)/$TotalBudgetIncome,1) . '%','right');
455 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(100*($TotalLYIncome - $SectionPrdLY)/$TotalLYIncome,1). '%','right');
456 $YPos -= (2 * $line_height);
460 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,_('Profit').' - '._('Loss'));
461 $LeftOvers = $pdf->addTextWrap($Left_Margin+
310,$YPos,70,$FontSize,number_format(-$PeriodProfitLoss),'right');
462 $LeftOvers = $pdf->addTextWrap($Left_Margin+
370,$YPos,70,$FontSize,number_format(-$PeriodBudgetProfitLoss),'right');
463 $LeftOvers = $pdf->addTextWrap($Left_Margin+
430,$YPos,70,$FontSize,number_format(-$PeriodLYProfitLoss),'right');
465 $pdf->line($Left_Margin+
310, $YPos+
$line_height,$Left_Margin+
500, $YPos+
$line_height);
466 $pdf->line($Left_Margin+
310, $YPos,$Left_Margin+
500, $YPos);
468 $pdfcode = $pdf->output();
469 $len = strlen($pdfcode);
472 $title = _('Print Profit and Loss Error');
473 include('includes/header.inc');
475 prnMsg( _('There were no entries to print out for the selections specified') );
476 echo '<BR><A HREF="'. $rootpath.'/index.php?' . SID
. '">'. _('Back to the menu'). '</A>';
477 include('includes/footer.inc');
480 header('Content-type: application/pdf');
481 header('Content-Length: ' . $len);
482 header('Content-Disposition: inline; filename=Profit_Loss.pdf');
483 header('Expires: 0');
484 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
485 header('Pragma: public');
492 include('includes/header.inc');
493 echo "<FORM METHOD='POST' ACTION=" . $_SERVER['PHP_SELF'] . '?' . SID
. '>';
494 echo "<INPUT TYPE=HIDDEN NAME='FromPeriod' VALUE=" . $_POST['FromPeriod'] . "><INPUT TYPE=HIDDEN NAME='ToPeriod' VALUE=" . $_POST['ToPeriod'] . '>';
496 $NumberOfMonths = $_POST['ToPeriod'] - $_POST['FromPeriod'] +
1;
498 if ($NumberOfMonths >12){
500 prnMsg(_('A period up to 12 months in duration can be specified') . ' - ' . _('the system automatically shows a comparative for the same period from the previous year') . ' - ' . _('it cannot do this if a period of more than 12 months is specified') . '. ' . _('Please select an alternative period range'),'error');
501 include('includes/footer.inc');
505 $sql = 'SELECT lastdate_in_period FROM periods WHERE periodno=' . $_POST['ToPeriod'];
506 $PrdResult = DB_query($sql, $db);
507 $myrow = DB_fetch_row($PrdResult);
508 $PeriodToDate = MonthAndYearFromSQLDate($myrow[0]);
511 $SQL = 'SELECT accountgroups.sectioninaccounts,
512 accountgroups.parentgroupname,
513 accountgroups.groupname,
514 chartdetails.accountcode,
515 chartmaster.accountname,
516 Sum(CASE WHEN chartdetails.period=' . $_POST['FromPeriod'] . ' THEN chartdetails.bfwd ELSE 0 END) AS firstprdbfwd,
517 Sum(CASE WHEN chartdetails.period=' . $_POST['FromPeriod'] . ' THEN chartdetails.bfwdbudget ELSE 0 END) AS firstprdbudgetbfwd,
518 Sum(CASE WHEN chartdetails.period=' . $_POST['ToPeriod'] . ' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lastprdcfwd,
519 Sum(CASE WHEN chartdetails.period=' . ($_POST['FromPeriod'] - 12) . ' THEN chartdetails.bfwd ELSE 0 END) AS lyfirstprdbfwd,
520 Sum(CASE WHEN chartdetails.period=' . ($_POST['ToPeriod']-12) . ' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lylastprdcfwd,
521 Sum(CASE WHEN chartdetails.period=' . $_POST['ToPeriod'] . ' THEN chartdetails.bfwdbudget + chartdetails.budget ELSE 0 END) AS lastprdbudgetcfwd
522 FROM chartmaster INNER JOIN accountgroups
523 ON chartmaster.group_ = accountgroups.groupname INNER JOIN chartdetails
524 ON chartmaster.accountcode= chartdetails.accountcode
525 WHERE accountgroups.pandl=1
526 GROUP BY accountgroups.sectioninaccounts,
527 accountgroups.parentgroupname,
528 accountgroups.groupname,
529 chartdetails.accountcode,
530 chartmaster.accountname,
531 accountgroups.sequenceintb
532 ORDER BY accountgroups.sectioninaccounts,
533 accountgroups.sequenceintb,
534 accountgroups.groupname,
535 accountgroups.sequenceintb,
536 chartdetails.accountcode';
538 $AccountsResult = DB_query($SQL,$db,_('No general ledger accounts were returned by the SQL because'),_('The SQL that failed was'));
540 echo '<CENTER><FONT SIZE=4 COLOR=BLUE><B>' . _('Statement of Profit and Loss for the'). ' ' . $NumberOfMonths . ' ' . _('months to'). ' ' . $PeriodToDate . '</B></FONT><BR>';
542 /*show a table of the accounts info returned by the SQL
543 Account Code , Account Name , Month Actual, Month Budget, Period Actual, Period Budget */
545 echo '<TABLE CELLPADDING=2>';
547 if ($_POST['Detail']=='Detailed'){
549 <TD class='tableheader'>"._('Account')."</TD>
550 <TD class='tableheader'>"._('Account Name')."</TD>
551 <TD COLSPAN=2 class='tableheader'>"._('Period Actual')."</TD>
552 <TD COLSPAN=2 class='tableheader'>"._('Period Budget')."</TD>
553 <TD COLSPAN=2 class='tableheader'>"._('Last Year').'</TD>
555 } else { /*summary */
557 <TD COLSPAN=2 class='tableheader'></TD>
558 <TD COLSPAN=2 class='tableheader'>"._('Period Actual')."</TD>
559 <TD COLSPAN=2 class='tableheader'>"._('Period Budget')."</TD>
560 <TD COLSPAN=2 class='tableheader'>"._('Last Year')."</TD>
566 $k=0; //row colour counter
568 $SectionPrdActual= 0;
570 $SectionPrdBudget= 0;
573 $ParentGroups = array();
575 $ParentGroups[$Level]='';
576 $GrpPrdActual = array(0);
577 $GrpPrdLY = array(0);
578 $GrpPrdBudget = array(0);
581 while ($myrow=DB_fetch_array($AccountsResult)) {
584 if ($myrow['groupname']!= $ActGrp){
585 if ($myrow['parentgroupname']!=$ActGrp AND $ActGrp!=''){
586 while ($myrow['groupname']!=$ParentGroups[$Level] AND $Level>0) {
587 if ($_POST['Detail']=='Detailed'){
590 <TD COLSPAN=6><HR></TD>
592 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level] . ' ' . _('total');
594 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level];
596 if ($Section ==1){ /*Income */
598 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
600 <TD ALIGN=RIGHT>%s</TD>
602 <TD ALIGN=RIGHT>%s</TD>
604 <TD ALIGN=RIGHT>%s</TD>
607 number_format(-$GrpPrdActual[$Level]),
608 number_format(-$GrpPrdBudget[$Level]),
609 number_format(-$GrpPrdLY[$Level]));
612 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
613 <TD ALIGN=RIGHT>%s</TD>
615 <TD ALIGN=RIGHT>%s</TD>
617 <TD ALIGN=RIGHT>%s</TD>
621 number_format($GrpPrdActual[$Level]),
622 number_format($GrpPrdBudget[$Level]),
623 number_format($GrpPrdLY[$Level]));
625 $GrpPrdLY[$Level] = 0;
626 $GrpPrdActual[$Level] = 0;
627 $GrpPrdBudget[$Level] = 0;
628 $ParentGroups[$Level] ='';
631 //still need to print out the old group totals
632 if ($_POST['Detail']=='Detailed'){
635 <TD COLSPAN=6><HR></TD>
637 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level] . ' ' . _('total');
639 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level];
642 if ($Section ==1){ /*Income */
644 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
646 <TD ALIGN=RIGHT>%s</TD>
648 <TD ALIGN=RIGHT>%s</TD>
650 <TD ALIGN=RIGHT>%s</TD>
653 number_format(-$GrpPrdActual[$Level]),
654 number_format(-$GrpPrdBudget[$Level]),
655 number_format(-$GrpPrdLY[$Level]));
658 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
659 <TD ALIGN=RIGHT>%s</TD>
661 <TD ALIGN=RIGHT>%s</TD>
663 <TD ALIGN=RIGHT>%s</TD>
667 number_format($GrpPrdActual[$Level]),
668 number_format($GrpPrdBudget[$Level]),
669 number_format($GrpPrdLY[$Level]));
671 $GrpPrdLY[$Level] = 0;
672 $GrpPrdActual[$Level] = 0;
673 $GrpPrdBudget[$Level] = 0;
674 $ParentGroups[$Level] ='';
679 if ($myrow['sectioninaccounts']!= $Section){
681 if ($SectionPrdLY+
$SectionPrdActual+
$SectionPrdBudget !=0){
682 if ($Section==1) { /*Income*/
694 <TD COLSPAN=2><FONT SIZE=4>%s</FONT></td>
696 <TD ALIGN=RIGHT>%s</TD>
698 <TD ALIGN=RIGHT>%s</TD>
700 <TD ALIGN=RIGHT>%s</TD>
703 number_format(-$SectionPrdActual),
704 number_format(-$SectionPrdBudget),
705 number_format(-$SectionPrdLY));
706 $TotalIncome = -$SectionPrdActual;
707 $TotalBudgetIncome = -$SectionPrdBudget;
708 $TotalLYIncome = -$SectionPrdLY;
719 <TD COLSPAN=2><FONT SIZE=4>%s</FONT></td>
721 <TD ALIGN=RIGHT>%s</TD>
723 <TD ALIGN=RIGHT>%s</TD>
725 <TD ALIGN=RIGHT>%s</TD>
728 number_format($SectionPrdActual),
729 number_format($SectionPrdBudget),
730 number_format($SectionPrdLY));
732 if ($Section==2){ /*Cost of Sales - need sub total for Gross Profit*/
735 <TD COLSPAN=6><HR></TD>
738 <TD COLSPAN=2><FONT SIZE=4>'._('Gross Profit').'</FONT></td>
740 <TD ALIGN=RIGHT>%s</TD>
742 <TD ALIGN=RIGHT>%s</TD>
744 <TD ALIGN=RIGHT>%s</TD>
746 number_format($TotalIncome - $SectionPrdActual),
747 number_format($TotalBudgetIncome - $SectionPrdBudget),
748 number_format($TotalLYIncome - $SectionPrdLY));
750 if ($TotalIncome !=0){
751 $PrdGPPercent = 100*($TotalIncome - $SectionPrdActual)/$TotalIncome;
755 if ($TotalBudgetIncome !=0){
756 $BudgetGPPercent = 100*($TotalBudgetIncome - $SectionPrdBudget)/$TotalBudgetIncome;
760 if ($TotalLYIncome !=0){
761 $LYGPPercent = 100*($TotalLYIncome - $SectionPrdLY)/$TotalLYIncome;
767 <TD COLSPAN=6><HR></TD>
770 <TD COLSPAN=2><FONT SIZE=2><I>'._('Gross Profit Percent').'</I></FONT></td>
772 <TD ALIGN=RIGHT><I>%s</I></TD>
774 <TD ALIGN=RIGHT><I>%s</I></TD>
776 <TD ALIGN=RIGHT><I>%s</I></TD>
777 </TR><TR><TD COLSPAN=6> </TD></TR>',
778 number_format($PrdGPPercent,1) . '%',
779 number_format($BudgetGPPercent,1) . '%',
780 number_format($LYGPPercent,1). '%');
785 $SectionPrdActual =0;
786 $SectionPrdBudget =0;
788 $Section = $myrow['sectioninaccounts'];
790 if ($_POST['Detail']=='Detailed'){
792 <td COLSPAN=6><FONT SIZE=4 COLOR=BLUE><B>%s</B></FONT></TD>
794 $Sections[$myrow['sectioninaccounts']]);
802 if ($myrow['groupname']!= $ActGrp){
804 if ($myrow['parentgroupname']==$ActGrp AND $ActGrp !=''){ //adding another level of nesting
808 $ParentGroups[$Level] = $myrow['groupname'];
809 $ActGrp = $myrow['groupname'];
810 if ($_POST['Detail']=='Detailed'){
812 <td COLSPAN=6><FONT SIZE=2 COLOR=BLUE><B>%s</B></FONT></TD>
814 $myrow['groupname']);
819 $AccountPeriodActual = $myrow['lastprdcfwd'] - $myrow['firstprdbfwd'];
820 $AccountPeriodLY = $myrow['lylastprdcfwd'] - $myrow['lyfirstprdbfwd'];
821 $AccountPeriodBudget = $myrow['lastprdbudgetcfwd'] - $myrow['firstprdbudgetbfwd'];
822 $PeriodProfitLoss +
= $AccountPeriodActual;
823 $PeriodBudgetProfitLoss +
= $AccountPeriodBudget;
824 $PeriodLYProfitLoss +
= $AccountPeriodLY;
826 for ($i=0;$i<=$Level;$i++
){
827 $GrpPrdLY[$i] +
=$AccountPeriodLY;
828 $GrpPrdActual[$i] +
=$AccountPeriodActual;
829 $GrpPrdBudget[$i] +
=$AccountPeriodBudget;
831 $SectionPrdLY +
=$AccountPeriodLY;
832 $SectionPrdActual +
=$AccountPeriodActual;
833 $SectionPrdBudget +
=$AccountPeriodBudget;
835 if ($_POST['Detail']==_('Detailed')){
838 echo "<tr bgcolor='#CCCCCC'>";
841 echo "<tr bgcolor='#EEEEEE'>";
845 $ActEnquiryURL = "<A HREF='$rootpath/GLAccountInquiry.php?" . SID
. '&Period=' . $_POST['ToPeriod'] . '&Account=' . $myrow['accountcode'] . "&Show=Yes'>" . $myrow['accountcode'] . '<A>';
851 <td ALIGN=RIGHT>%s</td>
853 <td ALIGN=RIGHT>%s</td>
855 <td ALIGN=RIGHT>%s</td>
858 $myrow['accountname'],
859 number_format(-$AccountPeriodActual),
860 number_format(-$AccountPeriodBudget),
861 number_format(-$AccountPeriodLY));
865 <td ALIGN=RIGHT>%s</td>
867 <td ALIGN=RIGHT>%s</td>
869 <td ALIGN=RIGHT>%s</td>
873 $myrow['accountname'],
874 number_format($AccountPeriodActual),
875 number_format($AccountPeriodBudget),
876 number_format($AccountPeriodLY));
885 if ($myrow['groupname']!= $ActGrp){
886 if ($myrow['parentgroupname']!=$ActGrp AND $ActGrp!=''){
887 while ($myrow['groupname']!=$ParentGroups[$Level] AND $Level>0) {
888 if ($_POST['Detail']=='Detailed'){
891 <TD COLSPAN=6><HR></TD>
893 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level] . ' ' . _('total');
895 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level];
897 if ($Section ==1){ /*Income */
899 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
901 <TD ALIGN=RIGHT>%s</TD>
903 <TD ALIGN=RIGHT>%s</TD>
905 <TD ALIGN=RIGHT>%s</TD>
908 number_format(-$GrpPrdActual[$Level]),
909 number_format(-$GrpPrdBudget[$Level]),
910 number_format(-$GrpPrdLY[$Level]));
913 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
914 <TD ALIGN=RIGHT>%s</TD>
916 <TD ALIGN=RIGHT>%s</TD>
918 <TD ALIGN=RIGHT>%s</TD>
922 number_format($GrpPrdActual[$Level]),
923 number_format($GrpPrdBudget[$Level]),
924 number_format($GrpPrdLY[$Level]));
926 $GrpPrdLY[$Level] = 0;
927 $GrpPrdActual[$Level] = 0;
928 $GrpPrdBudget[$Level] = 0;
929 $ParentGroups[$Level] ='';
932 //still need to print out the old group totals
933 if ($_POST['Detail']=='Detailed'){
936 <TD COLSPAN=6><HR></TD>
938 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level] . ' ' . _('total');
940 $ActGrpLabel = str_repeat('___',$Level) . $ParentGroups[$Level];
943 if ($Section ==1){ /*Income */
945 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
947 <TD ALIGN=RIGHT>%s</TD>
949 <TD ALIGN=RIGHT>%s</TD>
951 <TD ALIGN=RIGHT>%s</TD>
954 number_format(-$GrpPrdActual[$Level]),
955 number_format(-$GrpPrdBudget[$Level]),
956 number_format(-$GrpPrdLY[$Level]));
959 <TD COLSPAN=2><FONT SIZE=2><I>%s </I></FONT></td>
960 <TD ALIGN=RIGHT>%s</TD>
962 <TD ALIGN=RIGHT>%s</TD>
964 <TD ALIGN=RIGHT>%s</TD>
968 number_format($GrpPrdActual[$Level]),
969 number_format($GrpPrdBudget[$Level]),
970 number_format($GrpPrdLY[$Level]));
972 $GrpPrdLY[$Level] = 0;
973 $GrpPrdActual[$Level] = 0;
974 $GrpPrdBudget[$Level] = 0;
975 $ParentGroups[$Level] ='';
980 if ($myrow['sectioninaccounts']!= $Section){
982 if ($Section==1) { /*Income*/
994 <TD COLSPAN=2><FONT SIZE=4>%s</FONT></td>
996 <TD ALIGN=RIGHT>%s</TD>
998 <TD ALIGN=RIGHT>%s</TD>
1000 <TD ALIGN=RIGHT>%s</TD>
1002 $Sections[$Section],
1003 number_format(-$SectionPrdActual),
1004 number_format(-$SectionPrdBudget),
1005 number_format(-$SectionPrdLY));
1006 $TotalIncome = -$SectionPrdActual;
1007 $TotalBudgetIncome = -$SectionPrdBudget;
1008 $TotalLYIncome = -$SectionPrdLY;
1019 <TD COLSPAN=2><FONT SIZE=4>%s</FONT></td>
1021 <TD ALIGN=RIGHT>%s</TD>
1023 <TD ALIGN=RIGHT>%s</TD>
1025 <TD ALIGN=RIGHT>%s</TD>
1027 $Sections[$Section],
1028 number_format($SectionPrdActual),
1029 number_format($SectionPrdBudget),
1030 number_format($SectionPrdLY));
1032 if ($Section==2){ /*Cost of Sales - need sub total for Gross Profit*/
1035 <TD COLSPAN=6><HR></TD>
1038 <TD COLSPAN=2><FONT SIZE=4>'._('Gross Profit').'</FONT></td>
1040 <TD ALIGN=RIGHT>%s</TD>
1042 <TD ALIGN=RIGHT>%s</TD>
1044 <TD ALIGN=RIGHT>%s</TD>
1046 number_format($TotalIncome - $SectionPrdActual),
1047 number_format($TotalBudgetIncome - $SectionPrdBudget),
1048 number_format($TotalLYIncome - $SectionPrdLY));
1050 if ($TotalIncome !=0){
1051 $PrdGPPercent = 100*($TotalIncome - $SectionPrdActual)/$TotalIncome;
1055 if ($TotalBudgetIncome !=0){
1056 $BudgetGPPercent = 100*($TotalBudgetIncome - $SectionPrdBudget)/$TotalBudgetIncome;
1058 $BudgetGPPercent =0;
1060 if ($TotalLYIncome !=0){
1061 $LYGPPercent = 100*($TotalLYIncome - $SectionPrdLY)/$TotalLYIncome;
1067 <TD COLSPAN=6><HR></TD>
1070 <TD COLSPAN=2><FONT SIZE=2><I>'._('Gross Profit Percent').'</I></FONT></td>
1072 <TD ALIGN=RIGHT><I>%s</I></TD>
1074 <TD ALIGN=RIGHT><I>%s</I></TD>
1076 <TD ALIGN=RIGHT><I>%s</I></TD>
1077 </TR><TR><TD COLSPAN=6> </TD></TR>',
1078 number_format($PrdGPPercent,1) . '%',
1079 number_format($BudgetGPPercent,1) . '%',
1080 number_format($LYGPPercent,1). '%');
1085 $SectionPrdActual =0;
1086 $SectionPrdBudget =0;
1088 $Section = $myrow['sectioninaccounts'];
1090 if ($_POST['Detail']=='Detailed'){
1092 <td COLSPAN=6><FONT SIZE=4 COLOR=BLUE><B>%s</B></FONT></TD>
1094 $Sections[$myrow['sectioninaccounts']]);
1102 <TD COLSPAN=6><HR></TD>
1105 printf("<tr bgcolor='#ffffff'>
1106 <td COLSPAN=2><FONT SIZE=4 COLOR=BLUE><B>"._('Profit').' - '._('Loss')."</B></FONT></td>
1108 <td ALIGN=RIGHT>%s</td>
1110 <td ALIGN=RIGHT>%s</td>
1112 <td ALIGN=RIGHT>%s</td>
1114 number_format(-$PeriodProfitLoss),
1115 number_format(-$PeriodBudgetProfitLoss),
1116 number_format(-$PeriodLYProfitLoss)
1121 <TD COLSPAN=6><HR></TD>
1125 echo "<INPUT TYPE=SUBMIT Name='SelectADifferentPeriod' Value='"._('Select A Different Period')."'></CENTER>";
1128 include('includes/footer.inc');