Beispiel #1
0
 /**
  * Add contents insurance to the quote
  *
  * @param boolean furnished True or False depending on whether the property is furnished
  * @param string accidentalDamage Add accidental damage cover?
  * @param int coverAmount The amount to be insured (optional!)
  * @param int excess The chosen excess (optional!)
  */
 public function addContentsCover($furnished, $accidentalDamage = null, $coverAmount = null, $excess = null)
 {
     // Check to see if the product is already added to this quote - if it is remove it
     if ($this->hasProduct(self::UNFURNISHED_CONTENTS_COVER)) {
         $this->removeProduct(self::UNFURNISHED_CONTENTS_COVER);
     }
     if ($this->hasProduct(self::CONTENTS_COVER)) {
         $this->removeProduct(self::CONTENTS_COVER);
     }
     // Remove any emergency assistance that may be on the quote as you get that for free
     if ($this->hasProduct(self::EMERGENCY_ASSISTANCE) && !$this->hasProduct(self::BUILDING_COVER)) {
         $this->removeProduct(self::EMERGENCY_ASSISTANCE);
     }
     $quoteProducts = new Datasource_Insurance_Quote_Products();
     if ($furnished) {
         // Furnished contents cover
         // Add this product to the quote
         $quoteProducts->add($this->_quoteModel->ID, self::CONTENTS_COVER);
         // Now we need to add all the relevant meta data
         $quoteProductMetas = new Datasource_Insurance_Quote_Product_Metas();
         $quoteProductMetas->add($this->_quoteModel->ID, self::CONTENTS_COVER, 'cover_amount', $coverAmount);
         $quoteProductMetas->add($this->_quoteModel->ID, self::CONTENTS_COVER, 'excess', $excess);
         $quoteProductMetas->add($this->_quoteModel->ID, self::CONTENTS_COVER, 'accidental_damage', $accidentalDamage);
         // Add on free emergency assistance
         if (!$this->hasProduct(self::BUILDING_COVER)) {
             $quoteProducts->add($this->_quoteModel->ID, self::EMERGENCY_ASSISTANCE);
         }
     } else {
         // Unfurnished contents cover
         // Add this product to the quote
         $quoteProducts->add($this->_quoteModel->ID, self::UNFURNISHED_CONTENTS_COVER);
     }
     $this->save();
 }
Beispiel #2
0
 /**
  * Remove a product from the quote and clean up any meta data
  *
  * @param int productID ID of the product you want to remove
  * @return boolean True or False depending on success
  *
  * Example: $result = $quoteManager->removeProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER);
  */
 public function removeProduct($productID)
 {
     $quoteProducts = new Datasource_Insurance_Quote_Products();
     return $quoteProducts->remove($this->_quoteModel->ID, $productID);
 }