Cleanup comments. Small bugfixes. First run.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 5 Nov 2015 17:40:56 +0000 (18:40 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 5 Nov 2015 17:40:56 +0000 (18:40 +0100)
27 files changed:
access/login.php
access/password_reset.php
admin/attachments.php
admin/create_coy.php
admin/db/maintenance_db.inc
admin/db/users_db.inc
admin/includes/fa_patch.class.inc
admin/inst_chart.php
admin/inst_theme.php
admin/inst_upgrade.php
admin/print_profiles.php
admin/security_roles.php
admin/void_transaction.php
applications/application.php
dimensions/inquiry/search_dimensions.php
gl/includes/db/gl_db_bank_trans.inc
gl/includes/db/gl_db_banking.inc
gl/includes/db/gl_db_rates.inc
gl/includes/db/gl_db_trans.inc
gl/includes/db/gl_journal.inc
gl/includes/ui/gl_bank_ui.inc
gl/includes/ui/gl_journal_ui.inc
gl/inquiry/balance_sheet.php
gl/inquiry/gl_account_inquiry.php
gl/inquiry/gl_trial_balance.php
gl/inquiry/profit_loss.php
gl/inquiry/tax_inquiry.php

index 593f499279934942c9f9f524ff3651e92610fff4..fa91f35252fb730667c92b82e6e96cc1867afeca 100644 (file)
@@ -29,9 +29,9 @@ function defaultCompany()
        else
        {
                $demo_text = _("Please login here");
-    if (@$SysPrefs->allow_password_reset) {
-      $demo_text .= " "._("or")." <a href='$path_to_root/index.php?reset=1'>"._("request new password")."</a>";
-    }
+       if (@$SysPrefs->allow_password_reset) {
+               $demo_text .= " "._("or")." <a href='$path_to_root/index.php?reset=1'>"._("request new password")."</a>";
+       }
        }
 
        if (check_faillog())
@@ -109,7 +109,6 @@ function defaultCompany()
                        echo "</select>\n";
                        echo "</td></tr>";
                } else {
-//                     $coy = $def_coy;
                        text_row(_("Company"), "company_login_nickname", "", 20, 50);
                }
                start_row();
index bdea9136b89b6911fca2ae11d5823a6850a74fde..e9af83f7f8f8239b817ec684df1e1ba0d8abcfd4 100644 (file)
@@ -62,22 +62,21 @@ function defaultCompany()
 
        text_row(_("Email"), "email_entry_field", "", 20, 30);
 
-  $coy =  user_company();
-  if (!isset($coy))
-    $coy = $def_coy;
-  if (!@$SysPrefs->text_company_selection) {
-    echo "<tr><td>"._("Company")."</td><td><select name='company_login_name'>\n";
-    for ($i = 0; $i < count($db_connections); $i++)
-      echo "<option value=$i ".($i==$coy ? 'selected':'') .">" . $db_connections[$i]["name"] . "</option>";
-    echo "</select>\n";
-    echo "</td></tr>";
-  } else {
-//                     $coy = $def_coy;
-    text_row(_("Company"), "company_login_nickname", "", 20, 50);
-  }
-  start_row();
-  label_cell("Please enter your e-mail", "colspan=2 align='center' id='log_msg'");
-  end_row();
+    $coy =  user_company();
+    if (!isset($coy))
+        $coy = $def_coy;
+    if (!@$SysPrefs->text_company_selection) {
+        echo "<tr><td>"._("Company")."</td><td><select name='company_login_name'>\n";
+        for ($i = 0; $i < count($db_connections); $i++)
+            echo "<option value=$i ".($i==$coy ? 'selected':'') .">" . $db_connections[$i]["name"] . "</option>";
+        echo "</select>\n";
+        echo "</td></tr>";
+    } else {
+        text_row(_("Company"), "company_login_nickname", "", 20, 50);
+    }
+    start_row();
+    label_cell("Please enter your e-mail", "colspan=2 align='center' id='log_msg'");
+    end_row();
        end_table(1);
        echo "<center><input type='submit' value='&nbsp;&nbsp;"._("Send password -->")."&nbsp;&nbsp;' name='SubmitReset'
                 onclick='set_fullmode();'></center>\n";
index bd567bf23684dfee55970b98789a274138135d92..f600e3017fd5c39bde3556814785a8b226e39a92 100644 (file)
@@ -36,10 +36,7 @@ if ($view_id != -1)
                        $type = ($row['filetype']) ? $row['filetype'] : 'application/octet-stream';     
                header("Content-type: ".$type);
                header('Content-Length: '.$row['filesize']);
-               //if ($type == 'application/octet-stream')
-               //      header('Content-Disposition: attachment; filename='.$row['filename']);
-               //else
-                               header("Content-Disposition: inline");
+                       header("Content-Disposition: inline");
                echo file_get_contents(company_path(). "/attachments/".$row['unique_name']);
                exit();
                }
