EOL formatting cleanup.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Sat, 9 Apr 2011 10:15:20 +0000 (12:15 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Sat, 9 Apr 2011 10:15:20 +0000 (12:15 +0200)
gl/inquiry/gl_trial_balance.php
reporting/rep114.php
reporting/rep701.php
reporting/rep708.php
reporting/rep709.php
sales/includes/db/sales_order_db.inc

index 90bc1f2b4ca260aea29d2f1924725a03df12f4df..0b08c69d14ef9737fd133c66545415013d33aabb 100644 (file)
@@ -27,11 +27,11 @@ if ($use_date_picker)
 
 page(_($help_context = "Trial Balance"), false, false, "", $js);
 
-$k = 0;\r
-$pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0;\r
-$cls_pdeb = $cls_pcre = $cls_cdeb = $cls_ccre = $cls_tdeb = $cls_tcre = $cls_pbal = $cls_cbal = $cls_tbal = 0;\r
-$grp_pdeb = $grp_pcre = $grp_cdeb = $grp_ccre = $grp_tdeb = $grp_tcre = $grp_pbal = $grp_cbal = $grp_tbal = 0;\r
-\r
+$k = 0;
+$pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0;
+$cls_pdeb = $cls_pcre = $cls_cdeb = $cls_ccre = $cls_tdeb = $cls_tcre = $cls_pbal = $cls_cbal = $cls_tbal = 0;
+$grp_pdeb = $grp_pcre = $grp_cdeb = $grp_ccre = $grp_tdeb = $grp_tcre = $grp_pbal = $grp_cbal = $grp_tbal = 0;
+
 //----------------------------------------------------------------------------------------------------
 // Ajax updates
 //
@@ -64,19 +64,19 @@ function gl_inquiry_controls()
 
 //----------------------------------------------------------------------------------------------------
 
-function display_trial_balance($type, $typename)\r
+function display_trial_balance($type, $typename)
 {
        global $path_to_root;
-       \r
-       global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;\r
-       $printtitle = 0; //Flag for printing type name          \r
+       
+       global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;
+       $printtitle = 0; //Flag for printing type name          
 
        $k = 0;
 
-       //$accounts = get_gl_accounts();\r
-       //Get Accounts directly under this group/type\r
-       $accounts = get_gl_accounts(null, null, $type);         \r
-       \r
+       //$accounts = get_gl_accounts();
+       //Get Accounts directly under this group/type
+       $accounts = get_gl_accounts(null, null, $type);         
+       
        $pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0;
        $begin = begin_fiscalyear();
        if (date1_greater_date2($begin, $_POST['TransFromDate']))
@@ -85,15 +85,15 @@ function display_trial_balance($type, $typename)
        
        while ($account = db_fetch($accounts))
        {
-               //Print Type Title if it has atleast one non-zero account       \r
-               if (!$printtitle)\r
-               {       \r
-                       start_row("class='inquirybg' style='font-weight:bold'");\r
-                       label_cell("Group - ".$type ." - ".$typename, "colspan=8");\r
-                       end_row();              \r
-                       $printtitle = 1;                \r
-               }       \r
-       \r
+               //Print Type Title if it has atleast one non-zero account       
+               if (!$printtitle)
+               {       
+                       start_row("class='inquirybg' style='font-weight:bold'");
+                       label_cell("Group - ".$type ." - ".$typename, "colspan=8");
+                       end_row();              
+                       $printtitle = 1;                
+               }       
+       
                $prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false);
                $curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true);
                $tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true);
@@ -133,76 +133,76 @@ function display_trial_balance($type, $typename)
                end_row();
        }
 
