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($jsonData){ foreach($jsonData as $row){ $insertFeesArray['CourseID'] =$arrayDetails['CourseID']; $insertFeesArray['ProgramType'] =$row['program']; $insertFeesArray['FeesType'] =$arrayDetails['FeesType']; $insertFeesArray['FeesAmount'] =$row['FeesAmount']; $insertFeesArray['Sem_Year'] =$row['FeesName']; $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) { $updateFeesArray['ID'] = $row['ID']; $updateFeesArray['CourseID'] = $arrayDetails['CourseID']; // $insertFeesArray['ProgramType'] =$row['program']; //$insertFeesArray['FeesType'] =$arrayDetails['FeesType']; $updateFeesArray['FeesAmount'] = $row['FeesAmount']; $updateFeesArray['Sem_Year'] = $row['Sem_Year']; $updateFeesArray['UpdatedOn'] = $arrayDetails['UpdatedOn']; $updateFeesArray['UpdatedBy'] = $arrayDetails['UpdatedBy']; $this->db->where('ID', $updateFeesArray['ID']); $this->db->update(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(); } }