Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 67 |
Template24HallTicketsGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
110.00 | |
0.00% |
0 / 67 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTemplateName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
processData | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 21 |
|||
renderHallTicketsResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 39 |
<?php | |
//Template Hall Ticket For MAR IVANIOUS Collages | |
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 com\linways\core\ams\professional\templateEngine\twig\TwigCustomFunctions; | |
use Twig\TwigFunction; | |
class Template24HallTicketsGenerator extends HallTicketsResultDataGenerator | |
{ | |
public function __construct(){} | |
protected function getTemplateName($request){ | |
$templateName = "Template_24"; | |
$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 = []; | |
// $request->removeNotTheorySubject = true; | |
$studentsHallTicketsDetails = HallTicketsService::getInstance()->getAllHallTicketsStudentData($request); | |
if(empty($studentsHallTicketsDetails)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
foreach($studentsHallTicketsDetails as $student){ | |
$assignedHalls = []; | |
$requestForHalls = new \stdClass; | |
$requestForHalls->studentId = $student->id; | |
$assignedHalls = HallTicketsService::getInstance()->getStudentAssignedHallsAndSeatForExam($requestForHalls); | |
foreach($student->subjects as $subject){ | |
if(isset($assignedHalls[$subject->assessmentId])){ | |
// this college set seat no as hall name + seat no | |
$subject->hallName = $assignedHalls[$subject->assessmentId]->seatNo; | |
} | |
} | |
} | |
$response->studentData = $studentsHallTicketsDetails; | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
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{ | |
$twigFunctions = [ | |
new TwigFunction('getQr', [TwigCustomFunctions::class, 'getQr']), | |
// Add more functions here as needed | |
]; | |
$responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/HallTicketsTemplates/Template24/$templateName.twig"), [ 'data'=>$data],null,$twigFunctions); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
.half-page{ | |
height: 50% !important; | |
} | |
.pages { | |
height: 335mm !important; | |
} | |
</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' => "3mm", | |
'margin-left' => "1mm", | |
'margin-right' => "1mm", | |
'margin-bottom' => "2mm", | |
// '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; | |
} | |
} | |
} |