-       //Get Account groups/types under this group/type\r
-       $result = get_account_types(false, false, $type);\r
-       while ($accounttype=db_fetch($result))\r
-       {\r
-               //Print Type Title if has sub types and not previously printed\r
-               if (!$printtitle)\r
-               {\r
-                       start_row("class='inquirybg' style='font-weight:bold'");\r
-                       label_cell("Group - ".$type ." - ".$typename, "colspan=8");\r
-                       end_row();              \r
-                       $printtitle = 1;                \r
-               }\r
-               display_trial_balance($accounttype["id"], $accounttype["name"].' ('.$typename.')');\r
-       }\r
-}\r
-\r
-//----------------------------------------------------------------------------------------------------\r
-\r
-gl_inquiry_controls();\r
-\r
-if (isset($_POST['TransFromDate']))\r
-{\r
-       $row = get_current_fiscalyear();\r
-       if (date1_greater_date2($_POST['TransFromDate'], sql2date($row['end'])))\r
-       {\r
-               display_error(_("The from date cannot be bigger than the fiscal year end."));\r
-               set_focus('TransFromDate');\r
-               return;\r
-       }       \r
-}      \r
-div_start('balance_tbl');\r
-if (!isset($_POST['Dimension']))\r
-       $_POST['Dimension'] = 0;\r
-if (!isset($_POST['Dimension2']))\r
-       $_POST['Dimension2'] = 0;\r
-start_table(TABLESTYLE);\r
-$tableheader =  "<tr>\r
-       <td rowspan=2 class='tableheader'>" . _("Account") . "</td>\r
-       <td rowspan=2 class='tableheader'>" . _("Account Name") . "</td>\r
-       <td colspan=2 class='tableheader'>" . _("Brought Forward") . "</td>\r
-       <td colspan=2 class='tableheader'>" . _("This Period") . "</td>\r
-       <td colspan=2 class='tableheader'>" . _("Balance") . "</td>\r
-       </tr><tr>\r
-       <td class='tableheader'>" . _("Debit") . "</td>\r
-       <td class='tableheader'>" . _("Credit") . "</td>\r
-       <td class='tableheader'>" . _("Debit") . "</td>\r
-       <td class='tableheader'>" . _("Credit") . "</td>\r
-       <td class='tableheader'>" . _("Debit") . "</td>\r
-       <td class='tableheader'>" . _("Credit") . "</td>\r
-       </tr>";\r
-\r
-echo $tableheader;\r
-\r
-//display_trial_balance();\r
-\r
-$classresult = get_account_classes(false);\r
-while ($class = db_fetch($classresult))\r
-{\r
-       start_row("class='inquirybg' style='font-weight:bold'");\r
-       label_cell("Class - ".$class['cid'] ." - ".$class['class_name'], "colspan=8");\r
-       end_row();\r
-\r
-       //Get Account groups/types under this group/type with no parents\r
-       $typeresult = get_account_types(false, $class['cid'], -1);\r
-       while ($accounttype=db_fetch($typeresult))\r
-       {\r
-               display_trial_balance($accounttype["id"], $accounttype["name"]);\r
-       }\r
-}\r
-\r
+       //Get Account groups/types under this group/type
+       $result = get_account_types(false, false, $type);
+       while ($accounttype=db_fetch($result))
+       {
+               //Print Type Title if has sub types and not previously printed
+               if (!$printtitle)
+               {
+                       start_row("class='inquirybg' style='font-weight:bold'");
+                       label_cell("Group - ".$type ." - ".$typename, "colspan=8");
+                       end_row();              
+                       $printtitle = 1;                
+               }
+               display_trial_balance($accounttype["id"], $accounttype["name"].' ('.$typename.')');
+       }
+}
+
+//----------------------------------------------------------------------------------------------------
+
+gl_inquiry_controls();
+
+if (isset($_POST['TransFromDate']))
+{
+       $row = get_current_fiscalyear();
+       if (date1_greater_date2($_POST['TransFromDate'], sql2date($row['end'])))
+       {
+               display_error(_("The from date cannot be bigger than the fiscal year end."));
+               set_focus('TransFromDate');
+               return;
+       }       
+}      
+div_start('balance_tbl');
+if (!isset($_POST['Dimension']))
+       $_POST['Dimension'] = 0;
+if (!isset($_POST['Dimension2']))
+       $_POST['Dimension2'] = 0;
+start_table(TABLESTYLE);
+$tableheader =  "<tr>
+       <td rowspan=2 class='tableheader'>" . _("Account") . "</td>
+       <td rowspan=2 class='tableheader'>" . _("Account Name") . "</td>
+       <td colspan=2 class='tableheader'>" . _("Brought Forward") . "</td>
+       <td colspan=2 class='tableheader'>" . _("This Period") . "</td>
+       <td colspan=2 class='tableheader'>" . _("Balance") . "</td>
+       </tr><tr>
+       <td class='tableheader'>" . _("Debit") . "</td>
+       <td class='tableheader'>" . _("Credit") . "</td>
+       <td class='tableheader'>" . _("Debit") . "</td>
+       <td class='tableheader'>" . _("Credit") . "</td>
+       <td class='tableheader'>" . _("Debit") . "</td>
+       <td class='tableheader'>" . _("Credit") . "</td>
+       </tr>";
+
+echo $tableheader;
+
+//display_trial_balance();
+
+$classresult = get_account_classes(false);
+while ($class = db_fetch($classresult))
+{
+       start_row("class='inquirybg' style='font-weight:bold'");
+       label_cell("Class - ".$class['cid'] ." - ".$class['class_name'], "colspan=8");
+       end_row();
+
+       //Get Account groups/types under this group/type with no parents
+       $typeresult = get_account_types(false, $class['cid'], -1);
+       while ($accounttype=db_fetch($typeresult))
+       {
+               display_trial_balance($accounttype["id"], $accounttype["name"]);
+       }
+}
+
        //$prev = get_balance(null, $begin, $_POST['TransFromDate'], false, false);
        //$curr = get_balance(null, $_POST['TransFromDate'], $_POST['TransToDate'], true, true);
        //$tot = get_balance(null, $begin, $_POST['TransToDate'], false, true);
