Merged latest changes from stable branch.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Mon, 8 Oct 2012 12:03:18 +0000 (14:03 +0200)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Mon, 8 Oct 2012 12:03:18 +0000 (14:03 +0200)
21 files changed:
admin/display_prefs.php
config.default.php
gl/includes/db/gl_db_rates.inc
gl/inquiry/bank_inquiry.php
gl/manage/exchange_rates.php
gl/manage/gl_account_types.php
includes/current_user.inc
includes/date_functions.inc
includes/db/inventory_db.inc
includes/prefs/userprefs.inc
includes/session.inc
includes/sysnames.inc
includes/ui/ui_input.inc
includes/ui/ui_view.inc
js/inserts.js
reporting/includes/doctext.inc
reporting/includes/pdf_report.inc
reporting/rep209.php
themes/aqua/renderer.php
themes/cool/renderer.php
themes/default/renderer.php

index 2da5c592b66122c8941e15441c16880acafa72a3..3b4c825d9369d08a4903491fde49db3545b58c54 100644 (file)
@@ -33,6 +33,8 @@ if (isset($_POST['setprefs']))
                $_POST['theme'] = clean_file_name($_POST['theme']);
                $chg_theme = user_theme() != $_POST['theme'];
                $chg_lang = $_SESSION['language']->code != $_POST['language'];
+               $chg_date_format = user_date_format() != $_POST['date_format'];
+               $chg_date_sep = user_date_sep() != $_POST['date_sep'];
 
                set_user_prefs(get_post( 
                        array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec',
@@ -50,8 +52,7 @@ if (isset($_POST['setprefs']))
 
                if ($chg_theme && $allow_demo_mode)
                        $_SESSION["wa_current_user"]->prefs->theme = $_POST['theme'];
-
-               if ($chg_theme || $chg_lang)
+               if ($chg_theme || $chg_lang || $chg_date_format || $chg_date_sep)
                        meta_forward($_SERVER['PHP_SELF']);
 
                
index a932d258b149060ce871d21628f0176dd7b6d320..1eeba6e41c992b5cfc92388898ed08c57f4b499e 100644 (file)
@@ -139,7 +139,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_
        /* allow reopening closed transactions */
        $allow_gl_reopen = 0;
 
-       $dateformats    = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD");
+       $dateformats    = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD","MmmDDYYYY", "DDMmmYYYY", "YYYYMmmDD");
        $dateseps               = array("/", ".", "-", " ");
        $thoseps                = array(",", ".", " ");
        $decseps                = array(".", ",");
@@ -264,3 +264,12 @@ $text_company_selection  = false;
 */
 $login_delay = 30;
 $login_max_attempts = 10;
+
+/*
+       Choose Exchange Rate Provider
+       Default is ECB for backwards compatibility
+*/
+$xr_providers = array("ECB", "YAHOO", "GOOGLE", "BLOOMBERG");
+$dflt_xr_provider = 0;
+
+?>
\ No newline at end of file
index 5d98dcb7afd166084b4214e1901d771d1a1078a9..9f0f101d12d742704a46f983591c4fb53a6705a0 100644 (file)
@@ -76,10 +76,13 @@ function delete_exchange_rate($rate_id)
 //
 function retrieve_exrate($curr_b, $date)
 {
+       global $xr_providers, $dflt_xr_provider;
+       $xchg_rate_provider = ((isset($xr_providers) && isset($dflt_xr_provider)) ? $xr_providers[$dflt_xr_provider] : 'ECB');
+       
        $rate = hook_retrieve_exrate($curr_b, $date);
        if (is_numeric($rate))
                return $rate;
-       return get_extern_rate($curr_b, 'ECB', $date);
+       return get_extern_rate($curr_b, $xchg_rate_provider, $date);
 }
 //-----------------------------------------------------------------------------
 
@@ -93,16 +96,22 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
        }
        elseif ($provider == 'YAHOO')
        {
-               $filename = "/q?s={$curr_a}{$curr_b}=X";
-               $site = "finance.yahoo.com";
+               $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')
        {
                $filename = "/finance/converter?a=1&from={$curr_a}&to={$curr_b}";
-               $site = "finance.google.com";
+               $site = "www.google.com";
+       }
+       elseif ($provider == 'BLOOMBERG')
+       {
+               $filename = "/quote/{$curr_b}{$curr_a}:CUR";
+               $site = "www.bloomberg.com";
        }
        $contents = '';
-
        if (function_exists('curl_init'))
        {       // first check with curl as we can set short timeout;
                $retry = 1;
@@ -151,17 +160,24 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
        }
        elseif ($provider == 'YAHOO')
        {
-               $val = '';
-               if (preg_match('/Last\sTrade:(.*?)Trade\sTime/s', $contents, $matches)) {
+               $val = ''; 
+               $array = explode(',',$contents); // New operations for YAHOO. Safer.
+               $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')
        {
                $val = '';
+               
                $regexp = "%([\d|.]+)\s+{$curr_a}\s+=\s+<span\sclass=(.*)>([\d|.]+)\s+{$curr_b}\s*</span>%s";
                if (preg_match($regexp, $contents, $matches)) 
                {
@@ -170,6 +186,15 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date)
                        if ($val != 0)
                                $val = 1 / $val;
                }
+    }    
+       elseif ($provider == 'BLOOMBERG')
+       {
+               $val = '';
+               $stmask = '<span class=" price">';
+               $val = trim(strstr($contents, $stmask));
+               $stmask = chr(10);
+               $val = trim(strstr($val, $stmask));
+               $val = trim(strtok($val, $stmask)); 
     }    
        return $val;
 }  /* end function get_extern_rate */
index 4330a2ade68f54fd6de21a716c05fc9df2fcdc48..c667c8873641321b2b36ddd685967189aa2fd4f9 100644 (file)
@@ -68,7 +68,7 @@ display_heading($act['bank_account_name']." - ".$act['bank_curr_code']);
 start_table(TABLESTYLE);
 
 $th = array(_("Type"), _("#"), _("Reference"), _("Date"),
-       _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), "");
+       _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), _("Memo"), "");
 table_header($th);
 
 $bfw = get_balance_before_for_bank_account($_POST['bank_account'], $_POST['TransAfterDate']);
