public function substitutePayrate($substituteid) { $payrate = ''; $substitute = new Substitutes(); $subs = $substitute->getById($substituteid); if ($subs) { $payrate = $subs->payrate; } return $payrate; }
public function substituteName($substituteid) { $substitutesModel = new Substitutes(); $substitute = $substitutesModel->getById($substituteid); if (!$substitute) { $substituteName = "Not Set"; } else { $substituteName = $substitute->lastname . ", " . $substitute->firstname; } return $substituteName; }
public function trackAction() { $locationsModel = new Locations(); $this->view->locations = $locationsModel->getAll(); $employeesModel = new Employees(); if ($this->_me->admin == 1) { $this->view->employees = $employeesModel->getAll(); } else { $this->view->employees = $employeesModel->getAllByLocation($this->_me->location); } $substitutesModel = new Substitutes(); if ($this->_me->admin == 1) { $this->view->substitutes = $substitutesModel->getAll(); } else { //$this->view->substitutes = $substitutesModel->getAllByLocation($this->_me->location); $this->view->substitutes = $substitutesModel->getAll(); } if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if ($this->_me->admin == 1) { $emp = $employeesModel->getById($data['employee']); $data['location'] = $emp->location; } $data['user'] = $this->_me->id; $data['date_created'] = date('Y-m-d h:i:s', strtotime('now')); $start_day = date('l', strtotime($data['date'])); if ($start_day != 'Saturday' && $start_day != 'Sunday') { $days = $data['days']; unset($data['days']); // payrate $subs = $substitutesModel->getById($data['substitute']); if ($subs) { $data['payrate'] = $subs->payrate; } $recordsModel = new Records(); if ($recordsModel->insert($data)) { if ($days > 1) { $i = 1; $cnt_day = 0; $startdate = $data['date']; while ($i < $days) { $dayName = date('l', strtotime($startdate . " + {$i} days")); $c_day = 0; //omit weekends if ($dayName == 'Saturday') { // + 2 dias $cnt_day = 2; } if ($dayName == 'Sunday') { // + 1 dias $cnt_day = 2; } $c_day = $cnt_day + $i; $data['date'] = date('Y-m-d', strtotime($startdate . " + {$c_day} days")); $recordsModel->insert($data); $i++; } } $this->view->success = "Leave Record Saved."; } else { $this->view->error = "An Error Occurred."; } } else { $this->view->error = "Saturday and Sunday are not working days, please select other day."; } } }