@@ -227,7 +227,7 @@ while ($class = db_fetch($classresult))
 
        end_table(1);
        if (($pbal = round2($pbal, user_price_dec()))  != 0)
-               //display_warning(_("The Opening Balance is not in balance, probably due to a non closed Previous Fiscalyear."));\r
+               //display_warning(_("The Opening Balance is not in balance, probably due to a non closed Previous Fiscalyear."));
        div_end();
 
 //----------------------------------------------------------------------------------------------------
index 11735980d452c48f8e829415ee158b109db00995..da79d08a4f6aa10483514aa900dda1f3bd14f5e5 100644 (file)
@@ -32,21 +32,21 @@ function getTaxTransactions($from, $to, $tax_id)
 {
        $fromdate = date2sql($from);
        $todate = date2sql($to);
-\r
+
        $sql = "SELECT d.debtor_no, d.name AS cust_name, d.tax_id, 
                CASE WHEN net_amount IS NULL OR amount=0 THEN 
                        SUM(CASE WHEN dt.type=".ST_CUSTCREDIT." THEN (ov_amount+ov_freight+ov_discount)*-1 
                        ELSE (ov_amount+ov_freight+ov_discount) END *dt.rate) ELSE 
                        SUM(CASE WHEN dt.type=".ST_CUSTCREDIT." THEN -net_amount ELSE net_amount END *ex_rate) END AS total,
-               SUM(CASE WHEN dt.type=".ST_CUSTCREDIT." THEN -amount ELSE amount END *ex_rate) AS tax\r
-               FROM ".TB_PREF."debtor_trans dt\r
-                       LEFT JOIN ".TB_PREF."debtors_master d ON d.debtor_no=dt.debtor_no\r
-                       LEFT JOIN ".TB_PREF."trans_tax_details t ON (t.trans_type=dt.type AND t.trans_no=dt.trans_no)\r
-               WHERE (dt.type=".ST_SALESINVOICE." OR dt.type=".ST_CUSTCREDIT.") ";\r
-       if ($tax_id)\r
-               $sql .= "AND tax_id<>'' ";\r
-       $sql .= "AND dt.tran_date >=".db_escape($fromdate)." AND dt.tran_date<=".db_escape($todate)."\r
-               GROUP BY d.debtor_no, d.name, d.tax_id ORDER BY d.name"; \r
+               SUM(CASE WHEN dt.type=".ST_CUSTCREDIT." THEN -amount ELSE amount END *ex_rate) AS tax
+               FROM ".TB_PREF."debtor_trans dt
+                       LEFT JOIN ".TB_PREF."debtors_master d ON d.debtor_no=dt.debtor_no
+                       LEFT JOIN ".TB_PREF."trans_tax_details t ON (t.trans_type=dt.type AND t.trans_no=dt.trans_no)
+               WHERE (dt.type=".ST_SALESINVOICE." OR dt.type=".ST_CUSTCREDIT.") ";
+       if ($tax_id)
+               $sql .= "AND tax_id<>'' ";
+       $sql .= "AND dt.tran_date >=".db_escape($fromdate)." AND dt.tran_date<=".db_escape($todate)."
+               GROUP BY d.debtor_no, d.name, d.tax_id ORDER BY d.name"; 
     return db_query($sql,"No transactions were returned");
 }
 
