Exemplo n.º 1
0
 /**
  * @return JsonModel
  */
 public function ajaxMoneyAccountListAction()
 {
     /** @var BackofficeAuthenticationService $auth */
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     /** @var MoneyAccountService $moneyAccountService */
     $moneyAccountService = $this->getServiceLocator()->get('service_money_account');
     $params = $this->params();
     /** @var \DDD\Domain\MoneyAccount\MoneyAccount[]|ResultSet $moneyAccounts */
     $moneyAccounts = $moneyAccountService->moneyAccountList((int) $params->fromQuery('iDisplayStart'), (int) $params->fromQuery('iDisplayLength'), (int) $params->fromQuery('iSortCol_0'), $params->fromQuery('sSortDir_0'), $params->fromQuery('sSearch'), $params->fromQuery('all', '1'), $auth->getIdentity()->id);
     $tableData = [];
     if ($moneyAccounts->count()) {
         foreach ($moneyAccounts as $moneyAccount) {
             $router = $this->getEvent()->getRouter();
             $editUrl = $router->assemble(['controller' => 'money-account', 'action' => 'edit', 'id' => $moneyAccount->getId()], ['name' => 'finance/default']);
             $transactionsUrl = $router->assemble(['controller' => 'money-account', 'action' => 'transactions', 'id' => $moneyAccount->getId()], ['name' => 'finance/default']);
             $editBtn = '';
             $transactionsBtn = '';
             if ($auth->hasRole(Roles::ROLE_MONEY_ACCOUNT_GLOBAL_MANAGER) || $moneyAccount->isManager()) {
                 $editBtn = '<a class="btn btn-xs btn-primary" href="' . $editUrl . '" target="_blank" data-html-content="Edit"></a>';
                 $transactionsBtn = '<a class="btn btn-xs btn-primary" href="' . $transactionsUrl . '" target="_blank">Transactions</a>';
             } else {
                 if ($auth->hasRole(Roles::ROLE_MONEY_ACCOUNT_GLOBAL_MANAGER) || $moneyAccount->hasTransactionsView()) {
                     $transactionsBtn = '<a class="btn btn-xs btn-primary" href="' . $transactionsUrl . '" target="_blank">Transactions</a>';
                 } else {
                     continue;
                 }
             }
             $status = $moneyAccount->getActive() ? '<span class="label label-success">Active</span>' : '<span class="label label-default">Inactive</span>';
             array_push($tableData, ['<div class="text-center">' . $status . '</div>', $moneyAccount->getName(), MoneyAccountService::getMoneyAccountTypeById($moneyAccount->getType()), number_format($moneyAccount->getBalance(), 2), $moneyAccount->getCurrencyName(), $editBtn, $transactionsBtn]);
         }
     }
     $moneyAccountCount = $moneyAccountService->moneyAccountCount($params->fromQuery('sSearch'), $params->fromQuery('all', '1'));
     $resultArray = ['sEcho' => $params->fromQuery('sEcho'), 'iTotalRecords' => count($tableData), 'iTotalDisplayRecords' => count($tableData), 'iDisplayStart' => $params->fromQuery('iDisplayStart'), 'iDisplayLength' => (int) $params->fromQuery('iDisplayLength'), 'aaData' => $tableData];
     return new JsonModel($resultArray);
 }
