Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 38 |
| LMSCalendarService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
110.00 | |
0.00% |
0 / 38 |
| __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 |
|||
| getAllLMSCalendarHolidays | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 28 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\dto\LMSCalendar; | |
| use com\linways\core\ams\professional\dto\LMSCalendarEvent; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\core\ams\professional\mapper\LMSCalendarServiceMapper; | |
| use com\linways\core\ams\professional\request\GetLMSCalendarHolidaysRequest; | |
| /** | |
| * | |
| * @Date 23/12/20 | |
| */ | |
| class LMSCalendarService extends BaseService | |
| { | |
| private $mapper = []; | |
| private $imUtil = null; | |
| private $logger = null; | |
| /** | |
| * Presence of a static member variable | |
| * | |
| * @var null | |
| */ | |
| private static $_instance = null; | |
| /** | |
| * Locked down the constructor | |
| * | |
| * ProposedPlanService constructor. | |
| */ | |
| private function __construct() | |
| { | |
| $this->mapper = LMSCalendarServiceMapper::getInstance()->getMapper(); | |
| } | |
| /** | |
| * Prevent any object or instance of that class to be cloned | |
| */ | |
| private function __clone() | |
| { | |
| } | |
| /** | |
| * Have a single globally accessible static method | |
| * | |
| * @return LMSCalendarService|null | |
| */ | |
| 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; | |
| } | |
| /** | |
| * @param GetLMSCalendarHolidaysRequest $request | |
| * @return Object|LMSCalendarEvent[] | |
| * @throws ProfessionalException | |
| */ | |
| public function getAllLMSCalendarHolidays(GetLMSCalendarHolidaysRequest $request) | |
| { | |
| if (empty($request->endDate) || empty($request->startDate)) { | |
| throw new ProfessionalException(ProfessionalException::INVALID_DATE_RANGE, "Invalid date range given"); | |
| } | |
| if (empty($request->departmentId)) { | |
| throw new ProfessionalException(ProfessionalException::INVALID_DEPARTMENT_ID, "Invalid department details given"); | |
| } | |
| if (empty($request->batchId)) { | |
| throw new ProfessionalException(ProfessionalException::INVALID_BATCH_ID, "Invalid batch details given"); | |
| } | |
| $request->startDate = strtotime(date("Y-m-d", strtotime($request->startDate))); | |
| $request->endDate = strtotime(date("Y-m-d", strtotime($request->endDate))); | |
| try { | |
| $sql = "SELECT eventID as id, eventTitle as title,eventDesc as description, flag,examID as exam_id, | |
| assignmentID as assignment_id,subbatchID as sub_batch_id,hrholiday as hr_holiday,hr_holiday_session, | |
| deptID as department_id,batchID as batch_id,1 as is_holiday, | |
| from_unixtime(`timeStart`,'%Y-%m-%d %H:%i:%s') as start_time, | |
| from_unixtime(`timeEnd`,'%Y-%m-%d %H:%i:%s') as end_time | |
| FROM lms_calender | |
| WHERE timeStart BETWEEN '$request->startDate%' AND '$request->endDate%' | |
| AND flag IN (1,3) | |
| AND ((deptID=$request->departmentId AND batchID = $request->batchId) | |
| OR (deptID=$request->departmentId AND batchID = 0) OR (deptID=0 AND batchID = 0))"; | |
| return $this->executeQueryforList($sql, $this->mapper[LMSCalendarServiceMapper::GET_ALL_LMS_CALENDAR_HOLIDAYS]); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| } |