Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 124 |
| Template5PC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
380.00 | |
0.00% |
0 / 124 |
| __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 |
72.00 | |
0.00% |
0 / 44 |
|||
| 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 | |
| // MBCET | |
| 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 Template5PC 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 = "Template5PC"; | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college base | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $searchRequest = new \stdClass; | |
| // temporary fix for hiding PC | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| $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){ | |
| $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); | |
| } | |
| $batchDetails = json_decode($student->properties); | |
| $student->finalSem = $batchDetails->finalTermId; | |
| $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->cgpa = sprintf('%0.2f',round($student->cgpa, $student->roundOff)); | |
| $student->cgpaInWords = CommonUtil::convertNumberToWords($student->cgpa); | |
| $student->creditInWords = CommonUtil::convertNumberToWords($student->markDetails->credit); | |
| $student->genderTag = (strtoupper($student->gender) == "MALE") ? "Mr" : "Ms"; | |
| $customFields = AmsCustomFieldsService::getInstance()->getAmsCustomFieldValue(AmsCustomFieldsEntities::STUDENT, $studentId, []); | |
| if( $customFields ){ | |
| $student->ktuCode = $this->getCustomFieldObjectList($customFields)->studentData->KTU_CODE; | |
| } | |
| $student->qrData = $student->regNo ." | ".$student->name . " | CGPA - " .$student->cgpa; | |
| } | |
| $additionalInfo = new \stdClass(); | |
| $additionalInfo->currentDate = date("d/m/Y"); | |
| $response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| 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/Template5/$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 = 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"; | |
| } | |
| } | |
| } |