Exemplo n.º 2
0
 /**
  * @param ServiceLocatorInterface $sm
  * @param \DDD\Domain\MoneyAccount\MoneyAccount|bool $bankAccountData
  * @param int $moneyAccountId
  */
 public function __construct(ServiceLocatorInterface $sm, $bankAccountData, $moneyAccountId)
 {
     parent::__construct('bank-account');
     $this->setServiceLocator($sm);
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('method', 'post');
     $hidden = $moneyAccountId ? ' hidden' : '';
     $this->add(['name' => 'name', 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'name']]);
     $this->add(['name' => 'type', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => MoneyAccountService::getMoneyAccountTypes()], 'attributes' => ['class' => 'form-control' . $hidden, 'id' => 'type']]);
     $this->add(['name' => 'currency_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getCurrencyList()], 'attributes' => ['class' => 'form-control' . $hidden, 'id' => 'currency_id']]);
     $this->add(['name' => 'account_ending', 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'account_ending', 'size' => 4, 'maxlength' => 4]]);
     $this->add(['name' => 'description', 'attributes' => ['type' => 'textarea', 'class' => 'form-control', 'id' => 'description', 'rows' => 2]]);
     $userList = $this->getUserList();
     $userList[0] = '-- Please Select --';
     asort($userList);
     // Smart dropdown
     if ($moneyAccountId) {
         if (!isset($userList[$bankAccountData['responsible_person_id']])) {
             $userList[$bankAccountData['responsible_person_id']] = $bankAccountData['responsible_person_name'];
         }
         if (!isset($userList[$bankAccountData['card_holder_id']])) {
             $userList[$bankAccountData['card_holder_id']] = $bankAccountData['card_holder_name'];
         }
     }
     $this->add(['name' => 'card_holder_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $userList], 'attributes' => ['class' => 'form-control', 'id' => 'card_holder_id']]);
     $this->add(['name' => 'responsible_person_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $userList], 'attributes' => ['class' => 'form-control', 'id' => 'responsible_person_id']]);
     $this->add(['name' => 'is_searchable', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => [\DDD\Service\MoneyAccount::SEARCHABLE_YES => 'Yes', \DDD\Service\MoneyAccount::SEARCHABLE_NO => 'No']], 'attributes' => ['class' => 'form-control is-searchable']]);
     $this->add(['name' => 'legal_entity_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getLegalEntityList($moneyAccountId ? $bankAccountData['legal_entity_id'] : null)], 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'legal_entity_id']]);
     $this->add(['name' => 'bank_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getBankList()], 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'bank_id']]);
     $this->add(['name' => 'bank_account_number', 'attributes' => ['type' => 'text', 'class' => 'form-control', 'id' => 'bank_account_number']]);
     $this->add(['name' => 'view_transactions', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getUserList()], 'attributes' => ['class' => 'form-control selectize', 'id' => 'view_transactions', 'multiple' => true]]);
     $this->add(['name' => 'add_transactions', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getUserList()], 'attributes' => ['class' => 'form-control selectize', 'id' => 'add_transactions', 'multiple' => true]]);
     $this->add(['name' => 'manage_transactions', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getUserList()], 'attributes' => ['class' => 'form-control selectize', 'id' => 'manage_transactions', 'multiple' => true]]);
     $this->add(['name' => 'manage_account', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['value_options' => $this->getUserList()], 'attributes' => ['class' => 'form-control selectize', 'id' => 'manage_account', 'multiple' => true]]);
     $this->add(['name' => 'save', 'attributes' => ['type' => 'submit', 'class' => 'btn btn-primary state save-bank-account pull-right col-sm-2 col-xs-12 margin-left-10', 'value' => 'Save']]);
 }
Exemplo n.º 3
0
 public function moneyAccountCount($like, $all = '1')
 {
     /**
      * @var \ArrayObject $result
      */
     switch ($all) {
         case '1':
             $whereAll = 'AND ' . $this->getTable() . '.active = 1';
             break;
         case '2':
             $whereAll = 'AND ' . $this->getTable() . '.active = 0';
             break;
         default:
             $whereAll = ' ';
     }
     $result = $this->fetchAll(function (Select $select) use($like, $whereAll) {
         $select->join(['currencies' => DbTables::TBL_CURRENCY], $this->getTable() . '.currency_id = currencies.id', ['currency_name' => 'code'], Select::JOIN_LEFT);
         $typeQueryAtring = " ";
         if ($like) {
             $type = MoneyAcService::getMoneyAccountLike($like);
             if ($type !== false) {
                 $typeQueryAtring = " OR " . $this->getTable() . ".`type` = " . $type . " ";
             }
         }
         $select->where("(" . $this->getTable() . ".name like '%" . $like . "%'\n                OR currencies.code like '%" . $like . "%' " . $typeQueryAtring . ")\n                {$whereAll}");
         $select->columns(['id']);
     });
     return $result->count();
 }