2023-01-11 07:17:57 +00:00
|
|
|
<?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()
|
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
|
2023-01-11 07:17:57 +00:00
|
|
|
$data['deg']=$this->Degree_model->deg_list();
|
2023-01-21 13:41:47 +00:00
|
|
|
$data['dep']=$this->Degree_model->get_dep();
|
|
|
|
$this->load->view('degree/degree_list',$data);
|
2023-01-11 07:17:57 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function add_degree()
|
2023-01-11 07:17:57 +00:00
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
2023-02-07 13:11:26 +00:00
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-11 07:17:57 +00:00
|
|
|
$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'),
|
2023-02-07 13:11:26 +00:00
|
|
|
'createdBy'=>$currentUser,
|
2023-01-11 07:17:57 +00:00
|
|
|
'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');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function getDegree()
|
|
|
|
{
|
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$id=$_POST['id'];
|
|
|
|
$tableName="degree";
|
|
|
|
$select=array('id','name','departmentId');
|
|
|
|
$where=array('id'=>$id);
|
|
|
|
$degree=$this->Commonsql_model->selectTable($tableName,$where,$select);
|
|
|
|
if($degree->num_rows()>0){
|
|
|
|
$list1=$degree->row();
|
|
|
|
$id=$list1->id;
|
|
|
|
$name=$list1->name;
|
|
|
|
$departmentId=$list1->departmentId;
|
|
|
|
}
|
|
|
|
echo $id.'-'.$name.'-'.$departmentId;
|
|
|
|
}
|
|
|
|
function editDegree($id)
|
2023-01-11 07:17:57 +00:00
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
2023-01-11 07:17:57 +00:00
|
|
|
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$degName=$this->input->post('degreeName');
|
|
|
|
$depId=$this->input->post('depId');
|
2023-01-11 07:17:57 +00:00
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
$table="degree";
|
2023-01-11 07:17:57 +00:00
|
|
|
$where=array("id"=>$id);
|
2023-01-21 13:41:47 +00:00
|
|
|
$values=array('name'=>$degName,
|
|
|
|
'departmentId'=>$depId,
|
|
|
|
'upadatedOn'=>date('Y-m-d'),
|
2023-02-07 13:11:26 +00:00
|
|
|
'updatedBy'=>$currentUser);
|
2023-01-11 07:17:57 +00:00
|
|
|
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
|
|
//echo $this->db->last_query();exit;
|
|
|
|
if($result)
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully Updated');
|
2023-01-21 13:41:47 +00:00
|
|
|
redirect('degree');
|
2023-01-11 07:17:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
2023-01-21 13:41:47 +00:00
|
|
|
redirect('degree');
|
2023-01-11 07:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function deleteDegree()
|
2023-01-11 07:17:57 +00:00
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-11 07:17:57 +00:00
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
|
|
|
|
$degreeId=$this->input->post('degreeId');
|
|
|
|
//echo $degreeId;exit;
|
|
|
|
$table="degree";
|
|
|
|
$where=array("id"=>$degreeId);
|
2023-02-07 13:11:26 +00:00
|
|
|
$values=array('status'=>0,'updatedOn'=>date('Y-m-d'),'updatedBy'=>$currentUser);
|
2023-01-11 07:17:57 +00:00
|
|
|
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
|
|
if($result)
|
2023-01-21 13:41:47 +00:00
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully deleted');
|
|
|
|
redirect('degree');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('degree');
|
|
|
|
}
|
2023-01-11 07:17:57 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|