Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 93 |
HODService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 9 |
420.00 | |
0.00% |
0 / 93 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
__clone | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 4 |
|||
getHiddenBatchesFromHOD | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getAllAndHiddenBatchesFromHOD | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
addHiddenBatchFromHOD | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
removeHiddenBatchFromHOD | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
getAllHodDetails | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
addHodPrivileges | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
deleteHodPrivileges | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
getHodPrivilegesByStaffIdAndAcademicYear | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 17 |
<?php | |
namespace com\linways\core\ams\professional\service; | |
use com\linways\core\ams\professional\exception\ProfessionalException; | |
use com\linways\core\ams\professional\dto\HodPrivileges; | |
class HODService extends BaseService | |
{ | |
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; | |
} | |
/** | |
* Get hidden batches from HOD | |
* @param unknown $deptID | |
* @throws ProfessionalException | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @author Vishnu | |
*/ | |
public function getHiddenBatchesFromHOD($deptID) | |
{ | |
$deptID = $this->realEscapeString($deptID); | |
$query = "SELECT id, batchID, deptID FROM hidden_hod_batches WHERE deptID = ".$deptID.""; | |
try { | |
$batches=$this->executeQueryForList($query); | |
return $batches; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Get ALL & HIDDEN batches from the HOD of a department | |
* @param Int $deptID | |
* @throws ProfessionalException | |
* @return object|array|\com\linways\base\util\$objectList[] | |
* @author Vishnu | |
*/ | |
public function getAllAndHiddenBatchesFromHOD ( $deptID ) { | |
$deptID = $this->realEscapeString($deptID); | |
$query = "SELECT b.batchID, b.batchName, b.deptID, b.isPassOut, hhb.id AS isHidden FROM batches b LEFT JOIN hidden_hod_batches hhb ON (b.batchID = hhb.batchID AND b.deptID = hhb.deptID) WHERE b.deptID = ".$deptID." ORDER BY b.batchName"; | |
try{ | |
$batches = $this->executeQueryForList($query); | |
return $batches; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Save HIDDEN batches from HOD in a department. | |
* @param Int $batchID | |
* @param Int $deptID | |
* @param Int $adminID | |
* @throws ProfessionalException | |
* @return object|NULL|\com\linways\base\util\$objectList[] | |
* @author Vishnu | |
*/ | |
public function addHiddenBatchFromHOD($batchID, $deptID, $adminID) { | |
$batchID = $this->realEscapeString($batchID); | |
$deptID = $this->realEscapeString($deptID); | |
$adminID = $this->realEscapeString($adminID); | |
$query = "INSERT INTO hidden_hod_batches ( batchID, deptID, createdBy, createdDate, updatedBy, updatedDate) VALUES (".$batchID.", ".$deptID.", ".$adminID.", utc_timestamp(), ".$adminID.", utc_timestamp()); "; | |
try{ | |
return $this->executeQueryForObject ( $query, TRUE ); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Remove hidden batches of hod | |
* @param Int $batchID | |
* @param Int $deptID | |
* @throws ProfessionalException | |
* @return true | |
* @author Vishnu | |
*/ | |
public function removeHiddenBatchFromHOD ( $batchID, $deptID ) { | |
$batchID = $this->realEscapeString($batchID); | |
$deptID = $this->realEscapeString($deptID); | |
$query = "DELETE FROM hidden_hod_batches WHERE batchID = ".$batchID." AND deptID = ".$deptID.""; | |
try { | |
$this->executeQuery($query); | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
return true; | |
} | |
/** | |
* Get all hod details | |
* @param NULL | |
* @return object|array| | |
* @throws ProfessionalException | |
*/ | |
public function getAllHodDetails(){ | |
$sql ="SELECT staffID, staffName, deptID FROM staffaccounts WHERE isHOD > 0 AND isResigned != 1"; | |
try{ | |
$hods = $this->executeQueryForList($sql); | |
return $hods; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Add HOD privileges | |
* @param HodPrivileges $hodPrivileges | |
* @return Integer $id | |
* @throws ProfessionalException | |
*/ | |
public function addHodPrivileges(HodPrivileges $hod){ | |
$hod = $this->realEscapeObject($hod); | |
$sql = null; | |
$sql = "INSERT INTO hodPrivileges (staffID,batchIDs,semIDs,startEndYear) VALUES ($hod->staffID,'$hod->batchIDs','$hod->semIDs','$hod->startEndYear')"; | |
try{ | |
return $this->executeQueryForObject($sql,TRUE); | |
} | |
catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Delete HOD privileges | |
* @param Integer $staffID | |
* @param String semIDs | |
* @return NULL | |
* @throws ProfessionalException | |
*/ | |
public function deleteHodPrivileges($staffID,$startEndYear){ | |
$staffID = $this->realEscapeString($staffID); | |
$startEndYear = $this->realEscapeString($startEndYear); | |
$sql = "DELETE FROM hodPrivileges WHERE staffID = $staffID AND startEndYear = '$startEndYear' "; | |
try{ | |
$this->executeQuery($sql); | |
} | |
catch(\Exception $e){ | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
/** | |
* Get batchIDs,semIDs hod priveleges by staffID and academicYear | |
* @param Integer $staffID | |
* @param String $startEndYear | |
* @return object|array| | |
* @throws ProfessionalException | |
*/ | |
public function getHodPrivilegesByStaffIdAndAcademicYear($staffID,$startEndYear){ | |
$staffID = $this->realEscapeString($staffID); | |
$startEndYear = $this->realEscapeString($startEndYear); | |
$sql = "SELECT | |
batchIDs,semIDs | |
FROM | |
hodPrivileges | |
WHERE | |
staffID = $staffID | |
AND startEndYear = '$startEndYear'"; | |
try{ | |
$batchIDs = $this->executeQueryForObject($sql); | |
return $batchIDs; | |
} | |
catch(\Exception $e) { | |
throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
} | |
} | |
} | |