0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
SO
/
[
Home
]
File: ed_models.php
<?php require_once "../lib/config.php"; include_once BASE_DIR."/lib/db/connection.php"; require_once BASE_DIR."/lib/db/DBConnection.php"; include_once("../model/defaults_mdl.php"); class Ed_Models { protected $con; public function getBudgetHead($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select a.id as id,mas.name as name,mas.type as master_debit from tab_budget_head a" ." JOIN tab_budget_head_master mas ON a.budget_head_id = mas.id" ." where project_id='$project_id' "; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } public function addBudgetHead($data){ if(!self::insert("tab_budget_form",$data)){ return FALSE; }else{ return TRUE; } } public function getLastBudgetForm(){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select * from tab_budget_form where status = 'PENDING' AND created_by = '$u_id' order by id desc limit 1"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_object($sql)){ $arr = $row; } } }catch( Exception $ex){ } return $arr; } public function getBudgetForm($project_id,$from,$to,$status){ $arr = array(); $mult_st = ""; if(!empty($status) && $status != "All"){ $st = explode(",", $status); foreach ($st as $kk=>$ss) { $st[$kk] = "bf.status = '$ss'"; } $mult_st= " (".implode(" OR ", $st)." ) AND "; }else{ $$mult_st= " bf.status <> 'DELETED' AND"; } // echo $mult_st; $status_clause = $mult_st; $project_clause = (!empty($project_id) && $project_id != "All") ? " P.project_id='$project_id' AND " : " "; try{ $u_id=@$_SESSION['user_id']; $sql="select *,bh.id as id,bf.name sup_name,bf.amount,bfm.name as debit_head,LOWER(bf.status) as status, " . " DATE_FORMAT(bf.date_current ,'%d-%b-%Y') as created_on,bf.id AS id,inst.name as installment," . " IF( '0000-00-00' = bf.invoice_date OR '1970-01-01'=bf.invoice_date , ' ',bf.invoice_date ) as invoice_date " ." , GREATEST(DATE_FORMAT(bf.date_current ,'%d-%b-%Y'), COALESCE(DATE_FORMAT(bf.modified_on ,'%d-%b-%Y'), 0), COALESCE(" ." DATE_FORMAT(bf.modified_date_accounts ,'%d-%b-%Y'), 0)) as created_on " . " ,U.name as created_by from tab_budget_form bf " . " JOIN tab_budget_head bh ON bf.debit_head = bh.id " . " JOIN addproject P ON p.project_id = bf.project_id" . " LEFT OUTER JOIN tab_budget_head_master bfm ON bh.budget_head_id = bfm.id " . " LEFT OUTER JOIN tab_project_installment inst ON inst.id= bf.installment_id" . " LEFT OUTER JOIN user U ON U.user_id= bf.created_by" . " LEFT OUTER JOIN user UU ON FIND_IN_SET(P.fundtype, UU.accounts_type) AND UU.is_admin = 2 " . " where $project_clause"; if(!empty($from) && !empty($to)){ $sql.= " bf.date_current >='$from' AND bf.date_current <='$to' AND"; } $sql.= "$status_clause bf.created_by IN ($u_id,UU.user_id) AND P.user_id = $u_id AND bf.status <> 'DELETED' ORDER BY bf.id DESC"; // echo $sql; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } public function getBudgetFormById($id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select *,a.amount as amount,mas.type as bh_head_id," . " IF( '0000-00-00' = a.invoice_date OR '1970-01-01'=a.invoice_date , '',a.invoice_date ) as invoice_date , a.name as name from tab_budget_form a " ." JOIN tab_budget_head bh ON bh.id = a.debit_head " ." JOIN tab_budget_head_master mas ON mas.id = bh.budget_head_id " ." where a.id = '$id' AND a.created_by = '$u_id' AND a.status IN ('PENDING' , 'DECLINED')"; // echo "$sq/l"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_object($sql)){ $arr = $row; } } }catch( Exception $ex){ } return $arr; } public function editBudgetHead($id,$post){ if(!self::update("tab_budget_form",$post,"id = '$id' ")){ return FALSE; }else{ return TRUE; } } public function getBudgetHeadsForAProject($project_id){ $arr = array(); $count = 0; try{ $sql="select TBH.id as id ,TBHM.name as name FROM addproject a " ." JOIN tab_budget_head TBH ON tbh.project_id = a.project_id " ." JOIN tab_budget_head_master TBHM ON tbh.budget_head_id = TBHM.id where a.project_id = $project_id"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_object($sql)){ $arr[] = $row; } } $sql="select count(*) as cnt from addproject a" ." JOIN tab_project_installment inst ON inst.project_id = a.project_id " ." WHERE a.project_id = $project_id"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_object($sql)){ $count = $row->cnt; } } }catch( Exception $ex){ } return array("iterate" =>$arr, "count"=>$count); } public function addInstallment($project_id,$data,$name){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $date = date("Y-m-d H:i:s"); $conn = DBConnection::getConnect(); $key = array_keys($data); $value = array_values($data); $flag = TRUE; $sql ="INSERT INTO tab_project_installment (`project_id`, `name`, `created_on`, `created_by`) " ." VALUES('$project_id','$name','$date',$u_id) "; if ($conn->query($sql) === TRUE){ $last_id = $conn->insert_id; // echo $last_id; foreach ($data as $vv) { $budget_head_id = $vv['id'] ; $amount = $vv['v'] ; $query ="INSERT INTO tab_project_installment_details ( `installment_id`, `budget_head_id`, `amount`) " . " VALUES($last_id,$budget_head_id,'$amount')"; if ($conn->query($query) === TRUE){ }else{ // echo "Error: " . $query . "<br>" . $conn->error; $flag = FALSE; } } }else { // echo "Error: " . $sql . "<br>" . $conn->error; $flag = FALSE; } }catch( Exception $ex){ $flag = FALSE; } $st['status'] = $flag; return $st; } public function getInstallmentDetails($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select id,name from tab_project_installment " ." where project_id='$project_id' AND created_by = $u_id Order by id desc limit 1"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr = $row; } } }catch( Exception $ex){ } return $arr; } public function getProjectDetails($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $Columns = " p.project_code,MFT.name as fundtype, DATE_FORMAT(p.startdate ,'%d-%b-%Y') as startdate, DATE_FORMAT(p.end_date ,'%d-%b-%Y') as end_date,p.project_outlay,p.duration , p.project_id,p.project_title,p.duration,p.fundagency,P.investigators,CONCAT(U.salutation,U.name) as name, (SELECT GROUP_CONCAT(' ', CONCAT(UU.salutation,' ',UU.name)) from user as UU WHERE FIND_IN_SET(UU.user_id,(P.co_pi)) ) as co_pi,p.fundtype as fund_type_id" ; $sql="Select $Columns from addproject P " ." JOIN tab_master_fund_type MFT ON p.fundtype = MFT.id" ." JOIN user U ON p.user_id = U.user_id" ." " ." where P.project_id='$project_id' GROUP BY P.project_id "; // echo $sql; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr = $row; } } }catch( Exception $ex){ } return $arr; } public function getProjectInstallment($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select I.id,I.project_id,I.name AS installment_name,BHM.name debit_name,II.amount as amount,BHM.id as bhm_id from tab_project_installment I " ." JOIN tab_project_installment_details II ON II.installment_id = I.id" ." JOIN tab_budget_head BH ON BH.id = II.budget_head_id " ." JOIN tab_budget_head_master BHM ON BHM.id = BH.budget_head_id " ." where I.project_id='$project_id' AND I.created_by = $u_id"; // echo "$sql"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[$row['id']][]= $row; } } }catch( Exception $ex){ } return $arr; } public function getProjectOutlay($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select * from project_total_outlay " ." " ." " ." where project_id='$project_id' AND created_by = $u_id"; // echo "$sql"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } public function getProjectBudgetHead($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select BHM.name,BH.amount , BH.budget_head_id from tab_budget_head BH " ." JOIN tab_budget_head_master BHM ON BH.budget_head_id = BHM.id" ." " ." where BH.project_id='$project_id' AND BH.created_by = $u_id"; // echo "$sql"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } // --------------------------CORE FUNCTIONS public function insert($table, $data){ try { $key = array_keys($data); $value = array_values($data); $query ="INSERT INTO $table ( ". implode(',' , $key) .") VALUES('". implode("','" , $value) ."')"; // echo $query; $sql = mysql_query($query); if(mysql_affected_rows() >0){ return TRUE; }else{ return FALSE; } } catch (Exception $e) { return FALSE; } } function update($table, $data, $where){ try{ $cols = array(); foreach($data as $key=>$val) { $cols[] = "$key = '$val'"; } $sql = "UPDATE $table SET " . implode(', ', $cols) . " WHERE $where"; if (mysql_query($sql)) { return TRUE; } else { return FALSE; } } catch (Exception $e) { return FALSE; } } // Amal COde public function insertQuery($query){ try { $sql = mysql_query($query); if(mysql_affected_rows() >0){ return TRUE; }else{ return FALSE; } } catch (Exception $e) { return FALSE; } } public function insertAdv($table, $data){ try { $key = array_keys($data); $value = array_values($data); $query ="INSERT INTO $table ( ". implode(',' , $key) .") VALUES('". implode("','" , $value) ."')"; $sql = mysql_query($query); $lastInserted = mysql_insert_id(); if(mysql_affected_rows() >0){ return $lastInserted; }else{ return 0; } } catch (Exception $e) { return $e; } } public function addProject($data){ $project_id = self::insertAdv("addproject",$data); return $project_id; } public function addProjectTotalOutLay($data){ $query = 'insert into project_total_outlay ( amount, project_id,created_on, created_by, modified_on, modified_by ) values'.implode(',', $data); // echo "query : ". $query; $status = self::insertQuery($query); return $status; } public function addProjectBudgetDetails($data){ $query = 'insert into tab_budget_head ( project_id, budget_head_id, amount, created_on, created_by ) values '.implode(',', $data); // echo "query : ". $query; $arr = array(); foreach ($data as $value) { $id = self::insertAdv("tab_budget_head",$value); $arr[$value['budget_head_id']] = $id; } //print_r($arr); return $arr; } public function getAllFundTypes(){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="Select id,name from tab_master_fund_type" ; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } public function verifyPendingBudgetForms($budget_id){ $post = array("status" =>"VERIFIED"); if(!self::update("tab_budget_form",$post,"id IN ($budget_id) AND created_by = ".@$_SESSION['user_id'])){ return FALSE; }else{ return TRUE; } } public function getAllMasterBudgetHeads(){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="Select *,DATE_FORMAT(created_on ,'%d-%b-%Y') as created_on from tab_budget_head_master LIMIT 50" ; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } public function getBudgetSummary($project_id,$start_date,$end_date){ $summary = array(); $summary['installment_details'] = self::getProjectInstallmentTotal($project_id,$start_date,$end_date); $summary['received_funds'] = self::getInstallmentTotal($project_id,$start_date,$end_date); $summary['voucher_details'] = self::getVouchers($project_id,$start_date,$end_date); $summary['project_details'] = self::getProjectDetails($project_id); $summary['project_outlay'] = self::getProjectOutlayDetails($project_id); return $summary; } public function getProjectOutlayDetails($project_id){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="SELECT * from project_total_outlay WHERE project_id =$project_id "; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } public function getInstallmentTotal($project_id,$start_date,$end_date){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select I.id,I.project_id,I.name AS installment_name,sum(II.amount) as amount , case when DATE(I.created_on) BETWEEN '$start_date' AND '$end_date' then 1 else 0 end as is_show from tab_project_installment I " ." JOIN tab_project_installment_details II ON II.installment_id = I.id" ." JOIN tab_budget_head BH ON BH.id = II.budget_head_id " ." where I.project_id='$project_id' group by II.installment_id"; // echo "$sql"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[]= $row; } } }catch( Exception $ex){ } return $arr; } public function getVouchers($project_id,$start_date,$end_date){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="Select sum(TBF.amount) as amount,Bh.id as debit_head, BHM.name as debit_name,BHM.id as bhm_id from tab_budget_form TBF " ." JOIN tab_budget_head BH ON BH.id = TBF.debit_head" ." JOIN tab_budget_head_master BHM ON BHM.id = BH.budget_head_id" ." WHERE TBF.status ='ACCEPTED' " ." AND DATE(TBF.date_current) BETWEEN '$start_date' AND '$end_date' AND TBF.project_id = $project_id " ." group by TBF.debit_head ORDER BY BHM.id"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[$row['bhm_id']] = $row; } } }catch( Exception $ex){ } return $arr; } public function getProjectInstallmentTotal($project_id,$start_date,$end_date){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select I.id,I.project_id,I.name AS installment_name,BHM.name debit_name,SUM(II.amount) as amount,BHM.id as bhm_id from tab_project_installment I " ." JOIN tab_project_installment_details II ON II.installment_id = I.id" ." JOIN tab_budget_head BH ON BH.id = II.budget_head_id " ." JOIN tab_budget_head_master BHM ON BHM.id = BH.budget_head_id " ." where I.project_id='$project_id' AND " ." DATE(I.created_on) BETWEEN '$start_date' AND '$end_date' " ." group by II.budget_head_id ORDER BY BHM.id"; // echo "$sql"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ // $arr[$row['id']][]= $row; $arr[]= $row; } } }catch( Exception $ex){ } return $arr; } public function get_uc_details($project_id,$start_date,$end_date){ $to = date('Y-m-d',strtotime($start_date . "-1 days")); $arr['opening_balance'] = self::getUc($project_id,NULL,$to); $cu_from = date('Y-m-d',strtotime($start_date)); $cu_to = date('Y-m-d',strtotime($end_date)); $arr['current_balance'] = self::getUc($project_id,$cu_from,$cu_to); $arr['project_details'] = self::getProjectDetails($project_id); $arr['date'] = array('start_date' => getFisc()->start, "end_date" => getFisc()->today ); // echo "<pre>"; // print_r($arr); // echo "</pre>"; return $arr; } public function getUc($project_id, $from,$to){ $arr['installment_total'] = self::getProjectInstallmentTotalSUM($project_id,$from,$to); $arr['vouchers_sum'] = self::getVouchersSUM($project_id,$from,$to); return $arr; } public function getProjectInstallmentTotalSUM($project_id,$from,$to){ $arr = array(); $from = is_null($from) ? "P.startdate" : "'$from'"; try{ $u_id=@$_SESSION['user_id']; $sql="select I.id,I.project_id,I.name AS installment_name,SUM(II.amount) as amount from " ." tab_project_installment I JOIN addproject P ON P.project_id = I.project_id" ." JOIN tab_project_installment_details II ON II.installment_id = I.id" ." where I.project_id='$project_id' AND I.created_by = $u_id AND " ." DATE(I.created_on) BETWEEN $from AND '$to' " ." group by P.project_id"; $sql="select SUM(II.amount) as amount from " ." tab_project_installment I JOIN addproject P ON P.project_id = I.project_id" ." JOIN tab_project_installment_details II ON II.installment_id = I.id" ." where I.project_id='$project_id' AND I.created_by = $u_id AND " ." DATE(I.created_on) BETWEEN $from AND '$to' " ." group by P.project_id"; // echo $sql. "<br>"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ // $arr[$row['id']][]= $row; $arr= $row; } } }catch( Exception $ex){ } return $arr; } public function getVouchersSUM($project_id,$from,$to){ $arr = array(); $result = array(); $sum = 0; try{ $u_id=@$_SESSION['user_id']; $sql="Select IFNULL(sum(TBF.amount),0) as amount,TBHM.id as bhm_id, TBHM.name as bhm_name from tab_budget_form TBF " ." JOIN tab_budget_head TBH ON TBH.id= TBF.debit_head " ." JOIN tab_budget_head_master TBHM ON TBHM.id= TBH.budget_head_id " ." WHERE TBF.status ='ACCEPTED' AND DATE(TBF.date_current) BETWEEN '$from' AND '$to' " . " AND TBF.project_id = $project_id group by TBHM.id order by bhm_id asc"; // echo $sql; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ if(!empty($row['bhm_id'])){ $sum+= $row['amount']; $arr[] = $row; } } } }catch( Exception $ex){ } $result['amount'] = $sum; $result['details'] = $arr; return $result; } public function updateProject($project_id,$data){ if(!self::update("addproject",$data," project_id = '$project_id' ")) { return FALSE; }else{ return TRUE; } } public function saveProjectOutlayHistory($project_id,$outlay,$created_on){ $data = array(); $data["project_id"] = $project_id; $data["total_outlay"] = $outlay; $data["created_on"] = $created_on; if(!self::insert("project_outlay_history",$data)) { return FALSE; }else{ return TRUE; } } // Total summary public function getBudgetSummaryTotal($start_date,$end_date,$fund_type){ $summary = array(); $project_id = 0; $summary['installment_details'] = self::getInstallmentTotal_total($project_id,$start_date,$end_date,$fund_type); $summary['voucher_details'] = self::getVouchers_total($project_id,$start_date,$end_date,$fund_type); return $summary; } public function getInstallmentTotal_total($project_id,$start_date,$end_date,$fund_type){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $fund = ($fund_type==0) ? "" : "AND P.fundtype='$fund_type' "; $sql="select I.id,I.project_id,I.name AS installment_name,sum(II.amount) as amount, I.created_on , P.project_title, P.project_code, FT.name as fund_type, (SELECT GROUP_CONCAT(' ', CONCAT(UU.salutation,' ',UU.name)) from user as UU WHERE FIND_IN_SET(UU.user_id,(CONCAT(P.user_id,',',COALESCE(P.co_pi, '')))) ) as co_pi from tab_project_installment I JOIN tab_project_installment_details II ON II.installment_id = I.id JOIN tab_budget_head BH ON BH.id = II.budget_head_id JOIN addproject P ON p.project_id= I.project_id JOIN tab_master_fund_type FT on P.fundtype= FT.id WHERE DATE(I.created_on) BETWEEN '$start_date' AND '$end_date' $fund group by I.project_id"; // echo "$sql <br>"; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[$row['project_id']] = $row; } } }catch( Exception $ex){ } return $arr; } public function getVouchers_total($project_id,$start_date,$end_date,$fund_type){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $fund = ($fund_type==0) ? "" : "AND P.fundtype='$fund_type' "; $sql="Select TBF.project_id,SUM(TBF.amount) as amount,Bh.id as debit_head, BHM.name as debit_name,BHM.id as bhm_id ,TBF.date_current , P.project_title, P.project_code,FT.name as fund_type, (SELECT GROUP_CONCAT(' ', CONCAT(UU.salutation,' ',UU.name)) from user as UU WHERE FIND_IN_SET(UU.user_id,(CONCAT(P.user_id,',',COALESCE(P.co_pi, '')))) ) as co_pi from tab_budget_form TBF JOIN tab_budget_head BH ON BH.id = TBF.debit_head JOIN tab_budget_head_master BHM ON BHM.id = BH.budget_head_id JOIN addproject P ON p.project_id= TBF.project_id JOIN tab_master_fund_type FT on P.fundtype= FT.id WHERE TBF.status ='ACCEPTED' AND DATE(TBF.date_current) BETWEEN '2017-01-17' AND '2017-03-26' $fund group by TBF.project_id ORDER BY BHM.id"; // echo $sql; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[$row['project_id']] = $row; } } }catch( Exception $ex){ } return $arr; } public function getBudgetFormWithBudgetHead($from,$to,$budget_head){ $arr = array(); try{ $u_id=@$_SESSION['user_id']; $sql="select *,bh.id as id,bf.name sup_name,bf.amount,bfm.name as debit_head,LOWER(bf.status) as status, " . " DATE_FORMAT(bf.date_current ,'%d-%b-%Y') as created_on,bf.id AS id,inst.name as installment," . " IF( '0000-00-00' = bf.invoice_date OR '1970-01-01'=bf.invoice_date , ' ',bf.invoice_date ) as invoice_date " ." , DATE_FORMAT(bf.date_current ,'%d-%b-%Y') as created_on " . " ,bf.remarks,UU.name as created_by from tab_budget_form bf " . " JOIN tab_budget_head bh ON bf.debit_head = bh.id " . " JOIN addproject P ON p.project_id = bf.project_id" . " LEFT OUTER JOIN tab_budget_head_master bfm ON bh.budget_head_id = bfm.id " . " LEFT OUTER JOIN tab_project_installment inst ON inst.id= bf.installment_id" . " JOIN user UU ON UU.user_id= bf.created_by" . " where "; if(!empty($from) && !empty($to)){ $sql.= " bf.date_current >='$from' AND bf.date_current <='$to' AND "; } $sql.= " bfm.id=$budget_head AND bf.status = 'ACCEPTED' GROUP BY bf.id ORDER BY bf.id DESC"; // echo $sql; $sql = mysql_query($sql); if (mysql_num_rows($sql)>0){ while($row=mysql_fetch_assoc($sql)){ $arr[] = $row; } } }catch( Exception $ex){ } return $arr; } } ?>