Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 44
HostelService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
156.00
0.00% covered (danger)
0.00%
0 / 44
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 __clone
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 getInstance
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 5
 getHostelAdmittedStudents
0.00% covered (danger)
0.00%
0 / 1
42.00
0.00% covered (danger)
0.00%
0 / 28
 getHostelAdmittedStudentDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 9
<?php
namespace com\linways\core\ams\professional\service;
use com\linways\core\ams\professional\service\BaseService;
use com\linways\core\ams\professional\exception\ProfessionalException;
use com\linways\core\ams\professional\response\SearchHostelStudentsResponse;
use com\linways\core\ams\professional\request\SearchHostelStudentsRequest;
class HostelService 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;
    }
    /**
     * Get  hostel admitted students
     * @param SearchHostelStudentsRequest $hostelStudents
     * @throws ProfessionalException
     * @return \com\linways\core\ams\professional\response\SearchHostelStudentsResponse
     */
    public function getHostelAdmittedStudents($hostelStudents)
    {
        $hostelStudents = $this->realEscapeObject($hostelStudents);
        
        $hostelStudentsResponse = new SearchHostelStudentsResponse(); 
        
        $sql = "SELECT sa.studentID, sa.studentName, sa.studentAccount, sa.admissionNo, buildingID, sh.levelID, ir.roomID, ir.roomNo, irt.roomtypeName, irt.rentPerBed, sh.joiningDate FROM studentaccount sa INNER JOIN student_hosteler sh ON sa.studentID = sh.studentID INNER JOIN infrastructure_room ir ON ir.roomID = sh.roomID INNER JOIN  infrastructure_room_type irt ON irt.roomTypeID = ir.roomTypeID";
        
        if($hostelStudents->studentName)
        {
            $sql.=" AND studentName LIKE '%$hostelStudents->studentName%'";
        }
        if($hostelStudents->deptId)
        {
            $sql.= " AND deptID = $hostelStudents->deptId";
        }
        if($hostelStudents->batchId)
        {
            $sql.= " AND batchID = $hostelStudents->batchId";
        }
        if($hostelStudents->admissionNo)
        {
            $sql.= " AND admissionNo = '$hostelStudents->admissionNo'";
        }
        $sql.= " ORDER BY $hostelStudents->sortBy $hostelStudents->sortOrder";
        
        try {
            $hostelStudentsResponse->studentList = $this->executeQueryForList($sql);
            
        } catch (\Exception $e) {
            
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
        
        return $hostelStudentsResponse;
    }
    
    /**
     * Get  hostel admitted student by id
     * @param int $studentId
     * @throws ProfessionalException
     * @return object|NULL|\com\linways\base\util\$objectList[]
     */
    public function getHostelAdmittedStudentDetails($studentId)
    {
        $studentId = $this->realEscapeString($studentId);
        
        
        $sql = "SELECT sa.studentID, sa.myimage, sa.studentGender, sa.studentName, sa.studentAccount, sa.admissionNo, sa.studentPhone, buildingID, sh.levelID, ir.roomID, ir.roomNo, irt.roomtypeName, irt.rentPerBed, sh.joiningDate, dpt.deptName, bth.batchName, sem.year, sem.semName FROM studentaccount sa INNER JOIN department dpt ON dpt.deptID=sa.deptID INNER JOIN batches bth ON bth.batchID=sa.batchID INNER JOIN semesters sem ON sem.semID=bth.semID INNER JOIN student_hosteler sh ON sa.studentID = sh.studentID INNER JOIN infrastructure_room ir ON ir.roomID = sh.roomID INNER JOIN  infrastructure_room_type irt ON irt.roomTypeID = ir.roomTypeID WHERE sa.studentID=$studentId";
        
        try {
            
            return $this->executeQueryForObject($sql);
            
        } catch (\Exception $e) {
            
            throw new ProfessionalException($e->getCode(), $e->getMessage());
        }
        
    }
}