Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 194 |
| Template2RegularTabulationRegisterGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
1560.00 | |
0.00% |
0 / 194 |
| __construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getTemplateName | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 22 |
|||
| processData | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 52 |
|||
| renderRegularTabulationRegisterResult | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 39 |
|||
| rearrangeDataForPrint | |
0.00% |
0 / 1 |
380.00 | |
0.00% |
0 / 81 |
|||
| <?php | |
| // Template Regular TR For CHRIST College | |
| namespace com\linways\ec\core\service\RegularTabulationRegisterGenerator; | |
| use com\linways\ec\core\service\StudentMarkListService; | |
| use com\linways\ec\core\service\TabulationRegisterService; | |
| use com\linways\ec\core\service\ExamRegistrationService; | |
| use com\linways\ec\core\exception\ExamControllerException; | |
| use com\linways\base\util\TwigRenderer; | |
| use com\linways\core\ams\professional\util\PdfUtil; | |
| use com\linways\ec\core\service\CommonExamService; | |
| use com\linways\ec\core\service\GradeSchemeService; | |
| use com\linways\ec\core\service\RegularTabulationRegisterGenerator\RegularTabulationRegisterResultDataGenerator; | |
| class Template2RegularTabulationRegisterGenerator extends RegularTabulationRegisterResultDataGenerator | |
| { | |
| public function __construct(){} | |
| protected function getTemplateName($request){ | |
| $templateName = "template_2_ug"; | |
| $examRegistrationDetails = new \stdClass; | |
| $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
| if(empty($examRegistrationDetailsArray)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| $examRegistrationDetails->courseTypeName = $examRegistrationDetailsArray[0]->groups[0]->courseTypeName; | |
| $examRegistrationDetails->batchStartYear = $examRegistrationDetailsArray[0]->groups[0]->batchStartYear; | |
| if($examRegistrationDetails->degreeName == "BLISC"){ | |
| $templateName = "template_2_blisc"; | |
| } | |
| else if($examRegistrationDetails->courseTypeName == "UG"){ | |
| $templateName = "template_2_ug"; | |
| } | |
| else if($examRegistrationDetails->courseTypeName == "PG"){ | |
| $templateName = "template_2_pg"; | |
| } | |
| else{ | |
| $templateName = "template_2_ug"; | |
| } | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college base | |
| * | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $studentsMarkDetails = []; | |
| $examRegistrationData = TabulationRegisterService::getInstance()->getExamRegistrationDetailsForTabulationRegisterReports($request); | |
| $examRegistrationData->totalCredit = 0; | |
| $examRegistrationData->programName = $examRegistrationData->degreeName.' '.$examRegistrationData->streamName; | |
| $examRegistrationData->academicExamYear = ( $examRegistrationData->examYear - 1) . "-" . $examRegistrationData->examYear; | |
| if((int)$examRegistrationData->semInSemNumber % 2){ | |
| $examRegistrationData->academicExamYear = $examRegistrationData->examYear . "-" . ( $examRegistrationData->examYear + 1); | |
| } | |
| $searchRequest = new \stdClass; | |
| $searchRequest->fetchAllSemesterDetails = $examRegistrationData->isFinalSemester ? true : false; | |
| $searchRequest->considerSupplementary = true; | |
| $searchRequest->studentId = $request->studentId; | |
| $searchRequest->groupId = $request->groupId; | |
| $searchRequest->examRegistrationId = $request->examRegistrationId; | |
| $searchRequest->academicTermId = $request->academicTermId; | |
| $searchRequest->considerGraceMark = true; | |
| $searchRequest->supplementaryMonthUpperLimit = $examRegistrationData->examMonth; | |
| $searchRequest->supplementaryYearUpperLimit = $examRegistrationData->examYear; | |
| if($examRegistrationData->isFinalSemester){ | |
| $allSemesterDetails = CommonExamService::getInstance()->getAllAcademicTermsDetailsByBatch($searchRequest); | |
| $allSemesterDetails = array_filter($allSemesterDetails,function($academicTerm)use($examRegistrationData) { | |
| if($examRegistrationData->academicTermId != $academicTerm->id){ | |
| return $academicTerm; | |
| } | |
| }); | |
| uasort($allSemesterDetails, function($a, $b) { | |
| return ($a->orderNo > $b->orderNo); | |
| }); | |
| $response->allSemesterDetails = $allSemesterDetails; | |
| } | |
| $studentsMarkDetails = TabulationRegisterService::getInstance()->getAllRegistredStudentMarkDetailsForTabulationRegister($searchRequest); | |
| if(empty($studentsMarkDetails)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| $gradeSchemes = GradeSchemeService::getInstance()->getAllExamRegistrationGradeSchemes($request); | |
| array_walk($gradeSchemes,function($gradeScheme,$key){ | |
| $gradeScheme->properties = json_decode($gradeScheme->properties); | |
| $gradeScheme->rangeFrom = $gradeScheme->range_from; | |
| $gradeScheme->rangeTo = $gradeScheme->range_to; | |
| $gradeScheme->className = $gradeScheme->properties->class; | |
| }); | |
| $response->gradeSchemes = $gradeSchemes; | |
| $studentsMarkDetails = TabulationRegisterService::getInstance()->processStudentDataForRegularTabulationRegister($studentsMarkDetails,$searchRequest,$examRegistrationData); | |
| $response->studentData = $studentsMarkDetails->studentsDetails; | |
| foreach($studentsMarkDetails->displaySubjects as $subject){ | |
| $examRegistrationData->totalCredit += (int)$subject->credit; | |
| } | |
| $response->examRegistrationData = $examRegistrationData ; | |
| $response->examRegistrationData->subjects = $studentsMarkDetails->displaySubjects; | |
| $response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $response->displayContentOptions = $request->displayContentOptions; | |
| $response->isPrint = $request->isPrint ? true : false; | |
| return $response; | |
| } | |
| /** | |
| * Render Program Result | |
| * | |
| * @param $templateName | |
| * @param Object $data | |
| * @return Object | |
| */ | |
| protected function renderRegularTabulationRegisterResult($templateName, $data){ | |
| if(empty($data)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| else{ | |
| $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/TablationRegister/RegularTR/Template2/$templateName.twig"), [ 'data'=>$data ]); | |
| if ($data->examRegistrationData->isFinalSemester && $data->examRegistrationDetails->courseTypeName != "PG" && $data->isPrint) { | |
| // $responseHtml = $this->rearrangeDataForPrint($responseHtml); | |
| $totalWidth = 420; | |
| $totalHeight = 297; | |
| } | |
| elseif($data->examRegistrationDetails->courseTypeName == "PG"){ | |
| $totalWidth = 500; | |
| $totalHeight = 354; | |
| } | |
| else{ | |
| $totalWidth = 500; | |
| $totalHeight = 354; | |
| } | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= ""; | |
| $prtContent .= '</head><title>Consolidated MarkList</title><body>'; | |
| $prtContent .= $responseHtml; | |
| $prtContent .= '</body></html>'; | |
| $options = array( | |
| 'page-width' => $totalWidth."mm", | |
| 'page-height' => $totalHeight."mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "9mm", | |
| 'margin-left' => "1mm", | |
| 'margin-right' => "1mm", | |
| 'margin-bottom' => "9mm", | |
| // 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
| 'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
| ); | |
| $programResult = new \stdClass; | |
| $programResult->dispalyHtmlData = $responseHtml; | |
| $programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| } | |
| /** | |
| * rearrange Data For Print | |
| * @param $html | |
| * @return $responseHtml | |
| */ | |
| function rearrangeDataForPrint($html){ | |
| // split all html content into 6 parts | |
| $contentHtml = ""; | |
| $splitTag1 = explode("<!--tag1-->", $html); | |
| if (!strpos($html, "<!--tag1-->")) { | |
| return $html; | |
| } | |
| $pageHead = $splitTag1[0]; | |
| $tableHead = $splitTag1[1]; | |
| $contentHead = $splitTag1[2]; | |
| $tableHeadClose = $splitTag1[3]; | |
| $content = $splitTag1[4]; | |
| $tableFoot = $splitTag1[5]; | |
| $pageFoot = $splitTag1[6]; | |
| // split rows of head and student data | |
| $contentHeadRaws = explode("<!--tag2-->", $contentHead); | |
| $contentRaws = explode("<!--tag2-->", $content); | |
| // split table headings into parts like "studentName, Regno" and group of subject column | |
| $contentMainHeads = explode("<!--tag3-->", $contentHeadRaws[1]); | |
| $contentSubHeads = explode("<!--tag3-->", $contentHeadRaws[3]); | |
| $sliceCount = count($contentMainHeads); | |
| $studentHead = $contentMainHeads[0]; | |
| $students = []; | |
| $tableSlices = []; | |
| foreach ($contentRaws as $key => $contentRaw) { | |
| if (strpos($contentRaw, "<tr>") || strpos($contentRaw, "</tr>")) continue; | |
| // split table student details into parts like "student-1, REGNO-1" and group of subject mark details | |
| $contentSlices = explode("<!--tag3-->", $contentRaw); | |
| $students[$key] = $contentSlices[0]; | |
| for ($tableNum = 1; $tableNum < $sliceCount; $tableNum++) { | |
| $tableSlices[$tableNum][$key] = $contentSlices[$tableNum]; | |
| } | |
| } | |
| $studentCount = 0; | |
| $pageNum = 0; | |
| $contentPages = []; | |
| foreach ($students as $key => $student) { | |
| $studentCount++; | |
| if (!($studentCount % 36)) { | |
| $pageNum++; | |
| } | |
| foreach ($tableSlices as $tableNum => $tableSlice) { | |
| if (substr_count($tableSlices[$tableNum][$key], "<!--subject_tag-->") <= 0 && $tableNum > 1) continue; | |
| $subjectTagCount = substr_count($tableSlices[$tableNum][$key], "<!--subject_tag-->"); | |
| $tableWidth = ($subjectTagCount * 20) + 55; | |
| if (substr_count($tableSlices[$tableNum][$key], "<!--overallmark_tag-->") > 0) { | |
| $tableWidth += 20; | |
| } | |
| $tableWidth = $tableWidth > 100 ? 100 : $tableWidth; | |
| $extraColumn = 100 - $tableWidth; | |
| $extraColumnTd = ""; | |
| $extraColumnTdColspan = 106; | |
| if ($extraColumn) { | |
| $extraColumnTd = "<th width='$extraColumn%' style='border: 1px solid #ffff; border-left:1px #000; border-top:1px solid #fff; border-bottom: 1px solid #fff; border-right: 1px solid #fff;' rowspan='2' colspan='{{extraColumnTdColspan}}'> </th>"; | |
| } | |
| if (substr_count($tableSlices[$tableNum + 1][$key], "<!--subject_tag-->") <= 0) { | |
| if (!$contentPages[$pageNum]->contentTables[$tableNum]) { | |
| $tr = "<tr></tr><tr>$studentHead$contentMainHeads[$tableNum]" . $contentMainHeads[$tableNum + 1] . "$extraColumnTd</tr>"; | |
| $extraColumnTdColspan -= substr_count($tr, "<th") - 1; | |
| str_replace('{{extraColumnTdColspan}}', $extraColumnTdColspan, $tr); | |
| str_replace('{{extraColumnTdColspan}}', $extraColumnTdColspan, $extraColumnTd); | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= $tr; | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>" . $contentSubHeads[$tableNum - 1] . $contentSubHeads[$tableNum] . "</tr>$tableHeadClose"; | |
| } | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>" . $student . $tableSlice[$key] . $tableSlices[$tableNum + 1][$key] . "$extraColumnTd</tr>"; | |
| } else { | |
| if (!$contentPages[$pageNum]->contentTables[$tableNum]) { | |
| $tr = "<tr>$studentHead$contentMainHeads[$tableNum]$extraColumnTd</tr>"; | |
| $extraColumnTdColspan -= substr_count($tr, "<th") - 1; | |
| str_replace('{{extraColumnTdColspan}}', $extraColumnTdColspan, $tr); | |
| str_replace('{{extraColumnTdColspan}}', $extraColumnTdColspan, $extraColumnTd); | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= $tr; | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>" . $contentSubHeads[$tableNum - 1] . "</tr>$tableHeadClose"; | |
| } | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>$student$tableSlice[$key]$extraColumnTd</tr>"; | |
| } | |
| } | |
| } | |
| foreach ($contentPages as $pageNum => $page) { | |
| foreach ($page->contentTables as $tableNum => $table) { | |
| // $subjectTagCount = substr_count($table, "<!--subjectHead_tag-->"); | |
| // $tableWidth = ($subjectTagCount * 15) + 40; | |
| // if(substr_count($table, "<!--overallmark_tag-->") > 0) { | |
| // $tableWidth += 20; | |
| // } | |
| // $tableWidth = $tableWidth > 100 ? 100 : $tableWidth; | |
| // $replaceCount = 1; | |
| // $tableHeadWithNewWidth = str_replace("width:100%!important;", "width:$tableWidth%!important;", $tableHead, $replaceCount); | |
| $contentHtml .= "$tableHead $table $tableFoot"; | |
| } | |
| } | |
| $responseHtml = $pageHead . $contentHtml . $pageFoot; | |
| return $responseHtml; | |
| } | |
| } | |