139 lines
3.4 KiB
PHP
Executable File
139 lines
3.4 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Test_model extends CI_model {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->database();
|
|
}
|
|
|
|
function name_list(){
|
|
$this->db->order_by('id', 'DESC');
|
|
$query = $this->db->get('master_schedule');
|
|
|
|
return $query->result();
|
|
}
|
|
|
|
function save_name($post) {
|
|
|
|
$slot_name = $post['slot_name'];
|
|
|
|
$data = array(
|
|
'week_day' => $post['slot_week_day'],
|
|
'from_time' => $post['slot_from_time'],
|
|
'to_time' => $post['slot_to_time'],
|
|
);
|
|
|
|
$this->db->insert('master_schedule', $data);
|
|
}
|
|
function delete_name($id)
|
|
{
|
|
$this->db->where('id', $id);
|
|
$this->db->delete('master_schedule');
|
|
}
|
|
function edit_name($post,$id){
|
|
$data = array(
|
|
'week_day' => $post['slot_week_day'],
|
|
'from_time' => $post['slot_from_time'],
|
|
'to_time' => $post['slot_to_time'],
|
|
);
|
|
|
|
$this->db->where('id', $id);
|
|
$this->db->update('master_schedule', $data);
|
|
}
|
|
|
|
function duplicate_entry($post)
|
|
{
|
|
$val = $post['val'];
|
|
|
|
if (isset($post['currId'])) {
|
|
$currId = $post['currId'];
|
|
|
|
$query1 = $this->db->get_where('master_schedule', array('id' => $currId));
|
|
$exceptVal = $query1->result()[0]->name;
|
|
|
|
// SELECT * FROM `master_schedule` WHERE name='12Hours' AND name!='vatibra'
|
|
|
|
|
|
$this->db->where('name', $val);
|
|
$this->db->where('name !=', $exceptVal);
|
|
$query = $this->db->get('master_schedule');
|
|
|
|
}
|
|
else{
|
|
$query = $this->db->get_where('master_schedule', array('name' => $val));
|
|
}
|
|
|
|
|
|
|
|
if($query->num_rows() > 0)
|
|
{
|
|
return 'exist';
|
|
}
|
|
else{
|
|
return 'notexist';
|
|
}
|
|
|
|
}
|
|
function status_change($post){
|
|
|
|
|
|
$id = $post['id'];
|
|
$stat = $post['val'];
|
|
|
|
$this->db->set('status', $stat);
|
|
$this->db->where('id', $id);
|
|
$this->db->update('master_schedule');
|
|
|
|
if($stat == '1')
|
|
{
|
|
return 'Status set active';
|
|
}
|
|
else{
|
|
return 'Status set deactive';
|
|
}
|
|
}
|
|
|
|
function getWherevalue($id){
|
|
$this->db->where('id', $id);
|
|
$query = $this->db->get('master_schedule');
|
|
return $query->result();
|
|
}
|
|
|
|
function getNameBysearch($search) {
|
|
$this->db->order_by('id', 'desc');
|
|
$this->db->like('id', $search);
|
|
$this->db->or_like('week_day', $search);
|
|
$this->db->or_like('from_time', $search);
|
|
$this->db->or_like('to_time', $search);
|
|
$query = $this->db->get('master_schedule');
|
|
return $query->result();
|
|
}
|
|
|
|
function getNameByLimit($limit, $start) {
|
|
$this->db->order_by('id', 'desc');
|
|
$this->db->limit($limit, $start);
|
|
$query = $this->db->get('master_schedule');
|
|
return $query->result();
|
|
}
|
|
|
|
function getNameByLimitBySearch($limit, $start, $search) {
|
|
|
|
$this->db->like('id', $search);
|
|
|
|
$this->db->order_by('id', 'desc');
|
|
$this->db->or_like('week_day', $search);
|
|
$this->db->or_like('from_time', $search);
|
|
$this->db->or_like('to_time', $search);
|
|
|
|
$this->db->limit($limit, $start);
|
|
$query = $this->db->get('master_schedule');
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
}
|