6515996f87
Role, Employee, Department, Degree, Semester, Subject, Faculty Edit Completed
208 lines
5.2 KiB
PHP
208 lines
5.2 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()
|
|
{
|
|
$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()
|
|
{
|
|
|
|
$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'=>1,
|
|
'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)
|
|
{
|
|
|
|
$data['fac']=$this->Faculty_model->get_fac($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');
|
|
|
|
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'=>1);
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
//echo $this->last_query();exit;
|
|
if($result)
|
|
{
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
redirect('faculty');
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_userdata('err','Please try again');
|
|
redirect('faculty');
|
|
}
|
|
|
|
}
|
|
//echo "sdsd";exit;
|
|
|
|
//echo $this->db->last_query();exit;
|
|
|
|
}
|
|
|
|
function deleteFaculty()
|
|
{
|
|
if($this->input->post('submit'))
|
|
{
|
|
$facultyId=$this->input->post('facultyId');
|
|
|
|
$table="faculty";
|
|
$where=array("id"=>$facultyId);
|
|
$values=array('status'=>0);
|
|
|
|
$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');
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|