commitall
This commit is contained in:
95
account/application/controllers/master/Fiscalyear.php
Normal file
95
account/application/controllers/master/Fiscalyear.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
class Fiscalyear extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
checkLogin();
|
||||
}
|
||||
public function _remap($alias = "", $params = array())
|
||||
{
|
||||
$data['dataValue'] = $this->session;
|
||||
$data['pageTitle'] = "Fiscal Year";
|
||||
switch ($alias) {
|
||||
case 'add':
|
||||
if (isset($_POST['submit'])) {
|
||||
$TableData = array(
|
||||
'fiscalyear_code' => filter_var($_POST['fiscalyear_code']),
|
||||
'fiscalyear_year' => filter_var($_POST['fiscalyear_year']),
|
||||
'fiscalyear_from' => NepaliToEnglishDate(filter_var($_POST['fiscalyear_from'])),
|
||||
'fiscalyear_to' => NepaliToEnglishDate(filter_var($_POST['fiscalyear_to'])),
|
||||
'created_by' => 'admin',
|
||||
'created_on' => date('Y-m-d H:i:s'),
|
||||
'remarks' => filter_var($_POST['remarks']),
|
||||
'status' => 0,
|
||||
);
|
||||
$this->db->insert('tbl_fiscalyear', $TableData);
|
||||
redirect("master/fiscalyear");
|
||||
}
|
||||
loadView("fiscalyear/add", $data);
|
||||
break;
|
||||
case 'edit':
|
||||
if (isset($_POST['submit'])) {
|
||||
$id = $this->uri->segment(4);
|
||||
$TableData = array(
|
||||
'fiscalyear_code' => filter_var($_POST['fiscalyear_code']),
|
||||
'fiscalyear_year' => filter_var($_POST['fiscalyear_year']),
|
||||
'fiscalyear_from' => NepaliToEnglishDate(filter_var($_POST['fiscalyear_from'])),
|
||||
'fiscalyear_to' => NepaliToEnglishDate(filter_var($_POST['fiscalyear_to'])),
|
||||
'created_by' => 'admin',
|
||||
'created_on' => date('Y-m-d H:i:s'),
|
||||
'remarks' => filter_var($_POST['remarks']),
|
||||
'status' => isset($_POST['status']) ? $_POST['status'] : 1,
|
||||
);
|
||||
$this->db->where('fiscalyear_id', $id);
|
||||
$this->db->update('tbl_fiscalyear', $TableData);
|
||||
redirect("master/fiscalyear");
|
||||
}
|
||||
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||
$id = $this->uri->segment(4);
|
||||
// pre($id);
|
||||
$this->db->where('fiscalyear_id', $id);
|
||||
$data['Fiscalyear'] = $this->db->get('tbl_fiscalyear')->row();
|
||||
// pre($data['Fiscalyear']);die;
|
||||
$this->load->view("fiscalyear/ajaxedit", $data);
|
||||
} else {
|
||||
loadView("fiscalyear/edit", $data);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
$id = $this->uri->segment(4);
|
||||
if (!$this->myaccounts->hasTransaction('fiscalyear', $id)) {
|
||||
$this->db->set('status', -1);
|
||||
$this->db->set('remarks', "Deleted on " . date("Y-m-d H:i:s") . " by " . $this->session->userdata("loggedUser"));
|
||||
$this->db->where('fiscalyear_id', $id);
|
||||
$this->db->update('tbl_fiscalyear');
|
||||
redirect("master/fiscalyear");
|
||||
} else {
|
||||
$response = array(
|
||||
'status' => 'failed',
|
||||
'message' => 'Cannot delete fiscal year with associated transactions.'
|
||||
);
|
||||
$title="List of Fiscalyear";
|
||||
$data['pageTitle']=$title;
|
||||
$data['response']= json_encode($response);
|
||||
loadView("fiscalyear/list",$data);
|
||||
// return json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'select':
|
||||
$id = $this->uri->segment(4);
|
||||
$this->db->where('status<>-1');
|
||||
$this->db->set('status', 0);
|
||||
$this->db->update('tbl_fiscalyear');
|
||||
$this->db->set('status', 1);
|
||||
$this->db->where('fiscalyear_id', $id);
|
||||
$this->db->update('tbl_fiscalyear');
|
||||
redirect("logout");
|
||||
break;
|
||||
default:
|
||||
loadView("fiscalyear/list", $data);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user