public function createDraftAction() { $this->init(); // check auth $success = 1 < $this->ctrlLv ? true : false; if (!$success) { return $this->redirect()->toRoute('app', array('controller' => 'failed', 'action' => 'forbidden')); } $user_no = (int) $this->auth()->get('user_no'); $branch_no = (int) $this->auth()->get('branch_no'); $approval = new ApprovalTable(); $ref_no = trim($this->createRefNumber()); try { $id = (int) $approval->insertDraft($user_no, $ref_no); return $this->redirect()->toRoute('app', array('controller' => 'approval', 'action' => 'create', 'id' => $id)); } catch (\Exception $e) { die($e->getMessage()); } $response = array('message' => $id); $viewJson = new JsonModel(); $viewJson->setVariables($response); return $viewJson; }