@@ -54,18 +54,18 @@ function getTaxTransactions($from, $to, $tax_id)
 
 function print_sales_summary_report()
 {
-       global $path_to_root;\r
+       global $path_to_root;
        
        $from = $_POST['PARAM_0'];
        $to = $_POST['PARAM_1'];
-       $tax_id = $_POST['PARAM_2'];\r
+       $tax_id = $_POST['PARAM_2'];
        $comments = $_POST['PARAM_3'];
        $destination = $_POST['PARAM_4'];
-       if ($tax_id == 0)\r
-               $tid = _('No');\r
-       else\r
-               $tid = _('Yes');\r
-\r
+       if ($tax_id == 0)
+               $tid = _('No');
+       else
+               $tid = _('Yes');
+
 
        if ($destination)
                include_once($path_to_root . "/reporting/includes/excel_report.inc");
@@ -80,10 +80,10 @@ function print_sales_summary_report()
                                                1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
                                                2 => array(  'text' => _('Tax Id Only'),'from' => $tid,'to' => ''));
 
-       $cols = array(0, 130, 180, 270, 350, 500);\r
+       $cols = array(0, 130, 180, 270, 350, 500);
 
-       $headers = array(_('Customer'), _('Tax Id'), _('Total ex. Tax'), _('Tax'));\r
-       $aligns = array('left', 'left', 'right', 'right');\r
+       $headers = array(_('Customer'), _('Tax Id'), _('Total ex. Tax'), _('Tax'));
+       $aligns = array('left', 'left', 'right', 'right');
        $rep->Font();
        $rep->Info($params, $cols, $headers, $aligns);
        $rep->NewPage();
@@ -91,9 +91,9 @@ function print_sales_summary_report()
        $totalnet = 0.0;
        $totaltax = 0.0;
        $transactions = getTaxTransactions($from, $to, $tax_id);
-\r
-       $rep->TextCol(0, 4, _("Values in domestic currency"));\r
-       $rep->NewLine(2);\r
+
+       $rep->TextCol(0, 4, _("Values in domestic currency"));
+       $rep->NewLine(2);
        
        while ($trans=db_fetch($transactions))
        {
@@ -101,9 +101,9 @@ function print_sales_summary_report()
                $rep->TextCol(1, 2,     $trans['tax_id']);
                $rep->AmountCol(2, 3,   $trans['total'], $dec);
                $rep->AmountCol(3, 4,   $trans['tax'], $dec);
-               $totalnet += $trans['total'];\r
-               $totaltax += $trans['tax'];\r
-\r
+               $totalnet += $trans['total'];
+               $totaltax += $trans['tax'];
+
                $rep->NewLine();
 
                if ($rep->row < $rep->bottomMargin + $rep->lineHeight)
@@ -112,16 +112,16 @@ function print_sales_summary_report()
                        $rep->NewPage();
                }
        }
-\r
-       $rep->Font('bold');\r
-       $rep->NewLine();\r
-       $rep->Line($rep->row + $rep->lineHeight);\r
-       $rep->TextCol(0, 2,     _("Total"));\r
-       $rep->AmountCol(2, 3, $totalnet, $dec);\r
-       $rep->AmountCol(3, 4, $totaltax, $dec);\r
-       $rep->Line($rep->row - 5);\r
-       $rep->Font();\r
-\r
+
+       $rep->Font('bold');
+       $rep->NewLine();
+       $rep->Line($rep->row + $rep->lineHeight);
+       $rep->TextCol(0, 2,     _("Total"));
+       $rep->AmountCol(2, 3, $totalnet, $dec);
+       $rep->AmountCol(3, 4, $totaltax, $dec);
+       $rep->Line($rep->row - 5);
+       $rep->Font();
+
        $rep->End();
 }
 
index 8a86114d75fcf8c9372944612ced55aa73e474fa..30e6aa05595ae67b6a58affc4482625bcae367da 100644 (file)
@@ -25,7 +25,7 @@ include_once($path_to_root . "/gl/includes/gl_db.inc");
 
 //----------------------------------------------------------------------------------------------------
 
