apollodec/Apollo/api/application/models/DaybookMaster_model.php
venbatechnologies@gmail.com 61cf23e152 branch status issue fixed
2017-12-29 18:10:55 +05:30

116 lines
3.2 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: karthi
* Date: 12/26/17
* Time: 4:10 PM
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class DaybookMaster_model extends CI_Model {
/*
* add day book details
* created by kms
* */
public function addDetails($arrayDetails=null)
{
$this->db->select('TypeName');
$this->db->where('TypeName', $arrayDetails['TypeName']);
$this->db->where('TypeID', $arrayDetails['TypeID']);
if($this->db->get(INCOMEOUTCOMEMASTER)->first_row()){
$result['addStatus'] = false;
$result['message'] = "Name is already exist!";
} else {
$this->db->insert(INCOMEOUTCOMEMASTER, $arrayDetails);
if($this->db->affected_rows() == '1'){
$result['addStatus'] = true;
$result['message'] = "Successfully Day Book Master Details Added";
}
else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
return $result;
}
/*
* get day book details
* created by kms
* */
public function getDayBookDetails($requestedBy=null)
{
$this->db->select('IOM.ID,IOM.TypeName,IOM.TypeID,IOM.IsActive,PLD.ListName');
$this->db->from(INCOMEOUTCOMEMASTER .' as IOM');
$this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = IOM.TypeID');
$this->db->order_by('IOM.ID','DESC');
$details = $this->db->get();
if($details->result()){
$result['daybookStatus'] = true;
$result['details'] = $details->result();
}
else {
$result['daybookStatus'] = false;
$result['message'] = "No records found!";
}
$result['getDayBooktype'] = $this->getDayBookType('10');
return $result;
}
/*
* get day book type
* created by kms
* */
public function getDayBookType($typeID=null){
$this->db->select('ListCode,ListName');
$this->db->where('ListGroup', $typeID);
$typeDetails=$this->db->get(PICK_LIST_DETAILS);
return $typeDetails->result();
}
/*
* update day book details
* created by kms
* */
public function updateDayBook($arrayDetails=null)
{
$this->db->select('TypeName');
$this->db->where('TypeName', $arrayDetails['TypeName']);
$this->db->where('TypeID', $arrayDetails['TypeID']);
$this->db->where_not_in('ID', $arrayDetails['ID']);
if($this->db->get(INCOMEOUTCOMEMASTER)->first_row()){
$result['updateStatus'] = false;
$result['message'] = "Name is already exist!";
} else {
$this->db->where('ID',$arrayDetails['ID']);
$this->db->update(INCOMEOUTCOMEMASTER, $arrayDetails);
if($this->db->affected_rows() == '1'){
$result['updateStatus'] = true;
$result['message'] = "Successfully Day Book Details Updated";
}
else {
$result['updateStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
return $result;
}
}