diff --git a/admin/application/config/routes.php b/admin/application/config/routes.php index ba431a0..cdc2cb6 100644 --- a/admin/application/config/routes.php +++ b/admin/application/config/routes.php @@ -84,7 +84,7 @@ $route['edit-degree/(:num)'] = 'degree/editDegree/$1'; $route['semester'] = 'semester/semester_list'; $route['add-semester'] = 'semester/add_semester'; $route['edit-semester/(:num)'] = 'semester/editSemester/$1'; - +$route['view-semester/(:num)'] = 'semester/viewSemester/$1'; //subject// $route['subject'] = 'subject/subject_list'; @@ -102,7 +102,7 @@ $route['edit-faculty/(:num)'] = 'faculty/editFaculty/$1'; $route['student'] = 'student/student_list'; $route['add_student'] = 'student/add_student'; $route['view-student/(:num)'] = 'student/viewStudent/$1'; -$route['edit_student/(:num)'] = 'student/edit_student/$1'; +$route['edit-student/(:num)'] = 'student/editStudent/$1'; $route['deleted_student'] = 'student/deleted_student'; @@ -110,5 +110,5 @@ $route['deleted_student'] = 'student/deleted_student'; $route['project'] = 'project/project_list'; $route['add_project'] = 'project/add_project'; $route['view-project/(:num)'] = 'project/viewProject/$1'; -$route['edit_project/(:num)'] = 'project/edit_project/$1'; +$route['edit-project/(:num)'] = 'project/editProject/$1'; $route['deleted_project'] = 'project/deleted_project'; \ No newline at end of file diff --git a/admin/application/controllers/Project.php b/admin/application/controllers/Project.php index a4f4696..bac20db 100644 --- a/admin/application/controllers/Project.php +++ b/admin/application/controllers/Project.php @@ -148,60 +148,176 @@ class Project extends CI_Controller { } - function edit_project($id) + function editProject($id) { + $data['dep']=$this->Project_model->get_dep(); + $data['stu']=$this->Project_model->get_stu(); + $data['sub']=$this->Project_model->get_sub(); + $data['semester']=$this->Project_model->get_semester(); + $data['pro']=$this->Project_model->get_pro($id); - $this->load->view('project/edit_project',$data); + + $data['getMultipleImage']=$this->Project_model->getMultipleImage($id); if($this->input->post('submit')) { - $name=$this->input->post('projectName'); $date=$this->input->post('date'); - $student=$this->input->post('student'); - $semester=$this->input->post('semester'); - $subject=$this->input->post('subject'); - //$gender=$this->input->post('gender'); - $department=$this->input->post('department'); + $projectName=$this->input->post('projectName'); + $code=$this->input->post('code'); + $studentId=$this->input->post('student'); + $semesterId=$this->input->post('semesterId'); + $subjectId=$this->input->post('subjectId'); + $departmentId=$this->input->post('departmentId'); + $titleImage=$this->input->post('titleImage'); + $oldImage=$this->input->post('oldImage'); $description=$this->input->post('description'); - //$faculty=$this->input->post('faculty'); $drivelink=$this->input->post('drivelink'); - $video=$this->input->post('vedio'); - $image=$this->input->post('image'); + $video=$this->input->post('video'); + + if($titleImage=="" ){$newImage=$oldImage;} + if(file_exists($_FILES['titleImage']['tmp_name'])) + { + $temp_user_img=$_FILES['titleImage']['tmp_name']; + $newImage=str_replace(' ', '_', $_FILES["titleImage"]["name"]); + $allowed = array('png,jpeg,jpg'); + $extension1 = pathinfo($newImage, PATHINFO_EXTENSION); + $newImage='title'.date('ymdhis').'.'.$extension1; + $targetPath='./uploads/project/'; + $targetFile=$targetPath.$newImage; + move_uploaded_file($temp_user_img, $targetFile); + } - $table="project"; $where=array("id"=>$id); - $values=array('projectName'=>$name, + $values=array('projectName'=>$projectName, 'date'=>$date, - 'studentId'=>$student, - 'semesterId'=>$semester, - 'subjectId'=>$subject, - 'departmentId'=>$department, - // 'gender'=>$gender, + 'code'=>$code, + 'studentId'=>$studentId, + 'semesterId'=>$semesterId, + 'subjectId'=>$subjectId, + 'departmentId'=>$departmentId, + 'image'=>$newImage, 'description'=>$description, - //'faculty'=>$faculty, 'drivelink'=>$drivelink, 'vedio'=>$video, - 'image'=>$image, 'updatedOn'=>date('Y-m-d'), - 'updatedBy'=>1, - 'status'=>1); + 'updatedBy'=>1); $result=$this->Commonsql_model->updateTable($table,$where,$values); + + //Image Multiple + $title = $this->input->post('title'); + $profileimage = $this->input->post('profileimage'); + $projectDetailId = $this->input->post('projectDetailName'); + $oldImage = $this->input->post('profileimageOld'); + //print_r ($projectDetailId);exit; + + //Update old datas + foreach($title as $key=>$value) + { + + if($projectDetailId[$key]!="") + { + + if($_FILES['profileimage']['name'][$key]) + { + $temp_file=$_FILES['profileimage']['tmp_name'][$key]; + $business_doc=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]); + $extension1 = pathinfo($business_doc, PATHINFO_EXTENSION); + $newImage=$id.'.'.$business_doc; + $document='uploads/project/'.$newImage; + + $targetPath = './uploads/project/'; + $targetFile=$targetPath.$newImage; + + + if(move_uploaded_file($temp_file, $targetFile)) + { } + } + else{ + $newImage=$oldImage[$key]; + } + $tablename='projectdetail'; + $data=array('title'=>$title[$key], + 'image'=>$newImage); + $where=array('id'=>$projectDetailId[$key]); + $result=$this->Commonsql_model->updateTable($tablename,$where,$data); + //echo $this->db->last_query(); + + } + } + //Remove Existing One + $existingRow=$this->Project_model->getMultipleImage($id); + //echo $this->db->last_query(); + if($existingRow->num_rows()>0) + { + //echo "test";exit; + $primaryId=array(); + foreach($existingRow->result() as $list) + { + $primaryId[]=$list->id ; + } + } + //Remove Row + $diff=array_diff($primaryId,$projectDetailId); + //print_r ($diff);exit; + if($diff>0) + { + //echo "sdsds";exit; + foreach($diff as $value) + { + $where=array('id'=>$value); + $tablename="projectdetail"; + $values=array('status'=>0); + if($projectDetailId[$key]!=""){ + $result=$this->Commonsql_model->updateTable($tablename,$where,$values);} + //echo $this->db->last_query(); + } + } + //New Row Insertion + if($projectDetailId[$key]=="") + { + + if($_FILES['profileimage']['tmp_name']) + { + $tempDocument=$_FILES['profileimage']['tmp_name'][$key]; + $getImage=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]); + $extension1 = pathinfo($getImage, PATHINFO_EXTENSION); + $image=$id.'.'.$getImage; + //$document='uploads/subject/'.$business_document; + $targetPath = './uploads/project/'; + $targetFile=$targetPath.$image; + + + if(move_uploaded_file($tempDocument, $targetFile)) + { + $tablename='projectdetail'; + $data=array('projectId'=>$id, + 'title'=>$title[$key], + 'image'=>$image, + 'status'=>1); + + $result=$this->Commonsql_model->insert_table($tablename,$data); + } + } + + } + + if($result) - { - $this->session->set_userdata('suc','successfully Updated'); - redirect('project'); - - } - else - { - $this->session->set_userdata('err','Please try again'); - redirect('project'); - } + { + $this->session->set_userdata('suc','successfully Updated'); + redirect('project'); + + } + else + { + $this->session->set_userdata('err','Please try again'); + redirect('project'); + } } - + $this->load->view('project/edit_project',$data); } function deleteProject() diff --git a/admin/application/controllers/Semester.php b/admin/application/controllers/Semester.php index 18c35e0..a86f0f7 100644 --- a/admin/application/controllers/Semester.php +++ b/admin/application/controllers/Semester.php @@ -32,7 +32,15 @@ class Semester extends CI_Controller { $this->load->view('semester/semester_list',$data); } - + 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); + } + function add_semester() { $data['subject']=$this->Semester_model->listSubject(); @@ -48,12 +56,14 @@ class Semester extends CI_Controller { $subjectId=$this->input->post('subjectId'); $departmentId=$this->input->post('departmentId'); $degreeId=$this->input->post('degreeId'); - ///echo $departmentId; + + $subjectIdd = implode(",", (array)$subjectId); + //echo $subjectIdd;exit; //echo $degreeId; $table="semester"; $values=array('name'=>$name, 'year'=>$year, - 'subjectId'=>$subjectId, + 'subjectId'=>$subjectIdd, 'departmentId'=>$departmentId, 'degreeId'=>$degreeId, 'createdOn'=>date('Y-m-d'), @@ -88,11 +98,13 @@ class Semester extends CI_Controller { $departmentId=$this->input->post('departmentId'); $degreeId=$this->input->post('degreeId'); + $subjectIdd = implode(",", (array)$subjectId); + $table="semester"; $where=array("id"=>$id); $values=array( 'name'=>$name, 'year'=>$year, - 'subjectId'=>$subjectId, + 'subjectId'=>$subjectIdd, 'departmentId'=>$departmentId, 'degreeId'=>$degreeId, 'updatedOn'=>date('Y-m-d'), diff --git a/admin/application/controllers/Student.php b/admin/application/controllers/Student.php index 331c9c5..f4001c7 100644 --- a/admin/application/controllers/Student.php +++ b/admin/application/controllers/Student.php @@ -105,22 +105,36 @@ class Student extends CI_Controller { } - function edit_student($id) + function editStudent($id) { - - $data['stu']=$this->Student_model->get_stu($id); - $this->load->view('student/edit_student',$data); - + $data['dep']=$this->Student_model->get_dep(); + $data['stu']=$this->Student_model->get_stu($id); + if($this->input->post('submit')) { $name=$this->input->post('name'); $number=$this->input->post('mobileNumber'); $address=$this->input->post('address'); $department=$this->input->post('department'); + $date=$this->input->post('date'); $student=$this->input->post('student'); $gender=$this->input->post('gender'); $s_img=$this->input->post('image'); - + $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); + } $table="student"; $where=array("id"=>$id); @@ -129,13 +143,15 @@ class Student extends CI_Controller { 'studentId'=>$student, 'address'=>$address, 'department'=>$department, + 'dob'=>$date, 'gender'=>$gender, 'image'=>$s_img, //'update_on'=>date('Y-m-d'), // 'update_by'=>1, 'status'=>1); - + $result=$this->Commonsql_model->updateTable($table,$where,$values); + //echo $this->db->last_query();exit; if($result) { $this->session->set_userdata('suc','successfully Updated'); @@ -149,10 +165,7 @@ class Student extends CI_Controller { } } - //echo "sdsd";exit; - - //echo $this->db->last_query();exit; - + $this->load->view('student/edit_student',$data); } function deleteStudent() diff --git a/admin/application/controllers/Subject.php b/admin/application/controllers/Subject.php index 00c7b6a..d14afe6 100644 --- a/admin/application/controllers/Subject.php +++ b/admin/application/controllers/Subject.php @@ -86,17 +86,55 @@ class Subject extends CI_Controller { 'createdBy'=>1, 'status'=>1); $result=$this->Commonsql_model->insert_table($table,$values); - if($result) - { - $this->session->set_userdata('suc','successfully added'); - redirect('subject'); + + $subjectId=$this->db->insert_id(); + + //Image table insert + $title = $this->input->post('title'); + + foreach($title as $key=>$value) + { + if($_FILES['profileimage']['tmp_name']) + { + if (!is_dir('uploads/subject')) { + mkdir('./uploads/subject', 0777, TRUE); + } + $temp_vehicle_doc=$_FILES['profileimage']['tmp_name'][$key]; + $projectImage=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]); + $extension1 = pathinfo($projectImage, PATHINFO_EXTENSION); + $pImage=$subjectId.'.'.$projectImage; + $document='uploads/subject/'.$pImage; + + $targetPath = './uploads/subject/'; + $targetFile=$targetPath.$pImage; + + + if(move_uploaded_file($temp_vehicle_doc, $targetFile)) + { + $tablename='subjectdetail'; + $data=array('subjectId'=>$subjectId, + 'title'=>$title[$key], + 'image'=>$pImage, + 'status'=>1); - } - else - { - $this->session->set_userdata('err','Please try again'); - redirect('subject'); - } + $subject=$this->Commonsql_model->insert_table($tablename,$data); + //echo $this->db->last_query(); + + } + } + } + //exit; + if($result & $subject) + { + $this->session->set_userdata('suc','successfully added'); + redirect('subject'); + + } + else + { + $this->session->set_userdata('err','Please try again'); + redirect('subject'); + } } $this->load->view('subject/add_subject',$data); @@ -110,6 +148,8 @@ class Subject extends CI_Controller { $data['degree']=$this->Subject_model->degreeList(); $data['faculty']=$this->Subject_model->facultyList(); + $data['getMultipleImage']=$this->Subject_model->getMultipleImage($id); + ///echo $this->db->last_query();exit; if($this->input->post('submit')) { @@ -155,8 +195,105 @@ class Subject extends CI_Controller { $result=$this->Commonsql_model->updateTable($table,$where,$values); //echo $this->db->last_query();exit; - if($result) + + //Image Multiple + $title = $this->input->post('title'); + $profileimage = $this->input->post('profileimage'); + $subjectDetailId = $this->input->post('subjectDetailName'); + $oldImage = $this->input->post('profileimageOld'); + //print_r ($subjectDetailId);exit; + + //Update old datas + foreach($title as $key=>$value) + { + + if($subjectDetailId[$key]!="") + { + if($_FILES['profileimage']['name'][$key]) + { + $temp_file=$_FILES['profileimage']['tmp_name'][$key]; + $business_doc=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]); + $extension1 = pathinfo($business_doc, PATHINFO_EXTENSION); + $newImage=$id.'.'.$business_doc; + $document='uploads/subject/'.$newImage; + + $targetPath = './uploads/subject/'; + $targetFile=$targetPath.$newImage; + + + if(move_uploaded_file($temp_file, $targetFile)) + { } + } + else{ + $newImage=$oldImage[$key]; + } + $tablename='subjectdetail'; + $data=array('title'=>$title[$key], + 'image'=>$newImage); + $where=array('id'=>$subjectDetailId[$key]); + $result=$this->Commonsql_model->updateTable($tablename,$where,$data); + //echo $this->db->last_query(); + + } + } + //Remove Existing One + $existingRow=$this->Subject_model->getMultipleImage($id); + //echo $this->db->last_query(); + if($existingRow->num_rows()>0) + { + //echo "test";exit; + $primaryId=array(); + foreach($existingRow->result() as $list) + { + $primaryId[]=$list->id ; + } + } + //Remove Row + $diff=array_diff($primaryId,$subjectDetailId); + //print_r ($diff);exit; + if($diff>0) + { + //echo "sdsds";exit; + foreach($diff as $value) + { + $where=array('id'=>$value); + $tablename="subjectdetail"; + $values=array('status'=>0); + if($subjectDetailId[$key]!=""){ + $result=$this->Commonsql_model->updateTable($tablename,$where,$values);} + //echo $this->db->last_query(); + } + } + //New Row Insertion + if($subjectDetailId[$key]=="") + { + + if($_FILES['profileimage']['tmp_name']) + { + $tempDocument=$_FILES['profileimage']['tmp_name'][$key]; + $getImage=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]); + $extension1 = pathinfo($getImage, PATHINFO_EXTENSION); + $image=$id.'.'.$getImage; + //$document='uploads/subject/'.$business_document; + $targetPath = './uploads/subject/'; + $targetFile=$targetPath.$image; + + + if(move_uploaded_file($tempDocument, $targetFile)) + { + $tablename='subjectdetail'; + $data=array('subjectId'=>$id, + 'title'=>$title[$key], + 'image'=>$image, + 'status'=>1); + + $result=$this->Commonsql_model->insert_table($tablename,$data); + } + } + + } + if($result) { $this->session->set_userdata('suc','successfully Updated'); redirect('subject'); @@ -166,7 +303,6 @@ class Subject extends CI_Controller { $this->session->set_userdata('err','Please try again'); redirect('subject'); } - } $this->load->view('subject/edit_subject',$data); @@ -184,7 +320,11 @@ class Subject extends CI_Controller { $table="subject"; $where=array("id"=>$subjectId); $values=array('status'=>0); - + + $dTable="subjectdetail"; + $dWhere=array("subjectId"=>$subjectId); + $dValue=array('status'=>0); + $result=$this->Commonsql_model->updateTable($table,$where,$values); if($result) { diff --git a/admin/application/models/Project_model.php b/admin/application/models/Project_model.php index 5367984..ae6fcb7 100644 --- a/admin/application/models/Project_model.php +++ b/admin/application/models/Project_model.php @@ -146,4 +146,13 @@ class Project_model extends CI_Model { //echo $this->db->last_query(); exit; return $result; } + function getMultipleImage($id) + { + $this->db->select('id,title,image,projectId'); + $this->db->from('projectdetail'); + $this->db->where(array('status'=>1,'projectId'=>$id)); + $query = $this->db->get(); + //echo $this->db->last_query(); + return $query; + } } diff --git a/admin/application/models/Semester_model.php b/admin/application/models/Semester_model.php index 0116fda..eb3524f 100644 --- a/admin/application/models/Semester_model.php +++ b/admin/application/models/Semester_model.php @@ -11,7 +11,7 @@ class Semester_model extends CI_Model { function list_semester() { $this->db->select('s.id,s.name,s.year,sub.id as subId,sub.name as subName,dep.id as depId,dep.name as depName,deg.id as degId,deg.name as degName'); - $this->db->from('Semester as s'); + $this->db->from('semester as s'); $this->db->join('subject as sub','sub.id=s.subjectId','INNER'); $this->db->join('department as dep','dep.id=s.departmentId','INNER'); $this->db->join('degree as deg','deg.id=s.degreeId','INNER'); @@ -47,6 +47,17 @@ class Semester_model extends CI_Model { $query = $this->db->get(); //echo $this->db->last_query();exit; return $query; + } + function viewSemester($id) + { + $this->db->select('s.id,s.name,s.year,s.subjectId,dep.id as depId,dep.name as depName,deg.id as degId,deg.name as degName'); + $this->db->from('semester as s'); + $this->db->join('department as dep','dep.id=s.departmentId','INNER'); + $this->db->join('degree as deg','deg.id=s.degreeId','INNER'); + $this->db->where(array('s.status'=>1,'s.id'=>$id)); + $query = $this->db->get(); + //echo $this->db->last_query();exit; + return $query; } function getSemester($id) { @@ -58,4 +69,13 @@ class Semester_model extends CI_Model { return $query; } + function get_subject($id) + { + $this->db->select('*'); + $this->db->from('subject'); + $this->db->where(array('status'=>1,'id'=>$id)); + $query = $this->db->get(); + //echo $this->db->last_query();exit; + return $query; + } } diff --git a/admin/application/models/Subject_model.php b/admin/application/models/Subject_model.php index fe78a4f..cb7ea2c 100644 --- a/admin/application/models/Subject_model.php +++ b/admin/application/models/Subject_model.php @@ -64,4 +64,13 @@ class Subject_model extends CI_Model { //echo $this->db->last_query(); return $query; } + function getMultipleImage($id) + { + $this->db->select('id,title,image,subjectId'); + $this->db->from('subjectdetail'); + $this->db->where(array('status'=>1,'subjectId'=>$id)); + $query = $this->db->get(); + //echo $this->db->last_query(); + return $query; + } } diff --git a/admin/application/views/project/edit_project.php b/admin/application/views/project/edit_project.php index 474acc2..a3fedd8 100644 --- a/admin/application/views/project/edit_project.php +++ b/admin/application/views/project/edit_project.php @@ -1,145 +1,307 @@ load->view('includes/header');?> -