Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 366 |
| Template1ProgramResultGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
10920.00 | |
0.00% |
0 / 366 |
| __construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getTemplateName | |
0.00% |
0 / 1 |
342.00 | |
0.00% |
0 / 24 |
|||
| processData | |
0.00% |
0 / 1 |
2970.00 | |
0.00% |
0 / 193 |
|||
| renderProgramResult | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 63 |
|||
| rearrangeDataForPrint | |
0.00% |
0 / 1 |
650.00 | |
0.00% |
0 / 86 |
|||
| <?php | |
| namespace com\linways\ec\core\service\ProgramResultGenerator; | |
| 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\ProgramResultGenerator\ProgramResultDataGenerator; | |
| use com\linways\ec\core\service\ProgramResultService; | |
| use com\linways\ec\core\constant\CourseTypeConstants; | |
| use com\linways\ec\core\service\StudentSpecializationService; | |
| use com\linways\ec\core\service\MarklistCategorizeSubjectService; | |
| class Template1ProgramResultGenerator extends ProgramResultDataGenerator | |
| { | |
| public function __construct(){} | |
| protected function getTemplateName($request){ | |
| $templateName = "programReportTemplate_1"; | |
| $requestByGroupId = new \stdClass; | |
| $requestByGroupId->groupId = $request->groupId; | |
| $batchDetails = reset(CommonExamService::getInstance()->getBatchGroupDetailsByGroupId($requestByGroupId)); | |
| // $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
| if(empty($batchDetails)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| if($batchDetails->courseType == CourseTypeConstants::MBA){ | |
| $templateName = "programReportTemplate_1_MBA_till_2018"; | |
| } | |
| if($batchDetails->courseType == CourseTypeConstants::MBA && $batchDetails->startYear >= 2019){ | |
| $templateName = "programReportTemplate_1_MBA_2019_onwords"; | |
| } | |
| if(($batchDetails->courseType == CourseTypeConstants::PG || $batchDetails->courseType == CourseTypeConstants::MSW) && $batchDetails->startYear == 2014){ | |
| $templateName = "programReportTemplate_1_PG_MSW_2014"; | |
| } | |
| if(($batchDetails->courseType == 'MLISC' || $batchDetails->courseType == CourseTypeConstants::PG || $batchDetails->courseType == CourseTypeConstants::MSW) && $batchDetails->startYear >= 2019){ | |
| $templateName = "programReportTemplate_1_PG_MSW_MLISC_2019_onwords"; | |
| } | |
| if (($batchDetails->courseType == "BLISC" && $batchDetails->startYear >= 2014 && $batchDetails->startYear <= 2018) || ($batchDetails->courseType == "MLISC" && $batchDetails->startYear >= 2016 && $batchDetails->startYear <= 2018)) { | |
| $templateName = "programReportTemplate_1_MBA_till_2018"; | |
| } | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college data | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $requestByGroupId = new \stdClass; | |
| $requestByGroupId->groupId = $request->groupId; | |
| $response->batchDetails = reset(CommonExamService::getInstance()->getBatchGroupDetailsByGroupId($requestByGroupId)); | |
| $requestForStudents = new \stdClass; | |
| $requestForStudents->groupId = $request->groupId; | |
| $response->students = ProgramResultService::getInstance()->getOverAllStudentMarkDetails($requestForStudents); | |
| $markListSubjectCategories = MarklistCategorizeSubjectService::getInstance()->getAllSubjectCategories($requestByGroupId); | |
| $openCourseMarklistCatKey = array_search('1', array_column($markListSubjectCategories, "isOpenCourse")); | |
| $openCourseCatId = $openCourseMarklistCatKey === false ? null : $markListSubjectCategories[$openCourseMarklistCatKey]->subjectCategoryId; | |
| $secondLangMarklistCatKey = array_search('1', array_column($markListSubjectCategories, "isSecondLanguage")); | |
| $secondLangCatId = $secondLangMarklistCatKey === false ? null : $markListSubjectCategories[$secondLangMarklistCatKey]->subjectCategoryId; | |
| // // remove after testing | |
| // $response->batchDetails->courseType = CourseTypeConstants::MBA; | |
| // $response->batchDetails->startYear = 2018; | |
| $courseType = $response->batchDetails->courseType; | |
| $startYear = $response->batchDetails->startYear; | |
| foreach($response->students as $key=> $student){ | |
| $student->academicTerms = array_combine(array_column($student->academicTerms, 'id'), $student->academicTerms); | |
| $student->secondLanguageName = ""; | |
| $student->openCourseName = ""; | |
| $student->cgpa = round($student->cgpa,2); | |
| $student->cgpa = sprintf('%0.2f', $student->cgpa); | |
| if($request->passStatus == 'PASSED'){ | |
| if($student->isFailed != 'PASSED') unset($response->students[$key]); | |
| } | |
| if($request->passStatus == 'FAILED'){ | |
| if($student->isFailed != 'FAILED') unset($response->students[$key]); | |
| } | |
| if($courseType == CourseTypeConstants::MBA){ | |
| $requestForSpecialization = new \stdClass; | |
| $requestForSpecialization->studentId = $student->id; | |
| $requestForSpecialization->groupId = $request->groupId; | |
| $studentSpecialisation = StudentSpecializationService::getInstance()-> getStudentspecialization($requestForSpecialization); | |
| if($studentSpecialisation){ | |
| $student->specialization = $studentSpecialisation->name; | |
| } | |
| } | |
| foreach($student->academicTerms as $academicTerm){ | |
| $academicTerm->sgpa = sprintf("%.02f", round($academicTerm->sgpa, 2)); | |
| $academicTerm->subjects = array_combine(array_column($academicTerm->subjects, 'id'), $academicTerm->subjects); | |
| if (empty($reportHeads[$academicTerm->id])) { | |
| $semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($academicTerm->name); | |
| $reportHeads[$academicTerm->id]->name = "Semester ".$semesterNames->semNumber; | |
| $reportHeads[$academicTerm->id]->id = $academicTerm->id; | |
| $reportHeads[$academicTerm->id]->order = $academicTerm->academicTermOrderNo; | |
| } | |
| foreach($academicTerm->subjects as $subject){ | |
| if ($subject->latestExamType == 'IMPROVEMENT') { | |
| $examMonthYear = date("M-Y",strtotime("$subject->latestExamYear-$subject->latestExamMonth-1")); | |
| $improveExamMonthYears[$academicTerm->id.strtotime("$subject->latestExamYear-$subject->latestExamMonth-1")] = "$examMonthYear (S$semesterNames->semNumber)"; | |
| } | |
| $subject->gradePoint = (float)$subject->gradePoint; | |
| // for template_3 | |
| if (empty($reportHeads[$academicTerm->id]->subHeads[$subject->id])) { | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->id = $subject->id; | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->name = $subject->name; | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->code = $subject->code; | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->order = $subject->order; | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->credit = $subject->credit; | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->totalMaxMark = $subject->totalMarks; | |
| $reportHeads[$academicTerm->id]->subHeads[$subject->id]->maxGP = $subject->maxGradePoint; | |
| // for displaying all subjects | |
| $reportHeads[$academicTerm->id]->subjectArray[$subject->id]->id = $subject->id; | |
| $reportHeads[$academicTerm->id]->subjectArray[$subject->id]->name = $subject->name; | |
| $reportHeads[$academicTerm->id]->subjectArray[$subject->id]->code = $subject->code; | |
| $reportHeads[$academicTerm->id]->subjectArray[$subject->id]->order = $subject->order; | |
| } | |
| // ------- | |
| if(($subject->subCategoryId ) && ($subject->subCategoryId == $openCourseCatId)){ | |
| $academicTerm->subjects["opencourse"] = $subject; | |
| unset($reportHeads[$academicTerm->id]->subHeads[$subject->id]); | |
| $reportHeads[$academicTerm->id]->subHeads["opencourse"]->id = "opencourse"; | |
| $reportHeads[$academicTerm->id]->subHeads["opencourse"]->name = "Open Course"; | |
| $reportHeads[$academicTerm->id]->subHeads["opencourse"]->code = "Open Course"; | |
| $reportHeads[$academicTerm->id]->subHeads["opencourse"]->order = $subject->order; | |
| $reportHeads[$academicTerm->id]->subHeads["opencourse"]->credit = $subject->credit; | |
| $reportHeads[$academicTerm->id]->subHeads["opencourse"]->totalMaxMark = $subject->totalMarks; | |
| $student->openCourseName = $subject->name; | |
| } | |
| else if(($subject->subCategoryId ) && ($subject->subCategoryId == $secondLangCatId)){ | |
| $academicTerm->subjects["lang"] = $subject; | |
| unset($reportHeads[$academicTerm->id]->subHeads[$subject->id]); | |
| $reportHeads[$academicTerm->id]->subHeads["lang"]->id = "lang"; | |
| $reportHeads[$academicTerm->id]->subHeads["lang"]->name = "Lang"; | |
| $reportHeads[$academicTerm->id]->subHeads["lang"]->code = "Lang"; | |
| $reportHeads[$academicTerm->id]->subHeads["lang"]->order = $subject->order; | |
| $reportHeads[$academicTerm->id]->subHeads["lang"]->credit = $subject->credit; | |
| $reportHeads[$academicTerm->id]->subHeads["lang"]->totalMaxMark = $subject->totalMarks; | |
| $student->secondLanguageName = $subject->name; | |
| } | |
| $subjectCategoryWiseMarkData[$subject->subCategoryId]->creditGradePoint[$subject->id] = $subject->creditGradePoint; | |
| $subjectCategoryWiseMarkData[$subject->subCategoryId]->credit[$subject->id] = $subject->credit; | |
| $subjectCategoryWiseMarkData[$subject->subCategoryId]->totalMark[$subject->id] = $subject->markObtained; | |
| $subjectCategoryWiseMarkData[$subject->subCategoryId]->totalMaxMark[$subject->id] = $subject->totalMarks; | |
| // $subjectCategoryWiseMarkData[$subject->subCategoryId]->subjectName = $subject->name; | |
| // $subjectCategoryWiseMarkData[$subject->subCategoryId]->subjectCode = $subject->code; | |
| } | |
| } | |
| foreach ($markListSubjectCategories as $markListSubjectCategory) { | |
| $creditGradePoint = array_sum($subjectCategoryWiseMarkData[$markListSubjectCategory->subjectCategoryId]->creditGradePoint); | |
| $credit = array_sum($subjectCategoryWiseMarkData[$markListSubjectCategory->subjectCategoryId]->credit); | |
| $totalMark = array_sum($subjectCategoryWiseMarkData[$markListSubjectCategory->subjectCategoryId]->totalMark); | |
| $totalMaxMark = array_sum($subjectCategoryWiseMarkData[$markListSubjectCategory->subjectCategoryId]->totalMaxMark); | |
| $subjectCategoryName = $markListSubjectCategory->subjectCategoryName; | |
| if((!$markListSubjectCategory->isOpenCourse) && (!$markListSubjectCategory->isSecondLanguage )){ | |
| $displayName = $markListSubjectCategory->name; | |
| } | |
| $displayKey = implode('', unpack("C*", str_replace(" ", "", $displayName))); | |
| $subjectCategoryMarksKey = "C$markListSubjectCategory->subjectCategoryId" . "D$displayKey"; | |
| if (!empty($subjectCategoryWiseMarkData[$markListSubjectCategory->subjectCategoryId])) { | |
| $subjectCategoryMarks[$subjectCategoryMarksKey]->name = $displayName ? "$subjectCategoryName : $displayName" : $subjectCategoryName; | |
| $subjectCategoryMarks[$subjectCategoryMarksKey]->credit = $credit; | |
| $subjectCategoryMarks[$subjectCategoryMarksKey]->totalMark = $totalMark; | |
| $subjectCategoryMarks[$subjectCategoryMarksKey]->creditGradePoint = $creditGradePoint; | |
| $subjectCategoryMarks[$subjectCategoryMarksKey]->categoryCGPA = $categoryCGPA; | |
| $subjectCategoryMarks[$subjectCategoryMarksKey]->grade = $cgpaGrade; | |
| if (empty($programResultCategoryHeads[$subjectCategoryMarksKey])) { | |
| $programResultCategoryHeads[$subjectCategoryMarksKey]->key = $subjectCategoryMarksKey; | |
| $programResultCategoryHeads[$subjectCategoryMarksKey]->name = $displayName ? "$subjectCatName: $displayName" :$subjectCatName; | |
| $programResultCategoryHeads[$subjectCategoryMarksKey]->totalMaxMark = $totalMaxMark; | |
| $programResultCategoryHeads[$subjectCategoryMarksKey]->priority = $markListSubjectCategory->priority; | |
| } | |
| } | |
| } | |
| if (!empty($request->examMonthYears)) { | |
| if (!in_array("$student->latestExamYear-$student->latestExamMonth", $request->examMonthYears)) { | |
| unset($response->students[$key]); | |
| continue; | |
| } | |
| } | |
| } | |
| usort($reportHeads, function ($a, $b){ | |
| return $a->order > $b->order; | |
| }); | |
| usort($programResultCategoryHeads, function ($a, $b){ | |
| return $a->priority > $b->priority; | |
| }); | |
| if(!empty($response->students)){ | |
| $studentSample = reset($students); | |
| $semCount = count($studentSample->academicTerms); | |
| $subjectCategoryCount = count($programResultCategoryHeads); | |
| $totalWidth = ($semCount + 1) * 50 +($subjectCategoryCount * 40) + 90; | |
| $supplyExamMonthYears = []; | |
| $semesterWiseDetails = ExamRegistrationService::getInstance()-> supplyExamMonthAndYearSemesterWiseByStudent($requestByGroupId); | |
| ksort($semesterWiseDetails); | |
| foreach ($semesterWiseDetails as $semesterWiseDetail) { | |
| foreach ($semesterWiseDetail->exams as $key => $exam) { | |
| $exam->examMonth = sprintf("%02d", $exam->examMonth); | |
| $supplyChanceIndicator[$exam->academicTermId]["$exam->examYear$exam->examMonth"] = $key; | |
| $examMonthYear = date("M-Y",strtotime("$exam->examYear-$exam->examMonth-1")); | |
| if($courseType == CourseTypeConstants::MBA){ | |
| $supplyExamMonthYears[$key][strtotime("$exam->examYear-$exam->examMonth-1")] = "$examMonthYear"; | |
| } | |
| else{ | |
| $supplyExamMonthYears[$key][strtotime("$exam->examYear-$exam->examMonth-1")] = "$examMonthYear ($exam->academicTermName)"; | |
| } | |
| } | |
| } | |
| foreach ($supplyExamMonthYears as $key => $supplyExamMonthYear) { | |
| ksort($supplyExamMonthYear); | |
| $supplyExamMonthYears[$key] = implode(", ", $supplyExamMonthYear); | |
| } | |
| ksort($improveExamMonthYears); | |
| $improveExamMonthYears = implode(", ", $improveExamMonthYears); | |
| $improveExamMonthYears = $improveExamMonthYears? "(".$improveExamMonthYears.")" : ""; | |
| $response->externalName = "External"; | |
| $response->InternalName = "Internal"; | |
| $response->sgpaName = "SGPA"; | |
| $response->cgpaName = "CGPA"; | |
| if(($courseType == CourseTypeConstants::PG_BLISC && $startYear >= 2019 ) || ($courseType == CourseTypeConstants::MPHIL && $startYear == 2019 ) || ($courseType == CourseTypeConstants::MBA )){ | |
| $response->externalName = "ESA"; | |
| $response->InternalName = "ISA"; | |
| } | |
| if((($courseType == CourseTypeConstants::PG) && (($startYear > 2014) && ($startYear < 2019))) || | |
| ($courseType == CourseTypeConstants::PG_BLISC && $startYear >= 2019 ) || | |
| (($courseType == CourseTypeConstants::MSW) && (($startYear >= 2015) && ($startYear <= 2018))) || | |
| ($startYear < 2017) || | |
| (($courseType == CourseTypeConstants::UG) && (($startYear == 2018) || ($startYear >= 2019))) || | |
| ($courseType == CourseTypeConstants::MPHIL && $startYear == 2018 )){ | |
| $response->sgpaName = "SCPA"; | |
| $response->cgpaName = "CCPA"; | |
| } | |
| if($courseType == CourseTypeConstants::MBA){ | |
| $searchRequestForSpecialization = new \stdClass; | |
| $specialisation = StudentSpecializationService::getInstance()->getAllSpecialization($searchRequestForSpecialization); | |
| $response->specializationsList = $specialisation; | |
| } | |
| $response->semCount = $semCount; | |
| $response->subjectCategoryCount = $subjectCategoryCount; | |
| $response->programResultCategoryHeads = $programResultCategoryHeads; | |
| $response->reportHeads = $reportHeads; | |
| $response->totalWidth = $totalWidth; | |
| $response->supplyExamMonthYears = $supplyExamMonthYears; | |
| $response->supplyChanceIndicator = $supplyChanceIndicator; | |
| $response->improveExamMonthYears = $improveExamMonthYears; | |
| $response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| return $response; | |
| } | |
| else{ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| } | |
| /** | |
| * Render Program Result | |
| * @param $templateName | |
| * @param Object $data | |
| * @return Object | |
| */ | |
| protected function renderProgramResult($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/programReport/Template1/$templateName.twig"), [ 'data'=>$data ]); | |
| $reArrangedPrint = true; // TODO: flag enable from settings table. | |
| $printHtml = $responseHtml; | |
| if ($reArrangedPrint) { | |
| $printHtml = $this->rearrangeDataForPrint($responseHtml, $data->batchDetails); | |
| $totalWidth = 420; | |
| } | |
| if ($data->batchDetails->courseType == CourseTypeConstants::MBA && $data->batchDetails->startYear >= 2019) { | |
| $totalWidth = 460; | |
| } | |
| $prtContent = ""; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<style> | |
| *{ | |
| color:#000 !important; | |
| background-color: #fff !important; | |
| } | |
| td, th{ | |
| border:1px solid #000 !important; | |
| } | |
| table{ | |
| border:1px solid #000 !important; | |
| } | |
| .print-border-0 td{ | |
| border-left:1px solid #fff !important; | |
| } | |
| .print-border-b-0{ | |
| border-bottom:none !important; | |
| } | |
| .print-border-t-0{ | |
| border-top:none !important; | |
| } | |
| .print-border-tb-0{ | |
| border-top:none !important; | |
| border-bottom:none !important; | |
| } | |
| </style>"; | |
| $prtContent .= '</head><title>Programme Result</title><body>'; | |
| $prtContent .= $printHtml; | |
| $prtContent .= '</body></html>'; | |
| $totalWidth = $totalWidth < 297 ? 297 : $totalWidth; | |
| $totalHeight = $totalWidth / 1.414; | |
| $leftSpace = 15; | |
| $options = array( | |
| 'page-width' => $totalWidth."mm", | |
| 'page-height' => $totalHeight."mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "12mm", | |
| 'margin-left' => $leftSpace."mm", | |
| 'margin-right' => "15mm", | |
| 'margin-bottom' => "15mm", | |
| // '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->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| } | |
| private function rearrangeDataForPrint($html, $batchDetails){ | |
| // split all html content into 6 parts | |
| $htmlSlices = explode("<!--content-tag-->", $html); | |
| $htmlHead = $htmlSlices[0]; | |
| $page = $htmlSlices[1]; | |
| $htmlFoot = $htmlSlices[2]; | |
| $pageSlices = explode("<!--page-hbf-split-tag-->", $page); | |
| $pageHead = $pageSlices[0]; | |
| $pageBody = $pageSlices[1]; | |
| $pageFooter = $pageSlices[2]; | |
| $pageBodySlices = explode("<!--content-hbf-split-tag-->", $pageBody); | |
| $contentTableOpen = $pageBodySlices[0]; | |
| $contentHead = $pageBodySlices[1]; | |
| $contentHeadClose = $pageBodySlices[2]; | |
| $contentBody = $pageBodySlices[3]; | |
| $contentTableClose = $pageBodySlices[4]; | |
| // split rows of head and student data | |
| $contentHeadRaws = explode("<!--row-tag-->", $contentHead); | |
| $contentBodyRaws = explode("<!--row-tag-->", $contentBody); | |
| // split table headings into parts like "studentName, Regno" and group of subject column | |
| $contentMainHeads = explode("<!--part-tag-->", $contentHeadRaws[1]); | |
| $contentSubHeads = explode("<!--part-tag-->", $contentHeadRaws[3]); | |
| $sliceCount = count($contentMainHeads); | |
| $studentHead = $contentMainHeads[0]; | |
| $students = []; | |
| $tableSlices = []; | |
| foreach ($contentBodyRaws as $key => $contentRaw) { | |
| if(strpos($contentRaw, "<tr") || strpos($contentRaw, "</tr>")) continue; | |
| // split table student details into parts like "student-1, REGNO-1" and group of subject mark details | |
| $contentSlices = explode("<!--part-tag-->", $contentRaw); | |
| $students[$key] = $contentSlices[0]; | |
| for ($tableNum = 1; $tableNum < $sliceCount; $tableNum++) { | |
| $tableSlices[$tableNum][$key] = $contentSlices[$tableNum]; | |
| } | |
| } | |
| $studentCount = 0; | |
| $pageNum = 0; | |
| $nextPageNum = 0; | |
| $contentPages = []; | |
| if ($batchDetails->courseType == CourseTypeConstants::MBA && $batchDetails->startYear < 2019) { | |
| $rowCount = 40 ; | |
| } | |
| elseif ($batchDetails->courseType == CourseTypeConstants::MBA && $batchDetails->startYear >= 2019) { | |
| $rowCount = 60 ; | |
| } | |
| elseif (($batchDetails->courseType == "PG_BLISC" && $batchDetails->startYear >= 2014 && $batchDetails->startYear <= 2018) || ($batchDetails->courseType == "MLISC" && $batchDetails->startYear >= 2016 && $batchDetails->startYear <= 2018)) { | |
| $rowCount = 28 ; | |
| } | |
| else{ | |
| $rowCount = 30 ; | |
| } | |
| foreach ($students as $key => $student) { | |
| $studentCount++; | |
| $pageNum = $nextPageNum; | |
| if (!($studentCount % $rowCount)) { | |
| $nextPageNum++; | |
| } | |
| $last_tagFlag = false; | |
| foreach ($tableSlices as $tableNum => $tableSlice) { | |
| if ($last_tagFlag) { | |
| $last_tagFlag = false; | |
| continue; | |
| } | |
| if(substr_count($tableSlices[$tableNum + 1][$key], "<!--last_tag-->") > 0 || !$tableSlices[$tableNum + 1][$key]){ | |
| if (!$contentPages[$pageNum]->contentTables[$tableNum]) { | |
| $tr = "<tr>$studentHead $contentMainHeads[$tableNum]" . $contentMainHeads[$tableNum + 1]. "</tr>"; | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= $tr; | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>" . $contentSubHeads[$tableNum-1] . $contentSubHeads[$tableNum] . "</tr>$contentHeadClose"; | |
| } | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>" . $student . $tableSlice[$key] . $tableSlices[$tableNum + 1][$key] . "</tr>"; | |
| $last_tagFlag = true; | |
| } | |
| else { | |
| if (!$contentPages[$pageNum]->contentTables[$tableNum]) { | |
| $tr = "<tr>$studentHead$contentMainHeads[$tableNum]</tr>"; | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= $tr; | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>" . $contentSubHeads[$tableNum-1] . "</tr>$contentHeadClose"; | |
| } | |
| $contentPages[$pageNum]->contentTables[$tableNum] .= "<tr>$student$tableSlice[$key]</tr>"; | |
| } | |
| } | |
| } | |
| foreach ($contentPages as $pageNum => $page) { | |
| foreach ($page->contentTables as $tableNum => $table) { | |
| // $subjectTagCount = substr_count($table, "<!--subjectHead_tag-->"); | |
| // $tableWidth = ($subjectTagCount * 15) + 40; | |
| // if(substr_count($table, "<!--overallmark_tag-->") > 0) { | |
| // $tableWidth += 20; | |
| // } | |
| // $tableWidth = $tableWidth > 100 ? 100 : $tableWidth; | |
| // $replaceCount = 1; | |
| // $tableHeadWithNewWidth = str_replace("width:100%!important;", "width:$tableWidth%!important;", $tableHead, $replaceCount); | |
| $contentHtml .= "$pageHead $contentTableOpen $table $contentTableClose $pageFooter"; | |
| } | |
| } | |
| $contentHtml .= "$pageHead $htmlFoot $pageFooter"; | |
| $responseHtml = $htmlHead . $contentHtml; | |
| return $responseHtml; | |
| } | |
| } |