Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 74 |
Template9BarcodeGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
132.00 | |
0.00% |
0 / 74 |
__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 |
42.00 | |
0.00% |
0 / 25 |
|||
renderBarcodeResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 42 |
<?php | |
namespace com\linways\ec\core\service\BarcodeGenerator; | |
use com\linways\ec\core\service\BarcodeGenerationService; | |
use com\linways\ec\core\service\CommonExamService; | |
use com\linways\ec\core\service\ExamRegistrationService; | |
use com\linways\ec\core\service\ExamRegistrationSubjectService; | |
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\BarcodeGenerator\BarcodeResultDataGenerator; | |
use com\linways\ec\core\service\QrCodeGenerator; | |
use com\linways\core\ams\professional\templateEngine\twig\TwigCustomFunctions; | |
use Twig\TwigFunction; | |
class Template9BarcodeGenerator extends BarcodeResultDataGenerator | |
{ | |
public function __construct(){} | |
protected function getTemplateName($request){ | |
$templateName = "Template_9"; | |
$examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
if(empty($examRegistrationDetailsArray)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
return $templateName; | |
} | |
/** | |
* Process Student data college data | |
* @param $request | |
*/ | |
protected function processData($request){ | |
$response = new \stdClass; | |
$subjects = []; | |
$subjects = ExamRegistrationSubjectService::getInstance()->getAllAssessmentDetails($request); | |
if(empty($subjects)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$registeredStudentsDetails = []; | |
$registeredStudentsDetails = BarcodeGenerationService::getInstance()->getAllBarcodeStudentData($request); | |
if(empty($registeredStudentsDetails)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
foreach($registeredStudentsDetails as $student){ | |
foreach($student->subjects as $subject) | |
if($subject->isFalseNoGenerated == "1"){ | |
$student->isFalseNoGenerated = true; | |
$student->falseNo = $subject->falseNo; | |
unset($subject->subjects); | |
break; | |
} | |
} | |
$response->studentData = $registeredStudentsDetails; | |
$response->subjects = $subjects; | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
return $response; | |
} | |
/** | |
* Render Program Result | |
* @param $templateName | |
* @param Object $data | |
* @return Object | |
*/ | |
protected function renderBarcodeResult($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/BarcodeTemplates/Template9/$templateName.twig"), [ 'data'=>$data ],null,$twigFunctions); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
</style>"; | |
$prtContent .= '</head><title>Barcode List</title><body>'; | |
$prtContent .= $responseHtml; | |
$prtContent .= '</body></html>'; | |
$totalWidth = 70; | |
$totalHeight = 30; | |
// ob_get_clean(); | |
// ob_clean(); | |
$options = array( | |
'orientation' => "portrait", | |
'page-width' => $totalWidth."mm", | |
'page-height' => $totalHeight."mm", | |
'dpi' => 600, | |
'margin-bottom' => "0mm", | |
'margin-top' => "0mm", | |
'margin-left' => "1mm", | |
'margin-right' => "1mm", | |
'disable-smart-shrinking', | |
// 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
); | |
$responseHtmlData = null; | |
$responseHtmlData .= '<html><head>'; | |
$responseHtmlData .= "<style> | |
</style>"; | |
$responseHtmlData .= '</head><title>Barcode List</title><body>'; | |
$responseHtmlData .= $responseHtml; | |
$responseHtmlData .= '</body></html>'; | |
$programResult = new \stdClass; | |
$programResult->dispalyHtmlData = $responseHtmlData; | |
$programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
return $programResult; | |
} | |
} | |
} |