コード例 #1
0
ファイル: Financial.php プロジェクト: iteaoffice/organisation
 /**
  * @param ServiceManager $serviceManager
  */
 public function __construct(ServiceManager $serviceManager)
 {
     $financial = new Entity\Financial();
     parent::__construct($financial->get('underscore_entity_name'));
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '');
     $this->serviceManager = $serviceManager;
     $entityManager = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     $organisationFieldset = new ObjectFieldset($entityManager, $financial);
     $organisationFieldset->setUseAsBaseFieldset(true);
     $this->add($organisationFieldset);
     //Vat enforcement
     /**
      * @var $generalService GeneralService
      */
     $generalService = $serviceManager->get(GeneralService::class);
     $vatTypes = [0 => '-- No enforcement'];
     /**
      * @var $vatType VatType
      */
     foreach ($generalService->findAll('vatType') as $vatType) {
         $vatTypes[$vatType->getId()] = $vatType->getType();
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'vatType', 'options' => ['value_options' => $vatTypes, 'help-block' => _("txt-vat-type-help-block")], 'attributes' => ['label' => _("txt-vat-type")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'delete', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-delete")]]);
 }
コード例 #2
0
ファイル: Financial.php プロジェクト: iteaoffice/affiliation
 /**
  * @param AffiliationService $affiliationService
  * @param GeneralService     $generalService
  */
 public function __construct(AffiliationService $affiliationService, GeneralService $generalService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('action', '');
     $this->setAttribute('class', 'form-horizontal');
     $countries = [];
     foreach ($generalService->findAll('country') as $country) {
         $countries[$country->getId()] = $country->getCountry();
     }
     asort($countries);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'organisation', 'options' => ['label' => _("txt-organisation-name")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'registeredCountry', 'options' => ['value_options' => $countries, 'label' => _("txt-registered-country")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'vat', 'options' => ['label' => _("txt-vat-number")], 'attributes' => ['class' => 'form-control']]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'attention', 'options' => ['label' => _("txt-attention"), 'help-block' => _("txt-financial-attention-form-element-explanation")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-financial-attention-placeholder")]]);
     /*
      * Collect the financial contacts
      */
     $financialContactValueOptions = [];
     $financialContactValueOptions[$affiliationService->getAffiliation()->getContact()->getId()] = $affiliationService->getAffiliation()->getContact()->getFormName();
     /**
      * Add the associates
      */
     foreach ($affiliationService->getAffiliation()->getAssociate() as $contact) {
         $financialContactValueOptions[$contact->getId()] = $contact->getFormName();
     }
     $organisation = $affiliationService->getAffiliation()->getOrganisation();
     /**
      * Add the contacts in the organisation
      */
     foreach ($organisation->getContactOrganisation() as $contactOrganisation) {
         $financialContactValueOptions[$contactOrganisation->getContact()->getId()] = $contactOrganisation->getContact()->getFormName();
     }
     /**
      * Add all the financial contacts form other projects
      */
     foreach ($organisation->getAffiliation() as $affiliation) {
         if (!is_null($affiliation->getFinancial())) {
             $financialContactValueOptions[$affiliation->getFinancial()->getContact()->getId()] = $affiliation->getFinancial()->getContact()->getFormName();
         }
     }
     asort($financialContactValueOptions);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $financialContactValueOptions, 'label' => _("txt-financial-contact")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $organisationFinancial = new FinancialOrganisation();
     $this->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'omitContact', 'options' => ['value_options' => $organisationFinancial->getOmitContactTemplates(), 'label' => _("txt-omit-contact")], 'attributes' => ['required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'address', 'options' => ['label' => _("txt-address")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-address-placeholder"), 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'zipCode', 'options' => ['label' => _("txt-zip-code")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-zip-code-placeholder"), 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'city', 'options' => ['label' => _("txt-city")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-city-placeholder"), 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'country', 'options' => ['value_options' => $countries, 'label' => _("txt-country")], 'attributes' => ['class' => 'form-control', 'required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'preferredDelivery', 'options' => ['value_options' => $organisationFinancial->getEmailTemplates(), 'label' => _("txt-preferred-delivery")], 'attributes' => ['required' => true]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
コード例 #3
0
 /**
  * @return ViewModel
  */
 public function editAction()
 {
     $organisationService = $this->getOrganisationService()->setOrganisationId($this->params('id'));
     if (is_null($financial = $organisationService->getOrganisation()->getFinancial())) {
         $financial = new Financial();
         $financial->setOrganisation($organisationService->getOrganisation());
     }
     $data = array_merge(['vatType' => $financial->getVatType()->count() == 0 ? 0 : $financial->getVatType()->first()->getId()], $this->getRequest()->getPost()->toArray());
     $form = $this->getFormService()->prepare($financial, $financial, $data);
     if ($this->getRequest()->isPost()) {
         if (isset($data['delete'])) {
             $this->flashMessenger()->setNamespace('success')->addMessage(sprintf($this->translate("txt-financial-organisation-of-%s-has-successfully-been-removed"), $organisationService->getOrganisation()));
             $this->getOrganisationService()->removeEntity($financial);
             return $this->redirect()->toRoute('zfcadmin/organisation/view', ['id' => $organisationService->getOrganisation()->getId()], ['fragment' => 'financial']);
         }
         if (isset($data['cancel'])) {
             return $this->redirect()->toRoute('zfcadmin/organisation/view', ['id' => $organisationService->getOrganisation()->getId()], ['fragment' => 'financial']);
         }
         if ($form->isValid()) {
             /**
              * @var $financial Financial
              */
             $financial = $form->getData();
             if ($data['vatType'] == 0) {
                 $financial->setVatType(null);
             } else {
                 $vatType = $this->getGeneralService()->findEntityById('vatType', $data['vatType']);
                 $arrayCollection = new ArrayCollection();
                 $arrayCollection->add($vatType);
                 $financial->setVatType($arrayCollection);
             }
             $this->getOrganisationService()->updateEntity($financial);
             $this->flashMessenger()->setNamespace('success')->addMessage(sprintf($this->translate("txt-financial-organisation-%s-has-successfully-been-updated"), $organisationService->getOrganisation()));
             return $this->redirect()->toRoute('zfcadmin/organisation/view', ['id' => $organisationService->getOrganisation()->getId()], ['fragment' => 'financial']);
         }
     }
     return new ViewModel(['organisationService' => $organisationService, 'financial' => $financial, 'form' => $form]);
 }
コード例 #4
0
 /**
  * @param OrganisationService $organisationService
  */
 public function __construct(OrganisationService $organisationService)
 {
     parent::__construct();
     $this->setAttribute('method', 'get');
     $this->setAttribute('action', '');
     $filterFieldset = new Fieldset('filter');
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]);
     $types = [];
     foreach ($organisationService->findAll('type') as $type) {
         $types[$type->getId()] = $type->getType();
     }
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'type', 'options' => ['inline' => true, 'value_options' => $types], 'attributes' => ['label' => _("txt-organisation-type")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'options', 'options' => ['inline' => true, 'value_options' => [1 => _("txt-active-in-project")]], 'attributes' => ['label' => _("txt-options-type")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'vatStatus', 'options' => ['inline' => true, 'value_options' => Financial::getVatStatusTemplates()], 'attributes' => ['label' => _("txt-vat-status")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'omitContact', 'options' => ['inline' => true, 'value_options' => Financial::getOmitContactTemplates()], 'attributes' => ['label' => _("txt-omit-contact")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'requiredPurchaseOrder', 'options' => ['inline' => true, 'value_options' => Financial::getRequiredPurchaseOrderTemplates()], 'attributes' => ['label' => _("txt-required-purchase-order")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'email', 'options' => ['inline' => true, 'value_options' => Financial::getEmailTemplates()], 'attributes' => ['label' => _("txt-email")]]);
     $this->add($filterFieldset);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]);
 }