Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 59 |
V4StaffService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
132.00 | |
0.00% |
0 / 59 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
__clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
staffCurrentRolesAndDepartments | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 36 |
|||
isTutorCheck | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
<?php | |
namespace com\linways\core\ams\professional\service\v4Staff; | |
use com\linways\base\dto\Email; | |
use com\linways\base\dto\EmailTo; | |
use com\linways\base\dto\EmailFrom; | |
use com\linways\base\util\StringUtil; | |
use com\linways\core\ams\professional\logging\Events; | |
use com\linways\core\ams\professional\constant\Modules; | |
use com\linways\core\ams\professional\logging\AMSLogger; | |
use com\linways\core\ams\professional\constant\StatusConstants; | |
use com\linways\core\ams\professional\service\BaseService; | |
use com\linways\core\ams\professional\dto\v4\IntimationData; | |
use com\linways\core\ams\professional\service\CommonService; | |
use com\linways\core\ams\professional\logging\entities\Staff; | |
use com\linways\core\ams\professional\dto\v4\IntimationDataProperties; | |
use com\linways\core\ams\professional\dto\v4\AttendanceMarkedUser; | |
use com\linways\core\ams\professional\dto\v4\Attendance; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\service\StaffService; | |
class V4StaffService extends BaseService | |
{ | |
private static $_instance = null; | |
private $mapper = []; | |
private $logger = null; | |
private function __construct() | |
{ | |
$this->logger = AMSLogger::getLogger(); | |
} | |
// Prevent any object or instance of that class to be cloned | |
private function __clone() | |
{ | |
} | |
// 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; | |
} | |
/** | |
* V4 fetch intimation non sent student details | |
* | |
* @param $request $role | |
* @return $currentStaffRole | |
*/ | |
public function staffCurrentRolesAndDepartments($staffId){ | |
$currentStaffRole = new \stdClass(); | |
$roleCode = ""; | |
$isPrincipal = false; | |
try { | |
$isPrincipal = StaffService::getInstance()->isFacultyIsPrincipal($staffId); | |
$sql = "SELECT | |
DISTINCT st.staffID as staffId, | |
st.staffName as staffName, | |
dept.deptID as deptId, | |
dept.deptName, | |
r.code as roleCode | |
FROM roles r | |
INNER JOIN user_account_roles uar ON uar.role_id = r.id AND uar.user_type = 'STAFF' | |
INNER JOIN staffaccounts st ON st.staffID = uar.user_id | |
INNER JOIN v4_ams_staff_department_relations sta_d_t ON sta_d_t.staff_id = st.staffID | |
INNER JOIN department dept ON dept.deptID = sta_d_t.department_id | |
WHERE st.staffID = '$staffId' AND r.code IN ('HOD_DEFAULT','PRINCIPAL_DEFAULT') "; | |
$staffs = $this->executeQueryForList($sql); | |
foreach($staffs as $staff){ | |
$currentStaffRole->staffId = $staff->staffId; | |
$currentStaffRole->staffName = $staff->staffName; | |
$currentStaffRole->roles[$staff->roleCode] = $staff->roleCode; | |
$department = new \stdClass(); | |
$department->id = $staff->deptId; | |
$department->name = $staff->deptName; | |
$currentStaffRole->departments[] = $department; | |
} | |
$currentStaffRole->roles = array_values($currentStaffRole->roles); | |
if((!in_array('PRINCIPAL_DEFAULT',$currentStaffRole->roles)) && $isPrincipal){ | |
$currentStaffRole->roles[] = 'PRINCIPAL_DEFAULT'; | |
} | |
} catch (\Throwable $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $currentStaffRole; | |
} | |
/** | |
* V4 check is tutor | |
* | |
* @param $request $staffId $batchId | |
* @return $staff | |
*/ | |
public function isTutorCheck($staffId,$batchId){ | |
$staff = null; | |
try { | |
$sql = "SELECT DISTINCT stf.staffID as id,stf.staffName as name, b.batchID as v3BatchId | |
FROM staffaccounts stf | |
INNER JOIN groups_tutor gt ON gt.staff_id = stf.staffID | |
INNER JOIN `batches` b ON b.groups_id = gt.groups_id | |
WHERE stf.isResigned = 0 AND stf.staffID = $staffId AND gt.groups_id = '$batchId' "; | |
$staff = $this->executeQueryForObject($sql); | |
} catch (\Throwable $e) { | |
throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
} | |
return $staff; | |
} | |
} |