-function display_type ($type, $typename, &$dec, &$rep, $showbalance, $level)\r
+function display_type ($type, $typename, &$dec, &$rep, $showbalance, $level)
 {
        $printtitle = 0; //Flag for printing type name  
        
@@ -36,15 +36,15 @@ function display_type ($type, $typename, &$dec, &$rep, $showbalance, $level)
                //Print Type Title if it has atleast one non-zero account       
                if (!$printtitle)
                {
-                       $prefix = '';\r
-                       for ($sp=1; $sp<=$level; $sp++)\r
-                       {\r
-                               $prefix .= '         ';\r
-                       }               \r
+                       $prefix = '';
+                       for ($sp=1; $sp<=$level; $sp++)
+                       {
+                               $prefix .= '         ';
+                       }               
                        $printtitle = 1;
                        $rep->row -= 4;
                        $rep->TextCol(0, 1, $type);
-                       $rep->TextCol(1, 4, $prefix.$typename);\r
+                       $rep->TextCol(1, 4, $prefix.$typename);
                        $rep->row -= 4;
                        $rep->Line($rep->row);
                        $rep->NewLine();                
@@ -57,7 +57,7 @@ function display_type ($type, $typename, &$dec, &$rep, $showbalance, $level)
                        $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
                }
                $rep->TextCol(0, 1,     $account['account_code']);
-               $rep->TextCol(1, 2,     $prefix.$account['account_name']);\r
+               $rep->TextCol(1, 2,     $prefix.$account['account_name']);
                $rep->TextCol(2, 3,     $account['account_code2']);
                if ($showbalance == 1)  
                        $rep->AmountCol(3, 4, $balance, $dec);
@@ -79,8 +79,8 @@ function display_type ($type, $typename, &$dec, &$rep, $showbalance, $level)
                        $rep->Line($rep->row);
                        $rep->NewLine();                
                }
-               $nextlevel = $level + 1;\r
-               display_type($accounttype["id"], $accounttype["name"].' ('.$typename.')', $dec, $rep, $showbalance, $nextlevel);\r
+               $nextlevel = $level + 1;
+               display_type($accounttype["id"], $accounttype["name"].' ('.$typename.')', $dec, $rep, $showbalance, $nextlevel);
        }
 }
 
@@ -131,7 +131,7 @@ function print_Chart_of_Accounts()
                $typeresult = get_account_types(false, $class['cid'], -1);
                while ($accounttype=db_fetch($typeresult))
                {
-                       display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $showbalance, 0);\r
+                       display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $showbalance, 0);
                }
                $rep->NewLine();
        }
index d08ef0b0900ae2f4b21a685335d83bfe4a065899..e57d0a9f7265860fa0908b758454aadc52ff6e9c 100644 (file)
@@ -24,105 +24,105 @@ include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/gl/includes/gl_db.inc");
 
