Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 11 |
CRAP | |
0.00% |
0 / 228 |
| ExamRegistrationFeeService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 11 |
1056.00 | |
0.00% |
0 / 228 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| searchExamRegistrationCommonFees | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 26 |
|||
| getAllExamRegistrationFeeOperations | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 22 |
|||
| getFeeOperationsBaseTableDetails | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 18 |
|||
| deleteExamRegistrationCommonFeesAndFInes | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 26 |
|||
| deleteExamRegistrationSubTemplateFees | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| getAllExamRegistrationFeeTemplate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 15 |
|||
| getAllFeeTemplateDetailsByMappingId | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 35 |
|||
| saveExamRegistrationSubjectFeeTemplate | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 14 |
|||
| getAssignedBatchFeeTemplate | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 32 |
|||
| getRegisteredStudentSubjectDetails | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 25 |
|||
| <?php | |
| namespace com\linways\ec\core\service; | |
| use com\linways\base\util\MakeSingletonTrait; | |
| use com\linways\ec\core\exception\ExamControllerException; | |
| use com\linways\ec\core\mapper\ExamRegistrationFeeServiceMapper; | |
| class ExamRegistrationFeeService extends BaseService | |
| { | |
| use MakeSingletonTrait; | |
| private function __construct() { | |
| $this->mapper = ExamRegistrationFeeServiceMapper::getInstance()->getMapper(); | |
| } | |
| /** | |
| * Get Exam Registration Common Fee Template | |
| * @param $request | |
| * @return commonFees | |
| */ | |
| public function searchExamRegistrationCommonFees($request){ | |
| $request = $this->realEscapeObject($request); | |
| $whereQuery = ""; | |
| if(!empty($request->examRegistrationId)) { | |
| $whereQuery .= " AND eeftm.ec_exam_registration_id='$request->examRegistrationId' "; | |
| } | |
| $orderBy = " ORDER BY eeft.id ASC"; | |
| $query = "SELECT | |
| eeft.id as templateId, | |
| eeftm.id as mappingId, | |
| eeftm.template_name, | |
| eeft.fee_properties, | |
| eeft.fine_properties, | |
| eeft.operation_properties | |
| FROM | |
| ec_examregistration_fee_templates_mapping eeftm | |
| INNER JOIN ec_examregistration_fee_templates eeft ON | |
| eeft.ec_examregistration_fee_templates_mapping_id = eeftm.id | |
| WHERE | |
| 1 = 1"; | |
| try { | |
| $commonFees = $this->executeQueryForList($query.$whereQuery.$orderBy, $this->mapper[ExamRegistrationFeeServiceMapper::SEARCH_EXAM_REGISTRATION_COMMON_FEES]); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $commonFees; | |
| } | |
| /** | |
| * Get All Exam Registration Fee Operations | |
| * @return examRegistrationBatches | |
| */ | |
| public function getAllExamRegistrationFeeOperations(){ | |
| $query = " SELECT | |
| id AS operationId, | |
| display_name AS name, | |
| code, | |
| properties->>'$.baseTableName' AS baseTableName, | |
| properties->>'$.baseTablecolumnId' AS baseTablecolumnId, | |
| properties->>'$.baseTableColumnName' AS baseTableColumnName, | |
| remark, | |
| operation | |
| FROM | |
| ec_fee_operations | |
| WHERE | |
| 1 = 1"; | |
| try { | |
| $feeOperations = $this->executeQueryForList($query); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| array_walk($feeOperations, function($feeOperation){ | |
| $feeOperation->operation = json_decode($feeOperation->operation); | |
| }); | |
| return $feeOperations; | |
| } | |
| /** | |
| * Get Fee Operations Base Table Details | |
| * @param $baseTableObj | |
| * @return examRegistrationBatches | |
| */ | |
| public function getFeeOperationsBaseTableDetails($baseTabelObj){ | |
| $baseTabelObj = $this->realEscapeObject($baseTabelObj); | |
| $columnCondition = ""; | |
| $columnCondition = $baseTabelObj->baseTablecolumnId." AS id, "; | |
| $columnCondition .= $baseTabelObj->baseTableColumnName." AS name "; | |
| $tableName = $baseTabelObj->baseTableName; | |
| $query = " SELECT | |
| $columnCondition | |
| FROM | |
| $tableName | |
| WHERE | |
| 1 = 1"; | |
| try { | |
| $baseTableArray = $this->executeQueryForList($query); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $baseTableArray; | |
| } | |
| /** | |
| * Delete examRegistration template | |
| * @param String $id | |
| * @return NULL | |
| */ | |
| public function deleteExamRegistrationCommonFeesAndFInes($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $request = new \stdClass(); | |
| $request->templateId = $id; | |
| $entryCheck = $this->getAssignedBatchFeeTemplate($request); | |
| if($entryCheck){ | |
| throw new ExamControllerException(ExamControllerException::BATCHES_ALREADY_ASSIGNED_FOR_FEE_TEMPLATES,"Error deleting Exam Registration Fee Template! Batches Already Assigned."); | |
| } | |
| $query = "DELETE eeft | |
| FROM | |
| ec_examregistration_fee_templates_mapping eeftm | |
| INNER JOIN ec_examregistration_fee_templates eeft ON | |
| eeft.ec_examregistration_fee_templates_mapping_id = eeftm.id | |
| WHERE | |
| eeftm.id = '$id'"; | |
| $query1 = "DELETE FROM | |
| ec_examregistration_fee_templates_mapping | |
| WHERE | |
| id = '$id'"; | |
| try { | |
| $this->executeQuery($query); | |
| $this->executeQuery($query1); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException(ExamControllerException::ERROR_DELETING_EXAM_REGISTRATION_BATCH,"Error deleting Exam Registration Batch! Please try again"); | |
| } | |
| } | |
| /** | |
| * Delete examRegistration sub template | |
| * @param String $id | |
| * @return NULL | |
| */ | |
| public function deleteExamRegistrationSubTemplateFees($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $query = "DELETE | |
| FROM | |
| ec_examregistration_fee_templates | |
| WHERE | |
| id = '$id'"; | |
| try { | |
| $this->executeQuery($query); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException(ExamControllerException::ERROR_DELETING_EXAM_REGISTRATION_BATCH,"Error deleting Exam Registration Batch! Please try again"); | |
| } | |
| } | |
| /** | |
| * Get All Exam Registration Fee Operations | |
| * @params examRegistrationId | |
| * @return feeTemplates | |
| */ | |
| public function getAllExamRegistrationFeeTemplate($examRegistrationId){ | |
| $examRegistrationId = $this->realEscapeString($examRegistrationId); | |
| $query = " SELECT | |
| id, | |
| template_name AS name | |
| FROM | |
| ec_examregistration_fee_templates_mapping | |
| WHERE | |
| ec_exam_registration_id = '$examRegistrationId'"; | |
| try { | |
| $feeTemplates = $this->executeQueryForList($query); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $feeTemplates; | |
| } | |
| /** | |
| * Get All Fee Template Details By Mapping Id | |
| * @params examRegistrationId | |
| * @return feeTemplates | |
| */ | |
| public function getAllFeeTemplateDetailsByMappingId($templateId){ | |
| $templateId = $this->realEscapeString($templateId); | |
| $query = " SELECT | |
| eeft.id AS templateId, | |
| ec_examregistration_fee_templates_mapping_id AS mapingId, | |
| eeftm.template_name AS templateName, | |
| eeft.fee_properties, | |
| eeft.fine_properties, | |
| eeft.operation_properties AS property | |
| FROM | |
| ec_examregistration_fee_templates_mapping eeftm | |
| INNER JOIN ec_examregistration_fee_templates eeft ON | |
| eeft.ec_examregistration_fee_templates_mapping_id = eeftm.id | |
| WHERE | |
| eeftm.id = '$templateId' | |
| ORDER BY eeft.id"; | |
| try { | |
| $feeTemplates = $this->executeQueryForList($query); | |
| $feeOperation = (array) $this->getAllExamRegistrationFeeOperations(); | |
| foreach($feeTemplates as $feeTemplate){ | |
| $feeTemplate->fineProperty = json_decode($feeTemplate->fine_properties ); | |
| $feeTemplate->feeProperty = json_decode($feeTemplate->fee_properties ); | |
| $templateDetails = json_decode($feeTemplate->property ); | |
| $feeTemplate->operationProperty = $templateDetails; | |
| $operationId = current($templateDetails->operations)->id; | |
| $key = ''; | |
| if( $operationId){ | |
| $key = array_search( $operationId, array_column($feeOperation, 'operationId')); | |
| $feeTemplate->searchCondition = $feeOperation[$key]->name; | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $feeTemplates; | |
| } | |
| /** | |
| * Save exam registration subject fees | |
| * @params subjects | |
| * @return | |
| */ | |
| public function saveExamRegistrationSubjectFeeTemplate ($subjects) | |
| { | |
| $subjects = $this->realEscapeObject($subjects); | |
| try{ | |
| foreach($subjects as $subject){ | |
| $subject = (object) $subject; | |
| $feeJson = $subject->feesPropertiesArray ? json_encode($subject->feesPropertiesArray) : "{}"; | |
| $propertiesJson = $subject->properties ? json_encode($subject->properties) : "{}"; | |
| $query = "UPDATE ec_exam_registration_subject SET fees_properties = '$feeJson' , properties = '$propertiesJson' WHERE id = '$subject->id'"; | |
| $this->executeQuery($query); | |
| } | |
| }catch(\Exception $e) { | |
| throw new ExamControllerException ($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get fee template asssigned to batches | |
| * @params examRegistrationId | |
| * @return feeTemplates | |
| */ | |
| public function getAssignedBatchFeeTemplate($request){ | |
| $request = $this->realEscapeObject($request); | |
| $limitQuerry = "Limit 1"; | |
| $whereQuery = ''; | |
| if(!empty($request->studentRegistrationRequest)) { | |
| $joinQueary = " INNER JOIN ec_exam_registration_subject eers ON | |
| eers.ec_exam_registration_batch_id = eerb.id | |
| INNER JOIN ec_student_assessment_registration esar ON | |
| esar.am_assessment_id = eers.am_assessment_id AND CAST(esar.properties ->> '$.registrationStatus' AS CHAR) IN ('REGISTERED','APPLIED') "; | |
| } | |
| if($request->batchRelationId){ | |
| $whereQuery .= " AND eerb.id = '$request->batchRelationId'"; | |
| } | |
| if($request->templateId){ | |
| $whereQuery .= " AND eeftm.id = '$request->templateId'"; | |
| } | |
| $query = " SELECT | |
| DISTINCT eeftm.id, | |
| eeftm.template_name AS name | |
| FROM | |
| ec_examregistration_fee_templates_mapping eeftm | |
| INNER JOIN ec_exam_registration_batch eerb ON | |
| CAST(eerb.fees_properties ->> '$.feeTemplateId' AS CHAR) = eeftm.id | |
| $joinQueary | |
| WHERE | |
| 1 = 1 "; | |
| try { | |
| $feeTemplates = $this->executeQueryForList($query. $whereQuery.$limitQuerry); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $feeTemplates; | |
| } | |
| /** | |
| * Get Registered Student Subject Details | |
| * @params batchRelationId | |
| * @return $examRegistrationSubjectIds | |
| */ | |
| public function getRegisteredStudentSubjectDetails($request){ | |
| $request = $this->realEscapeObject($request); | |
| $whereQuery = ''; | |
| $examRegistrationSubjectIds = []; | |
| if($request->batchRelationId){ | |
| $whereQuery .= " AND eerb.id = '$request->batchRelationId'"; | |
| } | |
| $query = " SELECT | |
| DISTINCT eers.id | |
| FROM | |
| ec_exam_registration_batch eerb | |
| INNER JOIN ec_exam_registration_subject eers ON | |
| eers.ec_exam_registration_batch_id = eerb.id | |
| INNER JOIN ec_student_assessment_registration esar ON | |
| esar.am_assessment_id = eers.am_assessment_id AND | |
| CAST(esar.properties ->> '$.registrationStatus' AS CHAR) IN ('REGISTERED','APPLIED') | |
| WHERE | |
| 1 = 1 "; | |
| try { | |
| $examRegistrationSubjectIdList = $this->executeQueryForList($query. $whereQuery); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| $examRegistrationSubjectIds = array_column($examRegistrationSubjectIdList, 'id'); | |
| return $examRegistrationSubjectIds; | |
| } | |
| } |