Esempio n. 1
0
 /**
  * Adds a product selection to this signup entry
  * @param FormProduct $objFormProduct
  * @param integer $intQuantity only specify if we are dealing with an "optional" product, otherwise we assume 1
  * @param float $fltAmount only specify if we are allowed a variable amount to specify (e.g. for a donation), otherwise leave blank
  * @return SignupProduct
  */
 public function AddProduct(FormProduct $objFormProduct, $intQuantity = 1, $fltAmount = 0)
 {
     $objSignupProduct = new SignupProduct();
     $objSignupProduct->SignupEntry = $this;
     $objSignupProduct->FormProduct = $objFormProduct;
     switch ($objFormProduct->FormProductTypeId) {
         case FormProductType::Required:
             $objSignupProduct->Quantity = 1;
             break;
         case FormProductType::RequiredWithChoice:
             $objSignupProduct->Quantity = 1;
             break;
         case FormProductType::Optional:
             if ($intQuantity < $objFormProduct->MinimumQuantity || $intQuantity > $objFormProduct->MaximumQuantity) {
                 $intQuantity = $objFormProduct->MinimumQuantity;
             }
             $objSignupProduct->Quantity = $intQuantity;
             break;
         default:
             throw new Exception('Unhandled FormProductTypeId: ' . $objFormProduct->FormProductTypeId);
     }
     switch ($objFormProduct->FormPaymentTypeId) {
         case FormPaymentType::PayInFull:
             $objSignupProduct->Amount = $objFormProduct->Cost;
             break;
         case FormPaymentType::DepositRequired:
             $objSignupProduct->Amount = $objFormProduct->Cost;
             $objSignupProduct->Deposit = $objFormProduct->Deposit;
             break;
         case FormPaymentType::Donation:
             if ($fltAmount < 0) {
                 throw new QCallerException('Invalid Amount entered for Donation');
             }
             $objSignupProduct->Amount = $fltAmount;
             break;
         default:
             throw new Exception('Unhandled FormPaymentTypeId: ' . $objFormProduct->FormPaymentTypeId);
     }
     $objSignupProduct->Save();
     $this->RefreshAmounts();
     return $objSignupProduct;
 }
Esempio n. 2
0
File: result.php Progetto: alcf/chms
 /**
  * @return boolean whether or not the save was successful
  */
 protected function PerformSignupProductSave()
 {
     /**
      * @var SignupEntry
      */
     $objSignupEntry = $this->mctSignupEntry->SignupEntry;
     /**
      * @var FormProduct
      */
     $objFormProduct = $this->objSignupProduct->FormProduct;
     // Delete the "other" required w/ choice items if we are switching it
     if ($objFormProduct->FormProductTypeId == FormProductType::RequiredWithChoice) {
         foreach ($objSignupEntry->GetSignupProductArray() as $objSignupProduct) {
             if ($objSignupProduct->FormProduct->FormProductTypeId == FormProductType::RequiredWithChoice && $objSignupProduct->Id != $this->objSignupProduct->Id) {
                 $objSignupProduct->Delete();
             }
         }
     }
     $this->objSignupProduct->Quantity = $this->lstListbox->SelectedValue;
     $this->objSignupProduct->Amount = $this->txtFloat->Text;
     $this->objSignupProduct->Save();
     return true;
 }