-$pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0;\r
-\r
-//----------------------------------------------------------------------------------------------------\r
-\r
-function display_type ($type, $typename, &$dec, &$rep, $from, $to, $zero, $balances, $dimension, $dimension2)\r
-{\r
-       global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;\r
-       \r
-       $printtitle = 0; //Flag for printing type name  \r
-       \r
-       //Get Accounts directly under this group/type\r
-       $accounts = get_gl_accounts(null, null, $type); \r
-       \r
-       $begin = begin_fiscalyear();\r
-       if (date1_greater_date2($begin, $from))\r
-               $begin = $from;\r
-       $begin = add_days($begin, -1);\r
-       while ($account=db_fetch($accounts))\r
-       {\r
-               //Print Type Title if it has atleast one non-zero account       \r
-               if (!$printtitle)\r
-               {       \r
-                       $rep->row -= 4;\r
-                       $rep->TextCol(0, 8, _("Group")." - ".$type ." - ".$typename);   \r
-                       $printtitle = 1;\r
-                       $rep->row -= 4;\r
-                       $rep->Line($rep->row);\r
-                       $rep->NewLine();                        \r
-               }\r
-               \r
-               $prev = get_balance($account["account_code"], $dimension, $dimension2, $begin, $from, false, false);\r
-               $curr = get_balance($account["account_code"], $dimension, $dimension2, $from, $to, true, true);\r
-               $tot = get_balance($account["account_code"], $dimension, $dimension2, $begin, $to, false, true);\r
-\r
-               if ($zero == 0 && !$prev['balance'] && !$curr['balance'] && !$tot['balance'])\r
-                       continue;\r
-               $rep->TextCol(0, 1, $account['account_code']);\r
-               $rep->TextCol(1, 2,     $account['account_name']);\r
-               if ($balances != 0)\r
-               {\r
-                       if ($prev['balance'] >= 0.0)\r
-                               $rep->AmountCol(2, 3, $prev['balance'], $dec);\r
-                       else\r
-                               $rep->AmountCol(3, 4, abs($prev['balance']), $dec);\r
-                       if ($curr['balance'] >= 0.0)\r
-                               $rep->AmountCol(4, 5, $curr['balance'], $dec);\r
-                       else\r
-                               $rep->AmountCol(5, 6, abs($curr['balance']), $dec);\r
-                       if ($tot['balance'] >= 0.0)\r
-                               $rep->AmountCol(6, 7, $tot['balance'], $dec);\r
-                       else\r
-                               $rep->AmountCol(7, 8, abs($tot['balance']), $dec);\r
-               }\r
-               else\r
-               {\r
-                       $rep->AmountCol(2, 3, $prev['debit'], $dec);\r
-                       $rep->AmountCol(3, 4, $prev['credit'], $dec);\r
-                       $rep->AmountCol(4, 5, $curr['debit'], $dec);\r
-                       $rep->AmountCol(5, 6, $curr['credit'], $dec);\r
-                       $rep->AmountCol(6, 7, $tot['debit'], $dec);\r
-                       $rep->AmountCol(7, 8, $tot['credit'], $dec);\r
-                       $pdeb += $prev['debit'];\r
-                       $pcre += $prev['credit'];\r
-                       $cdeb += $curr['debit'];\r
-                       $ccre += $curr['credit'];\r
-                       $tdeb += $tot['debit'];\r
-                       $tcre += $tot['credit'];\r
-               }       \r
-\r
-               $pbal += $prev['balance'];\r
-               $cbal += $curr['balance'];\r
-               $tbal += $tot['balance'];\r
-               $rep->NewLine();\r
-\r
-               if ($rep->row < $rep->bottomMargin + $rep->lineHeight)\r
-               {\r
-                       $rep->Line($rep->row - 2);\r
-                       $rep->NewPage();\r
-               }\r
-       }\r
-               \r
-       //Get Account groups/types under this group/type\r
-       $result = get_account_types(false, false, $type);\r
-       while ($accounttype=db_fetch($result))\r
-       {\r
-               //Print Type Title if has sub types and not previously printed\r
-               if (!$printtitle)\r
-               {\r
-                       $rep->row -= 4;\r
-                       $rep->TextCol(0, 8, _("Group")." - ".$type ." - ".$typename);   \r
-                       $printtitle = 1;\r
-                       $rep->row -= 4;\r
-                       $rep->Line($rep->row);\r
-                       $rep->NewLine();                \r
-               }\r
-               display_type($accounttype["id"], $accounttype["name"].' ('.$typename.')', $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2);\r
-       }\r
-}\r
-\r
+$pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0;
+
+//----------------------------------------------------------------------------------------------------
+
+function display_type ($type, $typename, &$dec, &$rep, $from, $to, $zero, $balances, $dimension, $dimension2)
+{
+       global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;
+       
+       $printtitle = 0; //Flag for printing type name  
+       
+       //Get Accounts directly under this group/type
+       $accounts = get_gl_accounts(null, null, $type); 
+       
+       $begin = begin_fiscalyear();
+       if (date1_greater_date2($begin, $from))
+               $begin = $from;
+       $begin = add_days($begin, -1);
+       while ($account=db_fetch($accounts))
+       {
+               //Print Type Title if it has atleast one non-zero account       
+               if (!$printtitle)
+               {       
+                       $rep->row -= 4;
+                       $rep->TextCol(0, 8, _("Group")." - ".$type ." - ".$typename);   
+                       $printtitle = 1;
+                       $rep->row -= 4;
+                       $rep->Line($rep->row);
+                       $rep->NewLine();                        
+               }
+               
+               $prev = get_balance($account["account_code"], $dimension, $dimension2, $begin, $from, false, false);
+               $curr = get_balance($account["account_code"], $dimension, $dimension2, $from, $to, true, true);
+               $tot = get_balance($account["account_code"], $dimension, $dimension2, $begin, $to, false, true);
+
+               if ($zero == 0 && !$prev['balance'] && !$curr['balance'] && !$tot['balance'])
+                       continue;
+               $rep->TextCol(0, 1, $account['account_code']);
+               $rep->TextCol(1, 2,     $account['account_name']);
+               if ($balances != 0)
+               {
+                       if ($prev['balance'] >= 0.0)
+                               $rep->AmountCol(2, 3, $prev['balance'], $dec);
+                       else
+                               $rep->AmountCol(3, 4, abs($prev['balance']), $dec);
+                       if ($curr['balance'] >= 0.0)
+                               $rep->AmountCol(4, 5, $curr['balance'], $dec);
+                       else
+                               $rep->AmountCol(5, 6, abs($curr['balance']), $dec);
+                       if ($tot['balance'] >= 0.0)
+                               $rep->AmountCol(6, 7, $tot['balance'], $dec);
+                       else
+                               $rep->AmountCol(7, 8, abs($tot['balance']), $dec);
+               }
+               else
+               {
+                       $rep->AmountCol(2, 3, $prev['debit'], $dec);
+                       $rep->AmountCol(3, 4, $prev['credit'], $dec);
+                       $rep->AmountCol(4, 5, $curr['debit'], $dec);
+                       $rep->AmountCol(5, 6, $curr['credit'], $dec);
+                       $rep->AmountCol(6, 7, $tot['debit'], $dec);
+                       $rep->AmountCol(7, 8, $tot['credit'], $dec);
+                       $pdeb += $prev['debit'];
+                       $pcre += $prev['credit'];
+                       $cdeb += $curr['debit'];
+                       $ccre += $curr['credit'];
+                       $tdeb += $tot['debit'];
+                       $tcre += $tot['credit'];
+               }       
+
+               $pbal += $prev['balance'];
+               $cbal += $curr['balance'];
+               $tbal += $tot['balance'];
+               $rep->NewLine();
+
+               if ($rep->row < $rep->bottomMargin + $rep->lineHeight)
+               {
+                       $rep->Line($rep->row - 2);
+                       $rep->NewPage();
+               }
+       }
+               
+       //Get Account groups/types under this group/type
+       $result = get_account_types(false, false, $type);
+       while ($accounttype=db_fetch($result))
+       {
+               //Print Type Title if has sub types and not previously printed
+               if (!$printtitle)
+               {
+                       $rep->row -= 4;
+                       $rep->TextCol(0, 8, _("Group")." - ".$type ." - ".$typename);   
+                       $printtitle = 1;
+                       $rep->row -= 4;
+                       $rep->Line($rep->row);
+                       $rep->NewLine();                
+               }
+               display_type($accounttype["id"], $accounttype["name"].' ('.$typename.')', $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2);
+       }
+}
+
 //----------------------------------------------------------------------------------------------------
 
 print_trial_balance();
