Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 156 |
DataProviderService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
2756.00 | |
0.00% |
0 / 156 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
getAllDepartments | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 15 |
|||
getAllSemesters | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getAllAdmissionQuotas | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
getStudentDetailsToPrefillForm | |
0.00% |
0 / 1 |
702.00 | |
0.00% |
0 / 75 |
|||
getStudentDetailsModelToTakeReport | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 27 |
|||
resolveDynamicLayoutParameters | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 14 |
<?php | |
namespace com\linways\core\ams\professional\service\customFormBuilder; | |
use com\linways\core\ams\professional\service\BaseService; | |
use com\linways\core\ams\professional\service\CommonService; | |
use com\linways\core\ams\professional\service\StudentService; | |
use com\linways\core\ams\professional\service\SemesterService; | |
use com\linways\core\ams\professional\service\DepartmentService; | |
use com\linways\core\ams\professional\service\AdmissionQuotaService; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\exception\CustomFormBuilderException; | |
class DataProviderService extends BaseService | |
{ | |
// /Condition 1 - Presence of a static member variable | |
private static $_instance = null; | |
// /Condition 2 - Locked down the constructor | |
private function __construct() | |
{} | |
// Prevent any oustide instantiation of this class | |
// /Condition 3 - Prevent any object or instance of that class to be cloned | |
private function __clone() | |
{} | |
// Prevent any copy of this object | |
// /Condition 4 - Have a single globally accessible static method | |
public static function getInstance() | |
{ | |
if (! is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
self::$_instance = new self(); | |
return self::$_instance; | |
} | |
public function getAllDepartments(){ | |
$sql = ""; | |
$result = []; | |
$sql = "select deptID as id, deptName ,departmentDesc from department WHERE deptShow = 1"; | |
try{ | |
$result = $this->executeQueryForList($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException ( $e->getCode (), $e->getMessage () ); | |
} | |
foreach ($result as $department) { | |
$department->name = ""; | |
$department->name .= $department->deptName; | |
$department->name .= ($department->departmentDesc?'('. $department->departmentDesc.')':''); | |
} | |
return $result; | |
} | |
public function getAllSemesters(){ | |
$sql = ""; | |
$result = []; | |
$sql = "SELECT semID as id, semName as name FROM semesters order by orderNo"; | |
try{ | |
$result = $this->executeQueryForList($sql); | |
}catch(\Exception $e){ | |
throw new ProfessionalException ( $e->getCode (), $e->getMessage () ); | |
} | |
return $result; | |
} | |
public function getAllAdmissionQuotas(){ | |
$admissionQuotas = []; | |
try{ | |
$admissionQuotas = AdmissionQuotaService::getInstance()->getAllAdmissionQuotas(); | |
}catch(\Exception $e){ | |
throw new ProfessionalException ( $e->getCode (), $e->getMessage () ); | |
} | |
return $admissionQuotas; | |
} | |
/** | |
* get values of students to prefill a form | |
* | |
* @param [type] $studentId | |
* @param [type] $formSchema | |
* @return void | |
*/ | |
public function getStudentDetailsToPrefillForm($studentId, $formSchema){ | |
$model = new \stdClass(); | |
$studentDetails = StudentService::getInstance()->getStudentDetailsById($studentId); | |
$schema = $formSchema->schema; | |
foreach($schema as $key => $schemaElement){ | |
if(empty($schemaElement->autofill)){ | |
continue; | |
} | |
switch($schemaElement->autofill){ | |
case "GET_STUDENT_NAME": | |
$model->{$key} = $studentDetails->name; | |
break; | |
case "GET_DEPARTMENT_ID": | |
$model->{$key} = $studentDetails->deptID; | |
break; | |
case "GET_SEMESTER_ID": | |
$model->{$key} = $studentDetails->semID; | |
break; | |
case "GET_ENTRANCE_RANK": | |
$model->{$key} = $studentDetails->entranceRank; | |
break; | |
case "GET_PLUS_TWO_PERCENTAGE": | |
$model->{$key} = $studentDetails->plustwo; | |
break; | |
case "GET_NAME_OF_PARENTS": | |
if(!empty($studentDetails->studentFather) || !empty($studentDetails->studentMother)){ | |
$model->{$key} = implode(',', [$studentDetails->studentFather, $studentDetails->studentMother]); | |
} | |
break; | |
case "GET_NAME_OF_MOTHER": | |
if(!empty($studentDetails->studentMother)){ | |
$model->{$key} = $studentDetails->studentMother; | |
} | |
break; | |
case "GET_NAME_OF_FATHER": | |
if(!empty($studentDetails->studentFather)){ | |
$model->{$key} = $studentDetails->studentFather; | |
} | |
break; | |
case "GET_CURRENT_ADDRESS": | |
$model->{$key} = $studentDetails->studentAddress; | |
break; | |
case "GET_PHONE_NUMBER": | |
$model->{$key} = $studentDetails->studentPhone; | |
break; | |
case "GET_PARENT_OCCUPATION": | |
if(!empty($studentDetails->fatherOccupation) || !empty($studentDetails->motherOccupation)) | |
{ | |
$model->{$key} = implode(',', [$studentDetails->fatherOccupation, $studentDetails->motherOccupation]); | |
} | |
break; | |
case "GET_FATHER_OCCUPATION": | |
if(!empty($studentDetails->fatherOccupation)) | |
{ | |
$model->{$key} = $studentDetails->fatherOccupation; | |
} | |
break; | |
case "GET_MOTHER_OCCUPATION": | |
if( !empty($studentDetails->motherOccupation)) | |
{ | |
$model->{$key} = $studentDetails->motherOccupation; | |
} | |
break; | |
case "GET_ANNUAL_INCOME": | |
$model->{$key} = $studentDetails->annualIncome; | |
break; | |
case "GET_ADMISSION_QUOTA_ID": | |
$model->{$key} = $studentDetails->quotaId; | |
break; | |
default: | |
throw new ProfessionalException ( CustomFormBuilderException::INVALID_AUTO_FILL_FUNCTION_NAME, $schemaElement->autofill." is not a valid autofill function name" ); | |
break; | |
} | |
} | |
return $model; | |
} | |
/** | |
* Undocumented function | |
* | |
* @param [type] $formSchema | |
* @return void | |
*/ | |
public function getStudentDetailsModelToTakeReport($formSchema){ | |
$model = $formSchema->model; | |
$schema = $formSchema->schema; | |
$layout = $formSchema->reportLayout; | |
foreach($layout as $layoutElement){ | |
$schemaElement = $schema->{$layoutElement->key}; | |
if(empty($schemaElement->autofill) || empty($model->{$layoutElement->key})){ | |
continue; | |
} | |
switch($schemaElement->autofill){ | |
case "GET_DEPARTMENT_ID": | |
$departmentDetails = DepartmentService::getInstance()->getDepartmentById($model->{$layoutElement->key}); | |
$model->{$layoutElement->key} = $departmentDetails->name; | |
$model->{$layoutElement->key} .= ($departmentDetails->description?'('. $departmentDetails->description.')':''); | |
break; | |
case "GET_SEMESTER_ID": | |
$model->{$layoutElement->key} = SemesterService::getInstance()->getSemestersName($model->{$layoutElement->key}); | |
break; | |
case "GET_ADMISSION_QUOTA_ID": | |
$model->{$layoutElement->key} = AdmissionQuotaService::getInstance()->getQuotaNameById($model->{$layoutElement->key}); | |
break; | |
default: | |
continue; | |
break; | |
} | |
} | |
return $model; | |
} | |
/** | |
* Undocumented function | |
* | |
* @param [type] $reportLayout | |
* @return void | |
*/ | |
public function resolveDynamicLayoutParameters($reportLayout){ | |
global $COLLEGE_NAME, $COLLEGE_NAME_NEW, $COLLEGE_ADDRESS1, $COLLEGE_ADDRESS2; | |
foreach($reportLayout as $layout){ | |
if(empty($layout->customHtml)){ | |
continue; | |
} | |
if($layout->customHtml == "{{COLLEGE_NAME}}"){ | |
$layout->customHtml = "<div class='row m-b-10 p-0'><div class='text-center col-md-12 bold h3 p-0'><u>".(($COLLEGE_NAME_NEW?$COLLEGE_NAME_NEW:$COLLEGE_NAME).' '.$COLLEGE_ADDRESS1.' '.$COLLEGE_ADDRESS2)."</u></div></div>"; | |
} | |
if($layout->customHtml == "{{COLLEGE_HEADER}}"){ | |
$layout->customHtml = CommonService::getInstance()->getCollegeHeader('p-10'); | |
} | |
} | |
return $reportLayout; | |
} | |
} | |