예제 #1
0
파일: Person.class.php 프로젝트: alcf/chms
 /**
  * Given a home (and optional mailing) address validator (which is unlinked from any db entry), go ahead and make updates
  * to this person record accordingly.
  * 
  * If this person is part of multiple households, it will throw an error.
  * 
  * If this person is part of one household, it will update the information for the household.
  * 
  * If this person is not part of any houseold, it will create one for him/her.
  * 
  * @param AddressValidator $objHomeAddressValidator
  * @param AddressValidator $objMailingAddressValidator optional
  * @param string $strHomePhone optional
  */
 public function UpdateAddressInformation(AddressValidator $objHomeAddressValidator, AddressValidator $objMailingAddressValidator = null, $strHomePhone = null)
 {
     $objHouseholdArray = array();
     foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
         $objHouseholdArray[] = $objHouseholdParticipation->Household;
     }
     // Figure Out Household Information
     if (count($objHouseholdArray) > 1) {
         throw new QCallerException('Cannot call UpdateAddressInformation on a person who is part of multiple households: ' . $this->intId);
     }
     if (count($objHouseholdArray)) {
         $objHousehold = $objHouseholdArray[0];
     } else {
         $objHousehold = Household::CreateHousehold($this);
     }
     // Home Address
     $objHomeAddress = $objHousehold->GetCurrentAddress();
     $objAddress = $objHomeAddressValidator->CreateAddressRecord();
     // Are we using the existing Household CurrentAddress record?
     if ($objHomeAddress && $objHomeAddress->IsEqualTo($objAddress)) {
         // Yes -- so all we're handling is the phones
         $objHomePhoneArray = $objHomeAddress->GetPhoneArray();
         // Are we setting a home phone?
         if ($strHomePhone) {
             // Try and find the phone within the array
             foreach ($objHomePhoneArray as $objPhone) {
                 $blnFound = false;
                 if ($objPhone->Number == $strHomePhone) {
                     $objPhone->SetAsPrimary(null, $objHomeAddress);
                     $blnFound = true;
                 }
             }
             // If we didn't find an existing home phone, we will update the current primary (if applicable)
             // Or create a new one as primary
             if (!$blnFound) {
                 if (count($objHomePhoneArray)) {
                     $objHomePhoneArray[0]->Number = $strHomePhone;
                     $objHomePhoneArray[0]->Save();
                 } else {
                     $objPhone = new Phone();
                     $objPhone->Number = $strHomePhone;
                     $objPhone->Address = $objHomeAddress;
                     $objPhone->PhoneTypeId = PhoneType::Home;
                     $objPhone->Save();
                     $objPhone->SetAsPrimary(null, $objHomeAddress);
                 }
             }
             // Nope - we are deleting the home phone
         } else {
             foreach ($objHomePhoneArray as $objPhone) {
                 $objPhone->Delete();
             }
         }
         // Not an existing Household CurrentAddress record that matches -- so we are creating a new one
     } else {
         $objAddress->Household = $objHousehold;
         $objAddress->CurrentFlag = true;
         $objAddress->AddressTypeId = AddressType::Home;
         $objAddress->Save();
         $objHousehold->SetAsCurrentAddress($objAddress);
         // Add the phone if applicable
         if ($strHomePhone) {
             $objPhone = new Phone();
             $objPhone->Number = $strHomePhone;
             $objPhone->Address = $objAddress;
             $objPhone->PhoneTypeId = PhoneType::Home;
             $objPhone->Save();
             $objPhone->SetAsPrimary(null, $objAddress);
         }
     }
     // Mailing Address?
     if ($objMailingAddressValidator) {
         $objAddress = $objMailingAddressValidator->CreateAddressRecord();
         $blnFound = false;
         foreach ($this->GetAllAssociatedAddressArray($objHousehold) as $objExistingAddress) {
             if ($objExistingAddress->IsEqualTo($objAddress)) {
                 $this->MailingAddress = $objExistingAddress;
                 $this->RefreshPrimaryContactInfo();
                 $blnFound = true;
             }
         }
         if (!$blnFound) {
             $objAddress->AddressTypeId = AddressType::Other;
             $objAddress->Person = $this;
             $objAddress->CurrentFlag = true;
             $objAddress->Save();
             $this->MailingAddress = $objAddress;
             $this->RefreshPrimaryContactInfo();
         }
     } else {
         if ($this->MailingAddress) {
             $this->MailingAddress = null;
             $this->RefreshPrimaryContactInfo();
         }
     }
 }