@@ -87,11 +84,11 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
        elseif ($Mode == 'ADD_ITEM' && !isset($_FILES['filename']))
                display_error(_("Select attachment file."));
        elseif ($Mode == 'ADD_ITEM' && ($_FILES['filename']['error'] > 0)) {
-    if ($_FILES['filename']['error'] == UPLOAD_ERR_INI_SIZE) 
-                 display_error(_("The file size is over the maximum allowed."));
-    else
-                 display_error(_("Select attachment file."));
-  }
+       if ($_FILES['filename']['error'] == UPLOAD_ERR_INI_SIZE) 
+                       display_error(_("The file size is over the maximum allowed."));
+       else
+                       display_error(_("Select attachment file."));
+       }
        else {
                //$content = base64_encode(file_get_contents($_FILES['filename']['tmp_name']));
                $tmpname = $_FILES['filename']['tmp_name'];
index 588c727b8e5d40d5f54a251c5f3dc5a04931c483..56b4fe215a48cd93c26bebaa41f11af09b254599 100644 (file)
@@ -199,7 +199,7 @@ function handle_delete($id)
        }
        $err = remove_connection($id);
        if ($err == 0)
-               display_error(_("Error removing Database: ") . $dbase . _(", please remove it manually"));
+               display_error(_("Error removing Database: ") . $id . _(", please remove it manually"));
 
        if ($def_coy == $id)
                $def_coy = 0;
index 5c81bcc694e9af867a125ee33b20eb5f4d07e506..f621c2c2e6c5aee8df2a5a0c04e61406ed498cdd 100644 (file)
@@ -71,7 +71,6 @@ function write_config_db($new = false)
 
        if ($new)
                $tb_pref_counter++;
-       $n = count($db_connections);
        $msg = "<?php\n\n";
        $msg .= "/*Connection Information for the database\n";
        $msg .= "\$def_coy - the default company that is pre-selected on login\n\n";
@@ -209,7 +208,6 @@ function write_lang()
        global $path_to_root, $installed_languages, $dflt_lang;
 
        $installed_languages = array_natsort($installed_languages, 'code', 'code');
-       $n = count($installed_languages);
        $msg = "<?php\n\n";
 
        $msg .= "/* How to make new entries here for non-packaged languages:\n\n";
@@ -599,8 +597,6 @@ function db_export($conn, $filename, $zip='no', $comment='')
                $out.="\n";
        }
 
-    //$out.="use ".$db.";\n"; we don't use this option.
-
        if (db_fixed())
        {
                db_set_encoding();
@@ -658,9 +654,6 @@ function db_export($conn, $filename, $zip='no', $comment='')
                        $out.="DROP TABLE IF EXISTS `".$tablename."`;\n\n";
                        $out.=$table_sql[$tablename];
 
-                       // add auto_increment value
-//                     if ($auto_incr[$tablename])
-//                             $out.=" AUTO_INCREMENT=".$auto_incr[$tablename];
                        $out.=" ;";
                        $out.="\n\n";
 
@@ -752,8 +745,6 @@ function db_export($conn, $filename, $zip='no', $comment='')
                return false;
        }
 
-       //if ($zip == "zip")
-       //      $zip = $time;
        if (save_to_file($backupfile, $zip, $out))
        {
                $out = "";
index 55b31d747714c506cc11f475a5c752f32a980908..52b02411ffde046fb3a9f38b0e3ef83c97163d66 100644 (file)
@@ -122,23 +122,6 @@ function delete_user($id)
        db_query($sql, "could not delete user $id");
 }
 
-//-----------------------------------------------------------------------------------------------
-//
-//     Obsolete, to be removed in 2.4. This function as been spleet into get_user_auth/get_user_by_login
-//     in FA 2.3.6
-//
-function get_user_for_login($user_id, $password)
-{
-       set_global_connection();
-
-// do not exclude inactive records or you lost access after source upgrade
-// on sites using pre 2.2 database
-       $sql = "SELECT * FROM ".TB_PREF."users WHERE user_id = ".db_escape($user_id)." AND"
-               ." password=".db_escape($password);
-
-       return db_query($sql, "could not get validate user login for $user_id");
-}
-
 //-----------------------------------------------------------------------------------------------
 
 function get_user_auth($user_id, $password)
