0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
ACCOUNTS
/
[
Home
]
File: ac_ajax.php
<?php require_once "ac_models.php"; $functions = array('get_debit_head',"get_budget_forms","get_voucher_details","update_voucher_details","update_voucher_status","get_budget_forms_with_bh"); $f =@$_POST['f']; if(!empty($f) && in_array($f, $functions) ) { $func = $f; $func(); } function get_debit_head(){ $project_id = @$_POST['project_id']; $result['budget_head'] = Ac_Models::getBudgetHead($project_id); $result['installment'] = Ac_Models::getInstallmentDetails($project_id); echo json_encode($result); } function get_budget_forms(){ $data = @$_POST['data']; $project_id = $data[0]['value']; $date_range = $data[1]['value']; $status = $data[2]['value']; $project_id = ($project_id == 0) ? "All" : $project_id; $from = $to = ""; if(!empty($date_range)){ $date_range = explode("-", $date_range); $from = date("Y-m-d",strtotime(trim($date_range[0]))); $to = date("Y-m-d",strtotime(trim($date_range[1]))); } echo json_encode(Ac_Models::getBudgetForm($project_id,$from,$to,$status)); } function get_voucher_details(){ $id = @$_POST['voucher_id']; $voucher = Ac_Models::getBudgetFormById($id); $data =array(); if(!empty($voucher)){ $data['status']= TRUE; $arr['name'] = $voucher->name; $arr['invoice_date'] = isset($voucher->invoice_date) && !empty($voucher->invoice_date) ? date("m/d/Y",strtotime($voucher->invoice_date)) :""; $arr['invoice_number'] = $voucher->invoice_number; $arr['amount'] = $voucher->amount; $arr['bh_head_id'] = $voucher->bh_head_id; $project_details = CommonModel::getProjects(); $data['data'] = requireToVar("ac_edit_voucher_modal.php",$arr); }else{ $data['status']= FALSE; } echo json_encode($data); } function requireToVar($file,$arr){ ob_start(); require($file); return ob_get_clean(); } function update_voucher_details(){ $post = $_POST; $data = array(); $voucher_id = $post['voucher_id']; $response= array(); $response['status']= false; if(isset($post['data'])){ $data['name'] = $post['data']['name']; $data['amount'] = $post['data']['amount']; if(isset($post['data']['invoice_date']) && !empty($post['data']['invoice_date'])) $data['invoice_date'] = date("Y-m-d" ,strtotime($post['data']['invoice_date']) ) ; if(isset($post['data']['invoice_number']) && !empty($post['data']['invoice_number'])) $data['invoice_number'] = $post['data']['invoice_number']; $data['modified_date_accounts'] = date("Y-m-d H:i:s"); $post['date_current'] = date("Y-m-d"); $response['status']= Ac_Models::editBudgetHead($voucher_id,$data); } echo json_encode($response); } function update_voucher_status(){ $budget_id = @$_POST['budget_id']; $remarks = @$_POST['remarks']; $type = @$_POST['type']; if(Ac_Models::update_voucher_status($budget_id,$type,$remarks)){ $statusArray['status'] = true; }else{ $statusArray['status'] = false; $statusArray['error']="Some error occured, Try again"; } echo json_encode($statusArray); } function get_budget_forms_with_bh(){ $data = @$_POST['data']; $date_range = $data[0]['value']; $budget_head = $data[1]['value']; $from = $to = ""; if(!empty($date_range)){ $date_range = explode("-", $date_range); $from = date("Y-m-d",strtotime(trim($date_range[0]))); $to = date("Y-m-d",strtotime(trim($date_range[1]))); } $arr = Ac_Models::getBudgetFormWithBudgetHead($from,$to,$budget_head); $data = array(); if(!empty($arr)){ $data['html'] = requireToVar("voucher_details_row.php",$arr); $data["status"] =TRUE; }else{ $data["status"] =FALSE; } echo json_encode($data); } ?>