/** * * @return array */ public function listAction() { $this->view->page = $page = $this->getRequest()->getParam('page') ?: 1; if ($this->getRequest()->isPost()) { $this->view->post = $post = $this->getRequest()->getParams(); } $total = ContactQuery::create()->filter($post)->count(); $this->view->contacts = $contacts = ContactQuery::create()->filter($post)->page($page, $this->getMaxPerPage())->find(); $this->view->paginator = $this->createPaginator($total, $page); $this->view->people = \Application\Query\PersonQuery::create()->find()->toCombo(); $this->view->companies = \Application\Query\CompanyQuery::create()->find()->toCombo(); }
/** * */ public function exportToExcelAction() { $post['name'] = utf8_decode($this->getRequest()->getParam('name')); $post['name'] = '%' . $post['name'] . '%'; $post['status'] = $this->getRequest()->getParam('status'); $post['sap_id_bussiness_associate'] = $this->getRequest()->getParam('sap_id_bussiness_associate') . '%'; $customsBrokers = CustomsBrokerQuery::create()->filter($post)->find(); if (!$customsBrokers->isEmpty()) { $i = 1; while ($customsBroker = $customsBrokers->read()) { $address = AddressQuery::create()->innerJoinCompany()->whereAdd('Address2Company.id_company', $customsBroker->getIdCompany())->find()->getOne(); $company = CompanyQuery::create()->innerJoinAddress()->whereAdd('Company2Address.id_company', $customsBroker->getIdCompany())->find()->getOne(); $country = \Application\Query\CountryQuery::create()->whereAdd(\Application\Model\Bean\Country::CODE, $address->getCountry())->find()->getOne(); $data[$i] = array($company->getSapIdBussinessassociate(), $customsBroker->getName(), $country ? $country->getName() : null, $address->getState(), $address->getStreet(), $address->getSettlement(), $address->getDistrict(), $address->getCity(), $address->getZipCode(), $customsBroker->getStatusName()); $i++; } $header = array($this->i18n->_('SAP ID Business Associate'), $this->i18n->_('Name'), $this->i18n->_('Country'), $this->i18n->_('State'), $this->i18n->_('Street'), $this->i18n->_('Settlement'), $this->i18n->_('District'), $this->i18n->_('City'), $this->i18n->_('Zip Code'), $this->i18n->_('Status')); $title = $this->i18n->_('Customs Brokers Report'); $filename = 'customs_brokers_report'; $customsBrokersReport = new SimpleListReport(); $customsBrokersReport->setTableHeaders($header); $customsBrokersReport->setTableContent($data); $customsBrokersReport->setTableTitle($title); $customsBrokersReport->setFilename($filename); $customsBrokersReport->createSpreadsheet(); } else { $filter = $this->createFilterForUrl($post); $this->setFlash("error", $this->i18n->_('No records')); $this->_redirect('customs-broker/list'); } }
/** * */ public function reactivateAction() { $id = $this->getRequest()->getParam('id'); $company = CompanyQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the Company with id {$id}")); try { $this->getCompanyCatalog()->beginTransaction(); $company->setStatus(Company::$Status['Active']); $this->getCompanyCatalog()->update($company); $this->getCompanyCatalog()->commit(); $this->setFlash('ok', $this->i18n->_("Se reactivo correctamente el Company")); } catch (Exception $e) { $this->getCompanyCatalog()->rollBack(); $this->setFlash('error', $this->i18n->_($e->getMessage())); } $this->_redirect('company/list'); }