public static function fromArray($data) { $address = new Address(); if (isset($data['street'])) { $address->setStreet($data['street']); } if (isset($data['street2'])) { $address->setStreet2($data['street2']); } if (isset($data['zip'])) { $address->setZip($data['zip']); } if (isset($data['city'])) { $address->setCity($data['city']); } if (isset($data['country'])) { $address->setCountry($data['country']); } if (isset($data['state'])) { $address->setState($data['state']); } if (isset($data['tel'])) { $address->setTel($data['tel']); } if (isset($data['fax'])) { $address->setFax($data['fax']); } if (isset($data['email'])) { $address->setEmail($data['email']); } return $address; }
/** * Sets attributes from the Mage address on the AvaTax Request address. * * @return $this */ protected function _convertRequestAddress() { if (!$this->_requestAddress) { $this->_requestAddress = new Address(); } $this->_requestAddress->setLine1($this->_mageAddress->getStreet(1)); $this->_requestAddress->setLine2($this->_mageAddress->getStreet(2)); $this->_requestAddress->setCity($this->_mageAddress->getCity()); $this->_requestAddress->setRegion($this->_mageAddress->getRegionCode()); $this->_requestAddress->setCountry($this->_mageAddress->getCountry()); $this->_requestAddress->setPostalCode($this->_mageAddress->getPostcode()); return $this; }
/** * Initialize the object with raw data * * @param $data * @return Address */ public static function initializeWithRawData($data) { $item = new Address(); if (isset($data['full_address'])) { $item->setFullAddress($data['full_address']); } if (isset($data['country'])) { $item->setCountry($data['country']); } if (isset($data['country_name'])) { $item->setCountryName($data['country_name']); } return $item; }
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')); }
public function buildAtms($xml) { $pageOffset = (string) $xml->PageOffset; $totalCount = (string) $xml->TotalCount; $restaurantArray = array(); foreach ($xml->Restaurant as $restaurant) { $tmpRestaurant = new Restaurant(); $tmpRestaurant->setId((string) $restaurant->Id); $tmpRestaurant->setName((string) $restaurant->Name); $tmpRestaurant->setWebsiteUrl((string) $restaurant->WebsiteUrl); $tmpRestaurant->setPhoneNumber((string) $restaurant->PhoneNumber); $tmpRestaurant->setCategory((string) $restaurant->Category); $tmpRestaurant->setLocalFavoriteInd((string) $restaurant->LocalFavoriteInd); $tmpRestaurant->setHiddenGemInd((string) $restaurant->HiddenGemInd); $tmpLocation = new Location(); $location = $restaurant->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpRestaurant->setLocation($tmpLocation); array_push($restaurantArray, $tmpRestaurant); } $restaurants = new Restaurants($pageOffset, $totalCount, $restaurantArray); return $restaurants; }
public function buildMerchantIds($xml) { $merchantArray = array(); foreach ($xml->ReturnedMerchants->Merchant as $merchant) { $xmlAddress = $merchant->Address; $xmlCountrySubdivision = $merchant->Address->CountrySubdivision; $xmlCountry = $merchant->Address->Country; $xmlMerchant = $merchant; $address = new Address(); $address->setLine1((string) $xmlAddress->Line1); $address->setLine2((string) $xmlAddress->Line2); $address->setCity((string) $xmlAddress->City); $address->setPostalCode((string) $xmlAddress->PostalCode); $countrySubdivision = new CountrySubdivision(); $countrySubdivision->setCode((string) $xmlCountrySubdivision->Code); $countrySubdivision->setName((string) $xmlCountrySubdivision->Name); $country = new Country(); $country->setCode((string) $xmlCountry->Code); $country->setName((string) $xmlCountry->Name); $address->setCountrySubdivision($countrySubdivision); $address->setCountry($country); $tmpMerchant = new Merchant(); $tmpMerchant->setAddress($address); $tmpMerchant->setPhoneNumber((string) $xmlMerchant->PhoneNumber); $tmpMerchant->setBrandName((string) $xmlMerchant->BrandName); $tmpMerchant->setMerchantCategory((string) $xmlMerchant->MerchantCategory); $tmpMerchant->setMerchantDbaName((string) $xmlMerchant->MerchantDbaName); $tmpMerchant->setDescriptorText((string) $xmlMerchant->DescriptorText); $tmpMerchant->setLegalCorporateName((string) $xmlMerchant->LegalCorporateName); $tmpMerchant->setBrickCount((string) $xmlMerchant->BrickCount); $tmpMerchant->setComment((string) $xmlMerchant->Comment); $tmpMerchant->setLocationId((string) $xmlMerchant->LocationId); $tmpMerchant->setOnlineCount((string) $xmlMerchant->OnlineCount); $tmpMerchant->setOtherCount((string) $xmlMerchant->OtherCount); $tmpMerchant->setSoleProprietorName((string) $xmlMerchant->SoleProprietorName); array_push($merchantArray, $tmpMerchant); } $returnedMerchants = new ReturnedMerchants(); $returnedMerchants->setMerchant($merchantArray); $merchantIds = new MerchantIds(); $merchantIds->setReturnedMerchants($returnedMerchants); $merchantIds->setMessage($xml->Message); return $merchantIds; }
function create_ecp_PaymentMethod() { $uniqueValue = get_unique_value(); $merchantAccountId = 'account-' . $uniqueValue; $merchantPaymentMethodId = 'pm-' . $uniqueValue; $email = get_unique_value() . '@nomail.com'; $successUrl = 'http://good.com/'; //need a trailing slash $errorUrl = 'http://bad.com/'; //need a trailing slash $name = 'John Vindicia'; $addr1 = '303 Twin Dolphin Drive'; $city = 'Redwood City'; $district = 'CA'; $postalCode = '94065'; $country = 'US'; $address = new Address(); $address->setName($name); $address->setAddr1($addr1); $address->setCity($city); $address->setDistrict($district); $address->setPostalCode($postalCode); $address->setCountry($country); $paymentmethod = new PaymentMethod(); $paymentmethod->setType('ECP'); $paymentmethod->setAccountHolderName($name); $paymentmethod->setBillingAddress($address); $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId); $paymentmethod->setCurrency('USD'); $ecp = new ECP(); $ecp->setAccount('495958930'); $ecp->setRoutingNumber('611111111'); $ecp->setAllowedTransactionType('Inbound'); $ecp->setAccountType('ConsumerChecking'); $paymentmethod->setECP($ecp); $account = new Account(); $account->setMerchantAccountId($merchantAccountId); $account->setEmailAddress($email); $account->setShippingAddress($address); $account->setEmailTypePreference('html'); $account->setName($name); $account->setPaymentMethods(array($paymentmethod)); return $account; }
function create_paypal_PaymentMethod() { $uniqueValue = get_unique_value(); $merchantAccountId = 'account-' . $uniqueValue; $merchantPaymentMethodId = 'pm-' . $uniqueValue; $email = get_unique_value() . '@nomail.com'; $successUrl = 'http://good.com/'; //need a trailing slash $errorUrl = 'http://bad.com/'; //need a trailing slash $name = 'John Vindicia'; $addr1 = '303 Twin Dolphin Drive'; $city = 'Redwood City'; $district = 'CA'; $postalCode = '94065'; $country = 'US'; $address = new Address(); $address->setName($name); $address->setAddr1($addr1); $address->setCity($city); $address->setDistrict($district); $address->setPostalCode($postalCode); $address->setCountry($country); $paymentmethod = new PaymentMethod(); $paymentmethod->setType('PayPal'); $paymentmethod->setAccountHolderName($name); $paymentmethod->setBillingAddress($address); $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId); $paymentmethod->setCurrency('USD'); $paypal = new PayPal(); $paypal->setReturnUrl($successUrl); $paypal->setCancelUrl($errorUrl); $paymentmethod->setPaypal($paypal); $account = new Account(); $account->setMerchantAccountId($merchantAccountId); $account->setEmailAddress($email); $account->setShippingAddress($address); $account->setEmailTypePreference('html'); $account->setName($name); //$account->setPaymentMethods(array($paymentmethod)); //return $account; return array('account' => $account, 'paymentmethod' => $paymentmethod); }
/** * @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); }
private function buildInquireMapping($xml) { $inquireMapping = new InquireMapping(); $inquireMapping->setRequestId((string) $xml->RequestId); $mappings = new Mappings(); $mappingArray = array(); foreach ($xml->Mappings->Mapping as $mapping) { $tmpMapping = new Mapping(); $tmpMapping->setMappingId((string) $mapping->MappingId); $tmpMapping->setSubscriberId((string) $mapping->SubscriberId); $tmpMapping->setAccountUsage((string) $mapping->AccountUsage); $tmpMapping->setDefaultIndicator((string) $mapping->DefaultIndicator); $tmpMapping->setAlias((string) $mapping->Alias); $tmpMapping->setICA((string) $mapping->ICA); $tmpMapping->setAccountNumber((string) $mapping->AccountNumber); $tmpCardholderFullName = new CardholderFullName(); $cardholderFullName = $mapping->CardholderFullName; $tmpCardholderFullName->setCardholderFirstName((string) $cardholderFullName->CardholderFirstName); $tmpCardholderFullName->setCardholderMiddleName((string) $cardholderFullName->CardholderMiddleName); $tmpCardholderFullName->setCardholderLastName((string) $cardholderFullName->CardholderLastName); $tmpAddress = new Address(); $address = $mapping->Address; $tmpAddress->setLine1((string) $address->line1); $tmpAddress->setLine2((string) $address->line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setCountrySubdivision((string) $address->CountrySubdivision); $tmpAddress->setPostalCode((string) $address->PostalCode); $tmpAddress->setCountry((string) $address->Country); $tmpReceivingEligibility = new ReceivingEligibility(); $receivingEligibility = $mapping->ReceivingEligibility; $tmpReceivingEligibility->setEligible((string) $receivingEligibility->Eligible); $tmpCurrency = new Currency(); $currency = $receivingEligibility->Currency; $tmpCurrency->setAlphaCurrencyCode((string) $currency->AlphaCurrencyCode); $tmpCurrency->setNumericCurrencyCode((string) $currency->NumericCurrencyCode); $tmpCountry = new Country(); $country = $receivingEligibility->Country; $tmpCountry->setAlphaCountryCode((string) $country->AlphaCountryCode); $tmpCountry->setAlphaCountryCode((string) $country->NumericCountryCode); $tmpBrand = new Brand(); $brand = $receivingEligibility->Brand; $tmpBrand->setAcceptanceBrandCode((string) $brand->AcceptanceBrandCode); $tmpBrand->setProductBrandCode((string) $brand->ProductBrandCode); $tmpMapping->setExpiryDate((string) $mapping->ExpiryDate); $tmpReceivingEligibility->setCurrency($tmpCurrency); $tmpReceivingEligibility->setCountry($tmpCountry); $tmpReceivingEligibility->setBrand($tmpBrand); $tmpMapping->setCardholderFullName($tmpCardholderFullName); $tmpMapping->setAddress($tmpAddress); $tmpMapping->setReceivingEligibility($tmpReceivingEligibility); array_push($mappingArray, $tmpMapping); } $mappings->setMapping($mappingArray); $inquireMapping->setMappings($mappings); return $inquireMapping; }
/** * * Builds and Returns an Address object based off of the JSON input. * * @param vo_json JSON representation of an address * @return the Address * @throws JSONException if the json is not properly formatted */ static function buildFromJSON($o_data) { $o_instance = new Address(); if ($o_data != NULL) { if (array_key_exists("address_name", $o_data)) { $o_instance->setName($o_data['address_name']); } if (array_key_exists("address_line1", $o_data)) { $o_instance->setLine1($o_data['address_line1']); } if (array_key_exists("address_line2", $o_data)) { $o_instance->setLine2($o_data['address_line2']); } if (array_key_exists("address_city", $o_data)) { $o_instance->setCity($o_data['address_city']); } if (array_key_exists("address_state", $o_data)) { $o_instance->setState($o_data['address_state']); } if (array_key_exists("address_zipcode", $o_data)) { $o_instance->setZipcode($o_data['address_zipcode']); } if (array_key_exists("address_country", $o_data)) { $o_instance->setCountry($o_data['address_country']); } } return $o_instance; }
/** * Tests Address->setCountry() */ public function testSetCountry() { $this->Address->setCountry('country'); $this->assertEquals('country', $this->Address->country); }
public function getUserAddEditForm($target = '/admin/User', $admin = false, $addSection = true) { $form = new Form('user_addedit', 'POST', $target); if ($addSection) { $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); } if (@$_REQUEST['id']) { $this->__construct($_REQUEST['id']); $form->setConstants(array('id' => $_REQUEST['id'])); $form->addElement('hidden', 'id'); } elseif (!@$this->getId()) { $this->__construct(); } $statuses = array(1 => 'Active', 0 => 'Disabled'); $form->addElement('header', 'general', 'General Info'); if (!$admin && @$_REQUEST['id']) { //The user is editing their profile, Do not edit the username $form->addElement('static', 'a_username_label', 'Username (Email address)', $this->getUsername()); $form->setConstants(array('a_username' => $this->getUsername())); $form->addElement('hidden', 'a_username'); } else { $form->addElement('text', 'a_username', 'Username (Email address)'); $form->addRule('a_username', 'Please enter a username', 'required', null, 'client'); $form->addRule('a_username', 'Please enter a valid email address for the username', 'email', null, 'client'); } $form->addElement('password', 'a_password', 'Password'); $form->addElement('password', 'a_password_confirm', 'Confirm Password'); $form->addElement('text', 'a_name', 'Full Name'); //$form->addElement( 'text', 'a_email', 'Email Address'); $form->addElement('text', 'a_phone', 'Phone number'); $form->addElement('advcheckbox', 'a_join_newsletter', 'Sign me up for your E-Newsletter'); $form->addElement('header', 'billing_address_header', 'Billing Address'); $form->addElement('text', 'a_address', 'Address'); $form->addElement('text', 'a_city', 'City'); $form->addElement('text', 'a_postalcode', 'Postal Code'); $form->setConstants(array('a_state' => '1')); //31 is the ID of Alberta. It should be a SiteConfig variable $form->addElement('hidden', 'a_state'); $form->addElement('static', 'a_state1', 'State / Province', 'Alberta'); $form->setConstants(array('a_country' => '31')); //31 is the ID of Canada. It should be a SiteConfig variable $form->addElement('hidden', 'a_country'); $form->addElement('static', 'a_country1', 'Country', 'Canada'); $form->addElement('header', 'shipping_address_header', 'Shipping Address'); $form->addElement('text', 'shipping_address', 'Address'); $form->addElement('text', 'shipping_city', 'City'); $form->addElement('text', 'shipping_postalcode', 'Postal Code'); $form->setConstants(array('shipping_state' => '1')); //31 is the ID of Alberta. It should be a SiteConfig variable $form->addElement('hidden', 'shipping_state'); $form->addElement('static', 'shipping_state1', 'State / Province', 'Alberta'); $form->setConstants(array('shipping_country' => '31')); //31 is the ID of Canada. It should be a SiteConfig variable $form->addElement('hidden', 'shipping_country'); $form->addElement('static', 'shipping_country1', 'Country', 'Canada'); $form->addElement('header', 'save', 'Save'); if ($admin) { $form->addElement('select', 'a_status', 'Active Status', $statuses); } $form->addElement('submit', 'a_submit', 'Save'); $form->addElement('reset', 'a_cancel', 'Cancel'); if (isset($this->user) && $this->user->hasPerm('assigngroups')) { $sql = 'SELECT agp_id, agp_name from auth_groups'; $groups = Database::singleton()->query_fetch_all($sql); $assignableGroup = array(); foreach ($groups as $group) { $assignableGroup[$group['agp_id']] = $group['agp_name']; } if (@$this) { $defaultValues['a_group'] = $this->getAuthGroup(); } $form->addElement('select', 'a_group', 'Member Group', $assignableGroup); } $defaultValues['a_username'] = $this->getUsername(); $defaultValues['a_name'] = $this->getName(); //$defaultValues ['a_email'] = $this->getEmail(); $defaultValues['a_phone'] = $this->getPhone(); $defaultValues['a_join_newsletter'] = $this->getJoinNewsletter(); $defaultValues['a_password'] = null; $defaultValues['a_password_confirm'] = null; if (@$this->getAddress()) { $defaultValues['a_address'] = @$this->getAddress()->getStreetAddress(); $defaultValues['a_city'] = @$this->getAddress()->getCity(); $defaultValues['a_postalcode'] = @$this->getAddress()->getPostalCode(); } if (@$this->getShippingAddress()) { $defaultValues['shipping_address'] = @$this->getShippingAddress()->getStreetAddress(); $defaultValues['shipping_city'] = @$this->getShippingAddress()->getCity(); $defaultValues['shipping_postalcode'] = @$this->getShippingAddress()->getPostalCode(); } if ($admin) { $defaultValues['a_status'] = $this->getActiveStatus(); } $form->setDefaults($defaultValues); $form->addRule('a_name', 'Please enter the user\'s name', 'required', null, 'client'); //$form->addRule( 'a_email', 'Please enter an email address', 'required', null, 'client' ); //$form->addRule( 'a_email', 'Please enter a valid email address', 'email', null, 'client' ); $form->addRule('a_phone', 'Please enter a phone number', 'required', null, 'client'); $form->addRule('a_address', 'Please enter a billing address', 'required', null, 'client'); $form->addRule('a_city', 'Please enter a billing address city', 'required', null, 'client'); $form->addRule('a_postalcode', 'Please enter a billing address postal code', 'required', null, 'client'); $form->addRule('shipping_address', 'Please enter a shipping address', 'required', null, 'client'); $form->addRule('shipping_city', 'Please enter a shipping address city', 'required', null, 'client'); $form->addRule('shipping_postalcode', 'Please enter a shipping address postal code', 'required', null, 'client'); if (!isset($_REQUEST['id'])) { $form->addRule('a_password', 'Please enter a password', 'required', null, 'client'); $form->addRule('a_password_confirm', 'Please confirm the passwords match', 'required', null, 'client'); } $form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null, 'client'); if (isset($_REQUEST['a_submit']) && $form->validate()) { $this->setPassword($_REQUEST['a_password']); if ($admin || @(!$_REQUEST['id'])) { $this->setUsername($_REQUEST['a_username']); $this->setEmail($_REQUEST['a_username']); } $this->setActiveStatus(1); $this->setPhone($_REQUEST['a_phone']); $this->setName($_REQUEST['a_name']); $this->setJoinNewsletter(@$_REQUEST['a_join_newsletter']); if (@$this->getAddress()) { $billingTemp = new Address(@$this->getAddress()->getId()); } else { $billingTemp = new Address(); } $billingTemp->setStreetAddress($_REQUEST['a_address']); $billingTemp->setCity($_REQUEST['a_city']); $billingTemp->setPostalCode($_REQUEST['a_postalcode']); $billingTemp->setState($_REQUEST['a_state']); $billingTemp->setCountry($_REQUEST['a_country']); $billingTemp->save(); $this->setAddress($billingTemp); if (@$this->getShippingAddress()) { $shippingTemp = new Address(@$this->getShippingAddress()->getId()); } else { $shippingTemp = new Address(); } $shippingTemp->setStreetAddress($_REQUEST['shipping_address']); $shippingTemp->setCity($_REQUEST['shipping_city']); $shippingTemp->setPostalCode($_REQUEST['shipping_postalcode']); $shippingTemp->setState($_REQUEST['shipping_state']); $shippingTemp->setCountry($_REQUEST['shipping_country']); $shippingTemp->save(); $this->setShippingAddress($shippingTemp); if ($this->save()) { $_REQUEST["user_created"] = 1; } else { $form->addElement('static', 'Message', 'Username already exists'); $_REQUEST["username_already_exists"] = 1; } } return $form; }
public function getPeople($ids, $fields, $options, $token) { $first = $options->getStartIndex(); $max = $options->getCount(); $this->checkDb(); $ret = array(); $filterQuery = ''; $options->setFilterBy(null); //DateOfBirth $query = "\n\t\tSELECT * FROM `Profiles` WHERE `ID` IN (" . implode(',', $ids) . ") {$filterQuery} ORDER BY `ID`\n\t"; /* `ID` AS 'id', `NickName` AS 'first_name', `NickName` AS 'last_name', `DescriptionMe` AS 'about_me', 20 AS 'age', `DateOfBirth` AS 'date_of_birth', 1 AS 'children', '' AS 'ethnicity', '' AS 'fashion', '' AS 'happiest_when', '' AS 'humor', '' AS 'job_interests' */ $res = mysqli_query($this->db, $query); if ($res) { while ($row = @mysqli_fetch_array($res, MYSQLI_ASSOC)) { $person_id = $row['ID']; $sFirstName = isset($row['FirstName']) ? $row['FirstName'] : $row['NickName']; $sLastName = isset($row['LastName']) ? $row['LastName'] : ''; $name = new Name($sFirstName . ' ' . $sLastName); $name->setGivenName($sFirstName); $name->setFamilyName($sLastName); $person = new Person($person_id, $name); $person->setDisplayName($name->getFormatted()); $sAboutMe = isset($row['DescriptionMe']) ? $row['DescriptionMe'] : ''; $person->setAboutMe($sAboutMe); $sDateOfBirth = isset($row['DateOfBirth']) ? date('Y-m-d', $row['DateOfBirth']) : ''; $sAge = $sDateOfBirth != '' ? $this->bx_getAge($sDateOfBirth) : ''; $person->setAge($sAge); $sChildren = isset($row['Children']) ? $row['Children'] : ''; $person->setChildren($sChildren); $person->setBirthday($sDateOfBirth); $sEthnicity = isset($row['Ethnicity']) ? $row['Ethnicity'] : ''; $person->setEthnicity($sEthnicity); $sFashion = isset($row['Fashion']) ? $row['Fashion'] : ''; $person->setFashion($sFashion); $sHappiestWhen = isset($row['HappiestWhen']) ? $row['HappiestWhen'] : ''; $person->setHappiestWhen($sHappiestWhen); $sHumor = isset($row['Humor']) ? $row['Humor'] : ''; $person->setHumor($sHumor); $sJobInterests = isset($row['JobInterests']) ? $row['JobInterests'] : ''; $person->setJobInterests($sJobInterests); $sLivingArrangement = isset($row['LivingArrangement']) ? $row['LivingArrangement'] : ''; $person->setLivingArrangement($sLivingArrangement); $sLookingFor = isset($row['LookingFor']) ? $row['LookingFor'] : ''; $person->setLookingFor($sLookingFor); $sNickName = isset($row['NickName']) ? $row['NickName'] : ''; $person->setNickname($sNickName); $sPets = isset($row['Pets']) ? $row['Pets'] : ''; $person->setPets($sPets); $sPoliticalViews = isset($row['PoliticalViews']) ? $row['PoliticalViews'] : ''; $person->setPoliticalViews($sPoliticalViews); $sProfileSong = isset($row['ProfileSong']) ? $row['ProfileSong'] : ''; $person->setProfileSong($sProfileSong); $person->setProfileUrl($this->url_prefix . '/profile/' . $person_id); //'A' TODO $sProfileVideo = isset($row['ProfileVideo']) ? $row['ProfileVideo'] : ''; $person->setProfileVideo($sProfileVideo); $sRelationshipStatus = isset($row['RelationshipStatus']) ? $row['RelationshipStatus'] : ''; $person->setRelationshipStatus($sRelationshipStatus); $sReligion = isset($row['Religion']) ? $row['Religion'] : ''; $person->setReligion($sReligion); $sRomance = isset($row['Romance']) ? $row['Romance'] : ''; $person->setRomance($sRomance); $sScaredOf = isset($row['ScaredOf']) ? $row['ScaredOf'] : ''; $person->setScaredOf($sScaredOf); $sSexualOrientation = isset($row['SexualOrientation']) ? $row['SexualOrientation'] : ''; $person->setSexualOrientation($sSexualOrientation); $person->setStatus($row['UserStatus']); $person->setThumbnailUrl(!empty($row['thumbnail_url']) ? $this->url_prefix . $row['thumbnail_url'] : ''); //'A' TODO if (!empty($row['thumbnail_url'])) { // also report thumbnail_url in standard photos field (this is the only photo supported by partuza) $person->setPhotos(array(new Photo($this->url_prefix . $row['thumbnail_url'], 'thumbnail', true))); } $sUtcOffset = isset($row['TimeZone']) ? $row['TimeZone'] : "-00:00"; $person->setUtcOffset(sprintf('%+03d:00', $sUtcOffset)); // force "-00:00" utc-offset format if (!empty($row['Drinker'])) { $person->setDrinker($row['Drinker']); } if (!empty($row['Sex'])) { $person->setGender(strtolower($row['Sex'])); } if (!empty($row['Smoker'])) { $person->setSmoker($row['Smoker']); } /* the following fields require additional queries so are only executed if requested */ if (isset($fields['activities']) || in_array('@all', $fields)) { $activities = array(); //'A' we haven`t activities yet /*$res2 = mysqli_query($this->db, "select activity from person_activities where person_id = " . $person_id); while (list($activity) = @mysqli_fetch_row($res2)) { $activities[] = $activity; }*/ $person->setActivities($activities); } if (isset($fields['addresses']) || in_array('@all', $fields)) { $addresses = array(); $sCountry = isset($row['Country']) ? $row['Country'] : ''; $sRegion = isset($row['City']) ? $row['City'] : ''; //'A' region -> city $sZip = isset($row['zip']) ? $row['zip'] : ''; if (empty($row['unstructured_address'])) { $row['unstructured_address'] = trim($row['street_address'] . " " . $sRegion . " " . $sCountry); } $addres = new Address($row['unstructured_address']); $addres->setCountry($sCountry); if (!empty($row['latitude'])) { $addres->setLatitude($row['latitude']); } if (!empty($row['longitude'])) { $addres->setLongitude($row['longitude']); } if (!empty($row['locality'])) { $addres->setLocality($row['locality']); } $addres->setPostalCode($sZip); $addres->setRegion($sRegion); if (!empty($row['street_address'])) { $addres->setStreetAddress($row['street_address']); } if (!empty($row['street_address'])) { $addres->setType($row['street_address']); } //FIXME quick and dirty hack to demo PC $addres->setPrimary(true); $addresses[] = $addres; $person->setAddresses($addresses); } if (isset($fields['bodyType']) || in_array('@all', $fields)) { //'A' we haven`t bodyType at all /*$res2 = mysqli_query($this->db, "select * from person_body_type where person_id = " . $person_id); if (@mysqli_num_rows($res2)) { $row = @mysql_fetch_array($res2, MYSQLI_ASSOC); $bodyType = new BodyType(); $bodyType->setBuild($row['build']); $bodyType->setEyeColor($row['eye_color']); $bodyType->setHairColor($row['hair_color']); $bodyType->setHeight($row['height']); $bodyType->setWeight($row['weight']); $person->setBodyType($bodyType); }*/ } if (isset($fields['books']) || in_array('@all', $fields)) { //'A' we haven`t books at all /*$books = array(); $res2 = mysqli_query($this->db, "select book from person_books where person_id = " . $person_id); while (list($book) = @mysqli_fetch_row($res2)) { $books[] = $book; } $person->setBooks($books);*/ } if (isset($fields['cars']) || in_array('@all', $fields)) { //'A' we haven`t cars at all /*$cars = array(); $res2 = mysqli_query($this->db, "select car from person_cars where person_id = " . $person_id); while (list($car) = @mysqli_fetch_row($res2)) { $cars[] = $car; } $person->setCars($cars);*/ } if (isset($fields['currentLocation']) || in_array('@all', $fields)) { //'A' we haven`t currentLocation at all /*$addresses = array(); $res2 = mysqli_query($this->db, "select addresses.* from person_current_location, person_addresses, addresses where addresses.id = person_current_location.address_id and person_addresses.person_id = " . $person_id); if (@mysqli_num_rows($res2)) { $row = mysqli_fetch_array($res2, MYSQLI_ASSOC); if (empty($row['unstructured_address'])) { $row['unstructured_address'] = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']); } $addres = new Address($row['unstructured_address']); $addres->setCountry($row['country']); $addres->setLatitude($row['latitude']); $addres->setLongitude($row['longitude']); $addres->setLocality($row['locality']); $addres->setPostalCode($row['postal_code']); $addres->setRegion($row['region']); $addres->setStreetAddress($row['street_address']); $addres->setType($row['address_type']); $person->setCurrentLocation($addres); }*/ } if (isset($fields['emails']) || in_array('@all', $fields)) { $emails = array(); //'A' we haven`t multi emails, only single /*$res2 = mysqli_query($this->db, "select address, email_type from person_emails where person_id = " . $person_id); while (list($address, $type) = @mysqli_fetch_row($res2)) { $emails[] = new Email(strtolower($address), $type); // TODO: better email canonicalization; remove dups } $person->setEmails($emails);*/ $sEmail = isset($row['Email']) ? $row['Email'] : ''; $emails[] = new Email(strtolower($sEmail), 'main'); $person->setEmails($emails); } if (isset($fields['food']) || in_array('@all', $fields)) { //'A' we haven`t food at all /*$foods = array(); $res2 = mysqli_query($this->db, "select food from person_foods where person_id = " . $person_id); while (list($food) = @mysqli_fetch_row($res2)) { $foods[] = $food; } $person->setFood($foods);*/ } if (isset($fields['heroes']) || in_array('@all', $fields)) { //'A' we haven`t heroes at all /*$strings = array(); $res2 = mysqli_query($this->db, "select hero from person_heroes where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setHeroes($strings);*/ } if (isset($fields['interests']) || in_array('@all', $fields)) { //'A' we haven`t interests at all /* $strings = array(); $res2 = mysqli_query($this->db, "select interest from person_interests where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setInterests($strings);*/ } $organizations = array(); $fetchedOrg = false; if (isset($fields['jobs']) || in_array('@all', $fields)) { //'A' we haven`t jobs at all /*$res2 = mysqli_query($this->db, "select organizations.* from person_jobs, organizations where organizations.id = person_jobs.organization_id and person_jobs.person_id = " . $person_id); while ($row = mysqli_fetch_array($res2, MYSQLI_ASSOC)) { $organization = new Organization(); $organization->setDescription($row['description']); $organization->setEndDate($row['end_date']); $organization->setField($row['field']); $organization->setName($row['name']); $organization->setSalary($row['salary']); $organization->setStartDate($row['start_date']); $organization->setSubField($row['sub_field']); $organization->setTitle($row['title']); $organization->setWebpage($row['webpage']); $organization->setType('job'); if ($row['address_id']) { $res3 = mysqli_query($this->db, "select * from addresses where id = " . $row['address_id']); if (mysqli_num_rows($res3)) { $row = mysqli_fetch_array($res3, MYSQLI_ASSOC); if (empty($row['unstructured_address'])) { $row['unstructured_address'] = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']); } $addres = new Address($row['unstructured_address']); $addres->setCountry($row['country']); $addres->setLatitude($row['latitude']); $addres->setLongitude($row['longitude']); $addres->setLocality($row['locality']); $addres->setPostalCode($row['postal_code']); $addres->setRegion($row['region']); $addres->setStreetAddress($row['street_address']); $addres->setType($row['address_type']); $organization->setAddress($address); } } $organizations[] = $organization; } $fetchedOrg = true;*/ } if (isset($fields['schools']) || in_array('@all', $fields)) { //'A' we haven`t schools at all /*$res2 = mysqli_query($this->db, "select organizations.* from person_schools, organizations where organizations.id = person_schools.organization_id and person_schools.person_id = " . $person_id); while ($row = mysqli_fetch_array($res2, MYSQLI_ASSOC)) { $organization = new Organization(); $organization->setDescription($row['description']); $organization->setEndDate($row['end_date']); $organization->setField($row['field']); $organization->setName($row['name']); $organization->setSalary($row['salary']); $organization->setStartDate($row['start_date']); $organization->setSubField($row['sub_field']); $organization->setTitle($row['title']); $organization->setWebpage($row['webpage']); $organization->setType($row['school']); if ($row['address_id']) { $res3 = mysqli_query($this->db, "select * from addresses where id = " . $row['address_id']); if (mysqli_num_rows($res3)) { $row = mysqli_fetch_array($res3, MYSQLI_ASSOC); if (empty($row['unstructured_address'])) { $row['unstructured_address'] = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']); } $addres = new Address($row['unstructured_address']); $addres->setCountry($row['country']); $addres->setLatitude($row['latitude']); $addres->setLongitude($row['longitude']); $addres->setLocality($row['locality']); $addres->setPostalCode($row['postal_code']); $addres->setRegion($row['region']); $addres->setStreetAddress($row['street_address']); $addres->setType($row['address_type']); $organization->setAddress($address); } } $organizations[] = $organization; } $fetchedOrg = true;*/ } if ($fetchedOrg) { $person->setOrganizations($organizations); } //TODO languagesSpoken, currently missing the languages / countries tables so can't do this yet if (isset($fields['movies']) || in_array('@all', $fields)) { //'A' possible after /*$strings = array(); $res2 = mysqli_query($this->db, "select movie from person_movies where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setMovies($strings);*/ } if (isset($fields['music']) || in_array('@all', $fields)) { //'A' possible after /*$strings = array(); $res2 = mysqli_query($this->db, "select music from person_music where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setMusic($strings);*/ } if (isset($fields['phoneNumbers']) || in_array('@all', $fields)) { //'A' we haven`t phoneNumbers at all /*$numbers = array(); $res2 = mysqli_query($this->db, "select number, number_type from person_phone_numbers where person_id = " . $person_id); while (list($number, $type) = @mysqli_fetch_row($res2)) { $numbers[] = new Phone($number, $type); } $person->setPhoneNumbers($numbers);*/ } if (isset($fields['ims']) || in_array('@all', $fields)) { //'A' we haven`t ims at all /*$ims = array(); $res2 = mysqli_query($this->db, "select value, value_type from person_ims where person_id = " . $person_id); while (list($value, $type) = @mysqli_fetch_row($res2)) { $ims[] = new Im($value, $type); } $person->setIms($ims);*/ } if (isset($fields['accounts']) || in_array('@all', $fields)) { //'A' we haven`t accounts at all /*$accounts = array(); $res2 = mysqli_query($this->db, "select domain, userid, username from person_accounts where person_id = " . $person_id); while (list($domain, $userid, $username) = @mysqli_fetch_row($res2)) { $accounts[] = new Account($domain, $userid, $username); } $person->setAccounts($accounts);*/ } if (isset($fields['quotes']) || in_array('@all', $fields)) { //'A' we haven`t quotes at all /*$strings = array(); $res2 = mysqli_query($this->db, "select quote from person_quotes where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setQuotes($strings);*/ } if (isset($fields['sports']) || in_array('@all', $fields)) { //'A' we haven`t sports at all /*$strings = array(); $res2 = mysqli_query($this->db, "select sport from person_sports where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setSports($strings);*/ } if (isset($fields['tags']) || in_array('@all', $fields)) { $strings = array(); if (!empty($row['latitude'])) { $aProfileTags = preg_split("/[;,\\s]/", $_REQUEST['tags']); foreach ($aProfileTags as $sTag) { $strings[] = $sTag; } /*$res2 = mysqli_query($this->db, "select tag from person_tags where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; }*/ $person->setTags($strings); } } if (isset($fields['turnOns']) || in_array('@all', $fields)) { //'A' we haven`t turnOns at all /*$strings = array(); $res2 = mysqli_query($this->db, "select turn_on from person_turn_ons where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setTurnOns($strings);*/ } if (isset($fields['turnOffs']) || in_array('@all', $fields)) { //'A' we haven`t turnOffs at all /*$strings = array(); $res2 = mysqli_query($this->db, "select turn_off from person_turn_offs where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = $data; } $person->setTurnOffs($strings);*/ } if (isset($fields['urls']) || in_array('@all', $fields)) { //'A' we haven`t urls at all /*$strings = array(); $res2 = mysqli_query($this->db, "select url from person_urls where person_id = " . $person_id); while (list($data) = @mysqli_fetch_row($res2)) { $strings[] = new Url($data, null, null); } $strings[] = new Url($this->url_prefix . '/profile/' . $person_id, null, 'profile'); // always include profile URL $person->setUrls($strings);*/ } $ret[$person_id] = $person; } } try { $ret = $this->filterResults($ret, $options); $ret['totalSize'] = count($ret); } catch (Exception $e) { $ret['totalSize'] = count($ret) - 1; $ret['filtered'] = 'false'; } if ($first !== false && $max !== false && is_numeric($first) && is_numeric($max) && $first >= 0 && $max > 0) { $count = 0; $result = array(); foreach ($ret as $id => $person) { if ($id == 'totalSize' || $id == 'filtered') { $result[$id] = $person; continue; } if ($count >= $first && $count < $first + $max) { $result[$id] = $person; } ++$count; } return $result; } else { return $ret; } }
function getTax($calculationHelper, $calc, $price, $sale = false, $committ = false) { if ($calc->activated == 0) { return false; } $shopperData = $this->getShopperData(); if (!$shopperData) { return false; } //if(self::$stop) return self::$stop; if (!class_exists('TaxServiceSoap')) { require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php'; } if (!class_exists('DocumentType')) { require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php'; } if (!class_exists('DetailLevel')) { require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php'; } if (!class_exists('Line')) { require VMAVALARA_CLASS_PATH . DS . 'Line.class.php'; } if (!class_exists('ServiceMode')) { require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php'; } if (!class_exists('Line')) { require VMAVALARA_CLASS_PATH . DS . 'Line.class.php'; } if (!class_exists('GetTaxRequest')) { require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php'; } if (!class_exists('GetTaxResult')) { require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php'; } $client = new TaxServiceSoap('Development'); $request = new GetTaxRequest(); $origin = new Address(); //$destination = $this->fillValidateAvalaraAddress($calc); //In Virtuemart we have not differenct warehouses, but we have a shipment address //So when the vendor has a shipment address, we assume that it is his warehouse //Later we can combine products with shipment addresses for different warehouse (yehye, future music) //But for now we just use the BT address if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'; } $userId = VirtueMartModelVendor::getUserIdByVendorId($calc->virtuemart_vendor_id); $userModel = VmModel::getModel('user'); $virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId); // this is needed to set the correct user id for the vendor when the user is logged $userModel->getVendor($calc->virtuemart_vendor_id); $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE); $vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id]; //vmdebug('my vendor fields',$vendorFields); $origin->setLine1($vendorFields['fields']['address_1']['value']); $origin->setLine2($vendorFields['fields']['address_2']['value']); $origin->setCity($vendorFields['fields']['city']['value']); $origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']); $origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']); $origin->setPostalCode($vendorFields['fields']['zip']['value']); $request->setOriginAddress($origin); //Address if (isset($this->addresses[0])) { $destination = $this->addresses[0]; } else { return FALSE; } $request->setDestinationAddress($destination); //Address //vmdebug('The date',$origin,$destination); $request->setCompanyCode($calc->company_code); // Your Company Code From the Dashboard if ($calc->committ and $sale) { $request->setDocType(DocumentType::$SalesInvoice); // Only supported types are SalesInvoice or SalesOrder $request->setCommit(true); //invoice number, problem is that the invoice number is at this time not known, but the order_number may reachable $request->setDocCode($committ); vmdebug('Request as SalesInvoice with invoiceNumber ' . $committ); } else { $request->setDocType(DocumentType::$SalesOrder); $request->setCommit(false); //invoice number, problem is that the invoice number is at this time not known, neither the order_number $request->setDocCode('VM2.0.16_order_request'); vmdebug('Request as SalesOrder'); } $request->setDocDate(date('Y-m-d')); //date //$request->setSalespersonCode(""); // string Optional $request->setCustomerCode($shopperData['customer_id']); //string Required if (isset($shopperData['tax_usage_type'])) { $request->setCustomerUsageType($shopperData['tax_usage_type']); //string Entity Usage } $cartPrices = $calculationHelper->getCartPrices(); //vmdebug('$cartPrices',$cartPrices); $request->setDiscount($cartPrices['discountAmount']); //decimal //$request->setDiscount(0.0); // $request->setPurchaseOrderNo(""); //string Optional //If I understand correctly, we need to add for this an userfield, for example with the name //exemption_no, then user could enter their number. if (isset($shopperData['tax_exemption_number'])) { $request->setExemptionNo($shopperData['tax_exemption_number']); //string if not using ECMS which keys on customer code } $request->setDetailLevel('Tax'); //Summary or Document or Line or Tax or Diagnostic // $request->setReferenceCode1(""); //string Optional // $request->setReferenceCode2(""); //string Optional // $request->setLocationCode(""); //string Optional - aka outlet id for tax forms ///////////////////////////////////////// if (!class_exists('VirtueMartCart')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); $products = array(); if ($calculationHelper->inCart) { $products = $cart->products; $prices = $calculationHelper->getCartPrices(); foreach ($products as $k => $product) { if (!empty($prices[$k]['discountedPriceWithoutTax'])) { $price = $prices[$k]['discountedPriceWithoutTax']; } else { if (!empty($prices[$k]['basePriceVariant'])) { $price = $prices[$k]['basePriceVariant']; } else { vmdebug('There is no price in getTax for product ' . $k . ' ', $prices); $price = 0.0; } } $product->price = $price; if (!empty($price[$k]['discountAmount'])) { $product->discount = $price[$k]['discountAmount']; } else { $product->discount = FALSE; } } } else { $calculationHelper->_product->price = $price; $products[0] = $calculationHelper->_product; if (!isset($products[0]->amount)) { $products[0]->amount = 1; } if (isset($calculationHelper->productPrices['discountAmount'])) { $products[0]->discount = $calculationHelper->productPrices['discountAmount']; } else { $products[0]->discount = FALSE; } } $lines = array(); $n = 0; $lineNumbersToCartProductId = array(); foreach ($products as $k => $product) { $n++; $lineNumbersToCartProductId[$n] = $k; $line = new Line(); $line->setNo($n); //string // line Number of invoice $line->setItemCode($product->product_sku); //string $line->setDescription($product->product_name); //product description, like in cart, atm only the name, todo add customfields //$line->setTaxCode(""); //string $line->setQty($product->amount); //decimal $line->setAmount($product->price * $product->amount); //decimal // TotalAmmount $line->setDiscounted($product->discount * $product->amount); //boolean $line->setRevAcct(""); //string $line->setRef1(""); //string $line->setRef2(""); //string if (isset($shopperData['tax_exemption_number'])) { $line->setExemptionNo($shopperData['tax_exemption_number']); //string } if (isset($shopperData['tax_usage_type'])) { $line->setCustomerUsageType($shopperData['tax_usage_type']); //string } $lines[] = $line; } $line = new Line(); $line->setNo(++$n); //$lineNumbersToCartProductId[$n] = count($products)+1; $line->setItemCode($cart->virtuemart_shipmentmethod_id); $line->setDescription('Shipment'); $line->setQty(1); //$line->setTaxCode(); $cartPrices = $calculationHelper->getCartPrices(); //vmdebug('$calculationHelper $cartPrices',$cartPrices); $line->setAmount($cartPrices['shipmentValue']); if (isset($shopperData['tax_exemption_number'])) { $line->setExemptionNo($shopperData['tax_exemption_number']); //string } if (isset($shopperData['tax_usage_type'])) { $line->setCustomerUsageType($shopperData['tax_usage_type']); //string } $lines[] = $line; //vmdebug('avalaragetTax setLines',$lines); $request->setLines($lines); //vmdebug('My request',$request); $totalTax = 0.0; try { if (!class_exists('TaxLine')) { require VMAVALARA_CLASS_PATH . DS . 'TaxLine.class.php'; } if (!class_exists('TaxDetail')) { require VMAVALARA_CLASS_PATH . DS . 'TaxDetail.class.php'; } vmSetStartTime('avagetTax'); $getTaxResult = $client->getTax($request); vmTime('Avalara getTax', 'avagetTax'); /* * [0] => getDocCode [1] => getAdjustmentDescription [2] => getAdjustmentReason [3] => getDocDate [4] => getTaxDate [5] => getDocType [6] => getDocStatus [7] => getIsReconciled [8] => getLocked [9] => getTimestamp [10] => getTotalAmount [11] => getTotalDiscount [12] => getTotalExemption [13] => getTotalTaxable [14] => getTotalTax [15] => getHashCode [16] => getVersion [17] => getTaxLines [18] => getTotalTaxCalculated [19] => getTaxSummary [20] => getTaxLine [21] => getTransactionId [22] => getResultCode [23] => getMessages */ //vmdebug( 'GetTax is: '. $getTaxResult->getResultCode(),$getTaxResult); if ($getTaxResult->getResultCode() == SeverityLevel::$Success) { //vmdebug("DocCode: ".$request->getDocCode() ); //vmdebug("DocId: ".$getTaxResult->getDocId()."\n"); vmdebug("TotalAmount: " . $getTaxResult->getTotalAmount()); $totalTax = $getTaxResult->getTotalTax(); vmdebug("TotalTax: " . $totalTax); foreach ($getTaxResult->getTaxLines() as $ctl) { if ($calculationHelper->inCart) { $nr = $ctl->getNo(); if (isset($lineNumbersToCartProductId[$nr])) { $quantity = $products[$lineNumbersToCartProductId[$nr]]->amount; //on the long hand, the taxAmount must be replaced by taxAmountQuantity to avoid rounding errors $prices[$lineNumbersToCartProductId[$ctl->getNo()]]['taxAmount'] = $ctl->getTax() / $quantity; $prices[$lineNumbersToCartProductId[$ctl->getNo()]]['taxAmountQuantity'] = $ctl->getTax(); } else { //$this->_cartPrices['shipmentValue'] = 0; //could be automatically set to a default set in the globalconfig //$this->_cartPrices['shipmentTax'] = 0; //$this->_cartPrices['shipmentTotal'] = 0; //$prices = array('shipmentValue'=>$cartPrices['shipmentValue'],'shipmentTax'=> $ctl->getTax(), 'shipmentTotal' =>($cartPrices['shipmentValue'] +$ctl->getTax() )); //vmdebug('my $cartPrices',$cartPrices); $prices['shipmentTax'] = $ctl->getTax(); $prices['salesPriceShipment'] = $prices['shipmentValue'] + $ctl->getTax(); //$cartPrices = array_merge($prices,$cartPrices); //$calculationHelper->setCartPrices( $cartPrices ); $totalTax = $totalTax - $ctl->getTax(); //vmdebug('my $cartPrices danach',$cartPrices); } } //vmdebug('my lines ',$ctl); //vmdebug( " Line: ".$ctl->getNo()." Tax: ".$ctl->getTax()." TaxCode: ".$ctl->getTaxCode()); foreach ($ctl->getTaxDetails() as $ctd) { //vmdebug( " Juris Type: ".$ctd->getJurisType()."; Juris Name: ".$ctd->getJurisName()."; Rate: ".$ctd->getRate()."; Amt: ".$ctd->getTax() ); } } if ($calculationHelper->inCart) { $calculationHelper->setCartPrices($prices); } } else { foreach ($getTaxResult->getMessages() as $msg) { vmError($msg->getName() . ": " . $msg->getSummary()); } } } catch (SoapFault $exception) { $msg = "Exception: "; if ($exception) { $msg .= $exception->faultstring; } vmdebug($msg . '<br />' . $client->__getLastRequest() . '<br />' . $client->__getLastResponse()); } //self::$stop = $totalTax; return $totalTax; }
function createStandardRequest($calc, $products, $sign = 1) { if (!class_exists('TaxServiceSoap')) { require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php'; } if (!class_exists('DocumentType')) { require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php'; } if (!class_exists('DetailLevel')) { require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php'; } if (!class_exists('Line')) { require VMAVALARA_CLASS_PATH . DS . 'Line.class.php'; } if (!class_exists('ServiceMode')) { require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php'; } if (!class_exists('Line')) { require VMAVALARA_CLASS_PATH . DS . 'Line.class.php'; } if (!class_exists('GetTaxRequest')) { require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php'; } if (!class_exists('GetTaxResult')) { require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php'; } if (!class_exists('Address')) { require VMAVALARA_CLASS_PATH . DS . 'Address.class.php'; } if (is_object($calc)) { $calc = get_object_vars($calc); } $request = new GetTaxRequest(); $origin = new Address(); //In Virtuemart we have not differenct warehouses, but we have a shipment address //So when the vendor has a shipment address, we assume that it is his warehouse //Later we can combine products with shipment addresses for different warehouse (yehye, future music) //But for now we just use the BT address if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'; } $userId = VirtueMartModelVendor::getUserIdByVendorId($calc['virtuemart_vendor_id']); $userModel = VmModel::getModel('user'); $virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId); // this is needed to set the correct user id for the vendor when the user is logged $userModel->getVendor($calc['virtuemart_vendor_id']); $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE); $vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id]; $origin->setLine1($vendorFields['fields']['address_1']['value']); $origin->setLine2($vendorFields['fields']['address_2']['value']); $origin->setCity($vendorFields['fields']['city']['value']); $origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']); $origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']); $origin->setPostalCode($vendorFields['fields']['zip']['value']); $request->setOriginAddress($origin); //Address if (isset($this->addresses[0])) { $destination = $this->addresses[0]; } else { return FALSE; } if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } $calculator = calculationHelper::getInstance(); $request->setCurrencyCode($calculator->_currencyDisplay->_vendorCurrency_code_3); //CurrencyCode $request->setDestinationAddress($destination); //Address $request->setCompanyCode($calc['company_code']); // Your Company Code From the Dashboard $request->setDocDate(date('Y-m-d')); //date, checked $request->setCustomerCode(self::$vmadd['customer_number']); //string Required if (isset(self::$vmadd['tax_usage_type'])) { $request->setCustomerUsageType(self::$vmadd['tax_usage_type']); //string Entity Usage } if (isset(self::$vmadd['tax_exemption_number'])) { $request->setExemptionNo(self::$vmadd['tax_exemption_number']); //string if not using ECMS which keys on customer code } if (isset(self::$vmadd['taxOverride'])) { $request->setTaxOverride(self::$vmadd['taxOverride']); avadebug('I set tax override ', self::$vmadd['taxOverride']); } $setAllDiscounted = false; if (isset($products['discountAmount'])) { if (!empty($products['discountAmount'])) { //$request->setDiscount($sign * $products['discountAmount'] * (-1)); //decimal $request->setDiscount($sign * $products['discountAmount']); //decimal vmdebug('We sent as discount ' . $request->getDiscount()); $setAllDiscounted = true; } unset($products['discountAmount']); } $request->setDetailLevel('Tax'); //Summary or Document or Line or Tax or Diagnostic $lines = array(); $n = 0; $this->_lineNumbersToCartProductId = array(); foreach ($products as $k => $product) { $n++; $this->_lineNumbersToCartProductId[$n] = $k; $line = new Line(); $line->setNo($n); //string // line Number of invoice $line->setItemCode($product['product_sku']); //string $line->setDescription($product['product_name']); //product description, like in cart, atm only the name, todo add customfields if (!empty($product['categories'])) { //avadebug('AvaTax setTaxCode Product has categories !',$catNames); if (!class_exists('TableCategories')) { require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'categories.php'; } $db = JFactory::getDbo(); $catTable = new TableCategories($db); foreach ($product['categories'] as $cat) { $catTable->load($cat); $catslug = $catTable->slug; if (strpos($catslug, 'avatax-') !== FALSE) { $taxCode = substr($catslug, 7); if (!empty($taxCode)) { $line->setTaxCode($taxCode); } else { vmError('AvaTax setTaxCode, category could not be parsed ' . $catslug); } break; } } } //$line->setTaxCode(""); //string $line->setQty($product['amount']); //decimal $line->setAmount($sign * $product['price'] * $product['amount']); //decimal // TotalAmmount if ($setAllDiscounted or !empty($product['discount'])) { $line->setDiscounted(1); } else { $line->setDiscounted(0); } $line->setRevAcct(""); //string $line->setRef1(""); //string $line->setRef2(""); //string if (isset(self::$vmadd['tax_usage_type'])) { $line->setCustomerUsageType(self::$vmadd['tax_usage_type']); //string Entity Usage } if (isset(self::$vmadd['tax_exemption_number'])) { $line->setExemptionNo(self::$vmadd['tax_exemption_number']); //string if not using ECMS which keys on customer code } if (isset(self::$vmadd['taxOverride'])) { //create new TaxOverride Object set //$line->setTaxOverride(self::$vmadd['taxOverride']); } $lines[] = $line; } $this->newATConfig($calc); $request->setLines($lines); return $request; }
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')); }
private function showCreateCustomerPage() { if (WebRequest::wasPosted()) { try { // get variables $suTitle = WebRequest::post("suTitle"); $suFirstname = WebRequest::post("suFirstname"); $suLastname = WebRequest::post("suLastname"); $suAddress = WebRequest::post("suAddress"); $suCity = WebRequest::post("suCity"); $suPostcode = WebRequest::post("suPostcode"); $suCountry = WebRequest::post("suCountry"); $suEmail = WebRequest::post("suEmail"); $suPassword = WebRequest::post("suPassword"); $suConfirm = WebRequest::post("suConfirm"); // data validation if ($suTitle == "") { throw new CreateCustomerException("suTitle not specified"); } if ($suFirstname == "") { throw new CreateCustomerException("suFirstname not specified"); } if ($suLastname == "") { throw new CreateCustomerException("suLastname not specified"); } if ($suAddress == "") { throw new CreateCustomerException("suAddress not specified"); } if ($suCity == "") { throw new CreateCustomerException("suCity not specified"); } if ($suPostcode == "") { throw new CreateCustomerException("suPostcode not specified"); } if ($suCountry == "") { throw new CreateCustomerException("suCountry not specified"); } if ($suEmail == "") { throw new CreateCustomerException("suEmail not specified"); } if ($suPassword == "") { throw new CreateCustomerException("suPassword not specified"); } if ($suConfirm == "") { throw new CreateCustomerException("suConfirm not specified"); } if ($suPassword != $suConfirm) { throw new CreateCustomerException("Password mismatch"); } $customer = new Customer(); // set values $customer->setTitle($suTitle); $customer->setFirstname($suFirstname); $customer->setSurname($suLastname); $address = new Address(); $address->setLine1($suAddress); $address->setCity($suCity); $address->setPostcode($suPostcode); $address->setCountry($suCountry); $address->save(); $customer->setAddress($address); $customer->setEmail($suEmail); $customer->setPassword($suPassword); $customer->sendMailConfirm(); // save it $customer->save(); global $cScriptPath; $this->mHeaders[] = "Location: {$cScriptPath}/Customers"; } catch (CreateCustomerException $ex) { $this->mBasePage = "mgmt/custCreate.tpl"; $this->error($ex->getMessage()); } } else { $this->mBasePage = "mgmt/custCreate.tpl"; } }
/** * Generic address maker * * @param string $line1 * @param string $line2 * @param string $city * @param string $state * @param string $zip * @param string $country * @return Address */ protected function _newAddress($line1, $line2, $city, $state, $zip, $country = 'USA') { $address = new Address(); $address->setLine1($line1); $address->setLine2($line2); $address->setCity($city); $address->setRegion($state); $address->setPostalCode($zip); $address->setCountry($country); return $address; }
/** * @todo Implement testSetCountry(). */ public function testSetCountry() { $this->object->setCountry(8); $this->assertEquals($this->object->getCountry(), 8); }
public function merchant_application($data) { $errors = array(); $results = array(); $i = 0; // Instantiate State Model $States = new State(); // Newest modification for Merchant Application submission foreach ($data['Property'] as $property) { // Create client $o_bcpc = new BaseCommerceClient(RENTSQUARE_PARTNER_USER, RENTSQUARE_PARTNER_PASS, RENTSQUARE_PARTNER_KEY); $o_bcpc->setSandbox(BC_SANDBOXVALUE); $o_merch_app = new MerchantApplication(); $o_account = new Account(); // Account & Address infno //$o_account->setAccountName( $property['legal_name'] ); $o_account->setAccountName("RentSquare LLC"); $o_account->setAcceptACH(true); $o_account->setAcceptBC(true); // Legal Address $legal_state = $States->findById($property['legal_state_id']); $legal_state = $legal_state['State']['abbr']; $state_inc = $States->findById($property['state_inc']); $state_inc = $state_inc['State']['abbr']; $home_state = $States->findById($data['User']['state_id']); $home_state = $home_state['State']['abbr']; switch ($property['ownership_type']) { case 0: $ownership_type = 'Corporation'; break; case 1: $ownership_type = 'LLC'; break; case 2: $ownership_type = 'Partnership'; $state_inc = 'N/A'; break; case 3: $ownership_type = 'Sole Proprietor'; $property['legal_ein'] = $data['User']['ssn']; $state_inc = 'N/A'; break; } $o_legal_address = new Address(Address::$XS_ADDRESS_NAME_LEGAL); //$o_legal_address->setLine1( $property['legal_street'] ); //$o_legal_address->setCity( $property['legal_city'] ); //$o_legal_address->setState( $legal_state ); //$o_legal_address->setZipcode( $property['legal_zip'] ); $o_legal_address->setLine1("218 S. Formosa Ave"); $o_legal_address->setCity("Los Angeles"); $o_legal_address->setState("CA"); $o_legal_address->setZipcode("90036"); $o_legal_address->setCountry("USA"); $o_account->setLegalAddress($o_legal_address); //$o_account->setAccountPhoneNumber( $property['legal_phone'] ); //$o_account->setCustomerServicePhoneNumber( $data['User']['phone'] ); //$o_account->setEIN( $property['legal_ein'] ); $o_account->setAccountPhoneNumber("303-809-6116"); $o_account->setReferralPartnerID("a0Fi0000005jNJ3"); //*** Hardcoded at BC $o_account->setCongaTemplateId("a0d310000006iKoi"); //*** Hardcoded at BC $o_account->setCustomerServicePhoneNumber("303-809-6116"); $o_account->setDBA($property['legal_dba']); $o_account->setEntityType(Account::$XS_ENTITY_TYPE_CORP); $o_account->setAssociationNumber("268000"); $o_account->setEIN("452501975"); $o_account->setIpAddressOfAppSubmission("192.168.0.1"); //*** Hardcoded at BC $o_account->setWebsite('http://rentsquare.com'); // Settlement Account Bank Info $o_account->setSettlementAccountBankName($property['bank_name']); $o_account->setSettlementAccountBankPhone(''); //** TODO Required I think - need to add to form? $o_account->setSettlementAccountName($property['legal_name']); $o_account->setSettlementAccountNumber($property['bank_account_num']); $o_account->setSettlementAccountRoutingNumber($property['routing_number']); $o_account->setSettlementSameAsFeeAccount(true); $o_merch_app->setAccount($o_account); $o_dba_address = new Address(Address::$XS_ADDRESS_NAME_DBA); $o_dba_address->setLine1($property['legal_street']); $o_dba_address->setCity($property['legal_city']); $o_dba_address->setState($state_inc); //** Should this be legal state?? $o_dba_address->setZipcode($property['legal_zip']); $o_dba_address->setCountry("USA"); $o_location = new Location(); $o_location->setContactSameAsOwner(true); $o_location->setDescriptionOfProductsAndServices("Property Management Services"); $o_location->setDBAAddress($o_dba_address); //$o_location->setDescription( Location::$XS_DESCRIPTION_CONSULTING ); // Dont see in Angela's document //$o_cal = Calendar->getInstance(); //*** Hardcoded at BC //$o_cal->add( Calendar->YEAR, -2 ); //*** Hardcoded at BC //$o_year = $o_cal->getTime(); //*** Hardcoded at BC //$o_location->setEntityStartDate( $o_year ); //*** Hardcoded at BC $o_location->setEntityState($legal_state); //** Should this be legal state?? $o_location->setSalesAgentName('Sean Perlmutter'); $o_location->setProgramPricing('RentSquare'); $o_location->setProgramDetails('Fees Billed to Partner'); $o_contact = new PrincipalContact(); $o_contact->setLastName($data['User']['last_name']); $o_contact->setFirstName($data['User']['first_name']); $o_mailing = new Address(Address::$XS_ADDRESS_NAME_MAILING); $o_mailing->setLine1($data['User']['street']); $o_mailing->setCity($data['User']['city']); $o_mailing->setState($home_state); $o_mailing->setZipcode($data['User']['zip']); $o_mailing->setCountry("USA"); $o_contact->setMailingAddress($o_mailing); $o_contact->setPhoneNumber($data['User']['phone']); $o_contact->setMobilePhoneNumber($data['User']['phone']); $o_contact->setEmail($data['User']['email']); $o_contact->setTitle("Property Manager"); // This 'new' call is not valid - causing fatal error - passing in DOB from applicaiton instead //$o_cal = new Calendar(); //$o_cal->getInstance(); //$o_cal->add( Calendar.YEAR, -60 ); //$o_bday = $o_cal->getTime(); $o_bday = $data['User']['dob'] . " 00:00:00"; $o_contact->setBirthdate($o_bday); $o_contact->setAuthorizedUser(true); $o_contact->setAccountSigner(true); $o_contact->setOwnershipPercentage(100); $o_contact->setSSN($data['User']['ssn']); $o_contact->setIsPrimary(true); $o_location->addPrincipalContact($o_contact); $o_ach_details = new ACHDetails(); $o_ach_details->setTransactionFee('3.95'); $o_ach_details->setAverageTicketAmount($property['average_rent']); $o_ach_details->setMaxSingleTransactionAmount($property['average_rent'] * 3); $o_ach_details->setAverageMonthlyAmount($property['num_units'] * floatval($property['average_rent'])); $o_ach_details->setMaxDailyAmount($property['num_units'] * floatval($property['average_rent']) * 3); $o_ach_details->setAuthMethodOnlinePercentage('100'); $o_ach_details->setCompanyNameDescriptor('Same_As_legal'); $o_ach_details->setDescriptor('RentSquare'); $o_ach_details->addSubmissionMethod('Online'); $o_ach_details->addPaymentToFrom(''); $o_ach_details->setMerchantReports('true'); $o_ach_details->setPaymentUrl('http://rentsquare.com'); $o_ach_details->setIssueCredits('true'); $o_ach_details->setIssueDebits('true'); $o_location->setACHDetails($o_ach_details); $o_bc_details = new BankCardDetails(); $o_bc_details->setAcceptAmex(false); $o_bc_details->addDebitBrandsRequested("Visa,MasterCard,Discover Network,Credit,Debit"); $o_bc_details->setFeeOther("ie Annual Fee collected in month 3"); //** Not Sure If this is RIGHT $o_bc_details->setAverageMonthlyVolume(urlencode(floatval($property['num_units']) * floatval($property['average_rent']))); $o_bc_details->setMaxTicket(150); $o_bc_details->setMaxMonthlyVolume(4000); $o_bc_details->setPaymentUrl("https://www.url.com/payment"); $o_bc_details->setRecurring(true); $o_bc_details->setRetrievalFee(7.5); $o_bc_details->setWirelessFee(5); $o_bc_details->setCardholderCharged(BankCardDetails::$XS_CARDHOLDER_CHARGED_PURCHASE); $o_bc_details->setCardholderDataStoredLocally(false); $o_bc_details->setPreviouslyTerminatedAsVisaMastercardMerchant(false); $o_bc_details->setVisaMastercardSignage(true); $o_bc_details->set3rdPartyAccessToCardholderData(false); $o_bc_details->setMailOrderPercentage(0); $o_bc_details->setTelephoneOrderPercentage(0); $o_bc_details->setDuplicates(false); $o_bc_details->setUnpaidItemFee(30); $o_bc_details->setAuthorizationFee(0.25); $o_location->setBankCardDetails($o_bc_details); $o_merch_app->addLocation($o_location); $o_bc = $o_bcpc->submitApplication($o_merch_app); try { foreach ($o_bc as $merchAppObj) { $status = $merchAppObj->getResponseCode(); $messages = $merchAppObj->getResponseMessages(); if ($status != "200") { return array($status, $messages); } } } catch (Exeption $e) { $status = 0; $messages = $e->getMessage(); return array($status, $messages); } } // end foreach return array(1, ''); }
/** * Sets the shipping address for this payment request * @param String $postalCode * @param String $street * @param String $number * @param String $complement * @param String $district * @param String $city * @param String $state * @param String $country */ public function setShippingAddress($postalCode = null, $street = null, $number = null, $complement = null, $district = null, $city = null, $state = null, $country = null) { $param = $postalCode; if ($this->shipping == null) { $this->shipping = new Shipping(); } if (is_array($param)) { $this->shipping->setAddress(new Address($param)); } elseif ($param instanceof Address) { $this->shipping->setAddress($param); } else { $address = new Address(); $address->setPostalCode($postalCode); $address->setStreet($street); $address->setNumber($number); $address->setComplement($complement); $address->setDistrict($district); $address->setCity($city); $address->setState($state); $address->setCountry($country); $this->shipping->setAddress($address); } }
protected function runPage() { if (WebRequest::wasPosted()) { if (!WebRequest::postInt("calroom")) { $this->showCal(); return; } $startdate = new DateTime(WebRequest::post("qbCheckin")); $enddate = new DateTime(WebRequest::post("qbCheckout")); $room = Room::getById(WebRequest::postInt("calroom")); for ($date = $startdate; $date < $enddate; $date->modify("+1 day")) { if (!$room->isAvailable($date)) { $this->error("room-not-available"); $this->showCal(); return; } } // search for customer if (!($customer = Customer::getByEmail(WebRequest::post("qbEmail")))) { $customer = new Customer(); $suTitle = WebRequest::post("qbTitle"); $suFirstname = WebRequest::post("qbFirstname"); $suLastname = WebRequest::post("qbLastname"); $suAddress = WebRequest::post("qbAddress"); $suCity = WebRequest::post("qbCity"); $suPostcode = WebRequest::post("qbPostcode"); $suCountry = WebRequest::post("qbCountry"); $suEmail = WebRequest::post("qbEmail"); $customer->setPassword($suEmail); // set values $customer->setTitle($suTitle); $customer->setFirstname($suFirstname); $customer->setSurname($suLastname); $address = new Address(); $address->setLine1($suAddress); $address->setCity($suCity); $address->setPostCode($suPostcode); $address->setCountry($suCountry); $address->save(); $customer->setAddress($address); $customer->setEmail($suEmail); // save it $customer->save(); $customer->sendMailConfirm(); // save it again $customer->save(); } $booking = new Booking(); $booking->setStartDate(WebRequest::post("qbCheckin")); $booking->setEndDate(WebRequest::post("qbCheckout")); $booking->setAdults(WebRequest::post("qbAdults")); $booking->setChildren(WebRequest::post("qbChildren")); $booking->setPromocode(WebRequest::post("qbPromoCode")); $booking->setRoom($room->getId()); $booking->setCustomer($customer->getId()); $booking->save(); $msg = Message::getMessage("booking-confirmation"); $msg = str_replace("\$1", $booking->getStartDate(), $msg); $msg = str_replace("\$2", $booking->getEndDate(), $msg); $msg = str_replace("\$3", $booking->getAdults(), $msg); $msg = str_replace("\$4", $booking->getChildren(), $msg); $msg = str_replace("\$5", $booking->getRoom()->getName(), $msg); Mail::send($customer->getEmail(), Message::getMessage("booking-confimation-subject"), $msg); $this->mSmarty->assign("content", $msg); return; } throw new YouShouldntBeDoingThatException(); }
function wc_autoship_taxnow_add_tax_rates($tax_rates, $schedule_id) { include_once WP_PLUGIN_DIR . '/taxnow_woo/taxnow-woo.class.php'; include_once WP_PLUGIN_DIR . '/woocommerce-autoship/classes/wc-autoship-schedule.php'; if (class_exists('class_taxNOW_woo') && class_exists('WC_Autoship_Schedule')) { // Create TaxNOW instance $taxnow_woo = new class_taxNOW_woo(); // Get autoship schedule $schedule = new WC_Autoship_Schedule($schedule_id); // Get autoship customer $customer = $schedule->get_customer(); // Create service $service = $taxnow_woo->create_service('TaxServiceSoap', false); $request = new GetTaxRequest(); $request->setDocDate(date('Y-m-d', current_time('timestamp'))); $request->setDocCode(''); $request->setCustomerCode($customer->get_email()); $request->setCompanyCode(get_option('tnwoo_company_code')); $request->setDocType(DocumentType::$SalesOrder); $request->setDetailLevel(DetailLevel::$Tax); $request->setCurrencyCode(get_option('woocommerce_currency')); $request->setBusinessIdentificationNo(get_option('tnwoo_business_vat_id')); // Origin address $origin = new Address(); $origin->setLine1(get_option('tnwoo_origin_street')); $origin->setCity(get_option('tnwoo_origin_city')); $origin->setRegion(get_option('tnwoo_origin_state')); $origin->setPostalCode(get_option('tnwoo_origin_zip')); $origin->setCountry(get_option('tnwoo_origin_country')); $request->setOriginAddress($origin); // Destination address $destination = new Address(); $destination->setLine1($customer->get('shipping_address_1')); $destination->setCity($customer->get('shipping_city')); $destination->setRegion($customer->get('shipping_state')); $destination->setPostalCode($customer->get('shipping_postcode')); $destination->setCountry($customer->get('shipping_country')); $request->setDestinationAddress($destination); // Lines items $items = $schedule->get_items(); $lines = array(); $global_tax_code = get_option('tnwoo_default_tax_code'); foreach ($items as $i => $item) { // Get WooCommerce product ID $product_id = $item->get_product_id(); // Create line item $line = new Line(); $line->setItemCode($product_id); $line->setDescription($product_id); $tax_code = get_post_meta($product_id, '_taxnow_taxcode', true); $line->setTaxCode(!empty($tax_code) ? $tax_code : $global_tax_code); $line->setQty((int) $item->get_quantity()); $line->setAmount((double) $item->get_autoship_price()); $line->setNo($i + 1); $line->setDiscounted(0); $lines[] = $line; } $request->setLines($lines); // Pretax discount $discount_pretax = 0.0; // Send request $taxnow_woo->log_add_entry('calculate_tax', 'request', $request); try { $response = $service->getTax($request); $taxnow_woo->log_add_entry('calculate_tax', 'response', $response); if ($response->getResultCode() == SeverityLevel::$Success) { foreach ($response->GetTaxLines() as $l => $TaxLine) { foreach ($TaxLine->getTaxDetails() as $d => $TaxDetail) { // Create WooCommerce tax rate $tax_rate = array('rate' => 100.0 * $TaxDetail->getRate(), 'label' => $TaxDetail->getTaxName(), 'shipping' => 'no', 'compound' => 'no'); $tax_rates["wc_autoship_taxnow_{$l}_{$d}"] = $tax_rate; } } } } catch (Exception $e) { $taxnow_woo->log_add_entry('calculate_tax', 'exception', $e->getMessage()); } } // Return tax rates return $tax_rates; }
function db_addAddress($input) { // Insert into DB $addressNew = new Address(); $addressNew->setAdd1($_POST['add1']); $addressNew->setAdd2($_POST['add2']); $addressNew->setAdd3($_POST['add3']); $addressNew->setCity($_POST['city']); $addressNew->setCounty($_POST['county']); $addressNew->setCountry($_POST['country']); $addressNew->setPostcode($_POST['postcode']); $addressNew->setTel($_POST['tel']); $addressNew->setMob($_POST['mob']); $addressNew->setFax($_POST['fax']); $addressNew->setEmail($_POST['email']); $addressNew->setWeb($_POST['web']); $addressNew->setFacebook($_POST['facebook']); $addressNew->setTwitter($_POST['twitter']); $addressNew->setLinkedin($_POST['linkedin']); $addsid = $addressNew->insertIntoDB(); return $addsid; }
public static function readTransaction($str_xml) { // Parser $parser = new xmlParser($str_xml); // <transaction> $data = $parser->getResult('transaction'); $transaction = new Transaction(); // <transaction> <lastEventDate> if (isset($data["lastEventDate"])) { $transaction->setLastEventDate($data["lastEventDate"]); } // <transaction> <date> if (isset($data["date"])) { $transaction->setDate($data["date"]); } // <transaction> <code> if (isset($data["code"])) { $transaction->setCode($data["code"]); } // <transaction> <reference> if (isset($data["reference"])) { $transaction->setReference($data["reference"]); } // <transaction> <type> if (isset($data["type"])) { $transaction->setType(new TransactionType($data["type"])); } // <transaction> <status> if (isset($data["status"])) { $transaction->setStatus(new TransactionStatus($data["status"])); } if (isset($data["paymentMethod"]) && is_array($data["paymentMethod"])) { // <transaction> <paymentMethod> $paymentMethod = new PaymentMethod(); // <transaction> <paymentMethod> <type> if (isset($data["paymentMethod"]['type'])) { $paymentMethod->setType(new PaymentMethodType($data["paymentMethod"]['type'])); } // <transaction> <paymentMethod> <code> if (isset($data["paymentMethod"]['code'])) { $paymentMethod->setCode(new PaymentMethodCode($data["paymentMethod"]['code'])); } $transaction->setPaymentMethod($paymentMethod); } // <transaction> <grossAmount> if (isset($data["grossAmount"])) { $transaction->setGrossAmount($data["grossAmount"]); } // <transaction> <discountAmount> if (isset($data["discountAmount"])) { $transaction->setDiscountAmount($data["discountAmount"]); } // <transaction> <feeAmount> if (isset($data["feeAmount"])) { $transaction->setFeeAmount($data["feeAmount"]); } // <transaction> <netAmount> if (isset($data["netAmount"])) { $transaction->setNetAmount($data["netAmount"]); } // <transaction> <extraAmount> if (isset($data["extraAmount"])) { $transaction->setExtraAmount($data["extraAmount"]); } // <transaction> <installmentCount> if (isset($data["installmentCount"])) { $transaction->setInstallmentCount($data["installmentCount"]); } if (isset($data["items"]['item']) && is_array($data["items"]['item'])) { $items = array(); $i = 0; if (isset($data["items"]['item'][0])) { foreach ($data["items"]['item'] as $key => $value) { $item = self::parseTransactionItem($value); $items[$i] = $item; $i++; } } else { $items[0] = self::parseTransactionItem($data["items"]['item']); } // <transaction> <items> $transaction->setItems($items); } if (isset($data["sender"])) { // <transaction> <sender> $sender = new Sender(); // <transaction> <sender> <name> if (isset($data["sender"]["name"])) { $sender->setName($data["sender"]["name"]); } // <transaction> <sender> <email> if (isset($data["sender"]["email"])) { $sender->setEmail($data["sender"]["email"]); } if (isset($data["sender"]["phone"])) { // <transaction> <sender> <phone> $phone = new Phone(); // <transaction> <sender> <phone> <areaCode> if (isset($data["sender"]["phone"]["areaCode"])) { $phone->setAreaCode($data["sender"]["phone"]["areaCode"]); } // <transaction> <sender> <phone> <number> if (isset($data["sender"]["phone"]["number"])) { $phone->setNumber($data["sender"]["phone"]["number"]); } $sender->setPhone($phone); } $transaction->setSender($sender); } if (isset($data["shipping"]) && is_array($data["shipping"])) { // <transaction> <shipping> $shipping = new Shipping(); // <transaction> <shipping> <type> if (isset($data["shipping"]["type"])) { $shipping->setType(new ShippingType($data["shipping"]["type"])); } // <transaction> <shipping> <cost> if (isset($data["shipping"]["cost"])) { $shipping->setCost($data["shipping"]["cost"]); } if (isset($data["shipping"]["address"]) && is_array($data["shipping"]["address"])) { // <transaction> <shipping> <address> $address = new Address(); // <transaction> <shipping> <address> <street> if (isset($data["shipping"]["address"]["street"])) { $address->setStreet($data["shipping"]["address"]["street"]); } // <transaction> <shipping> <address> <number> if (isset($data["shipping"]["address"]["number"])) { $address->setNumber($data["shipping"]["address"]["number"]); } // <transaction> <shipping> <address> <complement> if (isset($data["shipping"]["address"]["complement"])) { $address->setComplement($data["shipping"]["address"]["complement"]); } // <transaction> <shipping> <address> <city> if (isset($data["shipping"]["address"]["city"])) { $address->setCity($data["shipping"]["address"]["city"]); } // <transaction> <shipping> <address> <state> if (isset($data["shipping"]["address"]["state"])) { $address->setState($data["shipping"]["address"]["state"]); } // <transaction> <shipping> <address> <district> if (isset($data["shipping"]["address"]["district"])) { $address->setDistrict($data["shipping"]["address"]["district"]); } // <transaction> <shipping> <address> <postalCode> if (isset($data["shipping"]["address"]["postalCode"])) { $address->setPostalCode($data["shipping"]["address"]["postalCode"]); } // <transaction> <shipping> <address> <country> if (isset($data["shipping"]["address"]["country"])) { $address->setCountry($data["shipping"]["address"]["country"]); } $shipping->setAddress($address); } // <transaction> <shipping> $transaction->setShipping($shipping); } return $transaction; }
public function buildMerchants($xml) { $merchants = new Merchants(); $merchants->setPageOffset((string) $xml->PageOffset); $merchants->setTotalCount((string) $xml->TotalCount); // merchant $merchantArray = array(); foreach ($xml->Merchant as $merchant) { $tmpMerchant = new Merchant(); $tmpMerchant->setId((string) $merchant->Id); $tmpMerchant->setName((string) $merchant->Name); $tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl); $tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber); $tmpMerchant->setCategory((string) $merchant->Category); $tmpLocation = new Location(); $location = $merchant->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); // ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES> //$tmpAcceptance = new Acceptance(); //$acceptance = $merchant->Acceptance; // FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES> //$tmpFeatures = new Features(); //$features = $merchant->Features; $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpMerchant->setLocation($tmpLocation); array_push($merchantArray, $tmpMerchant); } $merchants->setMerchant($merchantArray); return $merchants; }
/** * Get User(s) * Return array of Person Model Objects * * @param * $ids of the userIds * @param * $profileDetails profile fields to fetched for the users * @param * $options other query options to get Users * @return * $ret array of person objects */ public function getPeople($ids, $profileDetails, $options) { $ret = array(); foreach ($ids as $id) { $user = array(); $res = db_query("SELECT * FROM {profile_values} INNER JOIN {profile_fields} ON {profile_values}.fid = {profile_fields}.fid WHERE uid =%d", $id); if ($res) { while ($row = db_fetch_array($res)) { $user[$row['name']] = $row['value']; $user['uid'] = $row['uid']; } if (!empty($user)) { $user_id = $user['uid']; $name = new Name($user['profile_fname'] . ' ' . $user['profile_lname']); $name->setGivenName($user['profile_fname']); $name->setFamilyName($user['profile_lname']); $address = new Address("UNSTRUCTUREDADDRESS"); $address->setLocality($user['profile_city']); $address->setCountry($user['profile_country']); $person = new Person($user['uid'], $name); $person->setAddresses(array($address)); $person->setNickname($user['profile_nickname']); $person->setProfileUrl($this->url_prefix . 'user/' . $user['uid']); $person->setDisplayName($user['profile_fname'] . ' ' . $user['profile_lname']); $res = db_query("SELECT picture FROM {users} WHERE uid = %d", $id); $row = db_fetch_array($res); $person->setThumbnailUrl(!empty($row['picture']) ? $this->url_prefix . $row['picture'] : ''); if (strtolower($user['profile_gender']) == 'female') { $person->setGender('FEMALE'); } else { $person->setGender('MALE'); } $ret[$user_id] = $person; } } } //Invoke hook_people_alter() implementations $this->drupalAlter('people', $ret, $profileDetails, $options); return $ret; }
function CreateAccount($merchantAccountId, $email) { $account = new Account(); $account->setName('Migrated Customer'); $account->setMerchantAccountId($merchantAccountId); // Be conscious that using real email addresses in ProdTest depending on configuration will // have live emails triggered and sent on billing events for the Account. // It is recommended that when testing in ProdTest be certain to mask real email addresses. $account->setEmailAddress($email); $account->setEmailTypePreference('html'); $account->setWarnBeforeAutoBilling(true); $anyOtherHelpfulDataForCSRsWhenLookingUpAccount = new NameValuePair(); $anyOtherHelpfulDataForCSRsWhenLookingUpAccount->setName('HelpfulData'); $anyOtherHelpfulDataForCSRsWhenLookingUpAccount->setValue('BestCustomerEver'); $account->setNameValues(array($anyOtherHelpfulDataForCSRsWhenLookingUpAccount)); $address = new Address(); $address->setAddr1('303 Twin Dolphin Drive'); $address->setAddr2('Suite 200'); $address->setCity('Redwood City'); $address->setDistrict('CA'); $address->setPostalCode('94065'); $address->setCountry('US'); $address->setPhone('123-456-7890'); $srd = ''; $account->setShippingAddress($address); $response = $account->update($srd); // Log soap id for each API call. // $log->addDebug('Method = Account.update' . PHP_EOL); // $log->addDebug('Soap Id = ' . $response['data']->return->soapId . PHP_EOL); // $log->addDebug('Return Code = ' . $response['returnCode'] . PHP_EOL); // $log->addDebug('Return String = ' . $response['returnString'] . PHP_EOL); if ($response['returnCode'] == 200) { print "Call succeeded" . PHP_EOL; } else { print "Call failed" . PHP_EOL; print_r($response); } }
$parentID = $argv[1]; print "parent: {$parentID} \n"; $name = "Child One"; $addr1 = "19 Davis Dr"; $city = "Belmont"; $state = "CA"; $postalcode = "94002"; $country = "US"; $email = "childAccount" . rand(10000, 99999) . "@vindicia.com"; $address = new Address(); $address->setName($name); $address->setAddr1($addr1); $address->setCity($city); $address->setDistrict($state); $address->setPostalCode($postalcode); $address->setCountry($country); $accountID = "childAccount" . rand(1000, 9999) . "-" . rand(1000, 999999); $child1 = new Account(); $child1->setMerchantAccountId($accountID); $child1->setEmailAddress($email); $child1->setShippingAddress($address); $child1->setEmailTypePreference('html'); $child1->setWarnBeforeAutoBilling(false); $child1->setName($name); $parent = new Account(); $parent->setMerchantAccountId($parentID); // use the force flag to remove these children from a previous parent // and assign them to this new one //$force=true; $force = false; // use payerReplace to determine if any existing autobills of these children