136 lines
3.2 KiB
PHP
136 lines
3.2 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Department extends CI_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('Department_model');
|
|
$this->load->model('Commonsql_model');
|
|
|
|
}
|
|
|
|
/**
|
|
* Index Page for this controller.
|
|
*
|
|
* Maps to the following URL
|
|
* http://example.com/index.php/welcome
|
|
* - or -
|
|
* http://example.com/index.php/welcome/index
|
|
* - or -
|
|
* Since this controller is set as the default controller in
|
|
* config/routes.php, it's displayed at http://example.com/
|
|
*
|
|
* So any other public methods not prefixed with an underscore will
|
|
* map to /index.php/welcome/<method_name>
|
|
* @see https://codeigniter.com/user_guide/general/urls.html
|
|
*/
|
|
public function department_list()
|
|
{
|
|
$data['dep']=$this->Department_model->dep_list();
|
|
$this->load->view('department/department_list',$data);
|
|
}
|
|
|
|
|
|
|
|
function add_department()
|
|
{
|
|
|
|
$this->load->view('department/add_department');
|
|
if($this->input->post('submit'))
|
|
{
|
|
$depname=$this->input->post('depname');
|
|
$depcode=$this->input->post('depcode');
|
|
$year=$this->input->post('year');
|
|
|
|
$table="department";
|
|
|
|
$values=array('name'=>$depname,
|
|
'code'=>$depcode,
|
|
'year'=>$year,
|
|
//'created_on'=>date('Y-m-d'),
|
|
'created_by'=>1,
|
|
'status'=>1);
|
|
|
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
|
if($result)
|
|
{
|
|
$this->session->set_userdata('suc','successfully added');
|
|
redirect('department');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('department');
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function edit_department()
|
|
{
|
|
if($this->input->post('submit'))
|
|
{
|
|
|
|
$depname=$this->input->post('depname');
|
|
$depcode=$this->input->post('depcode');
|
|
$primaryid=$this->input->post('hiddendepid');
|
|
|
|
$table="department";
|
|
$where=array("dep_id"=>$primaryid);
|
|
$values=array('name'=>$depname,
|
|
'code'=>$depcode,
|
|
//'updated_on'=>date('Y-m-d'),
|
|
'update_by'=>1,
|
|
'status'=>1);
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
//echo $this->db->last_query();exit;
|
|
if($result)
|
|
|
|
{
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
redirect('department');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('department');
|
|
}
|
|
//echo $this->db->last_query();exit;
|
|
}
|
|
//$this->load->view('department/department_list',$data);
|
|
}
|
|
|
|
|
|
function delete_department()
|
|
{
|
|
if($this->input->post('submit'))
|
|
{
|
|
|
|
$primaryid=$this->input->post('hiddengffgdtpid');
|
|
//echo $primaryid ; exit;
|
|
$table="department";
|
|
$where=array("dep_id"=>$primaryid);
|
|
$values=array(
|
|
'status'=>0);
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
if($result)
|
|
{
|
|
$this->session->set_userdata('suc','successfully deleted');
|
|
redirect('department');
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('department');
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|