예제 #2
0
파일: new.php 프로젝트: alcf/chms
 protected function btnSave_Click()
 {
     // Perform USPS Validation (if applicable)
     if (trim($this->txtCity->Text) && !$this->chkInvalidFlag->Checked) {
         $objAddressValidator = new AddressValidator($this->txtAddress1->Text, $this->txtAddress2->Text, $this->txtCity->Text, $this->lstState->SelectedValue, $this->txtZipCode->Text);
         $objAddressValidator->ValidateAddress();
         if ($objAddressValidator->AddressValidFlag) {
             $this->txtAddress1->Text = $objAddressValidator->PrimaryAddressLine;
             $this->txtAddress2->Text = $objAddressValidator->SecondaryAddressLine;
             $this->txtCity->Text = $objAddressValidator->City;
             $this->lstState->SelectedValue = $objAddressValidator->State;
             $this->txtZipCode->Text = $objAddressValidator->ZipCode;
             $this->dlgMessage->HideDialogBox();
         } else {
             $this->dlgMessage->MessageHtml = '<p style="font-weight: bold;">This address is considered invalid with the USPS.</p><p style="font-size: 13px; color: #999;">Please make corrections or select <strong>"this is an INVALID address"</strong>.</p>';
             $this->dlgMessage->AddButton('Okay', MessageDialog::ButtonPrimary, 'dlgMessage_Reset');
             $this->dlgMessage->ShowDialogBox();
             return;
         }
     }
     $this->SavePerson();
     $this->SaveMembership();
     $this->SaveMarriage();
     $this->SaveAttribute();
     $this->AddToChurchEmailList();
     $this->mctPerson->Person->RefreshPrimaryContactInfo(true);
     if ($this->mctSpouse->Person->Id) {
         $this->mctSpouse->Person->RefreshPrimaryContactInfo(true);
     }
     if ($objHousehold = Household::LoadByHeadPersonId($this->mctPerson->Person->Id)) {
         $objHousehold->RefreshMembers();
     }
     $this->RedirectBack(true);
 }
예제 #3
0
파일: Address.class.php 프로젝트: alcf/chms
 /**
  * Validate this address against the USPS.
  * @ return boolean whether or not the address validated
  */
 public function ValidateUsps()
 {
     $objValidator = new AddressValidator($this->strAddress1, $this->strAddress2, $this->strCity, $this->strState, $this->strZipCode);
     $objValidator->ValidateAddress();
     if ($objValidator->AddressValidFlag) {
         $this->strAddress1 = $objValidator->PrimaryAddressLine;
         $this->strAddress2 = $objValidator->SecondaryAddressLine;
         $this->strCity = $objValidator->City;
         $this->strState = $objValidator->State;
         $this->strZipCode = $objValidator->ZipCode;
         $this->blnVerificationCheckedFlag = true;
         $this->blnInvalidFlag = false;
         $this->Save();
         return true;
     } else {
         return false;
     }
 }
