2023-01-05 12:19:39 +00:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Student extends CI_Controller {
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('Student_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 Student_list()
|
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
2023-01-05 12:19:39 +00:00
|
|
|
$data['stu']=$this->Student_model->list_stu();
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->load->view('student/student_list',$data);
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
public function viewStudent($id)
|
|
|
|
{
|
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
|
|
|
|
$data['viewStudent']=$this->Student_model->viewStudent($id);
|
|
|
|
$this->load->view('student/view_student',$data);
|
|
|
|
}
|
2023-01-05 12:19:39 +00:00
|
|
|
function add_student()
|
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
|
|
|
$data['dep']=$this->Student_model->get_dep();
|
|
|
|
$this->load->view('student/add_student',$data);
|
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
|
|
|
$email=$this->input->post('email');
|
|
|
|
$number=$this->input->post('mobileNumber');
|
2023-01-05 12:19:39 +00:00
|
|
|
$address=$this->input->post('address');
|
|
|
|
$department=$this->input->post('department');
|
2023-01-21 13:41:47 +00:00
|
|
|
$student=$this->input->post('student');
|
2023-01-05 12:19:39 +00:00
|
|
|
$gender=$this->input->post('gender');
|
2023-01-06 07:23:42 +00:00
|
|
|
$s_img=$this->input->post('image');
|
2023-01-21 13:41:47 +00:00
|
|
|
$date=$this->input->post('date');
|
|
|
|
//$dob= implode("-", array_reverse(explode("-", $date)));
|
|
|
|
if (!is_dir('uploads/student')) {
|
|
|
|
mkdir('./uploads/student', 0777, TRUE);
|
|
|
|
|
|
|
|
}
|
|
|
|
if(file_exists($_FILES['image']['tmp_name']))
|
|
|
|
{
|
|
|
|
$temp_user_img=$_FILES['image']['tmp_name'];
|
|
|
|
$s_img=str_replace(' ', '_', $_FILES["image"]["name"]);
|
|
|
|
$allowed = array('png,jpeg,jpg');
|
|
|
|
$extension1 = pathinfo($s_img, PATHINFO_EXTENSION);
|
|
|
|
$s_img=date('ymdhi').'.'.$extension1;
|
|
|
|
$targetPath='./uploads/student/';
|
|
|
|
$targetFile=$targetPath.$s_img;
|
|
|
|
move_uploaded_file($temp_user_img, $targetFile);
|
|
|
|
}
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
$table="student";
|
|
|
|
$values=array('name'=>$name,
|
2023-01-21 13:41:47 +00:00
|
|
|
'mobileNumber'=>$number,
|
|
|
|
'email'=>$email,
|
2023-01-05 12:19:39 +00:00
|
|
|
'address'=>$address,
|
|
|
|
'department'=>$department,
|
2023-01-21 13:41:47 +00:00
|
|
|
'studentId'=>$student,
|
2023-01-05 12:19:39 +00:00
|
|
|
'gender'=>$gender,
|
2023-01-06 07:23:42 +00:00
|
|
|
'image'=>$s_img,
|
2023-01-21 13:41:47 +00:00
|
|
|
'dob'=>$date,
|
2023-01-08 20:46:58 +00:00
|
|
|
'createdOn'=>date('Y-m-d'),
|
2023-02-07 13:11:26 +00:00
|
|
|
'createdBy'=>$currentUser,
|
2023-01-05 12:19:39 +00:00
|
|
|
'status'=>1);
|
|
|
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
|
|
|
if($result)
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully added');
|
|
|
|
redirect('student');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('student');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-24 10:05:16 +00:00
|
|
|
function editStudent($id)
|
2023-01-05 12:19:39 +00:00
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-24 10:05:16 +00:00
|
|
|
$data['dep']=$this->Student_model->get_dep();
|
|
|
|
$data['stu']=$this->Student_model->get_stu($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
|
|
|
$number=$this->input->post('mobileNumber');
|
2023-01-05 12:19:39 +00:00
|
|
|
$address=$this->input->post('address');
|
|
|
|
$department=$this->input->post('department');
|
2023-01-24 10:05:16 +00:00
|
|
|
$date=$this->input->post('date');
|
2023-01-21 13:41:47 +00:00
|
|
|
$student=$this->input->post('student');
|
2023-01-05 12:19:39 +00:00
|
|
|
$gender=$this->input->post('gender');
|
2023-01-06 07:23:42 +00:00
|
|
|
$s_img=$this->input->post('image');
|
2023-01-24 10:05:16 +00:00
|
|
|
$hiddenImage=$this->input->post('hiddenImage');
|
|
|
|
if (!is_dir('uploads/student')) {
|
|
|
|
mkdir('./uploads/student', 0777, TRUE);
|
|
|
|
}
|
|
|
|
if(file_exists($_FILES['image']['tmp_name']))
|
|
|
|
{
|
|
|
|
$temp_user_img=$_FILES['image']['tmp_name'];
|
|
|
|
$s_img=str_replace(' ', '_', $_FILES["image"]["name"]);
|
|
|
|
$allowed = array('png,jpeg,jpg');
|
|
|
|
$extension1 = pathinfo($s_img, PATHINFO_EXTENSION);
|
|
|
|
$s_img=date('ymdhi').'.'.$extension1;
|
|
|
|
$targetPath='./uploads/student/';
|
|
|
|
$targetFile=$targetPath.$s_img;
|
|
|
|
move_uploaded_file($temp_user_img, $targetFile);
|
|
|
|
}
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
$table="student";
|
|
|
|
$where=array("id"=>$id);
|
|
|
|
$values=array('name'=>$name,
|
2023-01-21 13:41:47 +00:00
|
|
|
'mobileNumber'=>$number,
|
|
|
|
'studentId'=>$student,
|
2023-01-05 12:19:39 +00:00
|
|
|
'address'=>$address,
|
|
|
|
'department'=>$department,
|
2023-01-24 10:05:16 +00:00
|
|
|
'dob'=>$date,
|
2023-01-05 12:19:39 +00:00
|
|
|
'gender'=>$gender,
|
2023-01-06 07:23:42 +00:00
|
|
|
'image'=>$s_img,
|
2023-02-07 13:11:26 +00:00
|
|
|
'update_on'=>date('Y-m-d'),
|
|
|
|
'update_by'=>$currentUser,
|
2023-01-05 12:19:39 +00:00
|
|
|
'status'=>1);
|
2023-01-24 10:05:16 +00:00
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
2023-01-24 10:05:16 +00:00
|
|
|
//echo $this->db->last_query();exit;
|
2023-01-05 12:19:39 +00:00
|
|
|
if($result)
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
|
|
redirect('student');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('student');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-01-24 10:05:16 +00:00
|
|
|
$this->load->view('student/edit_student',$data);
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function deleteStudent()
|
2023-01-05 12:19:39 +00:00
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$studentId=$this->input->post('studentId');
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
$table="student";
|
2023-01-21 13:41:47 +00:00
|
|
|
$where=array("id"=>$studentId);
|
2023-02-07 13:11:26 +00:00
|
|
|
$values=array('status'=>0,'updatedOn'=>date('Y-m-d'),'updatedBy'=>$currentUser);
|
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('student');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('student');
|
|
|
|
}
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|