Allowing SA_FISCALYEAR access to enter transactions on open fiscal years
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 4 Jun 2010 22:32:34 +0000 (22:32 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 4 Jun 2010 22:32:34 +0000 (22:32 +0000)
CHANGELOG.txt
admin/db/fiscalyears_db.inc
includes/date_functions.inc

index 27b4e7b5fd2a72597f2b12f9b83c8c7f677d30ed..894e5fe45baefa848dc440c6622a5ee26fec141b 100644 (file)
@@ -19,6 +19,11 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+05-Jun-2010 Joe Hunt
+! Allowing SA_FISCALYEAR access to enter transactions on open fiscal years
+$ /admin/db/fiscalyears_db.inc
+  /includes/date_functions.inc
+  
 31-May-2010 Joe Hunt
 ! Allowing modifying of Bank Payments/Deposits
 $ /gl/gl_bank.php
index 4dc32b6952de79e35ceb4e50a7f8d72336a16e44..ddbe19d0d03b7480a48d3b2544a11cb4aeb70d21 100644 (file)
@@ -71,11 +71,12 @@ function delete_fiscalyear($id)
        commit_transaction();
 }
 
-function is_date_in_fiscalyears($date)
+function is_date_in_fiscalyears($date, $closed=true)
 {
        $date = date2sql($date);
        $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE '$date' >= begin AND '$date' <= end";
-
+       if (!$closed)
+               $sql .= " AND closed=0";
        $result = db_query($sql, "could not get all fiscal years");
        return db_fetch($result) !== false;
 }
index 8fc1447a4c74cba52bed6e8ba8f81071569b43e4..d83c612a50655f674e2dd9ddd5780db8134e08a3 100644 (file)
@@ -35,7 +35,7 @@ function __date($year, $month, $day)
                $month = "0".$month;
        if ($how == 0)
                return $month.$sep.$day.$sep.$year;
-       else if ($how == 1)
+       elseif ($how == 1)
                return $day.$sep.$month.$sep.$year;
        else
                return $year.$sep.$month.$sep.$day;
@@ -105,7 +105,7 @@ function is_date($date_)
                global $date_system;
                if ($date_system == 1)
                        list($year, $month, $day) = jalali_to_gregorian($year, $month, $day);  
-               else if ($date_system == 2)     
+               elseif ($date_system == 2)      
                        list($year, $month, $day) = islamic_to_gregorian($year, $month, $day);  
                if (checkdate((int)$month, (int)$day, (int)$year))
                {
@@ -131,7 +131,7 @@ function Today()
        $day = date("j");
        if ($date_system == 1)
                list($year, $month, $day) = gregorian_to_jalali($year, $month, $day);
-       else if ($date_system == 2)     
+       elseif ($date_system == 2)      
                list($year, $month, $day) = gregorian_to_islamic($year, $month, $day);
        return __date($year, $month, $day);     
 }
@@ -162,6 +162,8 @@ function is_date_in_fiscalyear($date, $convert=false)
        global $path_to_root;
        include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
 
+       if ($_SESSION["wa_current_user"]->can_access(SA_FISCALYEAR)) // allow all open years for this one
+               return is_date_in_fixcalyears($date, false);
        $myrow = get_current_fiscalyear();
        if ($myrow['closed'] == 1)
                return 0;
@@ -202,7 +204,7 @@ function begin_month($date)
     list($day, $month, $year) = explode_date_to_dmy($date);
     if ($date_system == 1)
        list($year, $month, $day) = gregorian_to_jalali($year, $month, $day);
-    else if ($date_system == 2)        
+    elseif ($date_system == 2) 
        list($year, $month, $day) = gregorian_to_islamic($year, $month, $day);
        return __date($year, $month, 1);
 }
@@ -216,7 +218,7 @@ function end_month($date)
                list($year, $month, $day) = gregorian_to_jalali($year, $month, $day);
                $days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, ((((((($year - (($year > 0) ? 474 : 473)) % 2820) + 474) + 38) * 682) % 2816) < 682 ? 30 : 29));
        }
-       else if ($date_system == 2)
+       elseif ($date_system == 2)
        {
                list($year, $month, $day) = gregorian_to_islamic($year, $month, $day);
                $days_in_month = array(30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, (((((11 * $year) + 14) % 30) < 11) ? 30 : 29));
@@ -235,7 +237,7 @@ function add_days($date, $days) // accepts negative values as well
     {
        if ($date_system == 1)
                list($year, $month, $day) = gregorian_to_jalali(date("Y", $timet), date("n", $timet), date("j", $timet));
-       else if ($date_system == 2)     
+       elseif ($date_system == 2)      
                list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
        return __date($year, $month, $day);
     }
@@ -251,7 +253,7 @@ function add_months($date, $months) // accepts negative values as well
     {
        if ($date_system == 1)
                list($year, $month, $day) = gregorian_to_jalali(date("Y", $timet), date("n", $timet), date("j", $timet));
-       else if ($date_system == 2)     
+       elseif ($date_system == 2)      
                list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
        return __date($year, $month, $day);
     }
@@ -267,7 +269,7 @@ function add_years($date, $years) // accepts negative values as well
     {
        if ($date_system == 1)
                list($year, $month, $day) = gregorian_to_jalali(date("Y", $timet), date("n", $timet), date("j", $timet));
-       else if ($date_system == 2)     
+       elseif ($date_system == 2)      
                list($year, $month, $day) = gregorian_to_islamic(date("Y", $timet), date("n", $timet), date("j", $timet));
        return __date($year, $month, $day);
     }
@@ -299,7 +301,7 @@ function sql2date($date_)
        }
        if ($date_system == 1)
                list($year, $month, $day) = gregorian_to_jalali($year, $month, $day);
-       else if ($date_system == 2)
+       elseif ($date_system == 2)
                list($year, $month, $day) = gregorian_to_islamic($year, $month, $day);
        return __date($year, $month, $day);     
 } // end function sql2date
@@ -346,7 +348,7 @@ and converts to a yyyy/mm/dd format */
        }
        if ($date_system == 1)
                list($year, $month, $day) = jalali_to_gregorian($year, $month, $day); 
-       else if ($date_system == 2)
+       elseif ($date_system == 2)
                list($year, $month, $day) = islamic_to_gregorian($year, $month, $day); 
 
        // Pad with 0s if needed