예제 #4
0
파일: index.php 프로젝트: alcf/chms
 /**
  * Called back from PaymentPanel to actually generate a PaymentObject
  * or in this case, a OnlineDonation entry.
  * @return OnlineDonation
  */
 public function CreatePaymentObject()
 {
     // Create the PaymentObject
     $objPaymentObject = new OnlineDonation();
     // Person we attach is either the Login Record
     if (QApplication::$PublicLogin) {
         $objPaymentObject->Person = QApplication::$PublicLogin->Person;
     } else {
         $objAddressValidator = new AddressValidator($this->pnlPayment->txtAddress1->Text, $this->pnlPayment->txtAddress2->Text, $this->pnlPayment->txtCity->Text, $this->pnlPayment->lstState->SelectedValue, $this->pnlPayment->txtZipCode->Text);
         $objAddressValidator->ValidateAddress();
         $objAddress = $objAddressValidator->CreateAddressRecord();
         $objPaymentObject->AttachPersonWithInformation($this->pnlPayment->txtFirstName->Text, $this->pnlPayment->txtLastName->Text, $objAddress);
     }
     return $objPaymentObject;
 }
<?php

require_once __DIR__ . '/anymap/AddressValidator.php';
try {
    $validator = new AddressValidator(array(), 'http://webservices.anymap.be/wsdl/anymap/Geocoder.wsdl');
    $validator->init('nl');
    $city = 'Leuven';
    $country = 'be';
    $house_number = '43';
    $post_code = '3000';
    $street = 'Vanden Tymplestraat';
    #    $city         = 'Gruitrode'  ;
    #    $country      = 'be'         ;
    #    $house_number = '9'          ;
    #    $post_code    = '3670'       ;
    #    $street       = 'Snepstraat' ;
    if ($validator->validate($city, $country, $house_number, $post_code, $street)) {
        echo "ok\n";
    } else {
        echo "NOK\n";
    }
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
예제 #6
0
         $timePeriod = 30 * 24 * 60 * 60;
         break;
     case 4:
         // quarterly
         $timePeriod = 4 * 30 * 24 * 60 * 60;
         break;
 }
 print sprintf("today is: %s\n", date('Y-m-d', time()));
 $checkTime = strtotime($startDate);
 while ($checkTime < strtotime($objRecurringPayment->EndDate)) {
     if (date('Y-m-d', $checkTime) == date('Y-m-d', time())) {
         print "TODAYS THE DAY. MAKE A PAYMENT!\n";
         /**************/
         // Create the Payment Object
         $objPaymentObject = new OnlineDonation();
         $objAddressValidator = new AddressValidator($objCrypto->Decrypt($objRecurringPayment->Address1), $objCrypto->Decrypt($objRecurringPayment->Address2), $objCrypto->Decrypt($objRecurringPayment->City), $objRecurringPayment->State, $objCrypto->Decrypt($objRecurringPayment->Zip));
         $objAddressValidator->ValidateAddress();
         $objAddress = $objAddressValidator->CreateAddressRecord();
         $namearray = explode(' ', $objCrypto->Decrypt($objRecurringPayment->CardHolderName));
         $objPaymentObject->AttachPersonWithInformation($namearray[0], $namearray[1], $objAddress);
         $objPaymentObject->IsRecurringFlag = true;
         $objPaymentObject->RecurringPaymentId = $objRecurringPayment->Id;
         $mixReturn = CreditCardPayment::PerformAuthorization($objPaymentObject, null, $namearray[0], $namearray[1], $objAddress, $objRecurringPayment->Amount, $objCrypto->Decrypt($objRecurringPayment->AccountNumber), $objRecurringPayment->ExpirationDate, $objCrypto->Decrypt($objRecurringPayment->SecurityCode), $objRecurringPayment->CreditCardTypeId);
         // Success?
         if ($mixReturn instanceof CreditCardPayment) {
             print "Successful scheduling of payment.\n";
             $objPaymentObject->Status = true;
             $intDonationId = $objPaymentObject->Save();
             $strPaymentItems = '';
             $objDonationItems = RecurringDonationItems::LoadArrayByRecurringDonationId($objRecurringPayment->RecurringDonationAsRecurringPayment->Id);
             foreach ($objDonationItems as $objDonationItem) {