コード例 #1
0
 public function categoryAction()
 {
     $form = new \Accounting\Form\ExpenseCategoryFilter($this->getServiceLocator());
     $form->setData($this->params()->fromQuery());
     $this->getViewModel()->setVariable('form', $form);
     if ($form->isValid()) {
         $expenseCategory = new ExpenseCategory();
         $expenseCategory->exchangeArray($form->getData());
         $expenseCategory->addOption('loadUser', true);
         $expenseCategory->addOption('loadCompany', true);
         if (!$this->user()->getUser()->isAdmin()) {
             $expenseCategory->addOption('companyId', $this->user()->getCompanyId());
         }
         $expenseCategoryMapper = $this->getServiceLocator()->get('Accounting\\Model\\ExpenseCategoryMapper');
         $tree = new Tree();
         $expenseCategorytrees = $tree->toArrayRecusived($expenseCategoryMapper->fetchAll($expenseCategory));
         $this->getViewModel()->setVariable('expenseCategorys', $expenseCategorytrees);
     }
     return $this->getViewModel();
 }
コード例 #2
0
 public function indexAction()
 {
     $form = new \Accounting\Form\AccountFilter($this->getServiceLocator());
     $form->setData($this->params()->fromQuery());
     $this->getViewModel()->setVariable('form', $form);
     if ($form->isValid()) {
         $account = new Account();
         $account->exchangeArray($form->getData());
         $account->addOption('loadUser', true);
         $account->addOption('loadCompany', true);
         if (!$this->user()->getUser()->isAdmin()) {
             $account->addOption('companyId', $this->user()->getCompanyId());
         }
         if (!$this->user()->getCompanyId()) {
             return $this->page403();
         }
         $accountMapper = $this->getServiceLocator()->get('Accounting\\Model\\AccountMapper');
         $tree = new Tree();
         $accounttrees = $tree->toArrayRecusived($accountMapper->fetchAll($account));
         $this->getViewModel()->setVariable('paginator', $accounttrees);
     }
     return $this->getViewModel();
 }
コード例 #3
0
 public function loadAction()
 {
     $companyId = $this->getRequest()->getPost('companyId');
     if (!$companyId) {
         $companyId = $this->user()->getCompanyId();
     } elseif (!$this->company()->canManage($companyId)) {
         return $this->getJsonModel()->setVariables(array('code' => 0, 'messages' => ['Bạn không có quyền quản lí doanh nghiệp này']));
     }
     $modeLoad = $this->getRequest()->getPost('modeLoad');
     $accountIds = [];
     $accountMapper = $this->getServiceLocator()->get('\\Accounting\\Model\\AccountMapper');
     if ($modeLoad && $modeLoad == 'basic') {
         $account = new \Accounting\Model\Account();
         $account->setCompanyId($companyId);
         $accountIds = $accountMapper->recusiveBranchChildIds($account, [\Accounting\Model\Account::ID_CASH]);
     }
     $account = new \Accounting\Model\Account();
     if (count($accountIds)) {
         $account->addOption('ids', $accountIds);
     } else {
         $account->setCompanyId($companyId);
         $account->addOption('loadSystemAccount', true);
     }
     $tree = new \Home\Model\Tree();
     $accounts = $tree->toArrayRecusived($accountMapper->fetchAll($account));
     $data = [];
     if ($accounts) {
         foreach ($accounts as $account) {
             $data[] = array('id' => $account->getId(), 'name' => $account->getName(), 'code' => $account->getCode(), 'ord' => $account->getOption('ord'), 'displayName' => str_repeat('--', $account->getOption('ord') ?: 0) . $account->getName());
         }
     }
     return $this->getJsonModel()->setVariables(array('code' => 1, 'data' => $data));
 }
コード例 #4
0
 public function loadcategoriesAction()
 {
     $companyId = $this->getRequest()->getPost('companyId');
     if (!$companyId) {
         $companyId = $this->user()->getCompanyId();
     } else {
         if (!$this->company()->canManage($companyId)) {
             return $this->getJsonModel()->setVariables(array('code' => 0, 'messages' => ['Bạn không được quyền quản lí doanh nghiệp này']));
         }
     }
     $expenseCategory = new \Accounting\Model\ExpenseCategory();
     $expenseCategory->setCompanyId($companyId);
     $expenseCategoryMapper = $this->getServiceLocator()->get('\\Accounting\\Model\\ExpenseCategoryMapper');
     $tree = new \Home\Model\Tree();
     $categoies = $tree->toArrayRecusived($expenseCategoryMapper->fetchAll($expenseCategory));
     $data = [];
     if ($categoies) {
         foreach ($categoies as $expenseCategory) {
             $data[] = array('id' => $expenseCategory->getId(), 'name' => $expenseCategory->getName(), 'code' => $expenseCategory->getCode(), 'ord' => $expenseCategory->getOption('ord'), 'displayName' => str_repeat('--', $expenseCategory->getOption('ord') ?: 0) . $expenseCategory->getName());
         }
     }
     return $this->getJsonModel()->setVariables(array('code' => 1, 'data' => $data));
 }