public function save() { $workShiftId = $this->getValue('workShiftId'); if (empty($workShiftId)) { $workShift = new WorkShift(); $empArray = $this->getValue('assignedEmp'); $workShift->setName($this->getValue('name')); $workShift->setHoursPerDay($this->getValue('hours')); $workShift->save(); } else { $workShift = $this->getWorkShiftService()->getWorkShiftById($workShiftId); $workShift->setName($this->getValue('name')); $workShift->setHoursPerDay($this->getValue('hours')); $this->getWorkShiftService()->updateWorkShift($workShift); $employees = $this->getValue('assignedEmp'); $existingEmployees = $workShift->getEmployeeWorkShift(); $idList = array(); if ($existingEmployees[0]->getEmpNumber() != "") { foreach ($existingEmployees as $existingEmployee) { $id = $existingEmployee->getEmpNumber(); if (!in_array($id, $employees)) { $existingEmployee->delete(); } else { $idList[] = $id; } } } $this->resultArray = array(); $employeeList = array_diff($employees, $idList); $newList = array(); foreach ($employeeList as $employee) { $newList[] = $employee; } $empArray = $newList; } $this->_saveEmployeeWorkShift($workShift->getId(), $empArray); }
//return View::make('admin.scheduling', ['employeeInfo' => $employeeInfo, 'getUserEmployee' => $getUserEmployee]); if (!empty($groups)) { if (strcmp(strtolower($groups->name), strtolower('Employee')) !== 0) { return View::make('admin.scheduling', ['employeeInfo' => $employeeInfo, 'getUserEmployee' => $getUserEmployee]); } else { //http://jsfiddle.net/umz8t/458/ //http://stackoverflow.com/questions/16344354/how-to-make-blinking-flashing-text-with-css3 echo '<body style="background-color:#000000;"><p style="text-align:center; font-size:75px; color:#00ff00;">_We are watching you (>_<)</p></body>'; } } })); Route::post('/admin/scheduling/search/default/schedule/', array('as' => '', 'uses' => function () { //$data = Input::all(); $data['employee_number'] = Input::get('employee_number'); $employeeNumber = Employee::where('employee_number', '=', trim($data['employee_number']))->first(); $defaultSchedules = WorkShift::where('employee_id', '=', trim($employeeNumber->id))->get(); $employeeId = Session::get('userEmployeeId'); $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); $getUserEmployee = DB::table('users')->join('employees', 'users.employee_id', '=', 'employees.id')->join('users_groups', 'users_groups.user_id', '=', 'users.id')->join('groups', 'users_groups.group_id', '=', 'groups.id')->get(); return View::make('admin.scheduling', ['employeeInfo' => $employeeInfo, 'getUserEmployee' => $getUserEmployee, 'defaultSchedules' => $defaultSchedules]); //return View::make('admin.scheduling', ['employeeInfo' => $employeeInfo, 'defaultSchedules' => $defaultSchedules]); })); Route::post('/admin/scheduling/upload/new/schedule', array('as' => 'adminUploadNewSchedule', 'uses' => 'EmployeesController@postShift')); Route::post('/admin/scheduling/search/uploaded/schedule', array('as' => '', 'uses' => function () { $data = Input::all(); //$data['employee_number'] = Input::get('employee_number'); $employeeNumber = Employee::where('employee_number', '=', trim($data['employee_number']))->first(); $uploadedSchedules = Schedule::where('employee_id', '=', trim($employeeNumber->id))->whereBetween('schedule_date', array($data["schedule_date_from"], $data["schedule_date_to"]))->get(); $employeeId = Session::get('userEmployeeId'); $employee = new Employee();
public function updateWorkShift(WorkShift $workShift) { try { $q = Doctrine_Query::create()->update('WorkShift')->set('name', '?', $workShift->name)->set('hours_per_day', '?', $workShift->hoursPerDay)->set('start_time', '?', $workShift->getStartTime())->set('end_time', '?', $workShift->getEndTime())->where('id = ?', $workShift->id); return $q->execute(); } catch (Exception $e) { throw new DaoException($e->getMessage()); } }