Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 77 |
| Template31HallTicketsGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
182.00 | |
0.00% |
0 / 77 |
| __construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getTemplateName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| processData | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 36 |
|||
| renderHallTicketsResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 32 |
|||
| <?php | |
| //Template Hall Ticket For PRESIDENCY UNIVERSITY | |
| namespace com\linways\ec\core\service\HallTicketsGenerator; | |
| use com\linways\ec\core\service\HallTicketsService; | |
| use com\linways\ec\core\service\CommonExamService; | |
| 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\HallTicketsGenerator\HallTicketsResultDataGenerator; | |
| use TCPDFBarcode; | |
| class Template31HallTicketsGenerator extends HallTicketsResultDataGenerator | |
| { | |
| public function __construct(){} | |
| protected function getTemplateName($request){ | |
| $templateName = "Template_31"; | |
| $request->limitCondition = 1; | |
| $request->removeStream = 1; | |
| $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
| if(empty($examRegistrationDetailsArray)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college base | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $studentsHallTicketsDetails = []; | |
| $studentsHallTicketsDetails = HallTicketsService::getInstance()->getAllHallTicketsStudentData($request); | |
| if(empty($studentsHallTicketsDetails)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| $schoolRes = CommonExamService::getInstance()->getAllSchools(); | |
| $schools = []; | |
| foreach($schoolRes as $school){ | |
| $schools[$school->id] = $school->name; | |
| } | |
| foreach($studentsHallTicketsDetails as $student){ | |
| $subjectsWithDate = []; | |
| $subjectsWithoutDate = []; | |
| if($student->rollNo){ | |
| $barcodeObj = new TCPDFBarcode( $student->rollNo , 'C128'); | |
| $student->rollNoBarcode = $barcodeObj->getBarcodeHTML($w = 1, $h = 40, $color = 'black'); | |
| } | |
| $student->schoolName = $schools[$student->schoolId] ?? ''; | |
| foreach ($student->subjects as $subject) { | |
| $subject->classTypeCode = $subject->classType ? substr($subject->classType, 0, 1) : ''; | |
| if (!empty($subject->assessmentDate)) { | |
| $subject->assessmentDateNotReset = $subject->assessmentDate; | |
| $subject->assessmentDateWithDay = date("d/m/Y, l", strtotime($subject->assessmentDate)) ; | |
| $subjectsWithDate[] = $subject; | |
| } else { | |
| $subjectsWithoutDate[] = $subject; | |
| } | |
| } | |
| // Merge the arrays back together, with subjects with dates first | |
| $student->subjects = array_merge($subjectsWithDate, $subjectsWithoutDate); | |
| } | |
| $response->studentData = $studentsHallTicketsDetails; | |
| $response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $response->collegeData->isSealEnabled = CommonExamService::getInstance()->isValidURL($response->collegeData->collegeSeal); | |
| return $response; | |
| } | |
| /** | |
| * Render Program Result | |
| * @param $templateName | |
| * @param Object $data | |
| * @return Object | |
| */ | |
| protected function renderHallTicketsResult($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/HallTicketsTemplates/Template31/$templateName.twig"), [ 'data'=>$data ]); | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= " | |
| <style> | |
| </style>"; | |
| $prtContent .= '</head><title>Hall Ticket</title><body>'; | |
| $prtContent .= $responseHtml; | |
| $prtContent .= '</body></html>'; | |
| $totalWidth = 210; | |
| $totalHeight = 297; | |
| $options = array( | |
| 'page-width' => $totalWidth . "mm", | |
| 'page-height' => $totalHeight . "mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "5mm", | |
| 'margin-left' => "5mm", | |
| 'margin-right' => "5mm", | |
| 'margin-bottom' => "5mm", | |
| 'encoding'=>'UTF-8', | |
| // '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; | |
| } | |
| } | |
| } |