Fixed multipart email structure.
[fa-stable.git] / admin / db / fiscalyears_db.inc
index cbd4784ee9de60787cf55abce2cc6f65b24e9e6c..ebf6d4773e6680f076282cd9b7e8e679848fdea7 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;
 }
@@ -159,13 +160,12 @@ function open_year($year)
 //---------------------------------------------------------------------------------------------
 function delete_attachments_and_comments($type_no, $trans_no)
 {
-       global $comp_path;
        
        $sql = "SELECT * FROM ".TB_PREF."attachments WHERE type_no = $type_no AND trans_no = $trans_no";
        $result = db_query($sql, "Could not retrieve attachments");
        while ($row = db_fetch($result))
        {
-               $dir =  $comp_path."/".user_company(). "/attachments";
+               $dir =  company_path(). "/attachments";
                if (file_exists($dir."/".$row['unique_name']))
                        unlink($dir."/".$row['unique_name']);
                $sql = "DELETE FROM ".TB_PREF."attachments WHERE  type_no = $type_no AND trans_no = $trans_no";
@@ -236,7 +236,7 @@ function delete_this_fiscalyear($selected_id)
        {
                if ($row['type'] == ST_SALESINVOICE)
                {
-                       $deliveries = get_parent_trans(ST_SALESINVOICE,$row['trans_no']);
+                       $deliveries = get_sales_parent_numbers($row['type'], $row['trans_no']);
                        foreach ($deliveries as $delivery)
                        {
                                $sql = "DELETE FROM ".TB_PREF."debtor_trans_details WHERE debtor_trans_no = $delivery AND debtor_trans_type = ".ST_CUSTDELIVERY;