Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 73 |
Template1_3BarcodeGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
210.00 | |
0.00% |
0 / 73 |
__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 |
90.00 | |
0.00% |
0 / 35 |
|||
renderBarcodeResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 31 |
<?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 TCPDFBarcode; | |
class Template1_3BarcodeGenerator extends BarcodeResultDataGenerator | |
{ | |
public function __construct(){} | |
protected function getTemplateName($request){ | |
$templateName = "Template_1_3"; | |
$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"); | |
} | |
foreach($subjects as $subject){ | |
$subject->assessmentDate = $subject->assessmentDate ? date("d-m-Y", strtotime($subject->assessmentDate)) : ''; | |
} | |
$resisteredStudentsDetails = []; | |
$resisteredStudentsDetails = BarcodeGenerationService::getInstance()->getAllBarcodeStudentData($request); | |
if(empty($resisteredStudentsDetails)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$distinctDate = []; | |
foreach($resisteredStudentsDetails as $student){ | |
foreach($student->subjects as $subjectKey => $subject){ | |
if( $subject->isTheory == "0"){ | |
unset($student->subjects[$subjectKey]); | |
continue; | |
} | |
if($subject->isFalseNoGenerated == "1"){ | |
$barcodeObj = new TCPDFBarcode($subject->falseNo, 'C128'); | |
$subject->barcodeObj = $barcodeObj->getBarcodeHTML($w = 1, $h = 25, $color = 'black'); | |
} | |
$distinctDate[$subject->assessmentDate] = $subject->assessmentDate; | |
} | |
} | |
ksort($distinctDate); | |
$response->studentData = $resisteredStudentsDetails; | |
$response->subjects = $subjects; | |
$response->distinctDate = $distinctDate; | |
$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{ | |
$responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/BarcodeTemplates/Template1/$templateName.twig"), [ 'data'=>$data ]); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
</style>"; | |
$prtContent .= '</head><title>Barcode List</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' => "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->allowWinprint = 1; | |
$programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
return $programResult; | |
} | |
} | |
} |