227 lines
7.7 KiB
PHP
227 lines
7.7 KiB
PHP
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Subject_model extends CI_Model
|
|
{
|
|
|
|
|
|
public function addSubject($save=null,$jsonSemFeesData=null)
|
|
{
|
|
|
|
|
|
$this->db->insert('T_SubjectMaster', $save);
|
|
$subject_id = $this->db->insert_id();
|
|
if($this->db->affected_rows() == '1'){
|
|
|
|
if($jsonSemFeesData){
|
|
foreach($jsonSemFeesData as $row)
|
|
{
|
|
|
|
|
|
$insertFeesArray['Subject_ID'] =$subject_id;
|
|
$insertFeesArray['Semester'] =$row['Semester'];
|
|
$insertFeesArray['SubjectCode'] =$row['SubjectCode'];
|
|
$insertFeesArray['SubjectName'] =$row['SubjectName'];
|
|
$insertFeesArray['CreatedOn'] =$save['CreatedOn'];
|
|
$insertFeesArray['CreatedBy'] =$save['CreatedBy'];
|
|
|
|
|
|
$this->db->insert('T_SubjectDetails', $insertFeesArray);
|
|
|
|
}
|
|
|
|
$result['SubjectStatus'] = true;
|
|
$result['message'] = "Successfully Subject details added";
|
|
|
|
|
|
|
|
} else {
|
|
$result['SubjectStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
//update subject
|
|
|
|
public function updateSubject($save=null,$jsonSemFeesData=null,$updateID=null)
|
|
{
|
|
$this->db->where('ID',$updateID);
|
|
$upateStatus=$this->db->update('T_SubjectMaster', $save);
|
|
|
|
|
|
if($upateStatus) {
|
|
|
|
if ($jsonSemFeesData) {
|
|
foreach ($jsonSemFeesData as $row)
|
|
{
|
|
$subID = $row['ID'];
|
|
|
|
$updateFeesArray['Subject_ID'] =$updateID;
|
|
$updateFeesArray['Semester'] =$row['Semester'];
|
|
$updateFeesArray['SubjectCode'] =$row['SubjectCode'];
|
|
$updateFeesArray['SubjectName'] =$row['SubjectName'];
|
|
$updateFeesArray['UpdatedOn'] = $save['UpdatedOn'];
|
|
$updateFeesArray['UpdatedBy'] = $save['UpdatedBy'];
|
|
|
|
if($subID!='' OR $subID!=null){
|
|
$this->db->where('ID', $subID);
|
|
$this->db->update('T_SubjectDetails', $updateFeesArray);
|
|
}
|
|
else{
|
|
$this->db->insert('T_SubjectDetails', $updateFeesArray);
|
|
}
|
|
|
|
}
|
|
$result['SubjectStatus'] = true;
|
|
$result['message'] = "Successfully subject details updated";
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
$result['SubjectStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get subject details
|
|
public function getSubject()
|
|
{
|
|
$this->db->select('BS.BatchName,CU.ID,CS.CourseName,CU.Comments ,CU.IsActive,US.UniversityName');
|
|
$this->db->from('T_SubjectMaster'.' as CU');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityName');
|
|
$this->db->join(COURSE.' as CS', 'CS.CourseID = CU.Course');
|
|
$this->db->join(BATCH.' as BS', 'BS.BatchCode = CU.Batch');
|
|
|
|
|
|
$this->db->order_by('CU.CreatedOn','DESC');
|
|
$subjectDetails = $this->db->get();
|
|
|
|
if($subjectDetails->result()){
|
|
|
|
$result['SubjectStatus'] = true;
|
|
|
|
foreach ($subjectDetails->result() as $row){
|
|
$fetchData['ID']=$row->ID;
|
|
$fetchData['CourseName']=$row->CourseName;
|
|
$fetchData['BatchName']=$row->BatchName;
|
|
|
|
$fetchData['Comments']=$row->Comments;
|
|
|
|
$fetchData['IsActive']=$row->IsActive;
|
|
|
|
$fetchData['UniversityName']=$row->UniversityName;
|
|
$fetchData['feesStructures'] = $this->getSubjectDetails($row->ID);
|
|
|
|
$storeSubjectArray[]=$fetchData;
|
|
}
|
|
$result['details'] = $storeSubjectArray;
|
|
}
|
|
else {
|
|
$result['SubjectStatus'] = false;
|
|
$result['message'] = "No records found!";
|
|
}
|
|
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
|
|
// public function getUniversityDetails()
|
|
// {
|
|
// $this->db->select('UniversityID,UniversityName');
|
|
// $this->db->order_by('UniversityID','ASC');
|
|
// $this->db->where('IsActive','1');
|
|
// $universityDetails = $this->db->get(UNIVERSITY);
|
|
// return $universityDetails->result();
|
|
// }
|
|
|
|
|
|
|
|
public function getSubjectDetails($ID=null)
|
|
{
|
|
|
|
$this->db->select('ID,Subject_ID,Semester,SubjectCode,SubjectName');
|
|
$this->db->order_by('ID','ASC');
|
|
$this->db->where('Subject_ID',$ID);
|
|
$this->db->from('T_SubjectDetails');
|
|
$subjectDetails = $this->db->get();
|
|
return $subjectDetails->result();
|
|
}
|
|
|
|
|
|
|
|
|
|
/*** get university list******/
|
|
public function get_university_list() {
|
|
$this->db->select('*');
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
$this->db->from(UNIVERSITY);
|
|
$this->db->where('IsActive',1);
|
|
$univDetails = $this->db->get();
|
|
$universityDetails = $univDetails->result();
|
|
if (count($universityDetails) > 0) {
|
|
$results['univList'] = true;
|
|
$results['university_details'] = $universityDetails;
|
|
} else {
|
|
$results['univList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
return $results;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********get course&Batch for university********/
|
|
|
|
public function get_courseBatch_list($univId) {
|
|
$this->db->select('C.CourseID, C.CourseName');
|
|
$this->db->from(COURSE.' as C');
|
|
$this->db->where('UniversityID',$univId);
|
|
$this->db->where('IsActive',1);
|
|
$courseDetails = $this->db->get();
|
|
if($courseDetails->result()){
|
|
$this->db->select('B.BatchCode, B.BatchName');
|
|
$this->db->from(BATCH.' as B');
|
|
$this->db->where('UniversityID',$univId);
|
|
$this->db->where('IsActive',1);
|
|
$batchDetails = $this->db->get();
|
|
if( $batchDetails->result()) {
|
|
$result['courseStatus'] = true;
|
|
$result['course_details'] = $courseDetails->result();
|
|
$result['batch_details'] = $batchDetails->result();
|
|
} else {
|
|
$result['courseStatus'] = false;
|
|
$result['message'] = "No records found!";
|
|
}
|
|
}
|
|
else {
|
|
$result['courseStatus'] = false;
|
|
$result['message'] = "No records found!";
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
} |