/**
  * Upate time record
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->wireframe->print_button = false;
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     if ($this->active_time->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_time->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $timetracking_data = $this->request->post('time');
     if (!is_array($timetracking_data)) {
         $timetracking_data = array('user_id' => $this->active_time->getUserId(), 'record_user' => $this->active_time->getUser(), 'value' => $this->active_time->getValue(), 'body' => $this->active_time->getBody(), 'record_date' => $this->active_time->getRecordDate(), 'billable_status' => $this->active_time->getBillableStatus());
     }
     // if
     $this->smarty->assign('timetracking_data', $timetracking_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $timetracking_data['value'] = time_to_float($timetracking_data['value']);
         $old_user_id = $this->active_time->getUserId();
         $this->active_time->setAttributes($timetracking_data);
         if (isset($timetracking_data['user_id']) && $timetracking_data['user_id']) {
             $user_id = array_var($timetracking_data, 'user_id');
             if ($user_id) {
                 $user = Users::findById($user_id);
                 if (instance_of($user, 'User')) {
                     $timetracking_data['record_user'] = $user;
                     if ($user_id != $old_user_id) {
                         $this->active_time->setUser($user);
                     }
                     // if
                 }
                 // if
             }
             // if
         } else {
             if ($user_id == $old_user_id) {
                 $timetracking_data['record_user'] = $this->active_time->getUser();
                 // Not changed anonymous user
             }
             // if
         }
         // if
         $this->smarty->assign('timetracking_data', $timetracking_data);
         $save = $this->active_time->save();
         if ($save && !is_error($save)) {
             db_commit();
             if ($this->request->getFormat() == FORMAT_HTML) {
                 flash_success('Time record #:record_id has been updated', array('record_id' => $this->active_time->getId()));
                 $this->redirectToUrl($this->smarty->get_template_vars('time_url'));
             } else {
                 $this->serveData($this->active_time, 'time_record');
             }
             // if
         } else {
             db_rollback();
             if ($this->request->getFormat() == FORMAT_HTML) {
                 $this->smarty->assign('errors', $save);
             } else {
                 $this->serveData($save);
             }
             // if
         }
         // if
     }
     // if
 }