return db_fetch($result) !== false;
}
+function get_fiscalyear_begin_for_date($date)
+{
+ $date = date2sql($date);
+ $sql = "SELECT begin FROM ".TB_PREF."fiscal_year WHERE '$date' >= begin AND '$date' <= end";
+ $result = db_query($sql, "could not get begin date of the fiscal year");
+ $row = db_fetch_row($result);
+ if ($row != false)
+ return sql2date($row[0]);
+ else
+ return begin_fiscalyear();
+}
+
function check_begin_end_date($date1, $date2)
{
$sql = "SELECT MAX(end), MIN(begin) FROM ".TB_PREF."fiscal_year";
include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
$begin = "";
else
{
- $begin = begin_fiscalyear();
+ $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
if (date1_greater_date2($begin, $_POST['TransFromDate']))
$begin = $_POST['TransFromDate'];
$begin = add_days($begin, -1);
//Get Accounts directly under this group/type
$accounts = get_gl_accounts(null, null, $type);
- $begin = begin_fiscalyear();
+ $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
+ //$begin = begin_fiscalyear();
if (date1_greater_date2($begin, $_POST['TransFromDate']))
$begin = $_POST['TransFromDate'];
$begin = add_days($begin, -1);
$path_to_root="..";
include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
$begin = "";
else
{
- $begin = begin_fiscalyear();
+ $begin = get_fiscalyear_begin_for_date($from);
if (date1_greater_date2($begin, $from))
$begin = $from;
$begin = add_days($begin, -1);
$path_to_root="..";
include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/data_checks.inc");
//Get Accounts directly under this group/type
$accounts = get_gl_accounts(null, null, $type);
- $begin = begin_fiscalyear();
+ $begin = get_fiscalyear_begin_for_date($from);
if (date1_greater_date2($begin, $from))
$begin = $from;
$begin = add_days($begin, -1);