Ejemplo n.º 1
0
 public function deleteAction()
 {
     $id = empty($_GET['id']) ? '' : mysql_escape_string($_GET['id']);
     if ($this->webStorageIndex->indexHasId($id)) {
         $this->view->setParameter('file', $this->webStorageIndex->getIndexById($id));
         $timesheet = new Timesheet($id);
         if (isset($_POST['ispost']) && '1' == $_POST['ispost'] && isset($_POST['confirm_delete']) && '1' == $_POST['confirm_delete']) {
             $timesheet->delete();
             $this->redirectTo('/');
         } else {
             $this->view->setParameter('timesheet', $timesheet);
         }
     } else {
         $this->view->setTemplate('404_timesheet');
     }
 }
 public function exportAction()
 {
     $id = mysql_escape_string($_GET['id']);
     $week = !empty($_GET['week']) ? (int) $_GET['week'] : 1;
     if ($this->webStorageIndex->indexHasId($id)) {
         $type = !empty($_GET['type']) ? $_GET['type'] : 'html';
         $this->view->setParameter('timesheet', new Timesheet($id));
         switch ($type) {
             default:
             case 'html':
                 $this->view->header = array('title' => array(1 => $this->view->timesheet->getName()), 'description' => 'Timesheet pour la semaine (' . $week . ')', 'week-date' => $this->view->timesheet->getWeekDate($week));
                 $this->view->setParameter('weekindex', $week);
                 break;
             case 'csv':
                 header('Content-Encoding: UTF-8');
                 header('Content-type: text/csv; charset=UTF-8');
                 header("Content-type: text/csv");
                 header("Content-Disposition: attachment; filename=export_" . $id . "_week" . $week . ".csv");
                 header("Pragma: no-cache");
                 header("Expires: 0");
                 echo "";
                 // UTF-8 BOM
                 echo $this->view->timesheet->getName() . ' Timesheet pour la semaine (' . $week . ')' . "\n";
                 $timesheet = new Timesheet($id);
                 foreach ($timesheet->getTasksWeek($week) as $task) {
                     echo $task->getTime() . ';' . $task->getName() . "\n";
                 }
                 exit;
                 break;
         }
     } else {
         $this->view->setTemplate('404_timesheet');
     }
 }