97 lines
3.0 KiB
PHP
97 lines
3.0 KiB
PHP
|
<?php
|
||
|
defined('BASEPATH') or exit('No direct script access allowed');
|
||
|
|
||
|
class Branches extends CI_Controller
|
||
|
{
|
||
|
function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
checkLogin();
|
||
|
}
|
||
|
public function _remap($alias)
|
||
|
{
|
||
|
$data['dataValue'] = $this->session;
|
||
|
|
||
|
$data['pageTitle'] = "Company";
|
||
|
|
||
|
switch ($alias) {
|
||
|
case 'add':
|
||
|
if (isset($_POST['submit'])) {
|
||
|
$TableData = array(
|
||
|
'branch_name' => filter_var($_POST['branch_name'], FILTER_SANITIZE_STRING),
|
||
|
'branch_alias' => getalias($_POST['branch_name'], 'branch_alias', 'tbl_branches'),
|
||
|
'branch_address' => filter_var($_POST['branch_address'], FILTER_SANITIZE_STRING),
|
||
|
'vat' => $_POST['vat'],
|
||
|
'pan' => $_POST['pan'],
|
||
|
'created_by' => 'admin',
|
||
|
'created_on' => date('Y-m-d H:i:s'),
|
||
|
'remarks' => filter_var($_POST['remarks'], FILTER_SANITIZE_STRING),
|
||
|
'status' => 1,
|
||
|
);
|
||
|
$this->db->insert('tbl_branches', $TableData);
|
||
|
redirect("master/branches");
|
||
|
}
|
||
|
$data['editable'] = 0;
|
||
|
loadView("setup/addbranches", $data);
|
||
|
break;
|
||
|
case 'edit':
|
||
|
$id = $this->uri->segment(4);
|
||
|
if (isset($_POST['submit'])) {
|
||
|
$TableData = array(
|
||
|
'branch_name' => filter_var($_POST['branch_name'], FILTER_SANITIZE_STRING),
|
||
|
'branch_alias' => getalias($_POST['branch_name'], 'branch_alias', 'tbl_branches'),
|
||
|
'branch_address' => filter_var($_POST['branch_address'], FILTER_SANITIZE_STRING),
|
||
|
'vat' => $_POST['vat'],
|
||
|
'pan' => $_POST['pan'],
|
||
|
'created_by' => 'admin',
|
||
|
'created_on' => date('Y-m-d H:i:s'),
|
||
|
'remarks' => filter_var($_POST['remarks'], FILTER_SANITIZE_STRING),
|
||
|
'status' => 1,
|
||
|
);
|
||
|
$this->db->where('branch_id', $id);
|
||
|
$this->db->update('tbl_branches', $TableData);
|
||
|
redirect("master/branches");
|
||
|
}
|
||
|
|
||
|
$data['editable'] = 1;
|
||
|
$data['branchData'] = $this->db->where("branch_id", $id)->get("tbl_branches")->row();
|
||
|
loadView("setup/addbranches", $data);
|
||
|
break;
|
||
|
case 'select':
|
||
|
$id = $this->uri->segment(4);
|
||
|
$this->db->where('branch_id<>', $id);
|
||
|
$this->db->update('tbl_branches', ['status' => 0]);
|
||
|
|
||
|
$this->db->where('branch_id', $id);
|
||
|
$this->db->update('tbl_branches', ['status' => 1]);
|
||
|
redirect("master/branches");
|
||
|
break;
|
||
|
case 'delete':
|
||
|
$id = $this->uri->segment(4);
|
||
|
if (!$this->myaccounts->hasTransaction('branch', $id)) {
|
||
|
$this->db->where('branch_id', $id);
|
||
|
$this->db->delete('tbl_branches');
|
||
|
redirect("master/branches");
|
||
|
} else {
|
||
|
echo "Can't Delete!! Transaction Exitis";
|
||
|
}
|
||
|
|
||
|
|
||
|
break;
|
||
|
case 'list':
|
||
|
if (isset($_POST['branch'])) {
|
||
|
$this->db->where('branch_id!=', $_POST['branch']);
|
||
|
$this->db->update('tbl_branches', ["status" => 0]);
|
||
|
$this->db->where('branch_id', $_POST['branch']);
|
||
|
$this->db->update('tbl_branches', ["status" => 1]);
|
||
|
redirect("logout");
|
||
|
}
|
||
|
// loadView("setup/selectbranch", $data);
|
||
|
loadView("setup/listbranches", $data);
|
||
|
break;
|
||
|
default:
|
||
|
loadView("setup/listbranches", $data);
|
||
|
}
|
||
|
}
|
||
|
}
|