f2a40c268b
1. Have to test and deploy in server. 2. add faculty detail into employee table and student detail into employee table, 3. Change Teaching Assistant into multiple select 4. User Profile
245 lines
6.6 KiB
PHP
245 lines
6.6 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Faculty extends CI_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('Faculty_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 faculty_list()
|
|
{
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$data['fac']=$this->Faculty_model->list_fa();
|
|
$this->load->view('faculty/faculty_list',$data);
|
|
|
|
}
|
|
public function viewFaculty($id)
|
|
{
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$data['viewFaculty']=$this->Faculty_model->viewFaculty($id);
|
|
//echo $this->db->last_query();exit;
|
|
$this->load->view('faculty/view_faculty',$data);
|
|
}
|
|
|
|
function add_faculty()
|
|
{
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
$this->load->view('faculty/add_faculty');
|
|
|
|
if($this->input->post('submit'))
|
|
{
|
|
$faculty=$this->input->post('facultyId');
|
|
$name=$this->input->post('name');
|
|
$email=$this->input->post('email');
|
|
$date=$this->input->post('date');
|
|
$gender=$this->input->post('gender');
|
|
$number=$this->input->post('mobileNumber');
|
|
$address=$this->input->post('address');
|
|
$desi=$this->input->post('designation');
|
|
$f_img=$this->input->post('image');
|
|
|
|
//echo $date.'-------'.$dateofbirth;exit;
|
|
//$banner_image=$this->input->post('banner_image');
|
|
|
|
|
|
if (!is_dir('uploads/faculty')) {
|
|
mkdir('./uploads/faculty', 0777, TRUE);
|
|
|
|
}
|
|
if(file_exists($_FILES['image']['tmp_name']))
|
|
{
|
|
$temp_user_img=$_FILES['image']['tmp_name'];
|
|
$f_img=str_replace(' ', '_', $_FILES["image"]["name"]);
|
|
$allowed = array('png,jpeg,jpg');
|
|
$extension1 = pathinfo($f_img, PATHINFO_EXTENSION);
|
|
$f_img=date('ymdhi').'.'.$extension1;
|
|
$targetPath='./uploads/faculty/';
|
|
$targetFile=$targetPath.$f_img;
|
|
move_uploaded_file($temp_user_img, $targetFile);
|
|
}
|
|
|
|
$table="faculty";
|
|
$values=array('facultyId'=>$faculty,
|
|
'name'=>$name,
|
|
'email'=>$email,
|
|
'dob'=>$date,
|
|
'gender'=>$gender,
|
|
'mobileNumber'=>$number,
|
|
'address'=>$address,
|
|
'designation'=>$desi,
|
|
'image'=>$f_img,
|
|
'createdOn'=>date('Y-m-d'),
|
|
'createdBy'=>$currentUser,
|
|
'status'=>1);
|
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
|
$facultyId=$this->db->insert_id();
|
|
|
|
$table="employee";
|
|
$values=array('roleId'=>3,
|
|
'typeId'=>$facultyId,
|
|
'name'=>$name,
|
|
'email'=>$email,
|
|
'mobileNumber'=>$number,
|
|
'address'=>$address,
|
|
'image'=>$f_img,
|
|
'username'=>$name,
|
|
'password'=>md5($number),
|
|
'createdOn'=>date('Y-m-d'),
|
|
'createdBy'=>$currentUser,
|
|
'status'=>1);
|
|
|
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
|
if($result)
|
|
{
|
|
$this->session->set_userdata('suc','successfully added');
|
|
redirect('faculty');
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('faculty');
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function editFaculty($id)
|
|
{
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
$data['fac']=$this->Faculty_model->get_fac($id);
|
|
$data['employee']=$this->Faculty_model->get_employee($id);
|
|
$this->load->view('faculty/edit_faculty',$data);
|
|
|
|
if($this->input->post('submit'))
|
|
{
|
|
$facultyId=$this->input->post('facultyId');
|
|
$name=$this->input->post('name');
|
|
$email=$this->input->post('email');
|
|
$gender=$this->input->post('gender');
|
|
$number=$this->input->post('mobileNumber');
|
|
$dob=$this->input->post('dob');
|
|
$address=$this->input->post('address');
|
|
$desi=$this->input->post('designation');
|
|
$image=$this->input->post('image');
|
|
$hiddenImage=$this->input->post('hiddenImage');
|
|
$employeeId=$this->input->post('employeeId');
|
|
|
|
if($image==""){$newImage=$hiddenImage;}
|
|
|
|
if(file_exists($_FILES['image']['tmp_name']))
|
|
{
|
|
$temp_user_img=$_FILES['image']['tmp_name'];
|
|
$newImage=str_replace(' ', '_', $_FILES["image"]["name"]);
|
|
$allowed = array('png,jpeg,jpg');
|
|
$extension1 = pathinfo($newImage, PATHINFO_EXTENSION);
|
|
$newImage=date('ymdhi').'.'.$extension1;
|
|
$targetPath='./uploads/faculty/';
|
|
$targetFile=$targetPath.$newImage;
|
|
move_uploaded_file($temp_user_img, $targetFile);
|
|
}
|
|
|
|
|
|
$table="faculty";
|
|
$where=array("id"=>$id);
|
|
$values=array('facultyId'=>$facultyId,
|
|
'name'=>$name,
|
|
'email'=>$email,
|
|
'dob'=>$dob,
|
|
'gender'=>$gender,
|
|
'mobileNumber'=>$number,
|
|
'address'=>$address,
|
|
'designation'=>$desi,
|
|
'image'=>$newImage,
|
|
'updatedOn'=>date('Y-m-d'),
|
|
'updatedBy'=>$currentUser);
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
|
|
$table="employee";
|
|
$where=array("id"=>$employeeId);
|
|
$values=array('name'=>$name,
|
|
'email'=>$email,
|
|
'mobileNumber'=>$number,
|
|
'address'=>$address,
|
|
'image'=>$newImage,
|
|
'username'=>$name,
|
|
'password'=>md5($number),
|
|
'createdOn'=>date('Y-m-d'),
|
|
'updatedOn'=>date('Y-m-d'),
|
|
'updatedBy'=>$currentUser);
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
if($result)
|
|
{
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
redirect('faculty');
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('faculty');
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
function deleteFaculty()
|
|
{
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
if($this->input->post('submit'))
|
|
{
|
|
$facultyId=$this->input->post('facultyId');
|
|
|
|
$table="faculty";
|
|
$where=array("id"=>$facultyId);
|
|
$values=array('status'=>0,'updatedOn'=>date('Y-m-d'),'updatedBy'=>$currentUser);
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
if($result)
|
|
{
|
|
$this->session->set_userdata('suc','successfully deleted');
|
|
redirect('faculty');
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('faculty');
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|