db->select('CourseCode'); $this->db->where('CourseCode', $arrayDetails['CourseCode']); $this->db->where('UniversityID', $arrayDetails['UniversityID']); $this->db->where('BranchCode', $arrayDetails['BranchCode']); if($this->db->get(COURSE)->first_row()){ $result['courseStatus'] = false; $result['message'] = "This course id is already exist in same university"; } else { $this->db->insert(COURSE, $arrayDetails); if ($this->db->affected_rows() == '1') { $insert_id = $this->db->insert_id(); if($jsonSemFeesData){ foreach($jsonSemFeesData as $row){ $insertFeesArray['CourseID'] =$insert_id; $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); } /* // hide subject insert query if($subjectDetails){ $this->insertCourseSubjects($arrayDetails,$insert_id,$subjectDetails); }*/ $result['courseStatus'] = true; $result['message'] = "Successfully course details added"; } else{ $this -> db -> where('CourseCode', $arrayDetails['CourseCode']); $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($requestedBy,$branchCode) { $this->db->select('CU.CourseID,CU.CourseCode,CU.CourseName,CU.FeesType,CU.Specilization1,CU.Specilization2,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->where('CU.BranchCode',$branchCode); $this->db->where('US.BranchCode',$branchCode); $this->db->order_by('CU.CourseID','DESC'); $courseDetails = $this->db->get(); if($courseDetails->result()){ $result['courseStatus'] = true; foreach ($courseDetails->result() as $row){ $fetchData['CourseID']=$row->CourseID; $fetchData['CourseCode']=$row->CourseCode; $fetchData['CourseName']=$row->CourseName; $fetchData['FeesType']=$row->FeesType; $fetchData['Specilization1']=$row->Specilization1; $fetchData['Specilization2']=$row->Specilization2; $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); // $fetchData['existSubjects'] = $this->getExistCourseSubjectDetails($row->CourseID); $storeCourseArray[]=$fetchData; } $result['details'] = $storeCourseArray; } else { $result['courseStatus'] = false; $result['message'] = "No records found!"; } return $result; } public function getCourseUnivFeesTypes($requestedBy=null,$requestedBranch=null) { $result['universityDetails'] = $this->getUniversityDetails($requestedBy,$requestedBranch); $result['feesDetails'] = $this->getFeesDetails(); // $result['subjectetails'] = $this->getSubjectDetails($requestedBy,$requestedBranch); $result['courseStatus'] = true; return $result; } /* * update course details * created by kms * */ public function updateCourse($arrayDetails=null,$jsonData=null) //$subjectDetails=null { $this->db->select('CourseCode'); $this->db->where('CourseCode', $arrayDetails['CourseCode']); $this->db->where('UniversityID', $arrayDetails['UniversityID']); $this->db->where('BranchCode', $arrayDetails['BranchCode']); $this->db->where('CourseID !=', $arrayDetails['CourseID']); if($this->db->get(COURSE)->first_row()){ $result['courseStatus'] = false; $result['message'] = "This course id is already exist in same university"; } else{ $this->db->where('CourseID',$arrayDetails['CourseID']); $this->db->where('BranchCode', $arrayDetails['BranchCode']); $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); } } // update course subject details // $this->updateCourseSubjcetDetails($subjectDetails); $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($requestedBy,$requestedBranch) { $this->db->select('UniversityID,UniversityName'); $this->db->order_by('UniversityID','ASC'); $this->db->where('IsActive','1'); $this->db->where('BranchCode',$requestedBranch); $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(); } /* * get subject details * created by kms * */ public function getSubjectDetails($requestedBy,$requestedBranch){ $this->db->select('SubjectID,SubjectCode,SubjectName'); $this->db->order_by('SubjectID','DESC'); $this->db->where('IsActive','1'); $this->db->where('BranchCode',$requestedBranch); $subjectDetails = $this->db->get(SUBJECTMASTER); return $subjectDetails->result(); } /* *Insert course sujects * created by kms * */ public function insertCourseSubjects($details=null,$courseID=null,$subjects=null){ $insertSubject['UniversityID'] = $details['UniversityID']; $insertSubject['CourseID'] = $courseID; if ($subjects){ foreach ($subjects as $row){ $insertSubject['SubjectID'] = $row['SubjectID']; $insertSubject['IsActive'] = true; $insertSubject['CreatedBy'] = $details['CreatedBy']; $insertSubject['CreatedOn'] = $details['CreatedOn']; $this->db->insert(COURSESUBJECT, $insertSubject); } } return true; } /* * get exist Course subject details * created by kms * */ public function getExistCourseSubjectDetails($courseID=null){ $this->db->select('CSU.SubjectID,SM.SubjectCode,SM.SubjectName'); $this->db->order_by('CSID','ASC'); $this->db->where('CSU.CourseID',$courseID); $this->db->where('CSU.IsActive','1'); // $this->db->where('SM.IsActive','1'); $this->db->from(COURSESUBJECT.' as CSU'); $this->db->join(SUBJECTMASTER.' as SM', 'SM.SubjectID = CSU.SubjectID'); $subDetails = $this->db->get(); return $subDetails->result(); } /* * update course subject details * created by kms * */ public function updateCourseSubjcetDetails($sujects=null){ $deactiveStatus['IsActive']=false; $deactiveStatus['UpdatedBy']=$sujects['UpdatedBy']; $deactiveStatus['UpdatedOn']=$sujects['UpdatedOn']; $this->db->where('CourseID ',$sujects['CourseID']); $this->db->where('UniversityID ',$sujects['UniversityID']); $updateCourseSubjectDeactive = $this->db->update(COURSESUBJECT, $deactiveStatus); if($updateCourseSubjectDeactive){ if($sujects['Subjects']){ foreach ($sujects['Subjects'] as $srow){ $this->db->select('CSID'); $this->db->where('CourseID',$sujects['CourseID']); $this->db->where('UniversityID',$sujects['UniversityID']); $this->db->where('SubjectID',$srow); if($this->db->get(COURSESUBJECT)->first_row()){ $existStatusUpdate['IsActive']=true; $existStatusUpdate['UpdatedBy']=$sujects['UpdatedBy']; $existStatusUpdate['UpdatedOn']=$sujects['UpdatedOn']; $this->db->where('CourseID',$sujects['CourseID']); $this->db->where('UniversityID',$sujects['UniversityID']); $this->db->where('SubjectID',$srow); $this->db->update(COURSESUBJECT, $existStatusUpdate); } else{ $update_array["UniversityID"]=$sujects['UniversityID']; $update_array["CourseID"]=$sujects['CourseID']; $update_array["SubjectID"]=$srow; $update_array["IsActive"]=true; $update_array["CreatedBy"]=$sujects['UpdatedBy']; $update_array["CreatedOn"]=$sujects['UpdatedOn']; $this->db->insert(COURSESUBJECT, $update_array); } } } /* else{ $activateStatus['IsActive']=true; $this->db->where('CourseID ',$sujects['CourseID']); $this->db->where('UniversityID ',$sujects['UniversityID']); $this->db->update(COURSESUBJECT, $activateStatus); }*/ } return true; } }