143 lines
3.3 KiB
PHP
143 lines
3.3 KiB
PHP
|
<?php
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
||
|
class Degree extends CI_Controller {
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
$this->load->model('Degree_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 degree_list()
|
||
|
{
|
||
|
if($this->session->userdata('id')==""){redirect('');}
|
||
|
$data['deg']=$this->Degree_model->deg_list();
|
||
|
$this->load->view('degree/degree_list',$data);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
function add_degree()
|
||
|
{
|
||
|
$data['dep']=$this->Degree_model->get_dep();
|
||
|
$this->load->view('degree/add_degree',$data);
|
||
|
if($this->input->post('submit'))
|
||
|
{
|
||
|
$name=$this->input->post('name');
|
||
|
$depId=$this->input->post('depId');
|
||
|
|
||
|
|
||
|
$table="degree";
|
||
|
|
||
|
$values=array('name'=>$name,
|
||
|
'departmentId'=>$depId,
|
||
|
'createdOn'=>date('Y-m-d'),
|
||
|
'createdBy'=>1,
|
||
|
'status'=>1);
|
||
|
|
||
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
||
|
if($result)
|
||
|
{
|
||
|
$this->session->set_userdata('suc','successfully added');
|
||
|
redirect('degree');
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$this->session->set_userdata('err','Please try again');
|
||
|
redirect('degree');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function edit_department($id)
|
||
|
{
|
||
|
|
||
|
$data['dep']=$this->Department_model->get_dep($id);
|
||
|
//echo $this->db->last_query();exit;
|
||
|
$this->load->view('department/edit_department',$data);
|
||
|
|
||
|
|
||
|
if($this->input->post('submit'))
|
||
|
{
|
||
|
$name=$this->input->post('name');
|
||
|
$code=$this->input->post('code');
|
||
|
$year=$this->input->post('year');
|
||
|
$image=$this->input->post('image');
|
||
|
//$primaryid=$this->input->post('hiddendepid');
|
||
|
|
||
|
$table="department";
|
||
|
$where=array("id"=>$id);
|
||
|
$values=array('name'=>$name,
|
||
|
'code'=>$code,
|
||
|
'year'=>$year,
|
||
|
'image'=>$image,
|
||
|
'updatedOn'=>date('Y-m-d'),
|
||
|
'updatedBy'=>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');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
function deleted_department()
|
||
|
{
|
||
|
if($this->input->post('submit'))
|
||
|
{
|
||
|
$id=$this->input->post('hiddenpass');
|
||
|
//echo $id ; exit;
|
||
|
$table="department";
|
||
|
$where=array("id"=>$id);
|
||
|
$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');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|