예제 #1
0
 public function createTasksWeekFromData($weekIndex, $data)
 {
     $this->tasksByWeeks[$weekIndex] = Task::createTasksFromData($data, $weekIndex);
     ksort($this->tasksByWeeks);
     return $this;
 }
 public function edit()
 {
     $id = mysql_escape_string($_POST['id']);
     $taskindex = $weekindex = null;
     if (isset($_GET['task'])) {
         $taskindex = mysql_escape_string($_GET['task']);
         if (is_numeric($taskindex) && isset($_GET['week'])) {
             $weekindex = mysql_escape_string((int) $_GET['week']);
         }
     }
     $task = null;
     if ($this->webStorageIndex->indexHasId($id)) {
         $timesheet = new Timesheet($id);
         // Edit mode :
         if (null !== $weekindex && null !== $taskindex && $timesheet->hasTask($weekindex, $taskindex)) {
             $task = $timesheet->getTask($weekindex, $taskindex);
             $task->setTime($_POST['time']);
             $task->setName($_POST['name']);
             if ((int) $_POST['week'] != (int) $weekindex) {
                 $task->setWeek((int) $_POST['week']);
                 $task = clone $task;
                 $timesheet->deleteTask($weekindex, $taskindex);
                 $timesheet->addTask($task);
             }
             // Create mode :
         } else {
             $task = new Task();
             $task->setTime($_POST['time']);
             $task->setName($_POST['name']);
             $task->setWeek((int) $_POST['week']);
             $timesheet->addTask($task);
         }
         // Save timesheet :
         $timesheet->save();
         //$this->view->setParameter('file', $file);
         //$this->view->setParameter('timesheet', $timesheet);
     } else {
         $this->view->setTemplate('404_timesheet');
     }
 }