Example #1
0
 public function editTimeAndDate()
 {
     $this->load->library('jdf');
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->load->library("session");
     if ($this->form_validation->run('item/editTimeAndDate') === FALSE) {
         $this->load->view("templates/errorForm.php", array("fields" => array('id', 'date', 'endTime', 'startTime')));
     } else {
         $item = new Item($this->input->post("id"));
         if ($item->getUserId() != $this->session->getStudentId()) {
             echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>" . PHP_EOL;
             echo "->DEBUG at <b>" . __FUNCTION__ . "</b>at <b>" . __LINE__ . '</b>$item->user_id = ' . $item->getUserId() . "<br>" . PHP_EOL;
             echo "->DEBUG at <b>" . __FUNCTION__ . "</b>at <b>" . __LINE__ . '</b>$this->session->getStudentId() = ' . $this->session->getStudentId() . "<br>" . PHP_EOL;
             echo "->DEBUG at <b>" . __FUNCTION__ . "</b>at <b>" . __LINE__ . '</b>$item->user_id == $this->session->getStudentId() = ' . $item->user_id == $this->session->getStudentId() . "<br>";
             return;
         }
         $start = makeTime($this->input->post("date"), $this->input->post("startTime"));
         $end = makeTime($this->input->post("date"), $this->input->post("endTime"));
         try {
             $item->setStartEnd($start, $end);
             $item->update();
             $this->load->view("item/item_created.php", array("item" => $this->setFormat(array($item))));
         } catch (Item_Overlap_With_Other_Item $e) {
             $this->load->view("item/item_error.php");
             echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>";
             Item_Error::Item_Overlap_With_Other_Item();
         } catch (Item_Create_With_Zero_Duration $e) {
             $this->load->view("item/item_error.php");
             echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>";
             Item_Error::Item_Create_With_Zero_Duration();
         } catch (Item_Start_Greater_Than_End_Exception $e) {
             $this->load->view("item/item_error.php");
             echo "->IAMHERE at <b>" . __FUNCTION__ . "</b> at <b>" . __FILE__ . "</b> at <b>" . __LINE__ . "</b><br>";
             Item_Error::Item_Start_Greater_Than_End_Exception();
         }
     }
 }