Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 81 |
| AssignMealService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
342.00 | |
0.00% |
0 / 81 |
| __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 |
|||
| createSessionMeal | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| updateSessionMeal | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 15 |
|||
| deleteSessionMeal | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getSessionMealById | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getSessionMeal | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getAssignedItem | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getAssignedItemByItemCode | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\dto\AssignMeal; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| class AssignMealService 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; | |
| } | |
| /** | |
| * To assign meal to session | |
| * @param AssignMeal $meal | |
| * @throws ProfessionalException | |
| */ | |
| public function createSessionMeal($meal) | |
| { | |
| $meal->sessionCode = $this->realEscapeString($meal->sessionCode); | |
| $meal->itemCode = $this->realEscapeString($meal->itemCode); | |
| $meal->day = $this->realEscapeString($meal->day); | |
| $meal->date = $this->realEscapeString($meal->date); | |
| $meal->createdBy = $this->realEscapeString($meal->createdBy); | |
| $sql = "insert into assign_meal (sessioncode,itemCode,day,createdBy,createdDate,updatedBy,updatedDate) values ('$meal->sessionCode','$meal->itemCode','$meal->day','$meal->createdBy',utc_timestamp(),'$meal->createdBy',utc_timestamp())"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * To edit meal to session | |
| * @param AssignMeal $meal | |
| * @throws ProfessionalException | |
| */ | |
| public function updateSessionMeal($meal) | |
| { | |
| $meal->sessionCode = $this->realEscapeString($meal->sessionCode); | |
| $meal->itemCode = $this->realEscapeString($meal->itemCode); | |
| $meal->day = $this->realEscapeString($meal->day); | |
| $meal->date = $this->realEscapeString($meal->date); | |
| $meal->createdBy = $this->realEscapeString($meal->createdBy); | |
| $meal->updatedBy = $this->realEscapeString($meal->updatedBy); | |
| $meal->id = $this->realEscapeString($meal->id); | |
| $sql = "update assign_meal set sessioncode = '$meal->sessionCode', itemCode = '$meal->itemCode' ,day='$meal->day', date='$meal->date', updatedBy = '$meal->updatedBy', updatedDate = utc_timestamp() where id=$meal->id"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * To delete a meal assigned to session | |
| * @param int $id | |
| * @throws ProfessionalException | |
| */ | |
| public function deleteSessionMeal($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $sql = "delete from assign_meal where id='$id'"; | |
| try { | |
| $result = $this->executeQuery($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * | |
| * @param int $id | |
| * @throws ProfessionalException | |
| * @return AssignMeal Object | |
| */ | |
| public function getSessionMealById($id) | |
| { | |
| $id = $this->realEscapeString($id); | |
| $sql = "select sessioncode,itemCode,day from assign_meal where id='$id'"; | |
| try { | |
| $result = $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $result; | |
| } | |
| /** | |
| * To get the list of meals assigned to session | |
| * @throws ProfessionalException | |
| * @return AssignMeal objectList | |
| */ | |
| public function getSessionMeal() | |
| { | |
| $sql = "select sessioncode,itemCode,day from assign_meal order by field(day, 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'),field(sessioncode,'BREAKFAST','LUNCH','DINNER')"; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $result; | |
| } | |
| /** | |
| * To get an item assigned to a session | |
| * @param int $sessionCode | |
| * @param string $day | |
| * @throws ProfessionalException | |
| * @return AssignMeal object | |
| */ | |
| public function getAssignedItem($sessionCode,$day,$itemCode) | |
| { | |
| $sql = "select id from assign_meal where sessioncode ='$sessionCode' and day ='$day' and itemCode = '$itemCode'"; | |
| try { | |
| $result = $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $result; | |
| } | |
| public function getAssignedItemByItemCode($itemCode) | |
| { | |
| $sql = "select id from assign_meal where itemCode = '$itemCode'"; | |
| try { | |
| $result = $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $result; | |
| } | |
| } |