74 lines
3.0 KiB
PHP
74 lines
3.0 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
class Itemcategories extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
checkLogin();
|
|
}
|
|
public function _remap($alias = "", $params = array())
|
|
{
|
|
|
|
$data['dataValue'] = $this->session;
|
|
|
|
$data['pageTitle'] = "Item Categories";
|
|
|
|
switch ($alias) {
|
|
case 'add':
|
|
if (isset($_POST['submit'])) {
|
|
$TableData = array(
|
|
'units_id' => filter_var($_POST['units_id']),
|
|
'title' => filter_var($_POST['title']),
|
|
'description' => filter_var($_POST['description']),
|
|
'display_order' => filter_var($_POST['display_order']),
|
|
'status' => 1,
|
|
'remarks' => filter_var($_POST['remarks']),
|
|
'created_on' => date('Y-m-d H:i:s'),
|
|
'created_by' => 'admin',
|
|
);
|
|
$this->db->insert('tbl_itemcategories', $TableData);
|
|
redirect("inventory/itemcategories/list");
|
|
}
|
|
loadView("inventory/itemcategories/add", $data);
|
|
break;
|
|
case 'edit':
|
|
if (isset($_POST['submit'])) {
|
|
$id = $this->uri->segment(4);
|
|
$TableData = array(
|
|
'units_id' => filter_var($_POST['units_id']),
|
|
'title' => filter_var($_POST['title']),
|
|
'description' => filter_var($_POST['description']),
|
|
'display_order' => filter_var($_POST['display_order']),
|
|
'status' => 1,
|
|
'remarks' => filter_var($_POST['remarks']),
|
|
'created_on' => date('Y-m-d H:i:s'),
|
|
'created_by' => 'admin',
|
|
);
|
|
$this->db->where('itemcategory_id', $id);
|
|
$this->db->update('tbl_itemcategories', $TableData);
|
|
redirect("inventory/itemcategories/list");
|
|
}
|
|
$id = $this->uri->segment(4);
|
|
$this->db->where('itemcategory_id', $id);
|
|
$data['itemcategory']=$this->db->get("tbl_itemcategories")->row();
|
|
loadView("inventory/itemcategories/add", $data);
|
|
break;
|
|
case 'delete':
|
|
$id = $this->uri->segment(4);
|
|
if (!$this->myaccounts->hasTransaction("itemcategory", $id)) {
|
|
$this->db->where('itemcategory_id', $id);
|
|
$this->db->delete('tbl_itemcategories');
|
|
}
|
|
else
|
|
{
|
|
echo "Transaction Exists!!! Can't Delete";die;
|
|
}
|
|
redirect("inventory/itemcategories/list");
|
|
break;
|
|
default:
|
|
loadView("inventory/itemcategories/list", $data);
|
|
}
|
|
}
|
|
}
|