@@ -103,6 +103,7 @@ while ($myrow = db_fetch($result))
        display_debit_or_credit_cells($myrow["amount"]);
        amount_cell($running_total);
        label_cell(get_counterparty_name($myrow["type"], $myrow["trans_no"]));
+       label_cell(get_comments_string($myrow["type"], $myrow["trans_no"]));
        label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
        end_row();
        if ($myrow["amount"] > 0 ) 
index 90ab428f37db35a37d4d6eb6403c8791804f975c..49e924f6b41d0841d0d30239a3c9a21aaa531ebe 100644 (file)
@@ -108,8 +108,8 @@ function display_rates($curr_code)
 
 function display_rate_edit()
 {
-       global $selected_id, $Ajax;
-
+       global $selected_id, $Ajax, $xr_providers, $dflt_xr_provider;
+       $xchg_rate_provider = ((isset($xr_providers) && isset($dflt_xr_provider)) ? $xr_providers[$dflt_xr_provider] : 'ECB');
        start_table(TABLESTYLE2);
 
        if ($selected_id != "")
@@ -139,7 +139,7 @@ function display_rate_edit()
                $Ajax->activate('BuyRate');
        }
        amount_row(_("Exchange Rate:"), 'BuyRate', null, '',
-               submit('get_rate',_("Get"), false, _('Get current ECB rate') , true), 'max');
+               submit('get_rate',_("Get"), false, _('Get current rate from') . ' ' . $xchg_rate_provider , true), 'max');
 
        end_table(1);
 
index fcea4dbfcc32611445e8cadf679ba780db94d78f..a906f3e8b1c62a0c574f65f854d8ae24148b5ce9 100644 (file)
@@ -125,7 +125,7 @@ $result = get_account_types(check_value('show_inactive'));
 
 start_form();
 start_table(TABLESTYLE);
-$th = array(_("Group ID"), _("Group Name"), _("Subgroup Of"), _("Class Type"), "", "");
+$th = array(_("Group ID"), _("Group Name"), _("Subgroup Of"), _("Class"), "", "");
 inactive_control_column($th);
 table_header($th);
 
@@ -189,7 +189,7 @@ text_row_ex(_("Name:"), 'name', 50);
 
 gl_account_types_list_row(_("Subgroup Of:"), 'parent', null, _("None"), true);
 
-class_list_row(_("Class Type:"), 'class_id', null);
+class_list_row(_("Class:"), 'class_id', null);
 
 end_table(1);
 
index 71b8ee74bbc090c905c3cd7332e25eea2d0d3c4b..90a91a9c079b68e45344f3ed0609b87c9eddf2a8 100644 (file)
@@ -173,6 +173,74 @@ class current_user
                return $this->can_access($page_level);
        }
 
