apollodec/Apollo/api/application/models/Course_model.php
venbatechnologies@gmail.com d06b1c0cba status file
2017-12-07 11:31:25 +05:30

239 lines
7.7 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: karthi
* Date: 11/23/17
* Time: 4:58 PM
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Course_model extends CI_Model {
/*
* add course details
* created by kms
* */
public function addCourse($arrayDetails=null,$jsonSemFeesData=null)
{
$this->db->select('CourseID');
$this->db->where('CourseID', $arrayDetails['CourseID']);
if($this->db->get(COURSE)->first_row()){
$result['courseStatus'] = false;
$result['message'] = "This course id is already exist!";
} else {
$this->db->insert(COURSE, $arrayDetails);
if ($this->db->affected_rows() == '1') {
if($jsonSemFeesData){
foreach($jsonSemFeesData as $row){
$insertFeesArray['CourseID'] =$arrayDetails['CourseID'];
$insertFeesArray['ProgramType'] =$row['program'];
$insertFeesArray['FeesType'] =$row['FeesType'];
$insertFeesArray['FeesAmount'] =$row['FeesAmount'];
$insertFeesArray['Sem_Year'] =$row['programName'];
$insertFeesArray['UpdatedOn'] =$arrayDetails['CreatedOn'];
$insertFeesArray['UpdatedBy'] =$arrayDetails['CreatedBy'];
$this->db->insert(COURSE_FEES, $insertFeesArray);
}
$result['courseStatus'] = true;
$result['message'] = "Successfully course details added";
}
else{
$this -> db -> where('CourseID', $arrayDetails['CourseID']);
$this -> db -> delete('COURSE');
$result['courseStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
} else {
$result['courseStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
return $result;
}
/*
* get branch details
* parama id
* created by kms
* */
public function getCourse()
{
$this->db->select('CU.CourseID,CU.CourseName,CU.FeesType,CU.PC,CU.DC,CU.TC,CU.MC,CU.OtherFees,CU.IsActive,US.UniversityID,US.UniversityName');
$this->db->from(COURSE.' as CU');
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
$this->db->order_by('CU.CreatedOn','DESC');
$courseDetails = $this->db->get();
if($courseDetails->result()){
$result['courseStatus'] = true;
foreach ($courseDetails->result() as $row){
$fetchData['CourseID']=$row->CourseID;
$fetchData['CourseName']=$row->CourseName;
$fetchData['FeesType']=$row->FeesType;
$fetchData['PC']=$row->PC;
$fetchData['DC']=$row->DC;
$fetchData['TC']=$row->TC;
$fetchData['MC']=$row->MC;
$fetchData['OtherFees']=$row->OtherFees;
$fetchData['IsActive']=$row->IsActive;
$fetchData['UniversityID']=$row->UniversityID;
$fetchData['UniversityName']=$row->UniversityName;
$fetchData['feesStructures'] = $this->getCourseFeesDetails($row->CourseID);
$storeCourseArray[]=$fetchData;
}
$result['details'] = $storeCourseArray;
}
else {
$result['courseStatus'] = false;
$result['message'] = "No records found!";
}
$result['universityDetails'] = $this->getUniversityDetails();
$result['feesDetails'] = $this->getFeesDetails();
return $result;
}
/*
* update course details
* created by kms
* */
public function updateCourse($arrayDetails=null,$jsonData=null)
{
$this->db->where('CourseID',$arrayDetails['CourseID']);
$upateStatus=$this->db->update(COURSE, $arrayDetails);
if($upateStatus) {
if ($jsonData) {
foreach ($jsonData as $row) {
$feesID = $row['ID'];
$updateFeesArray['CourseID'] = $arrayDetails['CourseID'];
$updateFeesArray['FeesAmount'] = $row['FeesAmount'];
$updateFeesArray['Sem_Year'] = $row['programName'];
$updateFeesArray['UpdatedOn'] = $arrayDetails['UpdatedOn'];
$updateFeesArray['UpdatedBy'] = $arrayDetails['UpdatedBy'];
$updateFeesArray['ProgramType'] =$row['program'];
$updateFeesArray['FeesType'] =$row['FeesType'];
if($feesID!='' OR $feesID!=null){
$this->db->where('ID', $feesID);
$this->db->update(COURSE_FEES, $updateFeesArray);
}
else{
$this->db->insert(COURSE_FEES, $updateFeesArray);
}
}
$result['courseStatus'] = true;
$result['message'] = "Successfully course details updated";
}
}
else {
$result['courseStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
/*
* get university details
* created by kms
* */
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();
}
/*
* get fees details
* created by kms
* */
public function getFeesDetails()
{
$this->db->select('ListCode,ListName');
$this->db->order_by('ListCode','ASC');
$this->db->where('IsActive','1');
$this->db->where('ListGroup','3');
$feesDetails = $this->db->get(PICK_LIST_DETAILS);
if($feesDetails){
$result_fees = array();
foreach ($feesDetails->result() as $row)
{
$list_array['ListCode'] = $row->ListCode;
$list_array['ListName'] = $row->ListName;
if($row->ListCode=='F001'){
$list_array['programType']=$this->getFeesProgram('4');
}
else if($row->ListCode=='F002'){
$list_array['programType']=$this->getFeesProgram('5');
}
else{
$list_array['programType']="";
}
$result_fees[]=$list_array;
}
}
else{
$result_fees[]="";
}
return $result_fees;
}
/*
* get fees type
* created by kms
* */
public function getFeesProgram($programType=null)
{
$this->db->select('ListCode,ListName');
$this->db->order_by('ListCode','ASC');
$this->db->where('IsActive','1');
$this->db->where('ListGroup',$programType);
$feesDetails = $this->db->get(PICK_LIST_DETAILS);
return $feesDetails->result();
}
/*
* get course fees details
* created by kms
* */
public function getCourseFeesDetails($courseID=null){
$this->db->select('ID,CourseID,ProgramType,FeesAmount,Sem_Year,PLD.ListName as programName');
$this->db->order_by('ID','ASC');
$this->db->where('CourseID',$courseID);
$this->db->from(COURSE_FEES.' as CF');
$this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = CF.ProgramType');
$feesDetails = $this->db->get();
return $feesDetails->result();
}
}