Avoiding redundant passes in Fiscal Year deletion.
authorJoe <unknown>
Tue, 10 Dec 2013 07:21:07 +0000 (08:21 +0100)
committerJoe <unknown>
Tue, 10 Dec 2013 07:21:07 +0000 (08:21 +0100)
admin/db/fiscalyears_db.inc

index c605c064d2b0aae5bd7abdf9d541ea1f304f99ee..29e826dc2cfde0cd65ca1ee835176a3551ae2d7f 100644 (file)
@@ -190,11 +190,16 @@ function delete_attachments_and_comments($type_no, $trans_no)
        
        $sql = "SELECT * FROM ".TB_PREF."attachments WHERE type_no = $type_no AND trans_no = $trans_no";
        $result = db_query($sql, "Could not retrieve attachments");
+       $delflag = false;
        while ($row = db_fetch($result))
        {
+               $delflag = true;
                $dir =  company_path(). "/attachments";
                if (file_exists($dir."/".$row['unique_name']))
                        unlink($dir."/".$row['unique_name']);
+       }
+       if ($delflag)
+       {
                $sql = "DELETE FROM ".TB_PREF."attachments WHERE  type_no = $type_no AND trans_no = $trans_no";
                db_query($sql, "Could not delete attachment");
        }