+       function check_application_access($waapp)
+       {
+               if (!$this->hide_inaccessible_menu_items())
+               {
+                       return true;
+               }
+
+               foreach ($waapp->modules as $module)
+               {
+                       if ($this->check_module_access($module))
+                       {
+                               return true;
+                       }
+               }
+
+               return false;
+
+       }
+
+       function check_module_access($module)
+       {
+
+               if (!$this->hide_inaccessible_menu_items())
+               {
+                       return true;
+               }
+
+               if (sizeof($module->lappfunctions) > 0)
+               {
+                       foreach ($module->lappfunctions as $appfunction)
+                       {
+                               if ($appfunction->label != "" && $this->can_access_page($appfunction->access))
+                               {
+                                       return true;
+                               }
+                       }
+               }
+
+               if (sizeof($module->rappfunctions) > 0)
+               {
+                       foreach ($module->rappfunctions as $appfunction)
+                       {
+                               if ($appfunction->label != "" && $this->can_access_page($appfunction->access))
+                               {
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+
+       }
+
+       function hide_inaccessible_menu_items()
+       {
+               global $hide_inaccessible_menu_items;
+
+               if (!isset($hide_inaccessible_menu_items) || $hide_inaccessible_menu_items == 0)
+               {
+                       return false;
+               }
+
+               else
+               {
+                       return true;
+               }
+       }
+
        function set_db_connection($id = -1)
        {
                return set_global_connection($id);
index d1aacdf8302f7fbbf80da6089a8b16e86b19fda3..17a86ff7cf926101adaa8a6d0d69c21120f1fa14 100644 (file)
@@ -21,22 +21,31 @@ this can be a string either "d/m/Y" for UK/Australia/New Zealand dates or
 
 function __date($year, $month, $day)
 {
-       global $dateseps;
+       global $dateseps, $tmonths;
        
        $how = user_date_format();
        $sep = $dateseps[user_date_sep()];
        $day = (int)$day;
        $month = (int)$month;
-       if ($day < 10)
-               $day = "0".$day;
-       if ($month < 10)
-               $month = "0".$month;
+       if ($how < 3)
+       {
+               if ($day < 10)
+                       $day = "0".$day;
+               if ($month < 10)
+                       $month = "0".$month;
+       }               
        if ($how == 0)
                return $month.$sep.$day.$sep.$year;
        elseif ($how == 1)
                return $day.$sep.$month.$sep.$year;
-       else
+       elseif ($how == 2)
                return $year.$sep.$month.$sep.$day;
+       elseif ($how == 3)
+               return $tmonths[$month].$sep.$day.$sep.$year;
+       elseif ($how == 4)
+               return $day.$sep.$tmonths[$month].$sep.$year;
+       else
+               return $year.$sep.$tmonths[$month].$sep.$day;
 }
 
 function is_date($date_) 
@@ -49,47 +58,73 @@ function is_date($date_)
        $sep = $dateseps[user_date_sep()];
 
        $date_ = trim($date_);
-       $date_ = str_replace($sep, "", $date_);
-       if (strlen($date_) == 6)
+       $date = str_replace($sep, "", $date_);
+       
+       if ($how > 2)
+       {
+               global $tmonths;
+               $dd = explode($sep, $date_);
+               if ($how == 3)
+               {
+                       $day = $dd[1];
+                       $month = array_search($dd[0], $tmonths);
+                       $year = $dd[2];
+               } 
+               elseif ($how == 4)
+               {
+                       $day = $dd[0];
+                       $month = array_search($dd[1], $tmonths);
+                       $year = $dd[2];
+               } 
+               else
+               {
+                       $day = $dd[2];
+                       $month = array_search($dd[1], $tmonths);
+                       $year = $dd[0];
+               }
+               if ($year < 1000)
+                       return 0;
+       }
+       elseif (strlen($date) == 6)
        {
                if ($how == 0)
                {
-                       $day = substr($date_,2,2);
-                       $month = substr($date_,0,2);
-                       $year = substr($date_,4,2);
+                       $day = substr($date,2,2);
+                       $month = substr($date,0,2);
+                       $year = substr($date,4,2);
                } 
                elseif ($how == 1)
                {
-                       $day = substr($date_,0,2);
-                       $month = substr($date_,2,2);
-                       $year = substr($date_,4,2);
+                       $day = substr($date,0,2);
+                       $month = substr($date,2,2);
+                       $year = substr($date,4,2);
                } 
                else
                {
-                       $day = substr($date_,4,2);
-                       $month = substr($date_,2,2);
-                       $year = substr($date_,0,2);
+                       $day = substr($date,4,2);
+                       $month = substr($date,2,2);
+                       $year = substr($date,0,2);
                }
        }
-       elseif (strlen($date_) == 8)
+       elseif (strlen($date) == 8)
        {
                if ($how == 0)
                {
-                       $day = substr($date_,2,2);
-                       $month = substr($date_,0,2);
-                       $year = substr($date_,4,4);
+                       $day = substr($date,2,2);
+                       $month = substr($date,0,2);
+                       $year = substr($date,4,4);
                } 
                elseif ($how == 1)
                {
-                       $day = substr($date_,0,2);
-                       $month = substr($date_,2,2);
-                       $year = substr($date_,4,4);
+                       $day = substr($date,0,2);
+                       $month = substr($date,2,2);
+                       $year = substr($date,4,4);
                } 
                else
                {
-                       $day = substr($date_,6,2);
-                       $month = substr($date_,4,2);
-                       $year = substr($date_,0,4);
+                       $day = substr($date,6,2);
+                       $month = substr($date,4,2);
+                       $year = substr($date,0,4);
                }
        }
        if (!isset($year)|| (int)$year > 9999) 
@@ -97,7 +132,6 @@ function is_date($date_)
                return 0;
        }
 
-
        if (is_long((int)$day) && is_long((int)$month) && is_long((int)$year))
        {
                global $date_system;
@@ -262,7 +296,8 @@ function add_days($date, $days) // accepts negative values as well
                list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
        return __date($year, $month, $day);
     }
-    return date(user_date_display(), $timet);
+    list($year, $month, $day) = explode("-", date("Y-m-d", $timet));
+       return __date($year, $month, $day);
 }
 
 function add_months($date, $months) // accepts negative values as well
@@ -284,7 +319,8 @@ function add_months($date, $months) // accepts negative values as well
                list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
        return __date($year, $month, $day);
     }
-    return date(user_date_display(), $timet);
+    list($year, $month, $day) = explode("-", date("Y-m-d", $timet));
+       return __date($year, $month, $day);
 }
 
 function add_years($date, $years) // accepts negative values as well
@@ -300,7 +336,8 @@ function add_years($date, $years) // accepts negative values as well
                list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
        return __date($year, $month, $day);
     }
-    return date(user_date_display(), $timet);
+    list($year, $month, $day) = explode("-", date("Y-m-d", $timet));
+       return __date($year, $month, $day);
 }
 
 //_______________________________________________________________
