/**
  * Quick add time record
  *
  * @param void
  * @return null
  */
 function quick_add()
 {
     if (!TimeRecord::canAdd($this->logged_user, $this->active_project)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, lang("You don't have permission for this action"), true, true);
     }
     // if
     $this->skip_layout = true;
     $time_record_data = $this->request->post('time_record');
     if (!is_array($time_record_data)) {
         $time_record_data = array('record_date' => new DateValue(time() + get_user_gmt_offset($this->logged_user)), 'billable_status' => BILLABLE_STATUS_BILLABLE);
     }
     // if
     $this->smarty->assign(array('time_record_data' => $time_record_data, 'quick_add_url' => assemble_url('project_time_quick_add', array('project_id' => $this->active_project->getId()))));
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $this->active_time = new TimeRecord();
         $time_record_data['value'] = time_to_float($time_record_data['value']);
         $this->active_time->setAttributes($time_record_data);
         $this->active_time->setProjectId($this->active_project->getId());
         $this->active_time->setCreatedBy($this->logged_user);
         $this->active_time->setState(STATE_VISIBLE);
         $this->active_time->setVisibility(VISIBILITY_NORMAL);
         $user_id = array_var($time_record_data, 'user_id');
         if ($user_id) {
             $user = Users::findById($user_id);
             if (instance_of($user, 'User')) {
                 $this->active_time->setUser($user);
             }
             // if
         }
         // if
         $save = $this->active_time->save();
         if ($save && !is_error($save)) {
             db_commit();
             $this->active_time->ready();
             $this->smarty->assign(array('active_time_record' => $this->active_time, 'time_record_data' => array('user_id' => $this->logged_user->getId(), 'record_date' => $this->active_time->getRecordDate(), 'billable_status' => $this->active_time->getBillableStatus()), 'selected_form_url' => assemble_url('project_time_quick_add', array('project_id' => $this->active_project->getId(), 'skip_layout' => true)), 'project_id' => $this->active_project->getId()));
             $this->skip_layout = true;
         } else {
             db_rollback();
             $this->httpError(HTTP_ERR_OPERATION_FAILED, $save->getErrorsAsString(), true, true);
         }
         // if
     }
     // if
 }