@@ -132,7 +132,7 @@ print_trial_balance();
 function print_trial_balance()
 {
        global $path_to_root;
-       global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;\r
+       global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;
 
        $dim = get_company_pref('use_dimension');
        $dimension = $dimension2 = 0;
@@ -172,8 +172,8 @@ function print_trial_balance()
 
        $aligns2 = array('left', 'left', 'left', 'left', 'left');
 
-       $cols = array(0, 50, 150, 210, 270,     330, 390, 450, 510,     570);\r
-       //------------0--1---2----3----4----5----6----7----8--\r
+       $cols = array(0, 50, 150, 210, 270,     330, 390, 450, 510,     570);
+       //------------0--1---2----3----4----5----6----7----8--
 
        $headers = array(_('Account'), _('Account Name'), _('Debit'), _('Credit'), _('Debit'),
                _('Credit'), _('Debit'), _('Credit'));
@@ -207,21 +207,21 @@ function print_trial_balance()
        $rep->Font();
        $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
        $rep->NewPage();
-       \r
-       $classresult = get_account_classes(false);\r
-       while ($class = db_fetch($classresult))\r
+       
+       $classresult = get_account_classes(false);
+       while ($class = db_fetch($classresult))
        {
-               $rep->Font('bold');\r
-               $rep->TextCol(0, 1, $class['cid']);\r
-               $rep->TextCol(1, 4, $class['class_name']);\r
-               $rep->Font();\r
-               $rep->NewLine();\r
+               $rep->Font('bold');
+               $rep->TextCol(0, 1, $class['cid']);
+               $rep->TextCol(1, 4, $class['class_name']);
+               $rep->Font();
+               $rep->NewLine();
 
-               //Get Account groups/types under this group/type with no parents\r
-               $typeresult = get_account_types(false, $class['cid'], -1);\r
-               while ($accounttype=db_fetch($typeresult))\r
+               //Get Account groups/types under this group/type with no parents
+               $typeresult = get_account_types(false, $class['cid'], -1);
+               while ($accounttype=db_fetch($typeresult))
                {
-                       display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $from, $to,  $zero, $balances, $dimension, $dimension2);\r
+                       display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $from, $to,  $zero, $balances, $dimension, $dimension2);
                }
                $rep->NewLine();
        }
index 7c09e308041ef50459a724b51ae2b80a350adad9..dbe25e5bd59e82f1472f06b0c566ee4e9f055baf 100644 (file)
@@ -33,13 +33,13 @@ function getTaxTransactions($from, $to)
        $fromdate = date2sql($from);
        $todate = date2sql($to);
 
