/**
  * Show and process edit status form
  *
  * @param void
  * @return null
  */
 function edit_status()
 {
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall());
     }
     // if
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, true);
     }
     // if
     if (!$this->active_project->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     $project_data = $this->request->post('project');
     if (!is_array($project_data)) {
         $project_data = array('status' => $this->active_project->getStatus());
     }
     // if
     $this->smarty->assign('project_data', $project_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         switch (array_var($project_data, 'status')) {
             case PROJECT_STATUS_ACTIVE:
                 $save = $this->active_project->reopen();
                 break;
             case PROJECT_STATUS_PAUSED:
                 $save = $this->active_project->reopen(true);
                 break;
             case PROJECT_STATUS_COMPLETED:
                 $save = $this->active_project->complete($this->logged_user);
                 break;
             case PROJECT_STATUS_CANCELED:
                 $save = $this->active_project->complete($this->logged_user, true);
                 break;
             default:
                 $this->httpError(HTTP_ERR_BAD_REQUEST);
         }
         // switch
         if ($save && !is_error($save)) {
             db_commit();
             if ($this->request->isApiCall()) {
                 $this->serveData($this->active_project, 'project');
             } else {
                 flash_success("Status of ':name' project has been updated", array('name' => $this->active_project->getName()));
                 $this->redirectToUrl($this->active_project->getOverviewUrl());
             }
             // if
         } else {
             db_rollback();
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->smarty->assign('errors', $save);
             }
             // if
         }
         // if
     }
     // if
 }