Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 127 |
Template14PC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
420.00 | |
0.00% |
0 / 127 |
__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 |
90.00 | |
0.00% |
0 / 47 |
|||
renderTemplate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 30 |
|||
getCustomFieldObjectList | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 18 |
|||
getDataType | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 16 |
<?php | |
// IAGI | |
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; | |
use com\linways\core\ams\professional\constant\AmsCustomFieldsEntities; | |
use com\linways\core\ams\professional\service\AmsCustomFieldsService; | |
class Template14PC 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 = "Template14PC"; | |
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; | |
if( empty( $response->studentData ) ){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$courseType = reset($response->studentData)->courseType; | |
$batchStartYear = reset($response->studentData)->admissionYear; | |
foreach ($response->studentData as $studentId => $student){ | |
$batchDetails = json_decode($student->properties); | |
$uniqueNoReq = new \stdClass; | |
$uniqueNoReq->studentId = $student->studentId; | |
$uniqueNoReq->groupId = $student->groupsId; | |
$uniqueNoReq->type = 'PROVISIONAL_CERTIFICATE'; | |
$student->slNo = CommonExamService::getInstance()->getStudentBatchUniqueNumber($uniqueNoReq)->uniqueNo; | |
if ($student->slNo) { | |
$student->slNo = str_pad($student->slNo, 4, "0", STR_PAD_LEFT); | |
} | |
$student->studentImage = StudentService::getInstance()->getStudentProfilePic($student->studentId)->docpath; | |
$student->isPg = ($student->courseType == CourseTypeConstants::PG )? true : false; | |
$student->finalSem = $batchDetails->finalTermId; | |
$student->batchStartYear = $batchDetails->startYear; | |
$latestExamMonth = $student->markDetails->latestExamMonth; | |
$latestExamYear = $student->markDetails->latestExamYear; | |
$student->lastMonthYear = strtoupper(date("F - Y",strtotime("$latestExamYear-$latestExamMonth-1"))); | |
$student->roundOff = 2; | |
$student->percentageValue = $student->admissionYear >= 2019 ? 20 : 25; | |
$student->class = $student->markDetails->class; | |
$student->cgpa = round($student->cgpa, $student->roundOff); | |
$student->passingYear = substr($student->markDetails->latestExamYear, -2); | |
$student->cgpaInWords = CommonUtil::convertNumberToWords($student->cgpa); | |
$student->creditInWords = CommonUtil::convertNumberToWords($student->markDetails->credit); | |
$student->genderTag = (strtoupper($student->gender) == "MALE") ? "Mr" : "Ms"; | |
$student->qrData = $student->regNo ." | ".$student->name . " | CGPA - " .$student->cgpa; | |
$student->pdcFormat2 = true; | |
} | |
$additionalInfo = new \stdClass(); | |
$additionalInfo->currentDate = date("d.m.Y"); | |
$additionalInfo->courseType = $courseType; | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
$additionalInfo->currentDate = $request->filterSettings['markListDate']? date("d, F Y",strtotime($request->filterSettings['markListDate'])) : date("d, F Y"); | |
if($courseType == CourseTypeConstants::MTECH){ | |
$additionalInfo->showSpecialization = true; | |
} | |
$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/Template14/$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; | |
} | |
} | |
protected function getCustomFieldObjectList($customFields) | |
{ | |
$fieldList = []; | |
$response = new \stdClass(); | |
$studentData = new \stdClass(); | |
$orderNo = 1; | |
foreach ($customFields as $customField) { | |
$field = json_decode('{"columnName":"","displayName":"","fieldType":"","format":"","orderNo":0,"validation":"text","editable":true,"required":false,"relatedFieldList":[],"relatedFieldSeperator":"","foreignkeyTableDetails":{},"tableType":"CUSTOM"}'); | |
$field->columnName = $customField->code; | |
$field->displayName = $customField->label; | |
$field->fieldType = $this->getDataType($customField->dataType); | |
$field->orderNo = $orderNo++; | |
$studentData->{$customField->code} = $customField->value; | |
$fieldList[] = $field; | |
} | |
$response->fieldList = $fieldList; | |
$response->studentData = $studentData; | |
return $response; | |
} | |
protected function getDataType($dataType) | |
{ | |
switch($dataType) | |
{ | |
case "longtext": | |
return "textarea"; | |
break; | |
case "varchar": | |
return "text"; | |
break; | |
case "integer": | |
return "text"; | |
case "textarea": | |
return "text"; | |
break; | |
// default: | |
// return "select"; | |
} | |
} | |
} |