public function cblColumns_Click() { foreach ($this->cblColumns->GetAllItems() as $objItem) { $intId = substr($objItem->Value, 1); if (substr($objItem->Value, 0, 1) == 'q') { $objQuestion = FormQuestion::Load($intId); $objQuestion->ViewFlag = $objItem->Selected; $objQuestion->Save(); } else { $objProduct = FormProduct::Load($intId); $objProduct->ViewFlag = $objItem->Selected; $objProduct->Save(); } } $this->dtgSignupEntries_SetupColumns(); $this->dtgSignupEntries->Refresh(); }
public function lstRequiredWithChoice_Change() { // Erase any old entries foreach ($this->objSignupEntry->GetSignupProductArray() as $objSignupProduct) { if ($objSignupProduct->FormProduct->FormProductTypeId == FormProductType::RequiredWithChoice && $objSignupProduct->FormProductId != $this->lstRequiredWithChoice->SelectedValue) { $objSignupProduct->Delete(); } } // Create the new entry $objFormProduct = FormProduct::Load($this->lstRequiredWithChoice->SelectedValue); if ($objFormProduct) { $this->objSignupEntry->AddProduct($objFormProduct); } $this->RefreshForm(); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this FormProductMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing FormProduct object creation - defaults to CreateOrEdit * @return FormProductMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objFormProduct = FormProduct::Load($intId); // FormProduct was found -- return it! if ($objFormProduct) { return new FormProductMetaControl($objParentObject, $objFormProduct); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a FormProduct object with PK arguments: ' . $intId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new FormProductMetaControl($objParentObject, new FormProduct()); }
protected function Form_Create() { $this->objSignupForm = SignupForm::Load(QApplication::PathInfo(0)); $this->lblHeading = new QLabel($this); if (!$this->objSignupForm) { QApplication::Redirect('/events/'); } if (!$this->objSignupForm->Ministry->IsLoginCanAdminMinistry(QApplication::$Login)) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } if (QApplication::PathInfo(1)) { $objProduct = FormProduct::Load(QApplication::PathInfo(1)); if (!$objProduct) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } if ($objProduct->SignupFormId != $this->objSignupForm->Id) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } $this->strPageTitle .= 'Edit Product'; $this->lblHeading->Text = 'Edit ' . $objProduct->Type . ' Product'; } else { if (!QApplication::PathInfo(2)) { QApplication::Redirect('/events/form.php/' . $this->objSignupForm->Id); } $objProduct = new FormProduct(); $objProduct->SignupForm = $this->objSignupForm; $objProduct->FormProductTypeId = QApplication::PathInfo(2); $objProduct->OrderNumber = 100000; $this->strPageTitle .= 'Create New Product'; $this->lblHeading->Text = 'Create New ' . $objProduct->Type . ' Product'; switch ($objProduct->FormProductTypeId) { case FormProductType::Required: $objProduct->MinimumQuantity = 1; $objProduct->MaximumQuantity = 1; break; case FormProductType::RequiredWithChoice: $objProduct->MinimumQuantity = 1; $objProduct->MaximumQuantity = 1; break; case FormProductType::Optional: break; default: throw new Exception('Invalid FormProductType: ' . $objProduct->FormProductTypeId); } $objProduct->FormPaymentTypeId = FormPaymentType::PayInFull; } $this->mctProduct = new FormProductMetaControl($this, $objProduct); // Fields $this->lblFormProductType = $this->mctProduct->lblFormProductTypeId_Create(); $this->txtName = $this->mctProduct->txtName_Create(); $this->txtName->Required = true; $this->txtDescription = $this->mctProduct->txtDescription_Create(); $this->dtxDateStart = $this->mctProduct->dtxDateStart_Create(); $this->calDateStart = $this->mctProduct->calDateStart_Create(); $this->dtxDateEnd = $this->mctProduct->dtxDateEnd_Create(); $this->calDateEnd = $this->mctProduct->calDateEnd_Create(); switch ($objProduct->FormProductTypeId) { case FormProductType::Required: break; case FormProductType::RequiredWithChoice: break; case FormProductType::Optional: $this->txtMaximumQuantity = $this->mctProduct->txtMaximumQuantity_Create(); $this->txtMaximumQuantity->Required = true; $this->txtMaximumQuantity->Minimum = 0; $this->txtMinimumQuantity = $this->mctProduct->txtMinimumQuantity_Create(); $this->txtMinimumQuantity->Required = true; $this->txtMinimumQuantity->Minimum = 0; break; default: throw new Exception('Invalid FormProductType: ' . $objProduct->FormProductTypeId); } // Setup Payment $this->lstFormPaymentTypeId = $this->mctProduct->lstFormPaymentType_Create(); $this->lstFormPaymentTypeId->AddAction(new QChangeEvent(), new QAjaxAction('lstFormPaymentTypeId_Refresh')); $this->txtCost = $this->mctProduct->txtCost_Create(); $this->txtCost->HtmlBefore = '<span>$ </span>'; $this->txtCost->Minimum = 0; $this->txtDeposit = $this->mctProduct->txtDeposit_Create(); $this->txtDeposit->HtmlBefore = '<span>$ </span>'; $this->txtDeposit->Minimum = 0; $this->lstFormPaymentTypeId_Refresh(null, null, null); // Buttons $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->CssClass = 'primary'; $this->btnSave->CausesValidation = true; $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); $this->btnCancel = new QLinkButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); // Delete? if ($this->mctProduct->EditMode) { $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; if ($this->mctProduct->FormProduct->CountSignupProducts()) { $this->btnDelete->AddAction(new QClickEvent(), new QAlertAction('You cannot delete this product as there are already registrations that have selected it. A better idea would be to put an "end date" in the past.')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } else { $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this Product? This cannot be undone.')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } } }
protected function pxyEditFormProduct_Click($strFormId, $strControlId, $strParameter) { $objFormProduct = FormProduct::Load($strParameter); if ($objFormProduct->SignupFormId != $this->objSignupForm->Id) { return; } /** * @var SignupEntry */ $objSignupEntry = $this->mctSignupEntry->SignupEntry; /** * @var Person */ $objPerson = $this->mctSignupEntry->SignupEntry->Person; $this->dlgEdit->ShowDialogBox(); $this->dlgEdit->Template = dirname(__FILE__) . '/dlgEditResult_SignupProduct.tpl.php'; $this->intEditTag = self::EditTagProduct; $this->objSignupProduct = SignupProduct::LoadBySignupEntryIdFormProductId($objSignupEntry->Id, $objFormProduct->Id); if (!$this->objSignupProduct) { $this->objSignupProduct = new SignupProduct(); $this->objSignupProduct->SignupEntryId = $objSignupEntry->Id; $this->objSignupProduct->FormProductId = $objFormProduct->Id; $this->objSignupProduct->Amount = $objFormProduct->Cost; $this->objSignupProduct->Deposit = $objFormProduct->Deposit; $this->objSignupProduct->Quantity = $objFormProduct->MinimumQuantity; $this->btnDelete->Visible = false; } else { $this->btnDelete->Visible = true; } // Reset $this->ResetDialogControls(); $this->lstListbox->Name = 'Quantity'; for ($i = $objFormProduct->MinimumQuantity; $i <= $objFormProduct->MaximumQuantity; $i++) { $this->lstListbox->AddItem($i, $i, $i == $this->objSignupProduct->Quantity); } $this->txtFloat->Name = 'Cost per Item'; $this->txtFloat->Text = $this->objSignupProduct->Amount; }
public function pxyMoveUpProduct_Click($strFormId, $strControlId, $strParameter) { $objFormProduct = FormProduct::Load($strParameter); $objFormProduct->MoveUp(); foreach ($this->dtgProductsArray as $dtgProducts) { if ($dtgProducts->Name == $objFormProduct->FormProductTypeId) { $dtgProducts->Refresh(); } } }
/** * Reload this FormProduct from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved FormProduct object.'); } // Reload the Object $objReloaded = FormProduct::Load($this->intId); // Update $this's local variables to match $this->SignupFormId = $objReloaded->SignupFormId; $this->intOrderNumber = $objReloaded->intOrderNumber; $this->FormProductTypeId = $objReloaded->FormProductTypeId; $this->FormPaymentTypeId = $objReloaded->FormPaymentTypeId; $this->strName = $objReloaded->strName; $this->strDescription = $objReloaded->strDescription; $this->dttDateStart = $objReloaded->dttDateStart; $this->dttDateEnd = $objReloaded->dttDateEnd; $this->intMinimumQuantity = $objReloaded->intMinimumQuantity; $this->intMaximumQuantity = $objReloaded->intMaximumQuantity; $this->fltCost = $objReloaded->fltCost; $this->fltDeposit = $objReloaded->fltDeposit; $this->blnViewFlag = $objReloaded->blnViewFlag; }