Ejemplo n.º 1
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['name'])) {
         $name = $input['name'];
     }
     if (!empty($input['employeeID'])) {
         $employeeID = $input['employeeID'];
         $return = $this->stories->shiftsForEmployee($employeeID);
     }
     if (!empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getEmployeesWorkingBetween($startTime, $endTime);
     }
     if (!empty($input['employeeID']) && !empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $employeeID = $input['employeeID'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getHoursForEmployeeBetween($employeeID, $startTime, $endTime);
     }
     if (!empty($input['employeeI2D'])) {
         $employeeID = $input['employeeID2'];
         $return = $this->stories->shiftsForEmployee($employeeID);
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $return]);
 }
Ejemplo n.º 2
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['employeeID'])) {
         $employeeID = $input['employeeID'];
         $managers = $this->stories->getManagersByEmployeeID($employeeID);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['managers' => $managers]);
 }
Ejemplo n.º 3
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['startTime'] && !empty($input['endTime']))) {
         $startTime = \DateTime::createFromFormat('m-d-Y', $input['startTime']);
         $endTime = \DateTime::createFromFormat('m-d-Y', $input['endTime']);
         $success = $this->stories->getShiftsBetween($startTime, $endTime);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['result' => $success]);
 }
Ejemplo n.º 4
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['shiftID'] && !empty($input['employeeID']))) {
         $shiftID = $input['shiftID'];
         $employeeID = $input['shiftID'];
         $success = $this->stories->assignEmployeetoShift($employeeID, $shiftID);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['result' => $success]);
 }
Ejemplo n.º 5
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['employeeID'])) {
         $employeeID = $input['employeeID'];
         $success = $this->stories->getEmployeeDetails($employeeID);
     } else {
         throw new \Exception('Employee ID is required');
     }
     if ($success === null) {
         $success = 'Employee not found';
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['result' => $success]);
 }
Ejemplo n.º 6
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['employeeID']) && !empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $employeeID = $input['employeeID'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getHoursForEmployeeBetween($employeeID, $startTime, $endTime);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $return]);
 }
Ejemplo n.º 7
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['employeeID']) && !empty($input['startTime'] && !empty($input['endTime']))) {
         $employeeID = $input['employeeID'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $input['startTime']);
         $endTime = \DateTime::createFromFormat('m-d-Y', $input['endTime']);
         $break = !empty($input['break']) ? $input['break'] : 0;
         //This allows employers to easily "forget" to add the break time :P
         $success = $this->stories->createShiftForEmployee($employeeID, $startTime, $endTime, $break);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $success]);
 }
Ejemplo n.º 8
0
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     /**
      * Story 2:
      * Should this ask for an employee ID and return all shifts between times registered to prevent misuse?
      */
     if (!empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getEmployeesWorkingBetween($startTime, $endTime);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['employeesWorking' => $return]);
 }
Ejemplo n.º 9
0
 private function create_stories_from_select($rows)
 {
     $stories = new stories();
     foreach ($rows as $row) {
         if (isset($this->cache[$row['id']])) {
             $new = $this->cache[$row['id']];
         } else {
             $new = story::create($row['caption'], $row['description'], $row['created'], $row['modified']);
             $this->cache[$row['id']] = $new;
         }
         $stories->push($new);
     }
     return $stories;
 }