ok
Direktori : /home2/selectio/www/mm-tailor-billing/app/controllers/ |
Current File : //home2/selectio/www/mm-tailor-billing/app/controllers/Extra_option.php |
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Extra_option extends MY_Controller { public function __construct() { parent::__construct(); if (!$this->loggedIn) { redirect('login'); } $this->load->library('form_validation'); $this->load->model('extra_option_model'); } public function add() { if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect('pos'); } $this->form_validation->set_rules('name', lang('category_name'), 'required'); if ($this->form_validation->run() == true) { $data = ['code' => $this->input->post('code'), 'name' => $this->input->post('name'), 'tamil_name' => $this->input->post('tamil_name'), 'category' => $this->input->post('category'),]; } if ($this->form_validation->run() == true && $this->extra_option_model->addExtraOption($data)) { $this->session->set_flashdata('message', lang('extra_option_added')); redirect('extra_option'); } else { $this->data['error'] = (validation_errors() ? validation_errors() : $this->session->flashdata('error')); $this->data['page_title'] = lang('add_extra_option'); $bc = [['link' => site_url('extra_option'), 'page' => lang('extra_option')], ['link' => '#', 'page' => lang('add_extra_option')]]; $meta = ['page_title' => lang('add_extra_option'), 'bc' => $bc]; $this->page_construct('extra_option/add', $this->data, $meta); } } public function delete($id = null) { if (DEMO) { $this->session->set_flashdata('error', lang('disabled_in_demo')); redirect($_SERVER['HTTP_REFERER'] ?? 'welcome'); } if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect('pos'); } if ($this->input->get('id')) { $id = $this->input->get('id'); } if ($this->extra_option_model->deleteExtraOption($id)) { $this->session->set_flashdata('message', lang('category_deleted')); redirect('extra_option'); } } public function edit($id = null) { if (!$this->Admin) { $this->session->set_flashdata('error', lang('access_denied')); redirect('pos'); } if ($this->input->get('id')) { $id = $this->input->get('id'); } $this->form_validation->set_rules('name', lang('category_name'), 'required'); if ($this->form_validation->run() == true) { $data = ['code' => $this->input->post('code'), 'name' => $this->input->post('name'), 'category' => $this->input->post('category'), 'tamil_name' => $this->input->post('tamil_name')]; } if ($this->form_validation->run() == true && $this->extra_option_model->updateExtraOption($id, $data)) { $this->session->set_flashdata('message', lang('extra_option_updated')); redirect('extra_option'); } else { $this->data['error'] = (validation_errors() ? validation_errors() : $this->session->flashdata('error')); $this->data['extra_option'] = $this->extra_option_model->getExtraoptionByID($id); $this->data['page_title'] = lang('new_extra_option'); $bc = [['link' => site_url('extra_option'), 'page' => lang('extra_option')], ['link' => '#', 'page' => lang('edit_extra_option')]]; $meta = ['page_title' => lang('edit_extra_option'), 'bc' => $bc]; $this->page_construct('extra_option/edit', $this->data, $meta); } } ////IF category=1 THEN RETURN "Shirt" ELSEIF category=2 THEN RETURN "Pant" ELSE RETURN "Nothing" //IF(category=2,"Pant") //IF(category="1","Shirt","Pant") //(CASE WHEN category = "1" THEN price WHEN category = "2" THEN price_4 ELSE 1 END) public function get_extra_option() { $this->load->library('datatables'); $this->datatables->select('id, code, name, tamil_name, category, IF(category="1","Shirt-Category",IF(category="2","Pant-Category","Undefined")) as cat_name'); $this->datatables->from('extra_option'); $this->datatables->edit_column('category', "<span class='btn btn-info btn-xs'>$4</span>", 'id, code, name, cat_name'); $this->datatables->add_column('Actions', "<div class='text-center'><div class='btn-group'><a href='" . site_url('extra_option/edit/$1') . "' title='" . lang('edit_extra_option') . "' class='tip btn btn-warning btn-xs'><i class='fa fa-edit'></i></a> <a href='" . site_url('extra_option/delete/$1') . "' onClick=\"return confirm('" . lang('alert_x_category') . "')\" title='" . lang('delete_category') . "' class='tip btn btn-danger btn-xs'><i class='fa fa-trash-o'></i></a></div></div>", 'id, image, code, name'); $this->datatables->unset_column('id'); echo $this->datatables->generate(); } public function index() { $this->data['error'] = (validation_errors() ? validation_errors() : $this->session->flashdata('error')); $this->data['extra_option'] = $this->site->getAllCategories(); $this->data['page_title'] = lang('extra_option'); $bc = [['link' => '#', 'page' => lang('extra_option')]]; $meta = ['page_title' => lang('extra_option'), 'bc' => $bc]; $this->page_construct('extra_option/index', $this->data, $meta); } }