@@ -336,7 +373,7 @@ function sql2date($date_)
 
 function date2sql($date_)
 {
-       global $dateseps, $date_system;
+       global $dateseps, $date_system, $tmonths;
 /* takes a date in a the format specified in $DefaultDateFormat
 and converts to a yyyy/mm/dd format */
 
@@ -349,13 +386,17 @@ and converts to a yyyy/mm/dd format */
        $date_ = trim($date_);
     $year = $month = $day = 0;
     // Split up the date by the separator based on "how" to split it
-    if ($how == 0) // MMDDYYYY
+    if ($how == 0 || $how == 3) // MMDDYYYY or MmmDDYYYY
         list($month, $day, $year) = explode($sep, $date_);
-    elseif ($how == 1) // DDMMYYYY
+    elseif ($how == 1 || $how == 4) // DDMMYYYY or DDMmYYYY
         list($day, $month, $year) = explode($sep, $date_);
-    else // $how == 2, YYYYMMDD
+    else // $how == 2 || $how == 5, YYYYMMDD or YYYYMmmDD
         list($year, $month, $day) = explode($sep, $date_);
-
+       if ($how > 2)
+       {
+               global $tmonths;
+               $month = array_search($month, $tmonths);
+       }       
 //to modify assumption in 2030
        if ($date_system == 0 || $date_system == 3)
        {
index e0ea2ef7646f00d33338e2ab29246d0561b5dcf0..5613ecb8d8eba24b13f1b3839a4914da9323056f 100644 (file)
@@ -381,9 +381,7 @@ function get_stock_moves($type, $type_no, $visible=false)
 
 function void_stock_move($type, $type_no)
 {
-    $sql = "SELECT stock_id, standard_cost, loc_code, tran_date, reference, person_id, visible, discount_percent, price, 
-       sum(qty) qty FROM ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no)." 
-       GROUP BY stock_id, standard_cost, loc_code, tran_date, reference, person_id, visible, discount_percent, price HAVING sum(qty) <> 0";
+    $sql = "SELECT * from ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no);
 
     $result = db_query($sql, "Could not void stock moves");
     while ($row = db_fetch($result))
@@ -403,12 +401,10 @@ function void_stock_move($type, $type_no)
                                $trans_rate, -$row["qty"], sql2date($row["tran_date"]));
                }
 
-               //Post stock move for service items also
-        add_stock_move($type, $row["stock_id"], $type_no, $row["loc_code"],
-               sql2date($row["tran_date"]), $row["reference"], -$row["qty"]
-                       , $row["standard_cost"], $row["person_id"], $row["visible"],
-               $row["price"], $row["discount_percent"]);
     }
+       $sql = "DELETE FROM ".TB_PREF."stock_moves WHERE type=".db_escape($type)
+               ."      AND trans_no=".db_escape($type_no);
+       db_query($sql, "The stock movement cannot be delated");
 }
 
 //--------------------------------------------------------------------------------------------------
index caf0506648c0b963b0003129ed54ced26608495b..400ef1e16903dbf06d2f24d39d22f718033a0581 100644 (file)
@@ -166,8 +166,14 @@ class user_prefs
                        return "m".$sep."d".$sep."Y";
                elseif ($this->date_format == 1)
                        return "d".$sep."m".$sep."Y";
-               else
+               elseif ($this->date_format == 2)
                        return "Y".$sep."m".$sep."d";
+               elseif ($this->date_format == 3)
+                       return "M".$sep."j".$sep."Y";
+               elseif ($this->date_format == 4)
+                       return "j".$sep."M".$sep."Y";
+               else
+                       return "Y".$sep."M".$sep."j";
        }
 
        function tho_sep() 
index 66a7d240d235ce52b423449ce01edb820a7db2ef..52d16bdf3e0f951233f19f5f293f89eb28de6633 100644 (file)
@@ -155,7 +155,7 @@ function check_faillog()
 
        $user = $_SESSION["wa_current_user"]->user;
 
-       if (@$login_delay && ($login_faillog[$user][$_SERVER['REMOTE_ADDR']] >= @$login_max_attempts) && (time() < $login_faillog[$user]['last'] + $login_delay))
+       if (@$login_delay && (@$login_faillog[$user][$_SERVER['REMOTE_ADDR']] >= @$login_max_attempts) && (time() < $login_faillog[$user]['last'] + $login_delay))
                return true;
 
        return false;
index 7c296ad9632ab1ef910b4884bb44d4bf09d8149e..52f96c64b95a288a23498259281bbd4ebff44a56 100644 (file)
@@ -196,4 +196,7 @@ $bank_owner_types = array(
        BO_SUPPLIER => _("Supplier")
 );
 
+// This month array is for use with the last 3 dateformats. 
+$tmonths = array("", _("Jan"),_("Feb"),_("Mar"),_("Apr"),_("May"),_("Jun"),_("Jul"),_("Aug"),_("Sep"),_("Oct"),_("Nov"),_("Dec"));
+
 ?>
