/** * Updates an existing PropertyLease. * * @param Model_Referencing_PropertyLease * The property lease details to update in the datasource. * * @return void */ public function updatePropertyLease($propertyLease) { if (empty($propertyLease->address)) { $addressId = null; } else { //Obtain the addressId for storage in this datasource. $addressId = $propertyLease->address->id; //Update linked type. $addressDatasource = new Datasource_Core_Addresses(); $addressDatasource->updateAddress($propertyLease->address); } $data = array('address_id' => $addressId, 'monthly_rent' => empty($propertyLease->rentPerMonth) ? null : $propertyLease->rentPerMonth->getValue(), 'start_date' => empty($propertyLease->tenancyStartDate) ? null : $propertyLease->tenancyStartDate->toString(Zend_Date::ISO_8601), 'term' => empty($propertyLease->tenancyTerm) ? null : $propertyLease->tenancyTerm, 'no_of_tenants' => empty($propertyLease->noOfTenants) ? 1 : $propertyLease->noOfTenants); $where = $this->quoteInto('id = ?', $propertyLease->id); $this->update($data, $where); }
/** * Updates an existing OccupationalReferee in the datasource. * * @param Model_Referencing_OccupationalReferee * The OccupationalReferee to update. * * @return void */ public function updateReferee($occupationalReferee) { if (empty($occupationalReferee)) { return; } //Update linked name details, if given. if (empty($occupationalReferee->name)) { $nameId = null; } else { //Obtain the $nameId for storage in this datasource. $nameId = $occupationalReferee->name->id; //Update linked type. $namesDatasource = new Datasource_Core_Names(); $namesDatasource->updateName($occupationalReferee->name); } //Update linked contact details, if given. if (empty($occupationalReferee->contactDetails)) { $contactId = null; } else { //Obtain the $contactId for storage in this datasource. $contactId = $occupationalReferee->contactDetails->id; //Update linked type. $contactDatasource = new Datasource_Core_ContactDetails(); $contactDatasource->updateContactDetails($occupationalReferee->contactDetails); } //Update linked address details, if given. if (empty($occupationalReferee->address)) { $addressId = null; } else { //Obtain the $addressId for storage in this datasource. $addressId = $occupationalReferee->address->id; //Update linked type. $addressDatasource = new Datasource_Core_Addresses(); $addressDatasource->updateAddress($occupationalReferee->address); } //Update... $data = array('name_id' => empty($occupationalReferee->name) ? null : $occupationalReferee->name->id, 'contact_id' => empty($occupationalReferee->contactDetails) ? null : $occupationalReferee->contactDetails->id, 'address_id' => empty($occupationalReferee->address) ? null : $occupationalReferee->address->id, 'referee_position' => $occupationalReferee->position, 'organisation_name' => $occupationalReferee->organisationName); $where = $this->quoteInto('occupation_id = ?', $occupationalReferee->occupationId); $this->update($data, $where); }