function createAddress() { $address = new Address(); $address->setAddress("Av. Tiradentes"); $address->setNumber("123"); $address->setComplement("Ap. 203"); $address->setNeighborhood("Centro"); $address->setCity("São Paulo"); $address->setState(StateEnum::SAO_PAULO); $address->setZipCode("17500000"); return $address; }
private function parseForm(HTTPRequest $request, Address $address) { $title = htmlspecialchars($request->postData('title')); $address1 = htmlspecialchars($request->postData('address-1')); $address2 = htmlspecialchars($request->postData('address-2')); $zipCode = htmlspecialchars($request->postData('zip-code')); $city = htmlspecialchars($request->postData('city')); $country = 'France'; $address->setTitle($title); $address->setAddress1($address1); $address->setAddress2($address2); $address->setZipCode($zipCode); $address->setCity($city); $address->setCountry($country); $address->setUserId($this->app->user()->getAttribute('id')); }
/** * @group shopobjects */ function testSetAddressParameters() { // GIVEN $incompleteAddressParameter = $this->givenIncompleteAddressParameter(); // WHEN $address = new Address($incompleteAddressParameter); $address->setBirthday("01.02.1900"); $address->setCity("Cologne"); $address->setCompany("FakeCompany"); $address->setCountry("England"); $address->setEmailAddress("*****@*****.**"); $address->setFirstName("Max"); $address->setLastName("Miller"); $address->setSalutation("Mr."); $address->setState("NRW"); $address->setStreet("First street 2"); $address->setStreetDetails("c/o Mister Smith"); $address->setTitle("Master"); $address->setVatId("DE1234567890"); $address->setZipCode("12345"); // THEN $this->assertFalse($address->error()); $this->thenCompleteAddressInformationIsExisting($address); }
/** * @expectedException NfeFocus\Exception\FieldRequiredException */ public function testInvalidZipCode() { $zipcode = '0000000'; $address = new Address(); $address->setZipCode($zipcode); }
private function parseForm(HTTPRequest $request, ProfilePro $profilePro, Address $address) { //PROFILE $companyName = htmlspecialchars($request->postData('company-name')); $lastname = htmlspecialchars($request->postData('lastname')); $firstname = htmlspecialchars($request->postData('firstname')); $description = htmlspecialchars($request->postData('description')); $phone = htmlspecialchars($request->postData('phone')); $mobilePhone = htmlspecialchars($request->postData('mobile-phone')); $officePhone = htmlspecialchars($request->postData('office-phone')); $website = htmlspecialchars($request->postData('website')); //ADDRESS $address1 = htmlspecialchars($request->postData('address-1')); $address2 = htmlspecialchars($request->postData('address-2')); $zipCode = htmlspecialchars($request->postData('zip-code')); $city = htmlspecialchars($request->postData('city')); $country = 'France'; $profilePro->setCompanyName($companyName); $profilePro->setLastname($lastname); $profilePro->setFirstname($firstname); $profilePro->setDescription($description); $profilePro->setPhone($phone); $profilePro->setMobilePhone($mobilePhone); $profilePro->setOfficePhone($officePhone); $profilePro->setWebsite($website); $profilePro->setUserId($this->app->user()->getAttribute('id')); $address->setAddress1($address1); $address->setAddress2($address2); $address->setZipCode($zipCode); $address->setCity($city); $address->setCountry($country); $address->setTitle($companyName); $address->setUserId($this->app->user()->getAttribute('id')); }
function contactParser($data) { $contact = new Contact(); if (isset($data['id'])) { $contact->setId($data['id']); } if (isset($data['firstName'])) { $contact->setFirstName($data['firstName']); } if (isset($data['name'])) { $contact->setName($data['name']); } if (isset($data['mail'])) { $contact->setMail($data['mail']); } if (isset($data['phone'])) { $contact->setPhone($data['phone']); } if (isset($data['phone2'])) { $contact->setPhone2($data['phone2']); } if (isset($data['phone3'])) { $contact->setPhone3($data['phone3']); } if (isset($data['company'])) { $contact->setCompany($data['company']); } if (isset($data['address'])) { $dataAddress = $data['address']; $address = new Address(); if (isset($dataAddress['id'])) { $address->setId($dataAddress['id']); } if (isset($dataAddress['line1'])) { $address->setLine1($dataAddress['line1']); } if (isset($dataAddress['line2'])) { $address->setLine2($dataAddress['line2']); } if (isset($dataAddress['zipCode'])) { $address->setZipCode($dataAddress['zipCode']); } if (isset($dataAddress['city'])) { $address->setCity($dataAddress['city']); } if (isset($dataAddress['latitude']) && isset($dataAddress['longitude'])) { $address->setLatitude($dataAddress['latitude']); $address->setLongitude($dataAddress['longitude']); } else { $mapService = new GoogleMapService(); $latlng = $mapService->getLatLong($address); if ($latlng != [] && sizeof($latlng) == 2) { $address->setLatitude($latlng[0]); $address->setLongitude($latlng[1]); } } $contact->setAddress($address); } if (isset($data['type'])) { if (isset($data['type']['id']) && isset($data['type']['name'])) { $type = new Type($data['type']['id'], $data['type']['name']); } elseif (isset($data['type']['name'])) { $type = new Type(null, $data['type']['name']); } else { $type = null; } $contact->setType($type); } if (isset($data['exchangeId'])) { $contact->setExchangeId($data['exchangeId']); } return $contact; }
/** * Used to get all the contacts from Exchange * @return array of contact */ public function getAllContacts() { try { $contactList = []; $request = new EWSType_FindItemType(); $request->ItemShape = new EWSType_ItemResponseShapeType(); $request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES; $request->ContactsView = new EWSType_ContactsViewType(); $request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType(); $request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType(); $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CONTACTS; $request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW; $response = parent::getEws()->FindItem($request); if (isset($response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Contact)) { $stdContacts = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Contact; } else { return null; } foreach ($stdContacts as $c) { $contact = new Contact(); if (isset($c->ItemId->Id)) { $contact->setExchangeId($c->ItemId->Id); } if (isset($c->CompleteName)) { if (isset($c->CompleteName->FirstName)) { $contact->setFirstName($c->CompleteName->FirstName); } if (isset($c->CompleteName->LastName)) { if (strpos($c->CompleteName->LastName, '--') !== false) { $nameAndType = $this->getTypeFromName($c->CompleteName->LastName); if (sizeof($nameAndType) == 2) { $contact->setName($nameAndType[0]); $typeService = new TypeService(); $type = $typeService->getType($nameAndType[1]); if ($type != null) { $contact->setType($type); } else { $contact->setType(null); } } else { $contact->setName($c->CompleteName->LastName); } } else { $contact->setName($c->CompleteName->LastName); } } } if (isset($c->PhoneNumbers->Entry)) { if (is_array($c->PhoneNumbers->Entry)) { $contact->setPhone($c->PhoneNumbers->Entry[0]->_); if (sizeof($c->PhoneNumbers->Entry) > 1) { if (isset($c->PhoneNumbers->Entry[1])) { $contact->setPhone2($c->PhoneNumbers->Entry[1]->_); } } if (sizeof($c->PhoneNumbers->Entry) > 2) { if (isset($c->PhoneNumbers->Entry[2])) { $contact->setPhone3($c->PhoneNumbers->Entry[2]->_); } } } else { $contact->setPhone($c->PhoneNumbers->Entry->_); } } if (isset($c->EmailAddresses->Entry)) { if (is_array($c->EmailAddresses->Entry)) { $contact->setMail($c->EmailAddresses->Entry[0]->_); } else { $contact->setMail($c->EmailAddresses->Entry->_); } } if (isset($c->CompanyName)) { $contact->setCompany($c->CompanyName); } if (isset($c->PhysicalAddresses->Entry)) { $address = new Address(); $stdAddress = $c->PhysicalAddresses->Entry; if (is_array($stdAddress)) { $address->setLine1($stdAddress[0]->Street); $address->setZipCode($stdAddress[0]->PostalCode); $address->setCity($stdAddress[0]->City); } else { if (isset($stdAddress->Street)) { $address->setLine1($stdAddress->Street); } if (isset($stdAddress->PostalCode)) { $address->setZipCode($stdAddress->PostalCode); } if (isset($stdAddress->City)) { $address->setCity($stdAddress->City); } } $contact->setAddress($address); } array_push($contactList, $contact); } if ($contactList == []) { $contactList = null; } return $contactList; } catch (Exception $e) { error_log($e->getMessage()); } return null; }
public function getAddressesByRayon($address, $rayon) { $list = []; try { if (!parent::getBdd()->inTransaction()) { parent::getBdd()->beginTransaction(); } $query = "SELECT *, ( 6371 * acos( cos( radians(:latitude) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:longitude) )\n + sin( radians(:latitude) ) * sin( radians( latitude ) ) ) ) AS distance FROM address HAVING distance < :rayon ORDER BY distance LIMIT 0 , 150;"; $request = parent::getBdd()->prepare($query); $request->bindParam(':latitude', $address->getLatitude()); $request->bindParam(':longitude', $address->getLongitude()); $request->bindParam(':rayon', $rayon); $request->execute(); while ($data = $request->fetch()) { $address = new Address(); $address->setId($data['id']); $address->setLine1($data['line1']); $address->setLine2($data['line2']); $address->setZipCode($data['zipcode']); $address->setCity($data['city']); $address->setLatitude($data['latitude']); $address->setLongitude($data['longitude']); array_push($list, $address); } if ($list == []) { return null; } return $list; } catch (Exception $e) { error_log($e->getMessage()); } return null; }