-       $sql = "SELECT tt.name as taxname, taxrec.*, taxrec.amount*ex_rate AS amount,\r
+       $sql = "SELECT tt.name as taxname, taxrec.*, taxrec.amount*ex_rate AS amount,
                    taxrec.net_amount*ex_rate AS net_amount,
                                IF(ISNULL(supp.supp_name), debt.name, supp.supp_name) as name,
                                branch.br_name
                FROM ".TB_PREF."trans_tax_details taxrec
-               LEFT JOIN ".TB_PREF."tax_types tt\r
-                       ON taxrec.tax_type_id=tt.id\r
+               LEFT JOIN ".TB_PREF."tax_types tt
+                       ON taxrec.tax_type_id=tt.id
                LEFT JOIN ".TB_PREF."supp_trans strans
                        ON taxrec.trans_no=strans.trans_no AND taxrec.trans_type=strans.type
                LEFT JOIN ".TB_PREF."suppliers as supp ON strans.supplier_id=supp.supplier_id
@@ -51,7 +51,7 @@ function getTaxTransactions($from, $to)
                        AND taxrec.trans_type <> ".ST_CUSTDELIVERY."
                        AND taxrec.tran_date >= '$fromdate'
                        AND taxrec.tran_date <= '$todate'
-               ORDER BY taxrec.trans_type, taxrec.tran_date, taxrec.trans_no, taxrec.ex_rate";\r
+               ORDER BY taxrec.trans_type, taxrec.tran_date, taxrec.trans_no, taxrec.ex_rate";
 //display_error($sql);
     return db_query($sql,"No transactions were returned");
 }
@@ -73,7 +73,7 @@ function getTaxInfo($id)
 
 function print_tax_report()
 {
-       global $path_to_root, $trans_dir, $Hooks, $systypes_array;\r
+       global $path_to_root, $trans_dir, $Hooks, $systypes_array;
        
        $from = $_POST['PARAM_0'];
        $to = $_POST['PARAM_1'];
@@ -104,11 +104,11 @@ function print_tax_report()
                                                1 => array('text' => _('Period'), 'from' => $from, 'to' => $to),
                                                2 => array('text' => _('Type'), 'from' => $summary, 'to' => ''));
 
-       $cols = array(0, 80, 130, 180, 270, 350, 400, 430, 480, 485, 520);\r
+       $cols = array(0, 80, 130, 180, 270, 350, 400, 430, 480, 485, 520);
 
        $headers = array(_('Trans Type'), _('Ref'), _('Date'), _('Name'), _('Branch Name'),
-               _('Net'), _('Rate'), _('Tax'), '', _('Name'));\r
-       $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right','left');\r
+               _('Net'), _('Rate'), _('Tax'), '', _('Name'));
+       $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right','left');
        $rep->Font();
        $rep->Info($params, $cols, $headers, $aligns);
        if (!$summaryOnly)
@@ -140,8 +140,8 @@ function print_tax_report()
                        $rep->AmountCol(5, 6, $trans['net_amount'], $dec);
                        $rep->AmountCol(6, 7, $trans['rate'], $dec);
                        $rep->AmountCol(7, 8, $trans['amount'], $dec);
-                       \r
-                       $rep->TextCol(9, 10, $trans['taxname']);\r
+                       
+                       $rep->TextCol(9, 10, $trans['taxname']);
 
                        $rep->NewLine();
 
index f8afbc7683ebcbedada5bbfa4d31e4d3dcea7054..db8f928a1663293d1ee9d96db153743a1f2a246f 100644 (file)
@@ -561,10 +561,10 @@ function get_sql_for_sales_orders_view($selected_customer, $trans_type, $trans_n
 
                elseif ($filter=='InvoiceTemplates' || $filter=='DeliveryTemplates')
                        $sql .= " AND sorder.type=1";
-                       \r
-               //Chaiatanya : New Filter\r
-               if ($customer_id != ALL_TEXT)\r
-                       $sql .= " AND sorder.debtor_no = ".db_escape($customer_id);             \r
+                       
+               //Chaiatanya : New Filter
+               if ($customer_id != ALL_TEXT)
+                       $sql .= " AND sorder.debtor_no = ".db_escape($customer_id);             
 
                $sql .= " GROUP BY sorder.order_no,
                                        sorder.debtor_no,