Ejemplo n.º 1
0
 public function editAction($model = null)
 {
     if ($this->_getParam('clientid')) {
         $this->view->client = $this->clientService->getClient($this->_getParam('clientid'));
     } else {
         $ownerId = za()->getConfig('owning_company');
         $this->view->client = $this->clientService->getClient($ownerId);
     }
     $this->view->locations = $this->expenseService->getExpenseLocations();
     $this->view->users = $this->userService->getUserList();
     $this->view->defaultProjectid = za()->getConfig('default_expense_project');
     $this->view->clients = $this->clientService->getClients();
     $this->view->projects = new ArrayObject();
     // Figure out the stuff for displaying the files
     if ($model == null) {
         if ((int) $this->_getParam('id')) {
             $this->view->model = $this->byId();
             //  $this->dbService->getById((int)$this->_getParam('id'), $modelType);
             $this->view->client = $this->clientService->getClient($this->view->model->clientid);
         } else {
             $this->view->model = new Expense();
         }
         $this->view->files = array();
     } else {
         $this->view->model = $model;
         $this->view->client = $this->clientService->getClient($this->view->model->clientid);
     }
     if ($this->view->client) {
         $this->view->projects = $this->projectService->getProjectsForClient($this->view->client);
         // get the support project at the very least
         if (!$this->view->defaultProjectid) {
             $project = $this->clientService->getClientSupportProject($this->view->client);
             $this->view->defaultProjectid = $project->id;
         }
     }
     $this->view->categories = $this->view->model->constraints['atocategory']->getValues();
     $this->view->expenseTypes = $this->view->model->constraints['expensetype']->getValues();
     $this->view->expenseCategories = $this->view->model->constraints['expensecategory']->getValues();
     if ($this->view->model->id) {
         $this->view->files = $this->expenseService->getExpenseFiles($this->view->model);
         $path = 'Expenses/' . $this->view->model->id;
         $this->view->filePath = $path;
     }
     $this->renderView('expense/edit.php');
 }