first commit
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Screen_Cards extends Admin_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('screen_cards_model');
|
||||
$this->load->helper('url');
|
||||
$this->load->model('combo_model');
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$data = [
|
||||
'card_models' => []
|
||||
];
|
||||
$this->load->library('table');
|
||||
$this->table->set_heading(
|
||||
[
|
||||
['data' => 'ID', 'style' => 'width:120px'],
|
||||
'Screen Name',
|
||||
'Trigger ID',
|
||||
['data' => 'Status', 'style' => 'width:120px'],
|
||||
['data' => '...', 'style' => 'width:200px'],
|
||||
]
|
||||
);
|
||||
$query = $this->screen_cards_model->getQueryAll();
|
||||
$tableData = $this->returnAdminTable(
|
||||
[
|
||||
'count_query' => $query,
|
||||
'query' => $query,
|
||||
],
|
||||
'/Screen_Cards/list/',
|
||||
[
|
||||
'per_page' => 20,
|
||||
'reuse_query_string' => TRUE,
|
||||
'uri_segment' => 3,
|
||||
]
|
||||
);
|
||||
$data['filterData'] = $params;
|
||||
$data['screen_cards_table'] = $tableData['output_table'];
|
||||
$data['links'] = $tableData['links'];
|
||||
$data['screen_name_ddl'] = $this->combo_model->getScreenNames('screen_name', '');
|
||||
$data['trigger_id_ddl'] = $this->combo_model->getTriggerIds('trigger_id', '');
|
||||
$this->renderView('view_list', $data);
|
||||
}
|
||||
|
||||
public function ajax_toggle()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$cur_status = $this->input->post('cur_status');
|
||||
$rs = $this->screen_cards_model->toggle($id, $cur_status);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($rs);
|
||||
}
|
||||
|
||||
private function renderView($page_name, $data)
|
||||
{
|
||||
$this->load->view('admin/view_admin_header', $data);
|
||||
$this->load->view('screencards/' . $page_name, $data);
|
||||
$this->load->view('admin/view_admin_footer', $data);
|
||||
}
|
||||
|
||||
public function create_or_update()
|
||||
{
|
||||
$data = $this->input->post();
|
||||
$rs = $this->screen_cards_model->create_or_update($data);
|
||||
if($rs){
|
||||
$this->session->set_flashdata('msg', empty($data['id']) ? 'Added' : 'Updated');
|
||||
}else{
|
||||
$this->session->set_flashdata('error', 'Screen Name & Trigger ID already exist, please try again!');
|
||||
}
|
||||
redirect('/Screen_Cards/list', 'refresh');
|
||||
}
|
||||
|
||||
public function get_by_id()
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
$data = $this->screen_cards_model->getById($id);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
//post delete
|
||||
public function delete()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if (!empty($id)) {
|
||||
$rs = $this->screen_cards_model->delete($id);
|
||||
} else {
|
||||
$rs = false;
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($rs);
|
||||
}
|
||||
// ajax validate is exists screen name - trigger id
|
||||
public function is_exists(){
|
||||
$id = $this->input->post('id'); // 0 if create new
|
||||
$screen_name = $this->input->post('screen_name');
|
||||
$trigger_id = $this->input->post('trigger_id');
|
||||
$is_exists = $this->screen_cards_model->is_exists($id, $screen_name, $trigger_id);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($is_exists);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user