apollodec/Apollo/api/application/models/Status_model.php
venbatechnologies@gmail.com d06b1c0cba status file
2017-12-07 11:31:25 +05:30

134 lines
3.5 KiB
PHP

<?php
/**
* Created by Visual Studio Code.
* User: Surendiran
* Date: 11/13/17
* Time: 8:03 PM
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Status_model extends CI_Model {
/*
* add status details
* params:StatusID,StatusName,activestatus
* created by Surendiran
* */
public function addstatus($arrayDetails=null)
{
$this->db->select('ListCode');
$this->db->where('ListGroup', '1');
$this->db->where('ListName', $arrayDetails['ListName']);
if($this->db->get(PICK_LIST_DETAILS)->first_row()){
$result['Status'] = false;
$result['message'] = "This Status Name is already exist!";
} else {
$this->db->insert(PICK_LIST_DETAILS, $arrayDetails);
if($this->db->affected_rows() == '1'){
$result['Status'] = true;
$result['message'] = "Successfully status Name is added";
}
else {
$result['Status'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
// $checkExistActivity = $this->db->get(PICK_LIST_DETAILS);
return $result;
}
/*
* get status details
* parama id
* created by Surendiran
* */
public function getStatus()
{
$this->db->select('ListCode,ListName,IsActive');
$this->db->where('ListGroup','1');
$this->db->order_by('ListCode','DESC');
$statusDetails = $this->db->get(PICK_LIST_DETAILS);
if($statusDetails->result()){
$result['Status'] = true;
$result['details'] = $statusDetails->result();
}
else {
$result['Status'] = false;
$result['message'] = "No records found!";
}
return $result;
}
/*
* update status details
* created by Surendiran
* */
public function update($arrayDetails=null,$ListCode=null)
// {
// $this->db->where('ListCode',$ListCode);
// $statusDetails=$this->db->update(PICK_LIST_DETAILS, $arrayDetails);
// if($statusDetails){
// $result['Status'] = true;
// $result['message'] = "Successfully status details updated";
// }
// else {
// $result['Status'] = false;
// $result['message'] = "Something went wrong.please try again";
// }
// return $result;
// }
{
$this->db->select('ListName');
$this->db->where('ListName', $arrayDetails['ListName']);
$this->db->where_not_in('ListCode', $ListCode);
if($this->db->get(PICK_LIST_DETAILS)->first_row()){
$result['Status'] = false;
$result['message'] = "This Status Name is already exist!";
} else {
$this->db->where('ListCode',$ListCode);
$this->db->update(PICK_LIST_DETAILS, $arrayDetails);
if($this->db->affected_rows() == '1'){
$result['Status'] = true;
$result['message'] = "Successfully status Name is updated";
}
else {
$result['Status'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
// $checkExistActivity = $this->db->get(PICK_LIST_DETAILS);
return $result;
}
}