コード例 #1
0
ファイル: CompanyController.php プロジェクト: Eximagen/sochi
 /**
  *
  * @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 = CompanyQuery::create()->filter($post)->count();
     $this->view->companies = $companies = CompanyQuery::create()->filter($post)->page($page, $this->getMaxPerPage())->find();
     $this->view->paginator = $this->createPaginator($total, $page);
     $this->view->addresses = \Application\Query\AddressQuery::create()->find()->toCombo();
 }
コード例 #2
0
ファイル: -ProductController.php プロジェクト: Eximagen/sochi
 /**
  * @author Jose luis
  */
 public function getCountryAction()
 {
     $id = $this->getRequest()->getParam('id');
     $idAddress = SupplierQuery::create()->findByPK($id)->getIdInvoiceAddress();
     $country = AddressQuery::create()->findByPK($idAddress)->getCountry();
     die(json_encode($country));
 }
コード例 #3
0
 /**
  *
  */
 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');
     }
 }
コード例 #4
0
 public function updateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $params["contacts"] = $this->getRequest()->getParam("contacts", array());
         $id = $this->getRequest()->getParam('id');
         //$idCourtyard = $this->getRequest()->getParam('id_courtyard');
         $courtyardParams = $this->getRequest()->getParam('courtyards');
         //die(print_r($courtyardParams));
         $forwarder = ForwarderQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the Forwarder with id {$id}"));
         //$courtyard = CourtyardQuery::create()->findOneOrThrow($idCourtyard, $this->i18n->_("It does not exist the Courtyard with id {$idCourtyard}"));
         try {
             $this->getForwarderCatalog()->beginTransaction();
             ForwarderFactory::populate($forwarder, $params);
             $this->getForwarderCatalog()->update($forwarder);
             //$this->getForwarderCatalog()->unlinkAllPortCustom($forwarder->getIdForwarder());
             foreach ($params['contacts'] as $idContact) {
                 $contact = ContactQuery::create()->findByPK($idContact);
                 $contact->setIdCompany($forwarder->getIdCompany());
                 $this->getContactCatalog()->update($contact);
             }
             foreach ($courtyardParams as $i => $courtyardParam) {
                 $idCourtyard = $courtyardParam['id_courtyard'];
                 $idAddress = $courtyardParam['id_address'];
                 if ($idCourtyard > 0) {
                     $courtyard = CourtyardQuery::create()->findByPKOrThrow($idCourtyard, $this->i18n->_("It does not exist the Courtyard with id {$idCourtyard}"));
                     CourtyardFactory::populate($courtyard, $courtyardParam);
                     $this->getCourtyardCatalog()->update($courtyard);
                     $this->getForwarderCatalog()->linkToPortCustom($forwarder->getIdForwarder(), $courtyard->getIdPortCustom());
                     $address = AddressQuery::create()->findByPKOrThrow($idAddress, $this->i18n->_("It does not exist the address with id {$idAddress}"));
                     AddressFactory::populate($address, $courtyardParam);
                     $this->getAddressCatalog()->update($address);
                 } else {
                     $newCourtyard = $courtyardParam;
                     $courtyard = CourtyardFactory::createFromArray($courtyardParam);
                     $courtyard->setIdForwarder($forwarder->getIdForwarder());
                     $this->getCourtyardCatalog()->create($courtyard);
                     $this->getForwarderCatalog()->linkToPortCustom($forwarder->getIdForwarder(), $courtyard->getIdPortCustom());
                     $arrayPhones = $newContacts['id_phone_number'];
                     $address = AddressFactory::createFromArray($newCourtyard);
                     $this->getAddressCatalog()->create($address);
                     //$this->getContactCatalog()->linkToAddress($contact->getIdPerson(), $address->getIdAddress(), $type);
                 }
             }
         } catch (Exception $e) {
             $this->getForwarderCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->setFlash('ok', $this->i18n->_("The Forwarder with id {$id} was updated"));
     $this->getForwarderCatalog()->commit();
     $this->_redirect('forwarder/list');
 }
コード例 #5
0
ファイル: CourtyardQuery.php プロジェクト: Eximagen/sochi
 /**
  * build fromArray
  * @param Query $query
  * @param array $fields
  * @param string $prefix
  */
 public static function build(Query $query, $fields, $prefix = 'Courtyard')
 {
     parent::build($query, $fields);
     $criteria = $query->where();
     $criteria->prefix($prefix);
     if (isset($fields['id_courtyard']) && !empty($fields['id_courtyard'])) {
         $criteria->add(Courtyard::ID_COURTYARD, $fields['id_courtyard']);
     }
     if (isset($fields['id_address']) && !empty($fields['id_address'])) {
         $criteria->add(Courtyard::ID_ADDRESS, $fields['id_address']);
     }
     if (isset($fields['id_port_custom']) && !empty($fields['id_port_custom'])) {
         $criteria->add(Courtyard::ID_PORT_CUSTOM, $fields['id_port_custom']);
     }
     if (isset($fields['id_forwarder']) && !empty($fields['id_forwarder'])) {
         $criteria->add(Courtyard::ID_FORWARDER, $fields['id_forwarder']);
     }
     if (isset($fields['id_contact']) && !empty($fields['id_contact'])) {
         $criteria->add(Courtyard::ID_CONTACT, $fields['id_contact']);
     }
     if (isset($fields['name']) && !empty($fields['name'])) {
         $criteria->add(Courtyard::NAME, $fields['name']);
     }
     if (isset($fields['status']) && !empty($fields['status'])) {
         $criteria->add(Courtyard::STATUS, $fields['status']);
     }
     $criteria->endPrefix();
 }
コード例 #6
0
 /**
  *
  * @return array
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     //$id = '14';
     $inspection = InspectionQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the Inspection with id {$id}"));
     $this->view->setTpl("New");
     $inspectors = \Application\Query\InspectorQuery::create()->innerJoinPerson()->addColumns(array('Inspector.*', 'Person.*'))->whereAdd('User.' . \Application\Model\Bean\User::STATUS, \Application\Model\Bean\User::$Status['Active'])->find();
     $inspectors = $inspectors->map(function (Inspector $inspector) {
         return array($inspector->getIdInspector() => $inspector->getFullName());
     });
     $address = AddressQuery::create()->findByPK($inspection->getIdAddress());
     $this->view->inspection = $inspection;
     $this->view->inspectionsTypes = $inspectionsTypes;
     $this->view->inspectorsSelected = $inspection->getIdInspector();
     $this->view->address = $address;
     $this->view->inspectors = $inspectors;
     $this->view->action = 'update';
     $this->view->selectedTypes = $selectedTypes = InspectionQuery::create()->innerJoinType()->addColumns(array('Type.type'))->whereAdd('Type.id_inspection', $inspection->getIdInspection())->fetchCol();
 }