Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 185 |
| SubjectGroupMapService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
1482.00 | |
0.00% |
0 / 185 |
| __construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| __clone | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getRankReportSubjectGroupById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| addRankReportSubjectGroup | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 18 |
|||
| updateRankReportSubjectGroup | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 23 |
|||
| deleteRankReportSubjectGroup | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| searchRankReportSubjectGroup | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| searchRankReportSubjectGroupMapping | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 50 |
|||
| getSubjectsForRankReportSubjectGroupMapping | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| addRankReportSubjectGroupMapping | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 37 |
|||
| getRankReportGroupByReportId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service\examcontroller; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\core\ams\professional\service\BaseService; | |
| class SubjectGroupMapService extends BaseService { | |
| // Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| // Condition 2 - Locked down the constructor | |
| private function __construct() {} | |
| // Prevent any oustide instantiation of this class | |
| // Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() {} | |
| // Prevent any copy of this object | |
| // Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() { | |
| if (! is_object ( self::$_instance )) { | |
| // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self (); | |
| } | |
| return self::$_instance; | |
| } | |
| /** | |
| * Get rank_report_subject_group details by id | |
| * @param Integer $id | |
| * @throws ProfessionalException | |
| * @return Object $rankReportSubjectGroupDetails | |
| * @author Vishnu M | |
| */ | |
| public function getRankReportSubjectGroupById ( $id ) { | |
| $id = $this->realEscapeString($id); | |
| $rankReportSubjectGroupDetails = null; | |
| try { | |
| $sql = "SELECT id, name FROM rank_report_subject_group WHERE id = '$id' "; | |
| $rankReportSubjectGroupDetails = $this->executeQueryForObject ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $rankReportSubjectGroupDetails; | |
| } | |
| /** | |
| * Add rank_report_subject_group details | |
| * @param RankReportSubjectGroup $rankReportSubjectGroup | |
| * @throws ProfessionalException | |
| * @return Integer $id | |
| * @author Vishnu M | |
| */ | |
| public function addRankReportSubjectGroup ( $rankReportSubjectGroup ) { | |
| $rankReportSubjectGroup = $this->realEscapeObject($rankReportSubjectGroup); | |
| $id = null; | |
| try { | |
| $sql = "INSERT INTO rank_report_subject_group ( | |
| name, | |
| isLanguage, | |
| student_count, | |
| created_by ) VALUES ( | |
| '".$rankReportSubjectGroup->name."', | |
| '".$rankReportSubjectGroup->isLanguage."', | |
| '".$rankReportSubjectGroup->studentCount."', | |
| '".$rankReportSubjectGroup->createdBy."' )"; | |
| $id = $this->executeQueryForObject ( $sql, TRUE ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $id; | |
| } | |
| /** | |
| * Update rank_report_subject_group details | |
| * @param RankReportSubjectGroup $rankReportSubjectGroup | |
| * @throws ProfessionalException | |
| * @author Vishnu M | |
| */ | |
| public function updateRankReportSubjectGroup ( $rankReportSubjectGroup ) { | |
| $rankReportSubjectGroup = $this->realEscapeObject($rankReportSubjectGroup); | |
| $setSql = ""; | |
| if (empty($rankReportSubjectGroup->id)) { | |
| throw new ProfessionalException(ProfessionalException::INVALID_REQUEST, "Invalid subject group"); | |
| } | |
| if ($rankReportSubjectGroup->name) { | |
| $setSql .= "name = '$rankReportSubjectGroup->name', "; | |
| } | |
| if ($rankReportSubjectGroup->isLanguage != "") { | |
| $setSql .= "isLanguage = '$rankReportSubjectGroup->isLanguage', "; | |
| } | |
| if ($rankReportSubjectGroup->studentCount) { | |
| $setSql .= "student_count = '$rankReportSubjectGroup->studentCount', "; | |
| } | |
| try { | |
| $sql = "UPDATE rank_report_subject_group SET | |
| $setSql | |
| updated_by = '$rankReportSubjectGroup->updatedBy' WHERE id = '$rankReportSubjectGroup->id' "; | |
| $this->executeQuery ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Delete rank_report_subject_group details | |
| * @param Integer $id | |
| * @throws ProfessionalException | |
| * @author Vishnu M | |
| */ | |
| public function deleteRankReportSubjectGroup ( $id ) { | |
| $id = $this->realEscapeString($id); | |
| try { | |
| $sql = "DELETE FROM rank_report_subject_group WHERE id = '$id' "; | |
| $this->executeQuery ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Search rank_report_subject_group details | |
| * @param RankReportSubjectGroupRequest $rankReportSubjectGroupRequest | |
| * @throws ProfessionalException | |
| * @return Array $rankReportSubjectGroupDetails | |
| * @author Vishnu M | |
| */ | |
| public function searchRankReportSubjectGroup ( $rankReportSubjectGroupRequest ) { | |
| $rankReportSubjectGroupRequest = $this->realEscapeObject($rankReportSubjectGroupRequest); | |
| $rankReportSubjectGroupDetails = null; | |
| $condition = null; | |
| if ( $rankReportSubjectGroupRequest->name ) { | |
| $condition .= " AND name = '$rankReportSubjectGroupRequest->name' "; | |
| } | |
| try { | |
| $sql = "SELECT id, name, isLanguage, student_count AS studentCount FROM rank_report_subject_group WHERE id = id $condition "; | |
| $rankReportSubjectGroupDetails = $this->executeQueryForList ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $rankReportSubjectGroupDetails; | |
| } | |
| /** | |
| * Search rank_report_subject_group_mapping details | |
| * @param RankReportSubjectGroupRequest $rankReportSubjectGroupRequest | |
| * @throws ProfessionalException | |
| * @return Object|Array $rankReportSubjectGroupDetails | |
| * @author Vishnu M | |
| */ | |
| public function searchRankReportSubjectGroupMapping ( $rankReportSubjectGroupRequest ) { | |
| $rankReportSubjectGroupRequest = $this->realEscapeObject($rankReportSubjectGroupRequest); | |
| $rankReportSubjectGroupDetails = null; | |
| $condition = null; | |
| if ( $rankReportSubjectGroupRequest->id ) { | |
| $condition .= " AND rrsgm.id = '$rankReportSubjectGroupRequest->id' "; | |
| } | |
| if ( $rankReportSubjectGroupRequest->groupId ) { | |
| $condition .= " AND rrsgm.rank_report_subject_group_id = '$rankReportSubjectGroupRequest->groupId' "; | |
| } | |
| if ( $rankReportSubjectGroupRequest->name ) { | |
| $condition .= " AND rrsgm.name = '$rankReportSubjectGroupRequest->name' "; | |
| } | |
| if ( $rankReportSubjectGroupRequest->rankReportId ) { | |
| $condition .= " AND rrsgm.rank_report_id = '$rankReportSubjectGroupRequest->rankReportId' "; | |
| } | |
| if ( $rankReportSubjectGroupRequest->semId ) { | |
| $condition .= " AND rrsgm.semesters_id = '$rankReportSubjectGroupRequest->semId' "; | |
| } | |
| try { | |
| $sql = "SELECT DISTINCT | |
| rrsgm.subjects_id AS subjectId, | |
| s.subjectName, | |
| s.subjectDesc, | |
| rrsgm.rank_report_subject_group_id AS subjectGroupId, | |
| rrsg.name AS groupName, | |
| rrsg.isLanguage, | |
| rrsgm.rank_report_id AS rankReportId, | |
| rrsgm.semesters_id AS semId, | |
| sem.semName, | |
| sem.orderNo, | |
| rrsgm.group_no AS groupNo, | |
| rrsg.student_count AS studentCount | |
| FROM | |
| rank_report_subject_group_mapping rrsgm | |
| INNER JOIN | |
| rank_report_subject_group rrsg ON (rrsgm.rank_report_subject_group_id = rrsg.id) | |
| INNER JOIN | |
| semesters sem ON (sem.semID = rrsgm.semesters_id) | |
| INNER JOIN | |
| subjects s ON (s.subjectID = rrsgm.subjects_id) | |
| WHERE | |
| rrsgm.id > 0 | |
| $condition | |
| ORDER BY rrsg.name ASC , sem.orderNo ASC , s.subjectPriority ASC"; | |
| $rankReportSubjectGroupDetails = $this->executeQueryForList ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $rankReportSubjectGroupDetails; | |
| } | |
| /** | |
| * @param $rankReportId | |
| * @param $subjectGroupId | |
| * @param $hdlDeptId | |
| * @return Object|null | |
| * @throws ProfessionalException | |
| * @author Vishnu M | |
| */ | |
| public function getSubjectsForRankReportSubjectGroupMapping ( $rankReportId, $subjectGroupId, $hdlDeptId ) { | |
| $rankReportId = $this->realEscapeString($rankReportId); | |
| $subjectGroupId = $this->realEscapeString($subjectGroupId); | |
| $hdlDeptId = $this->realEscapeString($hdlDeptId); | |
| $sql = null; | |
| $subjects = null; | |
| try { | |
| $sql = "SELECT DISTINCT s.subjectID as subjectId, s.subjectName, s.subjectDesc, rrsgm.rank_report_subject_group_id AS subjectGroupId, rrsgm.semesters_id AS semId, rrsgm.group_no AS groupNo FROM rank_report rr INNER JOIN batches b ON (b.batchStartYear = rr.year AND b.courseTypeID = rr.course_type_id) INNER JOIN sbs_relation sbs ON (sbs.batchID = b.batchID) INNER JOIN subjects s ON (s.subjectID = sbs.subjectID) LEFT JOIN rank_report_subject_group_mapping rrsgm ON (rrsgm.subjects_id = s.subjectID AND rrsgm.rank_report_id = rr.id AND rrsgm.rank_report_subject_group_id = '$subjectGroupId') WHERE rr.id = '$rankReportId' AND s.hdl_deptID = '$hdlDeptId' ORDER BY s.subjectName ASC"; | |
| $subjects = $this->executeQueryForList ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $subjects; | |
| } | |
| /** | |
| * @param $rankReportSubjectGroupMapping | |
| * @throws ProfessionalException | |
| * @author Vishnu M | |
| */ | |
| public function addRankReportSubjectGroupMapping ( $rankReportSubjectGroupMapping ) { | |
| $rankReportSubjectGroupMapping = $this->realEscapeObject($rankReportSubjectGroupMapping); | |
| $sql = null; | |
| $subjects = null; | |
| $values = []; | |
| try { | |
| if (!empty ( $rankReportSubjectGroupMapping ) && | |
| !empty ( $rankReportSubjectGroupMapping->subjectGroupMapping ) ) { | |
| $deleteSubjectMapping = null; | |
| foreach ( $rankReportSubjectGroupMapping->subjectGroupMapping as $subjectGroupMapping ) { | |
| $subjectGroupMapping = (Object) $subjectGroupMapping; | |
| $subjectId = $subjectGroupMapping->subjectId; | |
| if ( $subjectGroupMapping->semId ) { | |
| $values[] = "( | |
| " . $subjectGroupMapping->subjectId . ", | |
| " . $subjectGroupMapping->semId . ", | |
| " . $subjectGroupMapping->groupNo . ", | |
| " . $rankReportSubjectGroupMapping->rankReportSubjectGroupId . ", | |
| " . $rankReportSubjectGroupMapping->rankReportId . ", | |
| " . $rankReportSubjectGroupMapping->createdBy . " | |
| )"; | |
| } else { | |
| $deleteSubjectMapping[$subjectId] = $subjectId; | |
| } | |
| } | |
| if ( !empty ( $deleteSubjectMapping ) ) { | |
| $sqlDelete = "DELETE FROM rank_report_subject_group_mapping WHERE rank_report_id = '$rankReportSubjectGroupMapping->rankReportId' AND subjects_id IN (".implode(',', $deleteSubjectMapping).") AND rank_report_subject_group_id = '$rankReportSubjectGroupMapping->rankReportSubjectGroupId' "; | |
| $this->executeQuery ( $sqlDelete ); | |
| } | |
| if ( !empty ( $values ) ) { | |
| $sql = "INSERT INTO rank_report_subject_group_mapping ( subjects_id, semesters_id, group_no, rank_report_subject_group_id, rank_report_id, created_by ) VALUES " . implode(',', $values) . " ON DUPLICATE KEY UPDATE semesters_id = VALUES ( semesters_id ), rank_report_subject_group_id = VALUES ( rank_report_subject_group_id ), group_no = VALUES ( group_no ), updated_by = VALUES (created_by) "; | |
| $this->executeQuery ( $sql ); | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getRankReportGroupByReportId ( $rankReportId ) { | |
| $sql = "SELECT DISTINCT rank_report_subject_group_id as groupId FROM rank_report_subject_group_mapping WHERE rank_report_id = '$rankReportId' "; | |
| try { | |
| return $this->executeQueryForList ( $sql ); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| } | |
| ?> |