public function testapi()
 {
     $o_bcpc = new BaseCommerceClient(RENTSQUARE_MERCH_USER, RENTSQUARE_MERCH_PASS, RENTSQUARE_MERCH_KEY);
     $o_bcpc->setSandbox(BC_SANDBOXVALUE);
     $o_address = new Address();
     $o_address->setName(Address::$XS_ADDRESS_NAME_BILLING);
     $o_address->setLine1("123 Some Address");
     $o_address->setCity("Tempe");
     $o_address->setState("AZ");
     $o_address->setZipcode("12345");
     $o_bc = new BankCard();
     $o_bc->setBillingAddress($o_address);
     $o_bc->setExpirationMonth("02");
     $o_bc->setExpirationYear("2015");
     $o_bc->setName("Nick 2");
     $o_bc->setNumber("4111111111111111");
     $o_bc->setToken("myToken12asdfas3");
     $o_bc = $o_bcpc->addBankCard($o_bc);
     if ($o_bc->isStatus(BankCard::$XS_BC_STATUS_FAILED)) {
         //the add Failed, look at messages array for reason(s) why
         //var_dump( $o_bc->getMessages() );
         $this->set('message', $o_bc->getMessages());
     } else {
         if ($o_bc->isStatus(BankCard::$XS_BC_STATUS_ACTIVE)) {
             //Card added successfully
             //var_dump( $o_bc->getToken() );
             $this->set('message', $o_bc->getToken());
         }
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
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;
}
예제 #4
0
 /**
  * @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);
 }
예제 #5
0
 public function validate($street, $zip, $apartment = false, $city = false, $state = false)
 {
     $verify = new AddressVerify($this->config['username']);
     $address = new Address();
     $address->setFirmName(null);
     $address->setApt($apartment);
     $address->setAddress($street);
     $address->setCity($city);
     $address->setState($state);
     $address->setZip5($zip);
     $address->setZip4('');
     // Add the address object to the address verify class
     $verify->addAddress($address);
     // Perform the request and return result
     $val1 = $verify->verify();
     $val2 = $verify->getArrayResponse();
     // var_dump($verify->isError());
     // See if it was successful
     if ($verify->isSuccess()) {
         return ['address' => $val2['AddressValidateResponse']['Address']];
     } else {
         return ['error' => $verify->getErrorMessage()];
     }
 }
예제 #6
0
 /**
  * 
  * 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;
 }
예제 #7
0
 /**
  * Populates the Venue object from the request
  * @return bean Venue
  */
 private function getBeanFromRequest()
 {
     $venue = new Venue();
     $addr = new Address();
     $addr->setOid($_REQUEST['aoid']);
     $addr->setStreet($_REQUEST['street']);
     $addr->setUnit($_REQUEST['unit']);
     $addr->setCity($_REQUEST['city']);
     $addr->setState($_REQUEST['state']);
     $addr->setPostalCode($_REQUEST['postalCode']);
     $addr->setPhone($_REQUEST['phone']);
     $venue->setOid($_REQUEST['oid']);
     $venue->setName($_REQUEST['name']);
     $venue->setDescription($_REQUEST['description']);
     $venue->setPubState($_REQUEST['pubState']);
     $venue->setAddress($addr);
     if (isset($_REQUEST['gallery'])) {
         $venue->setGallery($_REQUEST['gallery']);
     }
     $links = array();
     //$links['exhibition'] = $_REQUEST['exhibition'];
     //$links['program'] = isset($_REQUEST['program']) ? $_REQUEST['program'] : null;
     //$links['course'] = isset($_REQUEST['course']) ? $_REQUEST['course'] : null;
     $venue->setEvents($links);
     return $venue;
 }
예제 #8
0
 /**
  * @todo Implement testSetState().
  */
 public function testSetState()
 {
     $this->object->setState(8);
     $this->assertEquals($this->object->getState(), 8);
 }
예제 #9
0
 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);
     }
 }
예제 #11
0
 public static function getAddresses($where = null)
 {
     $dados = Database::ReadAll("address a, city c, state s", "a.*, c.*, s.*", "WHERE a.id_city = c.id_city AND s.id_state = c.id_state " . $where);
     if (!$dados) {
         return '';
     }
     foreach ($dados as $dado) {
         $address = new Address();
         $address->setId($dado['ID_ADDRESS']);
         $address->setStreet($dado['NAME_ADDRESS']);
         $address->setNumber($dado['NUMBER']);
         $address->setComplement($dado['COMPLEMENT']);
         $address->setDistrict($dado['DISTRICT']);
         $address->setLatitude($dados['LATITUDE']);
         $address->setLongitude($dados['LONGITUDE']);
         $address->setCity($dado['NAME_CITY']);
         $address->setState($dado['INITIALS']);
         $address->setPs($dado['PS']);
         $addresses[] = $address;
     }
     return $addresses;
 }
예제 #12
0
 /**
  * @expectedException NfeFocus\Exception\FieldRequiredException
  */
 public function testInvalidState()
 {
     $state = 'São Paulo';
     $address = new Address();
     $address->setState($state);
 }
 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;
 }
예제 #14
0
파일: User.php 프로젝트: anas/feedstore
 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;
 }
예제 #15
0
 public function testSetStateWorks()
 {
     $address = new Address();
     $address->setState('RS');
     $this->assertEquals('RS', $address->getState());
 }