2023-01-05 12:19:39 +00:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Semester extends CI_Controller {
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('Semester_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 semester_list()
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$data['semester']=$this->Semester_model->list_semester();
|
|
|
|
$this->load->view('semester/semester_list',$data);
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
2023-01-24 10:05:16 +00:00
|
|
|
public function viewSemester($id)
|
|
|
|
{
|
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
|
|
|
|
$data['viewSemester']=$this->Semester_model->viewSemester($id);
|
|
|
|
//echo $this->db->last_query();exit;
|
|
|
|
$this->load->view('semester/view_semester',$data);
|
|
|
|
}
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
function add_semester()
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$data['subject']=$this->Semester_model->listSubject();
|
|
|
|
$data['department']=$this->Semester_model->listDepartment();
|
|
|
|
$data['degree']=$this->Semester_model->listDegree();
|
2023-01-05 12:19:39 +00:00
|
|
|
|
2023-01-06 07:23:42 +00:00
|
|
|
//$this->load->view('semester/add_semester');
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
$name=$this->input->post('name');
|
2023-01-21 13:41:47 +00:00
|
|
|
$year=$this->input->post('year');
|
|
|
|
$subjectId=$this->input->post('subjectId');
|
|
|
|
$departmentId=$this->input->post('departmentId');
|
|
|
|
$degreeId=$this->input->post('degreeId');
|
2023-01-24 10:05:16 +00:00
|
|
|
|
|
|
|
$subjectIdd = implode(",", (array)$subjectId);
|
|
|
|
//echo $subjectIdd;exit;
|
2023-01-21 13:41:47 +00:00
|
|
|
//echo $degreeId;
|
2023-01-05 12:19:39 +00:00
|
|
|
$table="semester";
|
|
|
|
$values=array('name'=>$name,
|
2023-01-21 13:41:47 +00:00
|
|
|
'year'=>$year,
|
2023-01-24 10:05:16 +00:00
|
|
|
'subjectId'=>$subjectIdd,
|
2023-01-21 13:41:47 +00:00
|
|
|
'departmentId'=>$departmentId,
|
|
|
|
'degreeId'=>$degreeId,
|
|
|
|
'createdOn'=>date('Y-m-d'),
|
2023-01-08 20:46:58 +00:00
|
|
|
'createdBy'=>1,
|
2023-01-05 12:19:39 +00:00
|
|
|
'status'=>1);
|
|
|
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
2023-01-21 13:41:47 +00:00
|
|
|
//echo $this->db->last_query();exit;
|
2023-01-05 12:19:39 +00:00
|
|
|
if($result)
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully added');
|
|
|
|
redirect('semester');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('semester');
|
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
}
|
|
|
|
$this->load->view('semester/add_semester',$data);
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function editSemester($id)
|
2023-01-05 12:19:39 +00:00
|
|
|
{
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
$name=$this->input->post('name');
|
2023-01-21 13:41:47 +00:00
|
|
|
$year=$this->input->post('year');
|
|
|
|
$subjectId=$this->input->post('subjectId');
|
|
|
|
$departmentId=$this->input->post('departmentId');
|
|
|
|
$degreeId=$this->input->post('degreeId');
|
2023-01-05 12:19:39 +00:00
|
|
|
|
2023-01-24 10:05:16 +00:00
|
|
|
$subjectIdd = implode(",", (array)$subjectId);
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
$table="semester";
|
|
|
|
$where=array("id"=>$id);
|
2023-01-21 13:41:47 +00:00
|
|
|
$values=array( 'name'=>$name,
|
|
|
|
'year'=>$year,
|
2023-01-24 10:05:16 +00:00
|
|
|
'subjectId'=>$subjectIdd,
|
2023-01-21 13:41:47 +00:00
|
|
|
'departmentId'=>$departmentId,
|
|
|
|
'degreeId'=>$degreeId,
|
|
|
|
'updatedOn'=>date('Y-m-d'),
|
|
|
|
'updatedby'=>1);
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
2023-01-21 13:41:47 +00:00
|
|
|
//echo $this->db->last_query();exit;
|
2023-01-05 12:19:39 +00:00
|
|
|
if($result)
|
2023-01-21 13:41:47 +00:00
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
|
|
redirect('semester');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('semester');
|
|
|
|
}
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
}
|
2023-01-21 13:41:47 +00:00
|
|
|
$data['subject']=$this->Semester_model->listSubject();
|
|
|
|
$data['department']=$this->Semester_model->listDepartment();
|
|
|
|
$data['degree']=$this->Semester_model->listDegree();
|
|
|
|
$data['getData']=$this->Semester_model->getSemester($id);
|
|
|
|
$this->load->view('semester/edit_semester',$data);
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function deleteSemester()
|
2023-01-05 12:19:39 +00:00
|
|
|
{
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$semesterId=$this->input->post('semesterId');
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
$table="semester";
|
2023-01-21 13:41:47 +00:00
|
|
|
$where=array("id"=>$semesterId);
|
|
|
|
$values=array('status'=>0);
|
2023-01-05 12:19:39 +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('semester');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('semester');
|
|
|
|
}
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|