\ No newline at end of file
index 04933bd68682dba3eea346740527feeb836883bd..d9140d51d53655b10e6237ba3c884cad79cad676 100644 (file)
@@ -646,7 +646,8 @@ function date_cells($label, $name, $title = null, $check=null, $inc_days=0,
                $aspect .= ' style="color:#FF0000"';
 
        default_focus($name);
-       echo "<input type=\"text\" name=\"$name\" class=\"$class\" $aspect size=\"10\" maxlength=\"12\" value=\"" 
+       $size = (user_date_format()>3)?11:10; 
+       echo "<input type=\"text\" name=\"$name\" class=\"$class\" $aspect size=\"$size\" maxlength=\"12\" value=\"" 
         . $_POST[$name]. "\""
         .($title ? " title='$title'": '')." > $post_label";
        echo "</td>\n";
index adf663288317479f0cee4a0238776d6114a370f5..e98f1d674c8bb0a93a3b935e8ffcc6a573a41462 100644 (file)
@@ -834,11 +834,11 @@ function get_js_date_picker()
 
     if (!file_exists($fpath) || $go_debug) {
 
-       global $dateseps, $date_system;
+       global $dateseps, $date_system, $tmonths;
 
        $how = user_date_format();                              // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
        $sep = $dateseps[user_date_sep()];              // date separator
-       $wstart = (($date_system == 1 || $date_system == 2 || $date_system == 3) ? 6 : ($how == 0 ? 0 : 1));    // weekstart (sun = 0, mon = 1)
+       $wstart = (($date_system == 1 || $date_system == 2 || $date_system == 3) ? 6 : ($how == 0 || $how == 3 ? 0 : 1));       // weekstart (sun = 0, mon = 1)
        $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
        $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
        $wno = _("W"); // week no
@@ -921,6 +921,7 @@ function CC() {
   var selectedDay = 0;
   var months = ['$months[0]','$months[1]','$months[2]','$months[3]','$months[4]','$months[5]','$months[6]','$months[7]','$months[8]','$months[9]','$months[10]','$months[11]'];
   var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
+  var tmonths = ['$tmonths[0]','$tmonths[1]','$tmonths[2]','$tmonths[3]','$tmonths[4]','$tmonths[5]','$tmonths[6]','$tmonths[7]','$tmonths[8]','$tmonths[9]','$tmonths[10]','$tmonths[11]','$tmonths[12]'];
   var dateField = null;
   function getProperty(p_property){
     var p_elm = calendarId;
@@ -1023,7 +1024,7 @@ function CC() {
   this.getWeek = getWeek;
   function getWeek(year, month, day) {
 ";
-       if ($how == 0)
+       if ($how == 0 || $how == 3)
                $js .= "  day++;";
        $js .= "
     var date = new Date(year,month-1,day);
@@ -1037,19 +1038,26 @@ function CC() {
   }
   this.setDate = setDate;
   function setDate(year, month, day) {
-    if (dateField) {
+    if (dateField){
+";
+       if ($how < 3)
+               $js .= "
       if (month < 10) {month = '0' + month;}
       if (day < 10) {day = '0' + day;}
 ";
-       if ($how == 0)
+       else
+               $js .= "
+      month = tmonths[month];
+";
+       if ($how == 0 || $how == 3)
                $js .= "
       var dateString = month+'$sep'+day+'$sep'+year;
 ";
-       else if ($how == 1)
+       else if ($how == 1 || $how == 4)
                $js .= "
       var dateString = day+'$sep'+month+'$sep'+year;
 ";
-       else
+       else if ($how == 2 || $how == 5)
                $js .= "
       var dateString = year+'$sep'+month+'$sep'+day;
 ";
@@ -1185,11 +1193,29 @@ function CC() {
         selectedMonth = parseInt(dateParts[1],10);
         selectedYear = parseInt(dateParts[2],10);
 ";
-       else
+       else if ($how == 2)
                $js .= "
         selectedYear = parseInt(dateParts[0],10);
         selectedMonth = parseInt(dateParts[1],10);
         selectedDay = parseInt(dateParts[2],10);
+";
+       else if ($how == 3)
+               $js .= "
+        selectedDay = parseInt(dateParts[1],10);
+        selectedMonth = parseInt(tmonths.indexOf(dateParts[0]),10);
+        selectedYear = parseInt(dateParts[2],10);
+";
+       else if ($how == 4)
+               $js .= "
+        selectedDay = parseInt(dateParts[0],10);
+        selectedMonth = parseInt(tmonths.indexOf(dateParts[1]),10);
+        selectedYear = parseInt(dateParts[2],10);
+";
+       else
+               $js .= "
+        selectedYear = parseInt(dateParts[0],10);
+        selectedMonth = parseInt(tmonths.indexOf(dateParts[1]),10);
+        selectedDay = parseInt(dateParts[2],10);
 ";
        $js .= "
       } catch(e) {}
index 2e706fb5e89b8dcab06b78d44192118b845890cf..a22238b6dc899531452ca61340cc0e518694790f 100644 (file)
@@ -213,47 +213,40 @@ function passBack(value) {
 */
 function fix_date(date, last)
 {
-       var regex = /(\d+)[^\d]*(\d+)*[^\d]*(\d+)*/;
-       var dat = regex.exec(last);
-       var cur = regex.exec(date);
+       var dat = last.split(user.datesep);
+       var cur = date.split(user.datesep);
        var day, month, year;
+       var day1, month1, year1;
 
 // TODO: user.date as default?
 // TODO: user.datesys
-       if (!dat || !cur) return date;
-
-       if (cur[3] != undefined) // full date entered
-               dat = cur;
-
-       if (user.datefmt == 0) // set defaults
+       if (date == "" || date == last) // should we return an empty date or should we return last?
+               return date;
+       if (user.datefmt == 0 || user.datefmt == 3) // set defaults
        {
-               day = dat[2]; month = dat[1]; year = dat[3];
-       } else if (user.datefmt == 1)
-       {
-               day = dat[1]; month = dat[2]; year = dat[3];
+               day = dat[1]; month = dat[0]; year = dat[2];
+               day1 = cur[1]; month1 = cur[0]; year1 = cur[2];
+       } else if (user.datefmt == 1 || user.datefmt == 4){
+               day = dat[0]; month = dat[1]; year = dat[2];
+               day1 = cur[0]; month1 = cur[1]; year1 = cur[2];
        } else {
-               day = dat[3]; month = dat[2]; year = dat[1];
-       }
-
-       if (cur[2] == undefined) // only day entred
-               day = cur[1];
-       else // day + month
-               if (cur[2] != undefined)
-               {
-                       if (user.datefmt==1)
-                               { day = cur[1]; month = cur[2] }
-                       else
-                               { day = cur[2]; month = cur[1] }
-               }
-
-       if (day<10) day = '0'+parseInt(day, 10);
-       if (month<10) month = '0'+parseInt(month, 10);
+               day = dat[2]; month = dat[1]; year = dat[0];
+               day1 = cur[2]; month1 = cur[1]; year1 = cur[0];
+       }       
+       if (day1 != undefined && day1 != "") // day entered
+               day = day1;
+       if (month1 != undefined && month1 != "") // month entered
+               month = month1;
+       if (year1 != undefined && year1 != "") // year entered
+               year = year1;
+       if (user.datefmt<3 && day<10) day = '0'+parseInt(day, 10);
+       if (user.datefmt<3 && month<10) month = '0'+parseInt(month, 10);
        if (year<100) year = year<60 ? (2000+parseInt(year,10)) : (1900+parseInt(year,10));
 
 //     console.info(day,month,year)
-       if (user.datefmt == 0)
+       if (user.datefmt == 0 || user.datefmt==3)
                return month+user.datesep+day+user.datesep+year;
-       if (user.datefmt == 1)
+       if (user.datefmt == 1 || user.datefmt==4)
                return day+user.datesep+month+user.datesep+year;
        return year+user.datesep+month+user.datesep+day;
 }
index f39254afee2f4a8fd830c47fd5188f43231b6296..21b3a8479508d2d59a31a2cad12d5e5fb3eaa4db 100644 (file)
@@ -53,7 +53,7 @@
                        $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference'])
                                ? $this->formData['reference'] : $this->formData['order_no'];
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData["customer_ref"],
+                               _("Customer's Reference") => $this->formData["customer_ref"],
                                _("Sales Person") => get_salesman_name($this->formData['salesman']),
                                _("Your VAT no.") => $this->formData['tax_id'],
                                _("Our Quotation No") => $this->formData['order_no'],
@@ -70,7 +70,7 @@
                        $this->formData['document_amount'] = $this->formData['order_no'];
 
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData["customer_ref"],
+                               _("Customer's Reference") => $this->formData["customer_ref"],
                                _("Sales Person") => get_salesman_name($this->formData['salesman']),
                                _("Your VAT no.") => $this->formData['tax_id'],
                                _("Our Order No") => $this->formData['order_no'],
@@ -91,7 +91,7 @@
                                        $ref = $this->formData['order_'];
                        }
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData["customer_ref"],
+                               _("Customer's Reference") => $this->formData["customer_ref"],
                                _("Sales Person") => get_salesman_name($this->formData['salesman']),
                                _("Your VAT no.") => $this->formData['tax_id'],
                                _("Our Order No") => $ref,
                        $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code'];
 
                        $aux_info = array(
-                               _("Customers Reference") => @$this->formData["customer_ref"],
+                               _("Customer's Reference") => @$this->formData["customer_ref"],
                                _("Sales Person") => get_salesman_name($this->formData['salesman']),
                                _("Your VAT no.") => $this->formData['tax_id'],
                                _("Our Order No") => $this->formData['order_'],
                                }
                        }
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData["customer_ref"],
+                               _("Customer's Reference") => $this->formData["customer_ref"],
                                _("Sales Person") => get_salesman_name($this->formData['salesman']),
                                _("Your VAT no.") => $this->formData['tax_id'],
                        );
                        $Addr2['address'] = '';
 
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData['supp_account_no'],
+                               _("Customer's Reference") => $this->formData['supp_account_no'],
                                _("Type") =>$systypes_array[$this->formData["type"]],
                                _("Your VAT no.") => $this->formData['tax_id'],
-                               _("Our Order No") => '',
+                               _("Supplier's Reference") => '',
                                _("Due Date") => sql2date($this->formData['tran_date']),
                        );
                        $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
                                ? $this->formData['reference'] : $this->formData['order_no'];
 
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData['supp_account_no'],
-                               _("Sales Person") => '',
-                               _("Your VAT no.") => '',
-                               _("Our Order No") => '',
-                               _("Due Date") => '',
+                               _("Customer's Reference") => $this->formData['supp_account_no'],
+                               _("Sales Person") => $this->formData['contact'],
+                               _("Your VAT no.") => $this->formData['tax_id'],
+                               _("Supplier's Reference") => $this->formData['requisition_no'],
+                               _("Order Date") => sql2date($this->formData['document_date']),
                        );
 
                        $this->headers = array(_("Item Code"), _("Item Description"),
                        $this->formData['document_name'] =_("Receipt No.");
                        $Addr1['title'] = _("With thanks from");
                        $aux_info = array(
-                               _("Customers Reference") => $this->formData["debtor_ref"],
+                               _("Customer's Reference") => $this->formData["debtor_ref"],
                                _("Type") =>$systypes_array[$this->formData["type"]],
                                _("Your VAT no.") => $this->formData['tax_id'],
                                _("Our Order No") => $this->formData['order_'],
                        $Payment_Terms = '';
                        $this->title = _("STATEMENT");
                        $aux_info = array(
-                               _("Customers Reference") => '',
+                               _("Customer's Reference") => '',
                                _("Sales Person") => '',
                                _("Your VAT no.") => $this->formData['tax_id'],
                                _("Our Order No") => '',
index 8523359d9c6919b336127e7c91eb897d35f5f9db..682b8af319c5a61e644677ce1600f97582cd9eed 100644 (file)
@@ -386,7 +386,7 @@ class FrontReport extends Cpdf
                        'DebtorName', 'supp_account_no', 'wo_ref', 'debtor_ref','type', 'trans_no', 
                        'StockItemName', 'tax_id', 'order_', 'delivery_date', 'units_issued',
                        'due_date', 'required_by', 'payment_terms', 'curr_code',
-                       'ov_freight', 'ov_gst', 'ov_amount', 'prepaid'),
+                       'ov_freight', 'ov_gst', 'ov_amount', 'prepaid', 'requisition_no', 'contact'),
                'branch' => array('br_address', 'br_name', 'salesman', 'disable_branch'),
                'sales_order' => array('deliver_to', 'delivery_address', 'customer_ref'),
                'bankaccount' => array('bank_name', 'bank_account_number', 'payment_service')
index 1131a350464478182e6962f7ad57ceccc7042dfd..b74ac209845ce4cc8abd5446e6b9943ac5193280 100644 (file)
@@ -34,7 +34,7 @@ print_po();
 function get_po($order_no)
 {
        $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name,  "
-               .TB_PREF."suppliers.supp_account_no,".TB_PREF."suppliers.tax_included,".TB_PREF."suppliers.tax_algorithm,
+               .TB_PREF."suppliers.supp_account_no,".TB_PREF."suppliers.tax_included,".TB_PREF."suppliers.tax_algorithm,".TB_PREF."suppliers.gst_no AS tax_id,
                ".TB_PREF."suppliers.curr_code, ".TB_PREF."suppliers.payment_terms, ".TB_PREF."locations.location_name,
                ".TB_PREF."suppliers.address, ".TB_PREF."suppliers.contact, ".TB_PREF."suppliers.tax_group_id
                FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations
index 72e200cb4bf5481da2a68bf8d75adddcbbc97a23..a5036185273ef75e67cbf5b425208b82c331a89f 100644 (file)
@@ -56,7 +56,7 @@
                                echo "<div class=tabs>";
                                foreach($applications as $app)
                                {
-                    if ($this->check_application_access($app))
+                    if ($_SESSION["wa_current_user"]->check_application_access($app))
                     {
                                                $acc = access_string($app->name);
                                                echo "<a class='".($sel_app == $app->id ? 'selected' : 'menu_tab')
                        global $path_to_root;
                        
                        $selected_app = $waapp->get_selected_application();
-                       if (!$this->check_application_access($selected_app))
+                       if (!$_SESSION["wa_current_user"]->check_application_access($selected_app))
                                return;
 
                        foreach ($selected_app->modules as $module)
                        {
-                       if (!$this->check_module_access($module))
+                       if (!$_SESSION["wa_current_user"]->check_module_access($module))
                                continue;
                                // image
                                echo "<tr>";
                                        {
                                                        echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                        }
-                                       elseif (!$this->hide_inaccessible_menu_items()) 
+                                       elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items()) 
                                        {
                                                        echo $img.'<span class="inactive">'
                                                                .access_string($appfunction->label, true)
                                                {
                                                                echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                                }
-                                               elseif (!$this->hide_inaccessible_menu_items()) 
+                                               elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items()) 
                                                {
                                                                echo $img.'<span class="inactive">'
                                                                        .access_string($appfunction->label, true)
 
                        echo "</table>";
                }
-
-        function check_application_access($waapp)
-        {
-            if (!$this->hide_inaccessible_menu_items())
-            {
-                return true;
-            }
-            
-            foreach ($waapp->modules as $module)
-            {
-                if ($this->check_module_access($module))
-                {
-                    return true;
-                }
-            }
-            
-            return false;
-                    
-        }
-        
-        function check_module_access($module)
-        {
-            
-            if (!$this->hide_inaccessible_menu_items())
-            {
-                return true;
-            }
-            
-            if (sizeof($module->lappfunctions) > 0)
-            {
-                foreach ($module->lappfunctions as $appfunction)
-                {
-                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
-                    {
-                        return true;
-                    }
-                }
-            }
-            
-            if (sizeof($module->rappfunctions) > 0)
-            {
-                foreach ($module->rappfunctions as $appfunction)
-                {
-                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
-                    {
-                        return true;
-                    }
-                }
-            }
-            
-            return false;
-            
-        }
-        
-        function hide_inaccessible_menu_items()
-        {
-            global $hide_inaccessible_menu_items;
-            
-            if (!isset($hide_inaccessible_menu_items) || $hide_inaccessible_menu_items == 0)
-            {
-                return false;
-            }
-            
-            else
-            {
-                return true;
-            }
-        }
        }
 
 ?>
\ No newline at end of file
index 8ce153f2a128f17eeaba66703001574f85953d91..bb5621356f31fe1f3b428d200fb267ae682ec22b 100644 (file)
@@ -56,7 +56,7 @@
                                echo "<div class=tabs>";
                                foreach($applications as $app)
                                {
-                    if ($this->check_application_access($app))
+                    if ($_SESSION["wa_current_user"]->check_application_access($app))
                     {
                                                $acc = access_string($app->name);
                                                echo "<a class='".($sel_app == $app->id ? 'selected' : 'menu_tab')
                {
                        global $path_to_root;
                        $selected_app = $waapp->get_selected_application();
-                       if (!$this->check_application_access($selected_app))
+                       if (!$_SESSION["wa_current_user"]->check_application_access($selected_app))
                                return;
 
                        foreach ($selected_app->modules as $module)
                        {
-                       if (!$this->check_module_access($module))
+                       if (!$_SESSION["wa_current_user"]->check_module_access($module))
                                continue;
                                // image
                                echo "<tr>";
                                        {
                                                        echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                        }
-                                       elseif (!$this->hide_inaccessible_menu_items()) 
+                                       elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items()) 
                                        {
                                                        echo $img.'<span class="inactive">'
                                                                .access_string($appfunction->label, true)
                                                {
                                                                echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                                }
-                                               elseif (!$this->hide_inaccessible_menu_items()) 
+                                               elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items()) 
                                                {
                                                                echo $img.'<span class="inactive">'
                                                                        .access_string($appfunction->label, true)
 
                        echo "</table>";
                }
-
-        function check_application_access($waapp)
-        {
-            if (!$this->hide_inaccessible_menu_items())
-            {
-                return true;
-            }
-            
-            foreach ($waapp->modules as $module)
-            {
-                if ($this->check_module_access($module))
-                {
-                    return true;
-                }
-            }
-            
-            return false;
-                    
-        }
-        
-        function check_module_access($module)
-        {
-            
-            if (!$this->hide_inaccessible_menu_items())
-            {
-                return true;
-            }
-            
-            if (sizeof($module->lappfunctions) > 0)
-            {
-                foreach ($module->lappfunctions as $appfunction)
-                {
-                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
-                    {
-                        return true;
-                    }
-                }
-            }
-            
-            if (sizeof($module->rappfunctions) > 0)
-            {
-                foreach ($module->rappfunctions as $appfunction)
-                {
-                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
-                    {
-                        return true;
-                    }
-                }
-            }
-            
-            return false;
-            
-        }
-        
-        function hide_inaccessible_menu_items()
-        {
-            global $hide_inaccessible_menu_items;
-            
-            if (!isset($hide_inaccessible_menu_items) || $hide_inaccessible_menu_items == 0)
-            {
-                return false;
-            }
-            
-            else
-            {
-                return true;
-            }
-        }
        }
 
 ?>
\ No newline at end of file
index 08d015abf77720543ab536995768f780b45cff2f..e32cbb46876460cd79495dce09593d8a09bfbaa1 100644 (file)
@@ -35,7 +35,7 @@
 
                function menu_header($title, $no_menu, $is_index)
                {
-                       global $path_to_root, $help_base_url, $db_connections, $show_inaccessible_menu_items;
+                       global $path_to_root, $help_base_url, $db_connections;
                        echo "<table class='callout_main' border='0' cellpadding='0' cellspacing='0'>\n";
                        echo "<tr>\n";
                        echo "<td colspan='2' rowspan='2'>\n";
@@ -57,7 +57,7 @@
                                echo "<div class=tabs>";
                                foreach($applications as $app)
                                {
-                    if ($this->check_application_access($app))
+                    if ($_SESSION["wa_current_user"]->check_application_access($app))
                     {
                         $acc = access_string($app->name);
                         echo "<a class='".($sel_app == $app->id ? 'selected' : 'menu_tab')
                        global $path_to_root;
 
                        $selected_app = $waapp->get_selected_application();
-                       if (!$this->check_application_access($selected_app))
+                       if (!$_SESSION["wa_current_user"]->check_application_access($selected_app))
                                return;
                        foreach ($selected_app->modules as $module)
                        {
-                       if (!$this->check_module_access($module))
+                       if (!$_SESSION["wa_current_user"]->check_module_access($module))
                                continue;
                                // image
                                echo "<tr>";
                                        {
                                                        echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                        }
-                                       elseif (!$this->hide_inaccessible_menu_items())
+                                       elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
                                        {
                                                        echo $img.'<span class="inactive">'
                                                                .access_string($appfunction->label, true)
                                                {
                                                                echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                                }
-                                               elseif (!$this->hide_inaccessible_menu_items())
+                                               elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
                                                {
                                                                echo $img.'<span class="inactive">'
                                                                        .access_string($appfunction->label, true)
                        }       
                        echo "</table>";
                }
-        
-        function check_application_access($waapp)
-        {
-            if (!$this->hide_inaccessible_menu_items())
-            {
-                return true;
-            }
-            
-            foreach ($waapp->modules as $module)
-            {
-                if ($this->check_module_access($module))
-                {
-                    return true;
-                }
-            }
-            
-            return false;
-                    
-        }
-        
-        function check_module_access($module)
-        {
-            
-            if (!$this->hide_inaccessible_menu_items())
-            {
-                return true;
-            }
-            
-            if (sizeof($module->lappfunctions) > 0)
-            {
-                foreach ($module->lappfunctions as $appfunction)
-                {
-                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
-                    {
-                        return true;
-                    }
-                }
-            }
-            
-            if (sizeof($module->rappfunctions) > 0)
-            {
-                foreach ($module->rappfunctions as $appfunction)
-                {
-                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
-                    {
-                        return true;
-                    }
-                }
-            }
-            
-            return false;
-            
-        }
-        
-        function hide_inaccessible_menu_items()
-        {
-            global $hide_inaccessible_menu_items;
-            
-            if (!isset($hide_inaccessible_menu_items) || $hide_inaccessible_menu_items == 0)
-            {
-                return false;
-            }
-            
-            else
-            {
-                return true;
-            }
-        }
     }