当前位置: 首页>>代码示例>>PHP>>正文


PHP Address::Save方法代码示例

本文整理汇总了PHP中Address::Save方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::Save方法的具体用法?PHP Address::Save怎么用?PHP Address::Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address::Save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SetAsCurrentAddress

 /**
  * Sets the address record as the "Current" address, and all others as "Previous"
  * Address MUST be associated with the household or this will throw an exception
  * @param Address $objCurrentAddress
  * @return void
  */
 public function SetAsCurrentAddress(Address $objCurrentAddress)
 {
     if ($objCurrentAddress->HouseholdId != $this->intId) {
         throw new QCallerException('Address does not belong to this Household');
     }
     // Get any home address and home phone records for this household (and any from-split households)
     $intAddressIdArray = array();
     $intPhoneIdArray = array();
     foreach ($this->GetAddressArray() as $objAddress) {
         if ($objAddress->Id != $objCurrentAddress->Id && $objAddress->CurrentFlag) {
             $objAddress->CurrentFlag = false;
             $objAddress->Save();
         }
         $intAddressIdArray[$objAddress->Id] = true;
         foreach ($objAddress->GetPhoneArray() as $objPhone) {
             $intPhoneIdArray[$objPhone->Id] = true;
         }
     }
     // Add any old HomeAddresses from previous households
     foreach ($this->GetHouseholdSplitAsSplitArray() as $objHouseholdSplit) {
         foreach ($objHouseholdSplit->Household->GetAddressArray() as $objAddress) {
             $intAddressIdArray[$objAddress->Id] = true;
             foreach ($objAddress->GetPhoneArray() as $objPhone) {
                 $intPhoneIdArray[$objPhone->Id] = true;
             }
         }
     }
     if (!$objCurrentAddress->CurrentFlag) {
         $objCurrentAddress->CurrentFlag = true;
         $objCurrentAddress->Save();
     }
     // Update "MailingAddress" and "StewardshipAddress" info for HouseholdParticipants
     // Update "PrimaryAddressText" info for HouseholdParticipants
     foreach ($this->GetHouseholdParticipationArray(QQ::Expand(QQN::HouseholdParticipation()->Person->Id)) as $objHouseholdParticipation) {
         $objPerson = $objHouseholdParticipation->Person;
         if (array_key_exists($objPerson->MailingAddressId, $intAddressIdArray)) {
             $objPerson->MailingAddress = $objCurrentAddress;
         }
         if (array_key_exists($objPerson->StewardshipAddressId, $intAddressIdArray)) {
             $objPerson->StewardshipAddress = $objCurrentAddress;
         }
         if (array_key_exists($objPerson->PrimaryPhoneId, $intPhoneIdArray)) {
             $objPerson->PrimaryPhone = $objCurrentAddress->PrimaryPhone;
         }
         $objPerson->RefreshPrimaryContactInfo();
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:53,代码来源:Household.class.php

示例2: GenerateAddressesAndPhonesForPerson

 protected static function GenerateAddressesAndPhonesForPerson(Person $objPerson)
 {
     $intAddressCount = rand(0, 5);
     for ($i = 0; $i < $intAddressCount; $i++) {
         $objAddress = new Address();
         $objAddress->AddressTypeId = QDataGen::GenerateFromArray(array_keys(AddressType::$NameArray));
         $objAddress->Person = $objPerson;
         $objAddress->Address1 = QDataGen::GenerateStreetAddress();
         if (rand(0, 1)) {
             $objAddress->Address2 = QDataGen::GenerateAddressLine2();
         }
         $objAddress->City = QDataGen::GenerateCity();
         $objAddress->State = QDataGen::GenerateUsState();
         $objAddress->ZipCode = rand(10000, 99999);
         $objAddress->Country = 'US';
         $objAddress->InvalidFlag = false;
         $objAddress->VerificationCheckedFlag = true;
         switch ($objAddress->AddressTypeId) {
             case AddressType::Temporary:
                 $objAddress->CurrentFlag = true;
                 $dttNextYear = QDateTime::Now();
                 $dttNextYear->Year++;
                 $objAddress->DateUntilWhen = QDataGen::GenerateDateTime(QDateTime::Now(), $dttNextYear);
                 break;
             default:
                 $objAddress->CurrentFlag = rand(0, 1);
                 break;
         }
         $objAddress->Save();
     }
     $intPhoneCount = rand(0, 5);
     $objPhoneArray = array();
     for ($i = 0; $i < $intPhoneCount; $i++) {
         $objPhone = new Phone();
         $objPhone->PhoneTypeId = QDataGen::GenerateFromArray(array_keys(PhoneType::$NameArray));
         while ($objPhone->PhoneTypeId == PhoneType::Home) {
             $objPhone->PhoneTypeId = QDataGen::GenerateFromArray(array_keys(PhoneType::$NameArray));
         }
         $objPhone->Number = QDataGen::GeneratePhone();
         $objPhone->Person = $objPerson;
         $objPhone->Save();
         $objPhoneArray[] = $objPhone;
     }
     if ($intPhoneCount && !rand(0, 2)) {
         QDataGen::GenerateFromArray($objPhoneArray)->SetAsPrimary();
     }
     $intEmailCount = rand(0, 5);
     $objEmailArray = array();
     for ($i = 0; $i < $intEmailCount; $i++) {
         $objEmail = new Email();
         $objEmail->Address = QDataGen::GenerateEmail($objPerson->FirstName, $objPerson->LastName);
         $objEmail->Person = $objPerson;
         $objEmail->Save();
         $objEmailArray[] = $objEmail;
     }
     if ($intEmailCount && !rand(0, 2)) {
         QDataGen::GenerateFromArray($objEmailArray)->SetAsPrimary();
     }
     $intMaxId = OtherContactMethod::CountAll();
     for ($intOtherContactMethodId = 1; $intOtherContactMethodId <= $intMaxId; $intOtherContactMethodId++) {
         if (!rand(0, 2)) {
             $objContactInfo = new OtherContactInfo();
             $objContactInfo->Person = $objPerson;
             $objContactInfo->OtherContactMethodId = $intOtherContactMethodId;
             $objContactInfo->Value = QDataGen::GenerateUsername($objPerson->FirstName, $objPerson->LastName);
             $objContactInfo->Save();
         }
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:69,代码来源:datagen.cli.php

示例3: CopyForPerson

 /**
  * Given an Address record -- copy it and assign it to the specified Person.
  * 
  * This is typically used to take a HomeAddress record for a Household and to resassign it
  * as a previous home address for each member of a household that is being merged with another household.
  * 
  * ANY LINKED PHONE NUMBERS WILL BE LOST. 
  * 
  * This will return the new address record that is now linked to the Person.
  * @param Person $objPerson 
  * @param integer $intAddressTypeId
  * @param boolean $blnCurrentFlag
  * @return Address
  */
 public function CopyForPerson(Person $objPerson, $intAddressTypeId, $blnCurrentFlag)
 {
     $objAddress = new Address();
     $objAddress->AddressTypeId = $intAddressTypeId;
     $objAddress->Person = $objPerson;
     $objAddress->Address1 = $this->Address1;
     $objAddress->Address2 = $this->Address2;
     $objAddress->Address3 = $this->Address3;
     $objAddress->City = $this->City;
     $objAddress->State = $this->State;
     $objAddress->ZipCode = $this->ZipCode;
     $objAddress->Country = $this->Country;
     $objAddress->CurrentFlag = $blnCurrentFlag;
     $objAddress->InvalidFlag = $this->InvalidFlag;
     $objAddress->Save();
     return $objAddress;
 }
开发者ID:alcf,项目名称:chms,代码行数:31,代码来源:Address.class.php

示例4: SetAsPrimary

 /**
  * This will set this phone object as the "primary" phone number for (if associated to an address) the address
  * or (if associated to a person) the person.
  * 
  * Alternatively, if the phone is associated with the address (e.g. a home phone), you can explicitly
  * pass in a Person in that house to set as "primary" for that person.
  * 
  * This will automatically UNSET as primary any current-primary phone (if applicable)
  * @return void
  */
 public function SetAsPrimary(Person $objPerson = null, Address $objAddress = null)
 {
     if ($objPerson) {
         if ($this->PersonId != $objPerson->Id && (!$this->Address || !$this->Address->Household || !HouseholdParticipation::LoadByPersonIdHouseholdId($objPerson->Id, $this->Address->HouseholdId))) {
             throw new QCallerException('Cannot set as primary phone for person not in the household for this address');
         }
         $objPerson->PrimaryPhone = $this;
         $objPerson->Save();
         $objPerson->RefreshPrimaryContactInfo();
     } else {
         if ($objAddress) {
             if ($objAddress->Id != $this->intAddressId) {
                 throw new QCallerException('Cannot set as primary phone for home address that does not own this phone object');
             }
             $objAddress->PrimaryPhone = $this;
             $objAddress->Save();
         } else {
             if ($this->Address) {
                 $this->Address->PrimaryPhone = $this;
                 $this->Address->Save();
             } else {
                 $this->Person->PrimaryPhone = $this;
                 $this->Person->Save();
                 $this->Person->RefreshPrimaryContactInfo();
             }
         }
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:38,代码来源:Phone.class.php

示例5: Create

 /**
  * API Method inserts a new Address record and render response as JSON
  */
 public function Create()
 {
     try {
         $json = json_decode(RequestUtil::GetBody());
         if (!$json) {
             throw new Exception('The request body does not contain valid JSON');
         }
         $address = new Address($this->Phreezer);
         // TODO: any fields that should not be inserted by the user should be commented out
         // this is an auto-increment.  uncomment if updating is allowed
         // $address->Idaddress = $this->SafeGetVal($json, 'idaddress');
         $address->City = $this->SafeGetVal($json, 'city');
         $address->Contact = $this->SafeGetVal($json, 'contact');
         $address->Street = $this->SafeGetVal($json, 'street');
         $address->Number = $this->SafeGetVal($json, 'number');
         $address->Complement = $this->SafeGetVal($json, 'complement');
         $address->Zipcode = $this->SafeGetVal($json, 'zipcode');
         $address->Otherinformation = $this->SafeGetVal($json, 'otherinformation');
         $address->Validate();
         $errors = $address->GetValidationErrors();
         if (count($errors) > 0) {
             $this->RenderErrorJSON('Please check the form for errors', $errors);
         } else {
             $address->Save();
             $this->RenderJSON($address, $this->JSONPCallback(), true, $this->SimpleObjectParams());
         }
     } catch (Exception $ex) {
         $this->RenderExceptionJSON($ex);
     }
 }
开发者ID:arianestolfi,项目名称:digital,代码行数:33,代码来源:AddressController.php

示例6: SaveAddresses

 public function SaveAddresses($addresses)
 {
     if ($this->isAddress == true) {
         $this->DeleteAddresses();
         if (is_array($addresses)) {
             foreach ($addresses as $key => $add) {
                 $address = new Address();
                 $address->person = $this->person_record_number;
                 $address->address_record_number = shn_create_uuid('address');
                 $address->address_type = $addresses[$key]['address_type'];
                 $address->address = $addresses[$key]['address'];
                 $address->country = $addresses[$key]['country'];
                 $address->phone = $addresses[$key]['phone'];
                 $address->cellular = $addresses[$key]['cellular'];
                 $address->fax = $addresses[$key]['fax'];
                 $address->email = $addresses[$key]['email'];
                 $address->web = $addresses[$key]['web'];
                 $address->start_date = $addresses[$key]['start_date'];
                 $address->end_date = $addresses[$key]['end_date'];
                 $address->Save();
             }
         }
     }
 }
开发者ID:GeraldScott,项目名称:OpenEvSys,代码行数:24,代码来源:Person.php


注:本文中的Address::Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。