BBnepal-Accounts/account/application/controllers/inventory/Stocklocations.php

69 lines
2.8 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Stocklocations extends CI_Controller
{
function __construct()
{
parent::__construct();
checkLogin();
}
public function _remap($alias = "", $params = array())
{
$data['dataValue'] = $this->session;
$data['pageTitle'] = "Stock Location";
switch ($alias) {
case 'add':
if (isset($_POST['submit'])) {
$TableData = array(
'title' => filter_var($_POST['title']),
'alias' => filter_var($_POST['alias']),
'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_stocklocations', $TableData);
redirect("inventory/stocklocations/list");
}
loadView("inventory/stocklocations/add", $data);
break;
case 'edit':
if (isset($_POST['submit'])) {
$id = $this->uri->segment(4);
$TableData = array(
'title' => filter_var($_POST['title']),
'alias' => filter_var($_POST['alias']),
'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('stocklocation_id', $id);
$this->db->update('tbl_stocklocations', $TableData);
redirect("inventory/stocklocations/list");
}
$id = $this->uri->segment(4);
$this->db->where('stocklocation_id', $id);
$data['stockLocation'] = $this->db->get("tbl_stocklocations")->row();
loadView("inventory/stocklocations/add", $data);
break;
case 'delete':
$id = $this->uri->segment(4);
$this->db->where('stocklocation_id', $id);
$this->db->delete('tbl_stocklocations');
redirect("inventory/stocklocations/list");
break;
default:
loadView("inventory/stocklocations/list", $data);
}
}
}