Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 70 |
Template1PC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
90.00 | |
0.00% |
0 / 70 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTemplateName | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 16 |
|||
processData | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 24 |
|||
renderTemplate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 30 |
<?php | |
// SBCOLLEGE | |
namespace com\linways\ec\core\service\ProvisionalMarksCardGenerator; | |
use com\linways\base\util\TwigRenderer; | |
use com\linways\ec\core\service\MarksCardService; | |
use com\linways\ec\core\service\CommonExamService; | |
use com\linways\core\ams\professional\util\PdfUtil; | |
use com\linways\core\ams\professional\util\CommonUtil; | |
use com\linways\ec\core\exception\ExamControllerException; | |
use com\linways\ec\core\service\FinalConsolidatedReportService; | |
use com\linways\ec\core\service\ProvisionalMarksCardGenerator\PCGenerator; | |
use com\linways\core\ams\professional\service\StudentService; | |
use com\linways\core\ams\professional\constant\examcontroller\CourseTypeConstants; | |
class Template1PC extends PCGenerator | |
{ | |
public function __construct(){} | |
protected function getTemplateName($request){ | |
$query = "SELECT | |
ct.course_Type AS courseType, | |
g.properties->>'$.startYear' AS batchStartYear | |
FROM | |
`groups` g | |
INNER JOIN program p ON | |
p.id = CAST(g.properties->>'$.programId' AS CHAR) | |
INNER JOIN course_type ct ON | |
ct.courseTypeID = p.course_type_id | |
WHERE g.id IN ('$request->groupId')"; | |
$courseDetails = $this->executeQueryForObject($query); | |
$courseType = $courseDetails->courseType; | |
$batchStartYear = $courseDetails->batchStartYear; | |
$templateName = "Template1PC"; | |
return $templateName; | |
} | |
/** | |
* Process Student data college base | |
* @param $request | |
*/ | |
protected function processData($request){ | |
$response = new \stdClass; | |
$searchRequest = new \stdClass; | |
$response->studentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
$courseType = reset($response->studentData)->courseType; | |
$batchStartYear = reset($response->studentData)->admissionYear; | |
foreach ($response->studentData as $studentId => $student){ | |
$batchDetails = json_decode($student->properties); | |
$student->finalSem = $batchDetails->finalTermId; | |
$latestExamMonth = $student->markDetails->latestExamMonth; | |
$latestExamYear = $student->markDetails->latestExamYear; | |
$student->lastMonthYear = date("M Y",strtotime("$latestExamYear-$latestExamMonth-1")); | |
$student->roundOff = $student->admissionYear < 2019 ? 2 : 3; | |
$student->percentageValue = $student->admissionYear >= 2019 ? 20 : 25; | |
$student->cgpa = round($student->cgpa, $student->roundOff); | |
$student->cgpaInWords = CommonUtil::convertNumberToWords($student->cgpa); | |
$student->creditInWords = CommonUtil::convertNumberToWords($student->markDetails->credit); | |
} | |
$additionalInfo = new \stdClass(); | |
$additionalInfo->currentDate = date("d.m.Y"); | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
$response->dateOfIssue = $request->filterSettings['markListDate']?: date("d-m-Y"); | |
$response->additionalInfo = $additionalInfo; | |
return $response; | |
} | |
/** | |
* Render Program Result | |
* @param $templateName | |
* @param Object $data | |
* @return Object | |
*/ | |
protected function renderTemplate($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/ProvisionalMarksCard/Template1/$templateName.twig"), [ 'data'=>$data ]); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
</style>"; | |
$prtContent .= '</head><title>Consolidated Marks Card</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' => "7.5mm", | |
'margin-left' => "7.5mm", | |
'margin-right' => "7.5mm", | |
'margin-bottom' => "7.5mm", | |
// 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
); | |
$finalCMC = new \stdClass; | |
$finalCMC->htmlData = $responseHtml; | |
$finalCMC->printData = PdfUtil::renderPdf($prtContent, $options); | |
return $finalCMC; | |
} | |
} | |
} |