/** * Import constructor. * * @param ContactService $contactService * @param SelectionService $selectionService */ public function __construct(ContactService $contactService, SelectionService $selectionService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('action', ''); $this->setAttribute('class', 'form-horizontal'); $selections = []; foreach ($selectionService->findAll('selection') as $selection) { /** @var $selection Selection */ if (is_null($selection->getSql())) { $selections[$selection->getId()] = $selection->getSelection(); } } asort($selections); $this->add(['type' => '\\Zend\\Form\\Element\\Select', 'name' => 'selection_id', 'options' => ["value_options" => $selections, 'empty_option' => '-- Append to existing selection', "label" => "txt-append-to-selection", "help-block" => _("txt-contact-import-append-to-selection-name-help-block")]]); $optins = []; foreach ($contactService->findAll('optIn') as $optin) { /** @var $optin OptIn */ $optins[$optin->getId()] = $optin->getOptIn(); } asort($optins); $this->add(['type' => '\\Zend\\Form\\Element\\MultiCheckbox', 'name' => 'optIn', 'options' => ["value_options" => $optins, "label" => "txt-select-opt-in", "help-block" => _("txt-contact-import-select-opt-in-help-block")]]); $this->add(['type' => '\\Zend\\Form\\Element\\Text', 'name' => 'selection', 'options' => ["label" => "txt-selection", "help-block" => _("txt-contact-import-selection-name-help-block")]]); $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => "txt-file", "help-block" => _("txt-contact-import-file-requirements")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'upload', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-verify-data")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'import', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-import")]]); }
/** * @param AffiliationService $affiliationService * @param ContactService $contactService */ public function __construct(AffiliationService $affiliationService, ContactService $contactService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $contacts = []; foreach ($contactService->findContactsInOrganisation($affiliationService->getAffiliation()->getOrganisation()) as $contact) { $contacts[$contact->getId()] = $contact->getDisplayName(); } $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $contacts, 'label' => _("txt-contact-name")], 'attributes' => ['class' => 'form-control', '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")]]); }
/** * @param CalendarService $calendarService * @param ContactService $contactService */ public function __construct(CalendarService $calendarService, ContactService $contactService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $this->setAttribute('action', ''); $contacts = []; foreach ($contactService->findPossibleContactByCalendar($calendarService->getCalendar()) as $contact) { $contacts[$contact->getId()] = $contact->getDisplayName(); } $this->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'contact', 'options' => ['value_options' => $contacts, 'label' => _("txt-contact-name")]]); $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")]]); }
/** * @param Affiliation $affiliation * @param ContactService $contactService */ public function __construct(Affiliation $affiliation, ContactService $contactService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $contactService->findContactsInAffiliation($affiliation); $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'receiver', 'options' => ['value_options' => $contactService->toFormValueOptions(), 'label' => _("txt-contact-name")], 'attributes' => ['class' => 'form-control', 'id' => 'receiver', 'required' => true]]); $this->add(['type' => EntitySelect::class, 'name' => 'deeplinkTarget', 'attributes' => ['label' => _("txt-deeplink-target")], 'options' => ['object_manager' => $contactService->getEntityManager(), 'target_class' => "Deeplink\\Entity\\Target", 'find_method' => ['name' => 'findBy', 'params' => ['criteria' => [], 'orderBy' => ['route' => 'ASC']]], 'label_generator' => function (Target $targetEntity) { return sprintf("%s (%s)", $targetEntity->getTarget(), $targetEntity->getRoute()); }]]); $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'subject', 'attributes' => ['label' => _("txt-subject"), 'class' => 'form-control']]); $this->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'message', 'attributes' => ['label' => _("txt-message"), 'rows' => 15, 'class' => 'form-control']]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-send")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]); }
/** * @return ContactService */ public function getContactService() { if ($this->contactService->isEmpty() && $this->getServiceLocator()->get('zfcuser_auth_service')->hasIdentity()) { $this->contactService->setContact($this->getServiceLocator()->get('zfcuser_auth_service')->getIdentity()); } return $this->contactService; }
/** * @param Doa[] $doa */ public function __construct(array $doa, ContactService $contactService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); /** * Create a fieldSet per DOA (and affiliation) */ foreach ($doa as $doa) { $affiliationFieldset = new Fieldset('affiliation_' . $doa->getAffiliation()->getId()); $contactService->findContactsInAffiliation($doa->getAffiliation()); $affiliationFieldset->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $contactService->toFormValueOptions(), 'label' => _("txt-contact-name")], 'attributes' => ['class' => 'form-control', 'id' => 'contact-' . $doa->getId(), 'required' => true]]); $affiliationFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'dateSigned', 'attributes' => ['class' => 'form-control', 'id' => 'dateSigned-' . $doa->getId(), 'required' => true]]); $this->add($affiliationFieldset); } $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")]]); }
/** * @return ContactService */ public function getContactService() { if (is_null($this->contactService)) { $this->contactService = $this->getServiceLocator()->get('contact_contact_service'); if ($this->getServiceLocator()->get('zfcuser_auth_service')->hasIdentity()) { $this->contactService->setContact($this->getServiceLocator()->get('zfcuser_auth_service')->getIdentity()); } } return $this->contactService; }
/** * @param Contact $object * * @return array */ public function extract($object) { $this->prepare($object); $values = $this->extractByValue($object); unset($values['phone']); foreach ($object->getPhone() as $phone) { $values['phone'][$phone->getType()->getId()]['phone'] = $phone->getPhone(); } unset($values['address']); foreach ($object->getAddress() as $address) { if ($address->getType()->getId() === AddressType::ADDRESS_TYPE_MAIL) { $values['address']['address'] = $address->getAddress(); $values['address']['zipCode'] = $address->getZipCode(); $values['address']['city'] = $address->getCity(); $values['address']['country'] = $address->getCountry(); } } unset($values['community']); foreach ($object->getCommunity() as $community) { $values['community'][$community->getType()->getId()]['community'] = $community->getCommunity(); } unset($values['profile']); $values['profile']['visible'] = !is_null($object->getProfile()) ? $object->getProfile()->getVisible() : null; $values['profile']['description'] = !is_null($object->getProfile()) ? $object->getProfile()->getDescription() : null; /** * Set the contact organisation */ $contactService = new ContactService(); $contactService->setContact($object); if (!is_null($object->getContactOrganisation())) { $organisationService = new OrganisationService(); $organisationService->setOrganisation($object->getContactOrganisation()->getOrganisation()); $values['contact_organisation']['organisation'] = $organisationService->parseOrganisationWithBranch($contactService->getContact()->getContactOrganisation()->getBranch()); if (!is_null($object->getContactOrganisation())) { $values['contact_organisation']['country'] = $object->getContactOrganisation()->getOrganisation()->getCountry()->getId(); } } return $values; }
/** * @param Selection $selection * @param ContactService $contactService */ public function addSelection(Selection $selection, ContactService $contactService) { foreach ($contactService->findContactsInSelection($selection) as $contact) { $this->addTo($contact); } }
/** * @param ServiceLocatorInterface $serviceLocator * * @return ContactService */ public function createService(ServiceLocatorInterface $serviceLocator) { $contactService = new ContactService(); $contactService->setServiceLocator($serviceLocator); /** @var EntityManager $entityManager */ $entityManager = $serviceLocator->get(EntityManager::class); $contactService->setEntityManager($entityManager); /** @var AdminService $adminService */ $adminService = $serviceLocator->get(AdminService::class); $contactService->setAdminService($adminService); /** @var ProjectService $projectService */ $projectService = $serviceLocator->get(ProjectService::class); $contactService->setProjectService($projectService); /** @var OrganisationService $organisationService */ $organisationService = $serviceLocator->get(OrganisationService::class); $contactService->setOrganisationService($organisationService); /** @var AddressService $addressService */ $addressService = $serviceLocator->get(AddressService::class); $contactService->setAddressService($addressService); /** @var GeneralService $generalService */ $generalService = $serviceLocator->get(GeneralService::class); $contactService->setGeneralService($generalService); /** @var DeeplinkService $deeplinkService */ $deeplinkService = $serviceLocator->get(DeeplinkService::class); $contactService->setDeeplinkService($deeplinkService); /** @var ModuleOptions $moduleOptions */ $moduleOptions = $serviceLocator->get(ModuleOptions::class); $contactService->setModuleOptions($moduleOptions); /** @var UserServiceOptionsInterface $zfcModuleOptions */ $zfcModuleOptions = $serviceLocator->get('zfcuser_module_options'); $contactService->setZfcUserOptions($zfcModuleOptions); return $contactService; }
/** * @param ContactService $contactService * * @return string */ public function parseContact(ContactService $contactService) { return $this->getRenderer()->render('contact/partial/contact', ['contact' => $contactService->getContact()]); }
/** * Profile constructor. * @param EntityManager $entityManager * @param ContactService $contactService * @param Contact $contact */ public function __construct(EntityManager $entityManager, ContactService $contactService, Contact $contact) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $this->setAttribute('action', ''); /** @var ContactService $contactService */ $doctrineHydrator = new ProfileHydrator($entityManager); $this->setHydrator($doctrineHydrator)->setObject($contact); /* * Add a hidden form element for the id to allow a check on the uniqueness of some elements */ $this->add(['type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'id']); $this->add(['type' => EntitySelect::class, 'name' => 'gender', 'options' => ['label' => _("txt-attention"), 'object_manager' => $entityManager, 'target_class' => 'General\\Entity\\Gender', 'find_method' => ['name' => 'findAll']], 'attributes' => ['required' => true]]); $this->add(['type' => EntitySelect::class, 'name' => 'title', 'options' => ['label' => _("txt-title"), 'object_manager' => $entityManager, 'target_class' => 'General\\Entity\\Title', 'find_method' => ['name' => 'findAll']], 'attributes' => ['required' => true]]); $this->add(['type' => Text::class, 'name' => 'firstName', 'options' => ['label' => _("txt-first-name")], 'attributes' => ['class' => 'form-control', 'required' => true, 'placeholder' => _("txt-give-your-first-name")]]); $this->add(['type' => Text::class, 'name' => 'middleName', 'options' => ['label' => _("txt-middle-name")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-give-your-middle-name")]]); $this->add(['type' => Text::class, 'name' => 'lastName', 'options' => ['label' => _("txt-last-name")], 'attributes' => ['class' => 'form-control', 'required' => true, 'placeholder' => _("txt-give-your-last-name")]]); /** * Produce a list of all phone numbers */ $phoneFieldSet = new Fieldset('phone'); /** @var PhoneType $phoneType */ foreach ($contactService->findAll('phoneType') as $phoneType) { if (in_array($phoneType->getId(), [PhoneType::PHONE_TYPE_DIRECT, PhoneType::PHONE_TYPE_MOBILE])) { $fieldSet = new Fieldset($phoneType->getId()); $fieldSet->add(['type' => Text::class, 'name' => 'phone', 'options' => ['label' => sprintf(_("%s Phone number"), $phoneType->getType())], 'attributes' => ['class' => 'form-control', 'placeholder' => sprintf(_("Give %s phone number"), $phoneType->getType())]]); $phoneFieldSet->add($fieldSet); } } $this->add($phoneFieldSet); /* * Add the form field for the address */ $addressFieldSet = new Fieldset('address'); $addressFieldSet->add(['type' => Text::class, 'name' => 'address', 'options' => ['label' => _("txt-address")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-address")]]); $addressFieldSet->add(['type' => Text::class, 'name' => 'zipCode', 'options' => ['label' => _("txt-zip-code")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-zip-code")]]); $addressFieldSet->add(['type' => Text::class, 'name' => 'city', 'options' => ['label' => _("txt-city")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-city")]]); $addressFieldSet->add(['type' => EntitySelect::class, 'name' => 'country', 'options' => ['label' => _("txt-country"), 'object_manager' => $entityManager, 'target_class' => Country::class, 'find_method' => ['name' => 'findBy', 'params' => ['criteria' => [], 'orderBy' => ['country' => 'ASC']]]], 'attributes' => ['required' => true]]); $this->add($addressFieldSet); $contactOrganisationFieldSet = new Fieldset('contact_organisation'); $contactOrganisationFieldSet->add(['type' => EntityRadio::class, 'name' => 'organisation_id', 'options' => ['label' => _("txt-organisation"), 'label_options' => ['disable_html_escape' => true], 'escape' => false, 'disable_inarray_validator' => true, 'object_manager' => $entityManager, 'target_class' => Organisation::class, 'find_method' => ['name' => 'findOrganisationForProfileEditByContact', 'params' => ['criteria' => [], 'contact' => $contact]], 'label_generator' => function (Organisation $organisation) { if (!is_null($organisation->getCountry())) { return sprintf("%s (%s)", $organisation->getOrganisation(), $organisation->getCountry()->getCountry()); } else { return sprintf("%s", $organisation->getOrganisation()); } }], 'attributes' => ['required' => !is_null($contact->getContactOrganisation()), 'id' => 'organisation']]); $contactOrganisationFieldSet->add(['type' => Text::class, 'name' => 'organisation', 'options' => ['label' => _("txt-organisation"), 'help-block' => _("txt-organisation-form-element-description")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-give-your-organisation")]]); $contactOrganisationFieldSet->add(['type' => EntitySelect::class, 'name' => 'country', 'options' => ['label' => _("txt-country"), 'object_manager' => $entityManager, 'target_class' => Country::class, 'find_method' => ['name' => 'findBy', 'params' => ['criteria' => [], 'orderBy' => ['country' => 'ASC']]]], 'attributes' => ['required' => true]]); $this->add($contactOrganisationFieldSet); $this->add(['type' => Text::class, 'name' => 'department', 'options' => ['label' => _("txt-department")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-give-your-department")]]); $this->add(['type' => Text::class, 'name' => 'position', 'options' => ['label' => _("txt-position")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-give-your-position")]]); /* * Produce a list of all phone numbers */ $profileFieldSet = new Fieldset('profile'); $profileEntity = new ProfileEntity(); $profileFieldSet->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'visible', 'options' => ['label' => _("txt-visibility"), 'value_options' => $profileEntity->getVisibleTemplates()]]); $profileFieldSet->add(['type' => 'Zend\\Form\\Element\\Textarea', 'name' => 'description', 'options' => ['label' => _("txt-expertise")], 'attributes' => ['class' => 'form-control', 'placeholder' => _("txt-give-your-expertise")]]); $this->add($profileFieldSet); $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'attributes' => ["class" => "form-control"], 'options' => ["label" => "txt-photo-file", "help-block" => _("txt-photo-requirements")]]); $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")]]); }