205 lines
9.8 KiB
PHP
Executable File
205 lines
9.8 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class DayBook_model extends CI_Model
|
|
{
|
|
|
|
/*
|
|
* day book update details
|
|
* params:
|
|
* created by kdk
|
|
* */
|
|
|
|
// get income expense type lists
|
|
public function get_Income_Expense_typeState(){
|
|
$this->db->select('t1.ListCode, t1.ListName');
|
|
$this->db->from(''.PICK_LIST_DETAILS. ' as t1');
|
|
$this->db->where('t1.ListGroup', 10);
|
|
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
|
$typeDetails = $this->db->get();
|
|
$typeStateDetails = $typeDetails->result();
|
|
// TypeName details
|
|
$this->db->select('t2.TypeName, t2.TypeID, t2.ID');
|
|
$this->db->from(''.INCOMEOUTCOMEMASTER. ' as t2');
|
|
$this->db->where('t2.IsActive', 1);
|
|
|
|
$typeNaDetails = $this->db->get();
|
|
$typeNameDetails = $typeNaDetails->result();
|
|
|
|
$results['typeNameStatus'] = true;
|
|
$results['typeList'] = $typeStateDetails;
|
|
$results['typeNameList'] = $typeNameDetails;
|
|
return $results;
|
|
}
|
|
|
|
public function emp_day_book_AccessChk($arr) {
|
|
$id = $arr['localUserID'];
|
|
$sql1 = "SELECT t1.FinanceModuleAccess FROM ".STAFF." as t1 LEFT JOIN ".LOGIN." as t2 ON t2.StaffID = t1.StaffID WHERE t2.id = $id";
|
|
// update branch to staff_branch table
|
|
$dayBookAccDetails = $this->db->query($sql1);
|
|
$dayBkAcesDetail = $dayBookAccDetails->result();
|
|
$result['dayBkAccessChkStatus'] = true;
|
|
$result['dayBkAccessChk_Value'] = $dayBkAcesDetail[0]->FinanceModuleAccess;
|
|
// echo $result['dayBkAccessChk_Value'];exit();
|
|
return $result;
|
|
}
|
|
|
|
public function get_Daybook_Details_List($reqData, $reqDataBy) {
|
|
|
|
if($reqData['date'] != '' && $reqData['dateTo'] != '') {
|
|
// $this->db->select('t1.*, t2.ListName, t3.TypeName');
|
|
// $this->db->from(''.DAYBOOKMASTER. ' as t1');
|
|
// $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
|
|
// $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
|
|
|
|
$d = new DateTime($reqData['date']);
|
|
$dTo = new DateTime($reqData['dateTo']);
|
|
$fromDate = $d->format('Y-m-d');
|
|
$toDate = $dTo->format('Y-m-d');
|
|
$reqpayType = $reqDataBy['localBranchID'];
|
|
|
|
$querys = "SELECT t1.*, t2.ListName, t3.TypeName , t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
|
|
LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
|
|
WHERE STR_TO_DATE(t1.Date, '%d-%m-%Y') BETWEEN '$fromDate'
|
|
AND '$toDate' AND t1.BranchCode = '$reqpayType' ORDER BY CreatedOn DESC";
|
|
|
|
// $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $fromDate);
|
|
// $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $toDate);
|
|
// $this->db->where('t1.Date', $reqData['date']);
|
|
// $this->db->order_by('CreatedOn', 'DESC');
|
|
// $this->db->where('t1.BranchCode', $reqDataBy['localBranchID']);
|
|
|
|
} else {
|
|
// $this->db->select('t1.*, t2.ListName, t3.TypeName');
|
|
// $this->db->from(''.DAYBOOKMASTER. ' as t1');
|
|
// $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
|
|
// $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
|
|
// // $this->db->where('t1.Date', $reqData['date']);
|
|
// $this->db->order_by('CreatedOn', 'DESC');
|
|
// $this->db->where('t1.BranchCode', $reqDataBy['localBranchID']);
|
|
$reqpayType = $reqDataBy['localBranchID'];
|
|
$querys = "SELECT t1.*, t2.ListName, t3.TypeName, t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
|
|
LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
|
|
WHERE t1.BranchCode = '$reqpayType' ORDER BY CreatedOn DESC";
|
|
}
|
|
|
|
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
|
$dayBookDetails = $this->db->query($querys);
|
|
$dayBookDetailsList = $dayBookDetails->result();
|
|
$results['dayBookListStatus'] = true;
|
|
$results['dayBookListDetails'] = $dayBookDetailsList;
|
|
return $results;
|
|
}
|
|
|
|
public function delete_dayBookDetails($id) {
|
|
|
|
$sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE ID ='$id'";
|
|
// update branch to staff_branch table
|
|
if ($this->db->query($sql1) == '1') {
|
|
$result['deletedStatus'] = true;
|
|
$result['message'] = "Entry is Deleted";
|
|
} else {
|
|
$result['deletedStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function update_dayBookDetails($Arr, $upFor) {
|
|
$this->db->where('ID', $upFor);
|
|
$this->db->update(DAYBOOKMASTER, $Arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['updateDetailsStatus'] = true;
|
|
$result['message'] = "Successfully Details Updated";
|
|
} else {
|
|
$result['updateDetailsStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// add dayBook
|
|
public function add_dayBook($Arr)
|
|
{
|
|
$this->db->insert(DAYBOOKMASTER, $Arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['addDayBookStatus'] = true;
|
|
$result['message'] = "Successfully DayBook Details Added";
|
|
|
|
} else {
|
|
$result['addDayBookStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function update_status_admin($arr) {
|
|
|
|
$Approval_By = $arr[0]['Approval_By'];
|
|
$Approval_Comments = $arr[0]['Approval_Comments'];
|
|
$UpdatedBy = $arr[0]['UpdatedBy'];
|
|
$UpdatedOn = $arr[0]['UpdatedOn'];
|
|
$status = $arr[0]['Status'];
|
|
$number = array();
|
|
foreach($arr as $ar){
|
|
array_push($number, $ar['ID']);
|
|
}
|
|
$updateFor = implode(',', $number);
|
|
|
|
$sql = "UPDATE ".DAYBOOKMASTER."
|
|
SET Status = '$status', Approval_By = '$Approval_By' ,
|
|
Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn'
|
|
WHERE id IN ($updateFor)";
|
|
$mBranchDetails = $this->db->query($sql);
|
|
// echo $mBranchDetails;
|
|
// echo $this->db->affected_rows(); exit();
|
|
if ($this->db->affected_rows() >= 1) {
|
|
$result['addStatus'] = true;
|
|
$result['message'] = "Successfully Details Updated";
|
|
} else {
|
|
$result['addStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function get_Daybook_Details_List_superAdmin($reqData, $reqDataBy){
|
|
|
|
if($reqData['date'] != '' && $reqData['dateTo'] != '') {
|
|
$this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName, t6.Firstname as Approved_by_name ');
|
|
$this->db->from(''.DAYBOOKMASTER. ' as t1');
|
|
$this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
|
|
$this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
|
|
$this->db->join('' . BRANCH . ' as t4', 't4.BranchCode = t1.BranchCode', 'LEFT');
|
|
$this->db->join('' . LOGIN . ' as t5', 't5.ID = t1.Approval_By', 'LEFT');
|
|
$this->db->join('' . STAFF . ' as t6', 't6.StaffID = t5.StaffID', 'LEFT');
|
|
$this->db->where('t1.Date >=', $reqData['date']);
|
|
$this->db->where('t1.Date <=', $reqData['dateTo']);
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
|
$dayBookDetails = $this->db->get();
|
|
$dayBookDetailsList = $dayBookDetails->result();
|
|
} else {
|
|
$this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName, t6.Firstname as Approved_by_name ');
|
|
$this->db->from(''.DAYBOOKMASTER. ' as t1');
|
|
$this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT');
|
|
$this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT');
|
|
$this->db->join('' . BRANCH . ' as t4', 't4.BranchCode = t1.BranchCode', 'LEFT');
|
|
$this->db->join('' . LOGIN . ' as t5', 't5.ID = t1.Approval_By', 'LEFT');
|
|
$this->db->join('' . STAFF . ' as t6', 't6.StaffID = t5.StaffID', 'LEFT');
|
|
// $this->db->where('t1.Date', $reqData['date']);
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
|
$dayBookDetails = $this->db->get();
|
|
$dayBookDetailsList = $dayBookDetails->result();
|
|
}
|
|
|
|
$results['dayBookListStatus'] = true;
|
|
$results['dayBookListDetails'] = $dayBookDetailsList;
|
|
return $results;
|
|
}
|
|
} |