index 1275898d08b4f76a9b4bc1955969ff58ade3115a..99aa0824265aac70f7ca087dd4990513deb633b9 100644 (file)
@@ -163,7 +163,7 @@ class fa_patch {
                                if ($result)
                                        $this->log_error(_("Upgrade failed. Original database content restored successfully."), 'Info');
                                else
-                                       $thi->log_error(sprintf(_("Database restore operation failed. Original database content is in %s file."), $this->backup));
+                                       $this->log_error(sprintf(_("Database restore operation failed. Original database content is in %s file."), $this->backup));
                                $this->post_fail($this->cur_company);
                        }
                } else {
index 0bdfcb7466e57dc21b688c34bd1a86b6df26a071..05165fbf5c5c97fcaec168d0a731b559a7e7d13a 100644 (file)
@@ -66,7 +66,6 @@ start_form(true);
 
                        alt_table_row_color($k);
 
-//             label_cell(is_array($ext['Descr']) ? $ext['Descr'][0] : $ext['Descr']);
                        label_cell($available ? get_package_view_str($pkg_name, $ext['name']) : $ext['name']);
 
                        label_cell($id === null ? _("None") :
index a2f260064f105d043c93669493deae743c4ba297..7c15dd53297c3a881d960165d50cc88c6d5bbe67 100644 (file)
@@ -71,7 +71,6 @@ start_form(true);
 
                        alt_table_row_color($k);
 
-//             label_cell(is_array($ext['Descr']) ? $ext['Descr'][0] : $ext['Descr']);
                        label_cell($available ? get_package_view_str($pkg_name, $ext['name']) : $ext['name']);
 
                        label_cell($id === null ? _("None") :
index 5fc66fc810378507edcc72488c4b74e01670a546..2fb9ac07e692294de6fe5d3109812dfa0d3ca21a 100644 (file)
@@ -63,6 +63,7 @@ start_form();
 $th = array(_("Company"), _("Table set"), _("Current version"), _("Last log"), _('Upgrade'));
 start_table(TABLESTYLE);
 table_header($th);
+$k = 0; //row colour counter
 
 $uptodate = true;
 foreach($site_status as $i => $comp)
index bf3d698f7cc0f0c7911dea339e53b7b4f0b71431..534c5168cf19ed88bccaf6c55ba4e2161166ce9b 100644 (file)
@@ -25,39 +25,38 @@ $selected_id = get_post('profile_id','');
 function get_reports() {
        global $path_to_root, $SysPrefs;
 
-if ($SysPrefs->go_debug || !isset($_SESSION['reports'])) {     
+       if ($SysPrefs->go_debug || !isset($_SESSION['reports'])) {      
        // to save time, store in session.
                $paths = array (
                        $path_to_root.'/reporting/',
                        company_path(). '/reporting/');
                $reports = array( '' => _('Default printing destination'));
 
-       foreach($paths as $dirno => $path) {
-               $repdir = opendir($path);
-               while(false !== ($fname = readdir($repdir)))
-               {
-               // reports have filenames in form rep(repid).php 
-               // where repid must contain at least one digit (reports_main.php is not ;)
-                       if (is_file($path.$fname) 
-//                             && preg_match('/.*[^0-9]([0-9]+)[.]php/', $fname, $match))
-                               && preg_match('/rep(.*[0-9]+.*)[.]php/', $fname, $match))
+               foreach($paths as $dirno => $path) {
+                       $repdir = opendir($path);
+                       while(false !== ($fname = readdir($repdir)))
                        {
-                               $repno = $match[1];
-                               $title = '';
-
-                               $line = file_get_contents($path.$fname);
-                               if (preg_match('/.*(FrontReport\()\s*_\([\'"]([^\'"]*)/', $line, $match)) {
-                                       $title = trim($match[2]);
-                               }
-                               else // for any 3rd party printouts without FrontReport() class use
+                               // reports have filenames in form rep(repid).php 
+                               // where repid must contain at least one digit (reports_main.php is not ;)
+                               if (is_file($path.$fname) 
+                                       && preg_match('/rep(.*[0-9]+.*)[.]php/', $fname, $match))
+                               {
+                                       $repno = $match[1];
+                                       $title = '';
+
+                                       $line = file_get_contents($path.$fname);
+                                       if (preg_match('/.*(FrontReport\()\s*_\([\'"]([^\'"]*)/', $line, $match)) {
+                                               $title = trim($match[2]);
+                                       }
+                                       else // for any 3rd party printouts without FrontReport() class use
                                        if (preg_match('/.*(\$Title).*[\'"](.*)[\'"].+/', $line, $match)) {
                                                $title = trim($match[2]);
                                        }
-                               $reports[$repno] = $title;
+                                       $reports[$repno] = $title;
+                               }
                        }
+                       closedir();
                }
-       closedir();
-       }
                ksort($reports);
                $_SESSION['reports'] = $reports;
        }
@@ -75,7 +74,7 @@ function clear_form()
 
 function check_delete($name)
 {
-// check if selected profile is used by any user
+       // check if selected profile is used by any user
        if ($name=='') return 0; // cannot delete system default profile
        return key_in_foreign_table($name, 'users', 'print_profile');
 }
@@ -100,7 +99,7 @@ if ( get_post('submit'))
                        $prof[$rep] = $val;
                }
                if ($_POST['profile_id']=='')
-               $_POST['profile_id'] = get_post('name');
+                       $_POST['profile_id'] = get_post('name');
                
                update_printer_profile($_POST['profile_id'], $prof);
                if ($selected_id == '') {
@@ -114,11 +113,11 @@ if ( get_post('submit'))
 
 if(get_post('delete'))
 {
- if (!check_delete(get_post('name'))) {
-       delete_printer_profile($selected_id);
-       display_notification(_('Selected printing profile has been deleted'));
-       clear_form();
- }
      if (!check_delete(get_post('name'))) {
+               delete_printer_profile($selected_id);
+               display_notification(_('Selected printing profile has been deleted'));
+               clear_form();
      }
 }
 
 if(get_post('_profile_id_update')) {
index 885acd774429cc856b8584d1675d109ceee552c2..4b438091f237794d6cfce657ea247aed74b7f2a1 100644 (file)
@@ -147,9 +147,6 @@ if (!isset($_POST['role']) || get_post('clone') || list_updated('role')) {
                $row = get_security_role($id);
                $_POST['description'] = $row['description'];
                $_POST['name'] = $row['role'];
-//     if ($row['inactive']
-//             $_POST['inactive'] = 1;
-       
                $_POST['inactive'] = $row['inactive'];
                $access = $row['areas'];
                $sections = $row['sections'];
@@ -214,8 +211,6 @@ end_table(1);
                        $ext = $newext; 
                        $sec = $newsec;
                        $m = $parms[0] & ~0xff;
-//                     if(!isset($security_sections[$m]))
-//                      display_error(sprintf("Bad section %X:", $m));
                        label_row($security_sections[$m].':', 
                                checkbox( null, 'Section'.$m, null, true, 
                                        _("On/off set of features")),
index 41ff2f77cbb7386503975fb4ae40fe33f5add323..13f1e439df8f7b7b2712dd007f61846a1fef6310 100644 (file)
@@ -104,7 +104,6 @@ function exist_transaction($type, $type_no)
                        return false;
                case ST_COSTUPDATE : // it's a stock cost update
                        return false;
-                       break;
        }
 
        return true;
@@ -241,7 +240,7 @@ function check_valid_entries()
        {
                display_error(_("The selected transaction was closed for edition and cannot be voided."));
                set_focus('trans_no');
-               return;
+               return false;
        }
        if (!is_date($_POST['date_']))
        {
index 4399695215fed7e16bc0aeb6ef014dd588ec2c27..81bf2e10ee262e6beb59a465c2a4d16b1dfa8869 100644 (file)
@@ -19,7 +19,7 @@ define('MENU_UPDATE', 'menu_update');
 define('MENU_SETTINGS', 'menu_settings');
 define('MENU_SYSTEM', 'menu_system');
 
-        class menu_item
+    class menu_item
        {
                var $label;
                var $link;
@@ -56,7 +56,7 @@ define('MENU_SYSTEM', 'menu_system');
                var $label;
                var $link;
                var $access;
-                var $category;
+        var $category;
                
                function app_function($label,$link,$access='SA_OPEN',$category='')
                {
@@ -85,7 +85,6 @@ define('MENU_SYSTEM', 'menu_system');
                function add_lapp_function($label,$link="",$access='SA_OPEN',$category='')
                {
                        $appfunction = new app_function($label,$link,$access,$category);
-                       //array_push($this->lappfunctions,$appfunction);
                        $this->lappfunctions[] = $appfunction;
                        return $appfunction;
                }
@@ -93,7 +92,6 @@ define('MENU_SYSTEM', 'menu_system');
                function add_rapp_function($label,$link="",$access='SA_OPEN',$category='')
                {
                        $appfunction = new app_function($label,$link,$access,$category);
-                       //array_push($this->rappfunctions,$appfunction);
                        $this->rappfunctions[] = $appfunction;
                        return $appfunction;
                }
@@ -120,7 +118,6 @@ define('MENU_SYSTEM', 'menu_system');
                function add_module($name, $icon = null) 
                {
                        $module = new module($name,$icon);
-                       //array_push($this->modules,$module);
                        $this->modules[] = $module;
                        return $module;
                }
@@ -144,15 +141,7 @@ define('MENU_SYSTEM', 'menu_system');
                //
                function report_class_url($class)
                {
-                       global $installed_extensions;
-
-                       // TODO : konwencja lub ?
-                       $classno = 7;
-//                     if (file_exists($path_to_root.'/'.$mod['path'].'/'.$entry['url']
-//                                     .'/'.'reporting/reports_custom.php'))
-                               return "reporting/reports_main.php?Class=".$class;
-//                     else
-//                             return '';
+                       return "reporting/reports_main.php?Class=".$class;
                }
        }
 
index 2d7c8541a9ced0c1645de5ce6cdebb61bdb86871..6d23976fb9cb008a7f4c0de8dd0b99d399aca266 100644 (file)
@@ -50,7 +50,6 @@ if (get_post('SearchOrders'))
        $Ajax->addDisable(true, 'OpenOnly', $disable);
 
        if ($disable) {
-//             $Ajax->addFocus(true, 'OrderNumber');
                set_focus('OrderNumber');
        } else
                set_focus('type_');
@@ -114,9 +113,6 @@ function is_overdue($row)
 
 function edit_link($row)
 {
-       //return $row["closed"] ?  '' :
-       //      pager_link(_("Edit"),
-       //              "/dimensions/dimension_entry.php?trans_no=" . $row["id"], ICON_EDIT);
        return pager_link(_("Edit"),
                        "/dimensions/dimension_entry.php?trans_no=" . $row["id"], ICON_EDIT);
 }
index e0dbdf287f21ac8f374e6afc9b3c8024cf86e7f8..be1551f57d87f7bae4f832fc25e188b8b5b47a3f 100644 (file)
@@ -34,9 +34,6 @@ function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_,
                $amount_bank = $amount;
        $amount_bank = round2($amount_bank, user_price_dec());  
 
-       // Also store the rate to the home
-       //$BankToHomeCurrencyRate = get_exchange_rate_to_home_currency($bank_account_currency, $date_);
-
        $sql = "INSERT INTO ".TB_PREF."bank_trans (type, trans_no, bank_act, ref,
                trans_date, amount, person_type_id, person_id) ";
 
@@ -152,7 +149,7 @@ function void_bank_trans($type, $type_no, $nested=false)
                        SET amount=0
                        WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no);
 
-       $result = db_query($sql, "could not void bank transactions for type=$type and trans_no=$type_no");
+       db_query($sql, "could not void bank transactions for type=$type and trans_no=$type_no");
 
        void_gl_trans($type, $type_no, true);
 
index 91a1e97b8272d3672105f914e810e90c523c18a3..e071b9ac8f6c27906b29301f26b5c824f6aab884 100644 (file)
@@ -20,11 +20,10 @@ function add_exchange_variation($trans_no, $date_, $acc_id, $account,
 
        // We have to calculate all the currency accounts belonging to the GL account
        // upto $date_ and calculate with the exchange rates. And then compare with the GL account balance.
-       // 2010-02-23 Joe Hunt with help of Ary Wibowo
-       $sql = "SELECT SUM(bt.amount) AS for_amount, ba.bank_curr_code
+       $sql = "SELECT SUM(bt.amount) AS for_amount, ba.bank_curr_code          
                FROM ".TB_PREF."bank_trans bt, ".TB_PREF."bank_accounts ba
                WHERE ba.id = bt.bank_act AND ba.account_code = ".db_escape($account)." AND bt.trans_date<='".date2sql($date_)."'
-               GROUP BY ba.bank_curr_code";
+               GROUP BY ba.bank_curr_code";    
        $result = db_query($sql, "Transactions for bank account $acc_id could not be calculated");
        while ($row = db_fetch($result))
        {
@@ -44,19 +43,15 @@ function add_exchange_variation($trans_no, $date_, $acc_id, $account,
                $trans_no = get_next_trans_no(ST_JOURNAL);
                $ref = $Refs->get_next(ST_JOURNAL);
 
-               add_journal(ST_JOURNAL, $trans_no, $diff, $date_ , $currency, $ref, '', $rate, $date_, $date_);
+               add_journal(ST_JOURNAL, $trans_no, $diff, $date_ , get_company_currency(), $ref, '', 1, $date_, $date_);
                $Refs->save(ST_JOURNAL, $trans_no, $ref);
                add_audit_trail(ST_JOURNAL, $trans_no, $date_);
-               add_comments(ST_JOURNAL, $trans_no, $date_, $memo);
 
                if ($person_type_id == null)
                        $person_type_id = PT_MISC;
                add_gl_trans(ST_JOURNAL, $trans_no, $date_, $account, 0, 0, _("Exchange Variance"),
                $diff, null, $person_type_id, $person_id);
 
-               // positive change in value is positive variance for AR and bank accounts, and negative for AP
-       $variance_act = ($diff < 0 && $person_id==PT_SUPPLIER) || ($diff > 0 && $person_id != PT_SUPPLIER)
-                ? 'exchange_diff_act' : 'exchange_diff_neg_act';
        add_gl_trans(ST_JOURNAL, $trans_no, $date_, get_company_pref('exchange_diff_act'), 0, 0, 
                _("Exchange Variance"), -$diff, null, $person_type_id, $person_id);
                commit_transaction();
@@ -65,7 +60,6 @@ function add_exchange_variation($trans_no, $date_, $acc_id, $account,
        return false;
 }
 
-//------------- New helper functions for revaluation of customer/supplier currencies 2011-05-08 Joe Hunt.
 function add_cust_supp_revaluation($ledger_act, $ex_act, $date, $amount, $person_type_id, $person_id, $memo)
 {
        global $Refs;
@@ -76,7 +70,7 @@ function add_cust_supp_revaluation($ledger_act, $ex_act, $date, $amount, $person
        $trans_no = get_next_trans_no(ST_JOURNAL);
        $ref = $Refs->get_next(ST_JOURNAL);
 
-       add_journal(ST_JOURNAL, $trans_no, $amount, $date, $currency, $ref, '', $rate, $date, $date);
+       add_journal(ST_JOURNAL, $trans_no, $amount, $date, get_company_currency(), $ref, '', 1, $date, $date);
        $Refs->save(ST_JOURNAL, $trans_no, $ref);
        add_audit_trail(ST_JOURNAL, $trans_no, $date);
 
@@ -309,9 +303,6 @@ function check_bank_transfer(
     $amount, $target_amount=0)
 {
        $dbResult = get_bank_trans(ST_BANKTRANSFER, $trans_no);
-       if (2 != db_num_rows($dbResult)) {
-               // How are errors handled? Throw an exception would be nice. CP 2014-10
-       }
 
        $old_from = db_fetch($dbResult);
        $old_to = db_fetch($dbResult);
index 0980cb363e6db29f43a6aa261dfac97d6a28fd50..b1d58da8d12adddc976022cee579260830631860 100644 (file)
@@ -62,12 +62,12 @@ function update_exchange_rate($curr_code, $date_, $buy_rate, $sell_rate)
 {
        if (is_company_currency($curr_code))
                display_db_error("Exchange rates cannot be set for company currency", "", true);
-
+                       
        $date = date2sql($date_);
-
+               
        $sql = "UPDATE ".TB_PREF."exchange_rates SET rate_buy=$buy_rate, rate_sell=".db_escape($sell_rate)
        ." WHERE curr_code=".db_escape($curr_code)." AND date_='$date'";
-
+                               
        db_query($sql, "could not add exchange rate for $curr_code");
 }
 
@@ -79,7 +79,7 @@ function add_exchange_rate($curr_code, $date_, $buy_rate, $sell_rate)
                display_db_error("Exchange rates cannot be set for company currency", "", true);
 
        $date = date2sql($date_);
-
+               
        $sql = "INSERT INTO ".TB_PREF."exchange_rates (curr_code, date_, rate_buy, rate_sell)
                VALUES (".db_escape($curr_code).", '$date', ".db_escape($buy_rate)
                .", ".db_escape($sell_rate).")";
@@ -143,8 +143,6 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
        {
                $filename = "/d/quotes.csv?s={$curr_a}{$curr_b}=X&f=sl1d1t1ba&e=.csv"; // new URL's for YAHOO
                $site = "download.finance.yahoo.com";
-        //$filename = "/q?s={$curr_a}{$curr_b}=X"; // Let old code be here for a while, Joe.
-               //$site = "finance.yahoo.com";
        }
        elseif ($provider == 'GOOGLE')
        {
@@ -161,21 +159,21 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
        {       // first check with curl as we can set short timeout;
                $retry = 1;
                do {
-              $ch = curl_init();
-          curl_setopt ($ch, CURLOPT_URL, 'http://'.$site.$filename);
-              curl_setopt ($ch, CURLOPT_COOKIEJAR, "$path_to_root/tmp/cookie.txt");
-          curl_setopt ($ch, CURLOPT_HEADER, 0);
-              curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
-              // prevent warning while safe_mode/open_basedir on (redireciton doesn't occur at least on ECB page)
-                  if (!ini_get('safe_mode') && !ini_get('open_basedir'))
-               curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
-              curl_setopt ($ch, CURLOPT_TIMEOUT, 3);
-          $contents = curl_exec ($ch);
-              curl_close($ch);
+               $ch = curl_init();
+               curl_setopt ($ch, CURLOPT_URL, 'http://'.$site.$filename);
+               curl_setopt ($ch, CURLOPT_COOKIEJAR, "$path_to_root/tmp/cookie.txt");
+               curl_setopt ($ch, CURLOPT_HEADER, 0);
+               curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+               // prevent warning while safe_mode/open_basedir on (redireciton doesn't occur at least on ECB page)
+                       if (!ini_get('safe_mode') && !ini_get('open_basedir'))
+                       curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
+               curl_setopt ($ch, CURLOPT_TIMEOUT, 3);
+               $contents = curl_exec ($ch);
+               curl_close($ch);
                        // due to resolver bug in some curl versions (e.g. 7.15.5) 
                        // try again for constant IP.
-                  $site="172.230.157.137";
-          } while( ($contents == '') && $retry--);
+                       $site="172.230.157.137";
+               } while( ($contents == '') && $retry--);
           
        } else {
                $contents = url_get_contents("http://".$site.$filename);
@@ -207,14 +205,6 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
                $val = $array[1];
                if ($val != 0)
                        $val = 1 / $val;
-               /* Let old code be here for a while, Joe.
-               //if (preg_match('/Last\sTrade:(.*?)Trade\sTime/s', $contents, $matches)) {
-                       $val = strip_tags($matches[1]);
-                       $val = str_replace(',', '', $val);
-                       if ($val != 0)
-                               $val = 1 / $val;
-               }
-               */
        }
        elseif ($provider == 'GOOGLE')
        {
@@ -249,5 +239,5 @@ function get_sql_for_exchange_rates($curr)
                FROM ".TB_PREF."exchange_rates "
                ."WHERE curr_code=".db_escape($curr)."
                 ORDER BY date_ DESC";
-       return $sql;
+       return $sql;     
 }
index 34b904f41da39e301b9cca44317baa2189a85005..9fd072b8daaf1a8b72cffbf2b9c5376d6b2bf450 100644 (file)
@@ -387,14 +387,11 @@ function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate,
        if(!$tax_type) return;  // $gl_code is not tax account
        
        $tax = get_tax_type($tax_type);
-       //if ($gl_code == $tax['sales_gl_code'])
        if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTDELIVERY || $trans_type == ST_CUSTCREDIT)
                $amount = -$amount;
        // we have to restore net amount as we cannot know the base amount
        if ($net_amount===null) {
                if ($tax['rate'] == 0) {
-//                     display_warning(_("You should not post gl transactions  
-//                             to tax account with     zero tax rate."));
                        $net_amount = 0;
                } else { 
                        // calculate net amount
index f3f49533d8ba388b5d96c1dd521bacc0df7f2e0d..ae32414cf24ae9615179ada6fbb4590a3cb3714c 100644 (file)
@@ -151,15 +151,10 @@ function void_journal_trans($type, $type_no, $use_transaction=true)
        $sql = "UPDATE ".TB_PREF."journal SET amount=0
                WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no);
 
-       $result = db_query($sql, "could not void journal transaction for type=$type and trans_no=$type_no");
+       db_query($sql, "could not void journal transaction for type=$type and trans_no=$type_no");
 
        void_bank_trans($type, $type_no, true);
 
-//     void_gl_trans($type, $type_no, true);    // this is done above
-//     void_trans_tax_details($type, $type_no); // ditto
-//     void_supp_allocations($type, $type_no); // ditto
-//     void_cust_allocations($type, $type_no); // ditto
-
        if ($use_transaction)
                commit_transaction();
 }
index 8e491712a03d52cf19cfa51953c190d3db5d46d4..b5a0932bc3dbcfa8f3d8491f2fe6632e8edd82bc 100644 (file)
@@ -11,7 +11,7 @@
 ***********************************************************************/
 function display_bank_header(&$order)
 {
-       global $Ajax, $Refs;
+       global $Ajax;
        $payment = $order->trans_type == ST_BANKPAYMENT;
 
        $customer_error = false;
@@ -57,9 +57,6 @@ function display_bank_header(&$order)
                text_row_ex($payment ?_("To the Order of:"):_("Name:"),
                                 'person_id', 40, 50);
                break;
-               //case PT_WORKORDER :
-       //      workorders_list_row(_("Work Order:"), 'person_id', null);
-       //      break;
                case PT_SUPPLIER :
                supplier_list_row(_("Supplier:"), 'person_id', null, false, true, false, true);
                break;
@@ -100,9 +97,6 @@ function display_bank_header(&$order)
                        amount_row($qid['base_desc'].":", 'totamount', price_format($qid['base_amount']),
                                 null, "&nbsp;&nbsp;".submit('go', _("Go"), false, false, true));
                        break;  
-               //case payment_person_types::Project() :
-       //      dimensions_list_row(_("Dimension:"), 'person_id', $_POST['person_id'], false, null, true);
-       //      break;
     }
 
        table_section(3, "33%");
@@ -151,7 +145,7 @@ function display_gl_items($title, &$order)
        if ($dim == 2)
                $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
                        _("Dimension")." 2", _("Amount"), _("Memo"), "");
-       else if ($dim == 1)
+       elseif ($dim == 1)
                $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
                        _("Amount"), _("Memo"), "");
        else
@@ -176,7 +170,6 @@ function display_gl_items($title, &$order)
                                label_cell(get_dimension_string($item->dimension_id, true));
                if ($dim > 1)
                                label_cell(get_dimension_string($item->dimension2_id, true));
-                       //amount_cell(abs($item->amount));
                        if ($order->trans_type == ST_BANKDEPOSIT)
                                amount_cell(-$item->amount);
                        else            
@@ -237,7 +230,6 @@ function gl_edit_item_controls(&$order, $dim, $Index=null)
                $_POST['amount'] = price_format(0);
                $_POST['dimension_id'] = 0;
                $_POST['dimension2_id'] = 0;
-               //$_POST['LineMemo'] = ""; // let memo go to next line Joe Hunt 2010-05-30
                if(isset($_POST['_code_id_update'])) {
                            $Ajax->activate('code_id');
                }
@@ -252,8 +244,6 @@ function gl_edit_item_controls(&$order, $dim, $Index=null)
                        $acc = get_supplier_accounts($_POST['person_id']);
                        $_POST['code_id'] = $acc['payable_account'];
                }
-               //elseif ($_POST['PayType'] == PT_WORKORDER)
-               //      $_POST['code_id'] = get_company_pref('default_assembly_act');
                else {
                        $_POST['code_id'] =
                                get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act');
index 67cbb15573112811d2fcff02df48a53c6eeff200..675d8734282788be0a46d54cf339f7e0b522db63 100644 (file)
@@ -101,7 +101,7 @@ function display_gl_items($title, &$order)
        if ($dim == 2)
                $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
                        _("Dimension")." 2", _("Debit"), _("Credit"), _("Memo"), "");
-       else if ($dim == 1)
+       elseif ($dim == 1)
                $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
                        _("Debit"), _("Credit"), _("Memo"), "");
        else
index e3f8a454fa26804848b008dbbcef4b9c3d46414d..e2cd107536108864a5b4e74d0b9724d2eb9545d5 100644 (file)
@@ -104,7 +104,6 @@ function display_type ($type, $typename, $from, $to, $convert, $dimension, $dime
                $parent1 = $acctype1["parent"];
                if ($drilldown && $parent1 == $_POST["AccGrp"])
                //END Patch#2           
-               //elseif ($drilldown && $type != $_POST["AccGrp"])
                {
                        $url = "<a href='$path_to_root/gl/inquiry/balance_sheet.php?TransFromDate=" 
                                . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 
@@ -164,8 +163,6 @@ function display_balance_sheet()
                $lclose = 0.0; 
                $calculateclose = 0.0;          
 
-               $parent = -1;
-
                //Get classes for BS
                $classresult = get_account_classes(false, 1);
        
@@ -174,14 +171,14 @@ function display_balance_sheet()
                        $classclose = 0.0;
                        $convert = get_class_type_convert($class["ctype"]);
                        $ctype = $class["ctype"];
-                       $classname = $class["class_name"];      
 
                        //Print Class Name      
                        table_section_title($class["class_name"]);
                        
                        //Get Account groups/types under this group/type
                        $typeresult = get_account_types(false, $class['cid'], -1);
-                               
+                       
+                       $k = 0;
                        while ($accounttype=db_fetch($typeresult))
                        {
                                $TypeTotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, 
index 14147f6cf52da9e2cf0f1e891afc368389a4f32f..400885561ee29198fec0970d3bca3956195de6c4 100644 (file)
@@ -132,7 +132,7 @@ function show_results()
        
        if ($dim == 2)
                $dim_cols = array(_("Dimension")." 1", _("Dimension")." 2");
-       else if ($dim == 1)
+       elseif ($dim == 1)
                $dim_cols = array(_("Dimension"));
        else
                $dim_cols = array();
index b8ad34fe9685111a61899d1f65b28792ba8e0a9d..0ba2443fa876f9535a0492ded41bd34295ff9085 100644 (file)
@@ -214,9 +214,6 @@ while ($class = db_fetch($classresult))
        }
 }
 
-       //$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);
        if (!check_value('Balance'))
        {
                start_row("class='inquirybg' style='font-weight:bold'");
index 8dcf81e2ff9a393f1fc84fc8f1788c3454444d7d..1543bddc1ba102842f8f071865bf58660b0e72b0 100644 (file)
@@ -55,7 +55,7 @@ if (isset($_GET["AccGrp"]))
 //----------------------------------------------------------------------------------------------------
 
 function display_type ($type, $typename, $from, $to, $begin, $end, $compare, $convert,
-       &$dec, &$pdec, &$rep, $dimension=0, $dimension2=0, $drilldown, $path_to_root)
+       $dimension=0, $dimension2=0, $drilldown, $path_to_root)
 {
        global $levelptr, $k;
                
@@ -106,7 +106,7 @@ function display_type ($type, $typename, $from, $to, $begin, $end, $compare, $co
        while ($accounttype=db_fetch($result))
        {       
                $totals_arr = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, 
-                       $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root);
+                       $compare, $convert, $dimension, $dimension2, $drilldown, $path_to_root);
                $per_balance_total += $totals_arr[0];
                $acc_balance_total += $totals_arr[1];
        }
@@ -212,9 +212,6 @@ function display_profit_and_loss($compare)
        else
                $drilldown = 0; // Root level
        
-       $dec = 0;
-       $pdec = user_percent_dec();
-
        if ($compare == 0 || $compare == 2)
        {
                $end = $to;
@@ -244,9 +241,6 @@ function display_profit_and_loss($compare)
        
        if (!$drilldown) //Root Level
        {
-               $parent = -1;
-               $classper = 0.0;
-               $classacc = 0.0;
                $salesper = 0.0;
                $salesacc = 0.0;        
        
@@ -264,10 +258,11 @@ function display_profit_and_loss($compare)
                        
                        //Get Account groups/types under this group/type
                        $typeresult = get_account_types(false, $class['cid'], -1);
+                       $k = 0; // row color
                        while ($accounttype=db_fetch($typeresult))
                        {
                                $TypeTotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, 
-                                       $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root);
+                                       $dimension, $dimension2, $drilldown, $path_to_root);
                                $class_per_total += $TypeTotal[0];
                                $class_acc_total += $TypeTotal[1];      
 
@@ -323,7 +318,7 @@ function display_profit_and_loss($compare)
                echo $tableheader;
                
                $classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, 
-                       $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root);
+                       $dimension, $dimension2, $drilldown, $path_to_root);
                
        }
                
index 90ec7fe7d0efa255898764da897b7e2284e57f17..d1a38637d9eb26a77f0d35a74831dffa866e43d6 100644 (file)
@@ -73,8 +73,6 @@ function tax_inquiry_controls()
 
 function show_results()
 {
-       global $path_to_root;
-
     /*Now get the transactions  */
        div_start('trans_tbl');
        start_table(TABLESTYLE);
@@ -83,8 +81,6 @@ function show_results()
        table_header($th);
        $k = 0;
        $total = 0;
-       $bdate = date2sql($_POST['TransFromDate']);
-       $edate  = date2sql($_POST['TransToDate']);
 
        $taxes = get_tax_summary($_POST['TransFromDate'], $_POST['TransToDate']);