diff --git a/admin/application/controllers/Project.php b/admin/application/controllers/Project.php index bac20db..f41ea99 100644 --- a/admin/application/controllers/Project.php +++ b/admin/application/controllers/Project.php @@ -245,64 +245,64 @@ class Project extends CI_Controller { //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) + + //Remove Existing One + $existingRow=$this->Project_model->getMultipleImage($id); + //echo $this->db->last_query(); + if($existingRow->num_rows()>0) { - $primaryId[]=$list->id ; + //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); + } + } + } } - //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) { @@ -329,7 +329,8 @@ class Project extends CI_Controller { $table="project"; $where=array("id"=>$projectId); $values=array('status'=>0); - + $result=$this->Commonsql_model->updateTable($table,$where,$values); + $dTable="projectdetail"; $dWhere=array("projectId"=>$projectId); $dValue=array('status'=>0); diff --git a/admin/application/controllers/Semester.php b/admin/application/controllers/Semester.php index a86f0f7..2a73ce5 100644 --- a/admin/application/controllers/Semester.php +++ b/admin/application/controllers/Semester.php @@ -53,35 +53,50 @@ class Semester extends CI_Controller { { $name=$this->input->post('name'); $year=$this->input->post('year'); - $subjectId=$this->input->post('subjectId'); - $departmentId=$this->input->post('departmentId'); - $degreeId=$this->input->post('degreeId'); - $subjectIdd = implode(",", (array)$subjectId); + //echo $subjectIdd;exit; //echo $degreeId; $table="semester"; - $values=array('name'=>$name, - 'year'=>$year, - 'subjectId'=>$subjectIdd, - 'departmentId'=>$departmentId, - 'degreeId'=>$degreeId, - 'createdOn'=>date('Y-m-d'), - 'createdBy'=>1, - 'status'=>1); + $values=array( 'name'=>$name, + 'year'=>$year, + 'createdOn'=>date('Y-m-d'), + 'createdBy'=>1, + 'status'=>1); $result=$this->Commonsql_model->insert_table($table,$values); + $semesterId=$this->db->insert_id(); //echo $this->db->last_query();exit; + + $subjectId=$this->input->post('subjectId'); + $degreeId=$this->input->post('degreeId'); + + foreach($subjectId as $key=>$value) + { + $SUBJECTID=$subjectId[$key]; + $DEGREEID=$degreeId[$key]; + $SUBID = implode(",", (array)$SUBJECTID); + + //echo $SUBID; + $tablename='semesterdetail'; + $data=array('semesterId'=>$semesterId, + 'degreeId'=>$DEGREEID, + 'subjectId'=>$SUBID, + 'status'=>1); + + $result=$this->Commonsql_model->insert_table($tablename,$data); + } + //exit; if($result) - { - $this->session->set_userdata('suc','successfully added'); - redirect('semester'); - - } - else - { - $this->session->set_userdata('err','Please try again'); - redirect('semester'); - } + { + $this->session->set_userdata('suc','successfully added'); + redirect('semester'); + + } + else + { + $this->session->set_userdata('err','Please try again'); + redirect('semester'); + } } $this->load->view('semester/add_semester',$data); @@ -90,28 +105,92 @@ class Semester extends CI_Controller { function editSemester($id) { + $data['subject']=$this->Semester_model->listSubject(); + $data['degree']=$this->Semester_model->listDegree(); + $data['getData']=$this->Semester_model->getSemester($id); + + $data['getSemesterDetail']=$this->Semester_model->getSemesterDetail($id); + //echo $this->db->last_query();exit; if($this->input->post('submit')) { $name=$this->input->post('name'); $year=$this->input->post('year'); - $subjectId=$this->input->post('subjectId'); - $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'=>$subjectIdd, - 'departmentId'=>$departmentId, - 'degreeId'=>$degreeId, 'updatedOn'=>date('Y-m-d'), 'updatedby'=>1); $result=$this->Commonsql_model->updateTable($table,$where,$values); //echo $this->db->last_query();exit; + + //Update Old One + $degreeId=$this->input->post('degreeId'); + $subjectId=$this->input->post('subjectId'); + $semesterDetailId=$this->input->post('semesterDetailName'); + + foreach($subjectId as $key=>$value) + { + $DEGREEID=$degreeId[$key]; + $SEMESTERDETAILID=$semesterDetailId[$key]; + $SUBJECTID=$subjectId[$key]; + $SUBID = implode(",", (array)$SUBJECTID); + + //echo $SUBID; + + $tablename='semesterdetail'; + $data=array('degreeId'=>$DEGREEID, + 'subjectId'=>$SUBID); + $where=array('id'=>$SEMESTERDETAILID); + $result=$this->Commonsql_model->updateTable($tablename,$where,$data); + + //Remove Existing One + $existingRow=$this->Semester_model->getSemesterDetail($id); + + //echo $this->db->last_query();exit; + + if($existingRow->num_rows()>0) + { + //echo "test";exit; + $primaryId=array(); + foreach($existingRow->result() as $list) + { + $primaryId[]=$list->id ; + } + } + //Remove Row + $diff=array_diff($primaryId,$semesterDetailId); + //print_r ($diff);exit; + if($diff>0) + { + //echo "sdsds";exit; + foreach($diff as $value) + { + $where=array('id'=>$value); + $tablename="semesterdetail"; + $values=array('status'=>0); + if($SEMESTERDETAILID!=""){ + $result=$this->Commonsql_model->updateTable($tablename,$where,$values);} + //echo $this->db->last_query(); + } + } + //New Row Insertion + if($SEMESTERDETAILID=="") + { + $tablename='semesterdetail'; + $data=array('semesterId'=>$id, + 'degreeId'=>$DEGREEID, + 'subjectId'=>$SUBID, + 'status'=>1); + $result=$this->Commonsql_model->insert_table($tablename,$data); + } + } + + + if($result) { $this->session->set_userdata('suc','successfully Updated'); @@ -125,10 +204,7 @@ class Semester extends CI_Controller { } } - $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); } @@ -141,8 +217,14 @@ class Semester extends CI_Controller { $table="semester"; $where=array("id"=>$semesterId); $values=array('status'=>0); - $result=$this->Commonsql_model->updateTable($table,$where,$values); + + $table="semesterdetail"; + $where=array("semesterId"=>$semesterId); + $values=array('status'=>0); + + $result=$this->Commonsql_model->updateTable($table,$where,$values); + //echo $this->db->last_query();exit; if($result) { $this->session->set_userdata('suc','successfully deleted'); diff --git a/admin/application/controllers/Subject.php b/admin/application/controllers/Subject.php index d14afe6..e60b472 100644 --- a/admin/application/controllers/Subject.php +++ b/admin/application/controllers/Subject.php @@ -236,63 +236,65 @@ class Subject extends CI_Controller { //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) + + //Remove Existing One + $existingRow=$this->Subject_model->getMultipleImage($id); + //echo $this->db->last_query(); + if($existingRow->num_rows()>0) { - $primaryId[]=$list->id ; + //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); + } + } + } } - //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'); @@ -320,7 +322,8 @@ class Subject extends CI_Controller { $table="subject"; $where=array("id"=>$subjectId); $values=array('status'=>0); - + $result=$this->Commonsql_model->updateTable($table,$where,$values); + $dTable="subjectdetail"; $dWhere=array("subjectId"=>$subjectId); $dValue=array('status'=>0); diff --git a/admin/application/controllers/new 1.txt b/admin/application/controllers/new 1.txt new file mode 100644 index 0000000..e91efda --- /dev/null +++ b/admin/application/controllers/new 1.txt @@ -0,0 +1,39 @@ +//Remove Existing One + $existingRow=$this->Semester_model->getSemesterDetail($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,$semesterDetailId); + //print_r ($diff);exit; + if($diff>0) + { + //echo "sdsds";exit; + foreach($diff as $value) + { + $where=array('id'=>$value); + $tablename="semesterdetail"; + $values=array('status'=>0); + if($SEMESTERDETAILID!=""){ + $result=$this->Commonsql_model->updateTable($tablename,$where,$values);} + //echo $this->db->last_query(); + } + } + + //New Row Insertion + if($subjectDetailId[$key]=="") + { + $tablename='semesterdetail'; + $data=array('semesterId'=>$id, + 'degreeId'=>$DEGREEID, + 'subjectId'=>$SUBID, + 'status'=>1); + $result=$this->Commonsql_model->insert_table($tablename,$data); + } \ No newline at end of file diff --git a/admin/application/models/Semester_model.php b/admin/application/models/Semester_model.php index eb3524f..edaa0a0 100644 --- a/admin/application/models/Semester_model.php +++ b/admin/application/models/Semester_model.php @@ -10,72 +10,74 @@ 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->select('s.id,s.name,s.year'); $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'); $this->db->where(array('s.status'=>1,)); $query = $this->db->get(); - //'sub.status'=>1,'dep.status'=>1,'deg.status'=>1 - //echo $this->db->last_query();exit; + //echo $this->db->last_query();exit; return $query; } - function listSubject() + function listSubject() { $this->db->select('id,name'); $this->db->from('subject'); $this->db->where(array('status'=>1)); $query = $this->db->get(); - //echo $this->db->last_query();exit; + //echo $this->db->last_query();exit; return $query; } - function listDepartment() + + function listDepartment() { $this->db->select('id,name'); $this->db->from('department'); $this->db->where(array('status'=>1)); $query = $this->db->get(); - //echo $this->db->last_query();exit; return $query; - } function listDegree() + } + + function listDegree() { $this->db->select('id,name'); $this->db->from('degree'); $this->db->where(array('status'=>1)); $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->select('s.id,s.name,s.year'); $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) + + function getSemester($id) { $this->db->select('*'); $this->db->from('semester'); $this->db->where(array('status'=>1,'id'=>$id)); $query = $this->db->get(); - //echo $this->db->last_query();exit; return $query; } - - function get_subject($id) + function getSemesterDetail($id) + { + $this->db->select('*'); + $this->db->from('semesterdetail'); + $this->db->where(array('status'=>1,'semesterId'=>$id)); + $query = $this->db->get(); + 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/views/project/add_project.php b/admin/application/views/project/add_project.php index d8bdcc1..81a5c9e 100644 --- a/admin/application/views/project/add_project.php +++ b/admin/application/views/project/add_project.php @@ -176,7 +176,7 @@