Beispiel #1
0
 public function dtgSignupEntries_SetupColumns()
 {
     $this->dtgSignupEntries->RemoveAllColumns();
     $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->Person->LastName, 'Name=Name', 'Html=<?= $_FORM->RenderName($_ITEM); ?>', 'HtmlEntities=false');
     //			$this->dtgSignupEntries->MetaAddTypeColumn('SignupEntryStatusTypeId', 'SignupEntryStatusType', 'Name=Status');
     foreach ($this->objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) {
         if ($objFormQuestion->ViewFlag) {
             $this->dtgSignupEntries->AddColumn(new QDataGridColumn($objFormQuestion->ShortDescription, '<?= $_FORM->RenderAnswer($_ITEM, ' . $objFormQuestion->Id . ',' . $objFormQuestion->FormQuestionTypeId . '); ?>', 'HtmlEntities=false'));
         }
     }
     foreach ($this->objSignupForm->GetFormProductArray(QQ::OrderBy(QQN::FormProduct()->FormProductTypeId, QQN::FormProduct()->OrderNumber)) as $objFormProduct) {
         if ($objFormProduct->ViewFlag) {
             /* $this->dtgSignupEntries->AddColumn(new QDataGridColumn($objFormProduct->Name. ' Quantity', '<?= $_FORM->RenderProductQuantity($_ITEM, ' . $objFormProduct->Id . '); ?>', 'HtmlEntities=false'));*/
             $this->dtgSignupEntries->AddColumn(new QDataGridColumn($objFormProduct->Name, '<?= $_FORM->RenderProductAmount($_ITEM, ' . $objFormProduct->Id . '); ?>', 'HtmlEntities=false'));
         }
     }
     if ($this->objSignupForm->CountFormProducts()) {
         $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->AmountPaid, 'Name=Paid', 'Html=<?= $_FORM->RenderAmount($_ITEM->AmountPaid); ?>');
         $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->AmountBalance, 'Name=Balance', 'Html=<?= $_FORM->RenderAmount($_ITEM->AmountBalance); ?>');
         $this->dtgSignupEntries->AddColumn(new QDataGridColumn('Payment Type', '<?= $_FORM->RenderPaymentType($_ITEM); ?>', 'HtmlEntities=false'));
     }
     $this->dtgSignupEntries->MetaAddColumn(QQN::SignupEntry()->DateSubmitted, 'Name=Submitted', 'Html=<?= $_ITEM->DateSubmitted ? $_ITEM->DateSubmitted->ToString("MMM D YYYY") : null; ?>');
 }
Beispiel #2
0
 protected function Form_Create()
 {
     // Attempt to load by Token and then by ID
     $this->objSignupForm = SignupForm::LoadByToken(QApplication::PathInfo(0));
     if (!$this->objSignupForm) {
         $this->objSignupForm = SignupForm::Load(QApplication::PathInfo(0));
     }
     // Ensure it is the correct type and it exists
     if (!$this->objSignupForm) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     $this->strPageTitle = $this->objSignupForm->Name . ' - Payment';
     // Ensure it is Active
     if (!$this->objSignupForm->ActiveFlag) {
         $this->strHtmlIncludeFilePath = '_notactive.tpl.php';
         return;
     }
     // Ensure we have Products that require some kind of payment
     if (!$this->objSignupForm->CountFormProducts()) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     // Get the SignupEntry
     $this->objSignupEntry = SignupEntry::Load(QApplication::PathInfo(1));
     // Ensure it is correct for the form and the signup person
     if (!$this->objSignupEntry || $this->objSignupEntry->SignupFormId != $this->objSignupForm->Id || $this->objSignupEntry->SignupByPersonId != QApplication::$PublicLogin->PersonId || $this->objSignupEntry->SignupEntryStatusTypeId != SignupEntryStatusType::Incomplete) {
         $this->strHtmlIncludeFilePath = '_notfound.tpl.php';
         return;
     }
     switch ($this->objSignupForm->SignupFormTypeId) {
         case SignupFormType::Event:
             $this->objChild = $this->objSignupForm->EventSignupForm;
             break;
         case SignupFormType::Course:
             $this->objChild = $this->objSignupForm->ClassMeeting;
             break;
     }
     $this->dtgProducts = new QDataGrid($this);
     $this->dtgProducts->AddColumn(new QDataGridColumn('Product / Item', '<?= $_FORM->RenderProduct($_ITEM); ?>', 'HtmlEntities=false', 'Width=550px'));
     $this->dtgProducts->AddColumn(new QDataGridColumn('Quantity', '<?= $_FORM->RenderQuantity($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgProducts->AddColumn(new QDataGridColumn('Cost', '<?= $_FORM->RenderCost($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgProducts->AddColumn(new QDataGridColumn('Total', '<?= $_FORM->RenderTotal($_ITEM); ?>', 'HtmlEntities=false', 'Width=100px'));
     $this->dtgProducts->SetDataBinder('dtgProducts_Bind');
     // Remove All Product Selections
     $this->objSignupEntry->DeleteAllSignupProducts();
     // Add Required Products
     foreach ($this->objSignupForm->GetFormProductArrayByType(FormProductType::Required, QQ::OrderBy(QQN::FormProduct()->OrderNumber)) as $objProduct) {
         if ($objProduct->IsAvailableRightNow()) {
             $objSignupProduct = SignupProduct::LoadBySignupEntryIdFormProductId($this->objSignupEntry->Id, $objProduct->Id);
             if (!$objSignupProduct) {
                 $this->objSignupEntry->AddProduct($objProduct);
             }
         }
     }
     // Deposit vs. Full Amount Choice
     $this->rblDeposit = new QRadioButtonList($this);
     $this->rblDeposit->Name = 'Payment Option';
     $this->rblDeposit->AddItem('Pay in Full', 1);
     $this->rblDeposit->AddItem('Deposit', 2);
     $this->rblDeposit->AddAction(new QClickEvent(), new QAjaxAction('rblDeposit_Click'));
     $this->btnRegister = new QButton($this);
     $this->btnRegister->CssClass = 'primary';
     $this->btnRegister->Text = 'Submit Registration';
     $this->btnRegister->AddAction(new QClickEvent(), new QAjaxAction('btnRegister_Click'));
     $this->btnRegister->CausesValidation = true;
     // Figure out which address to use
     $objAddress = $this->objSignupEntry->RetrieveAnyValidAddressObject();
     if (!$objAddress) {
         $objAddress = QApplication::$PublicLogin->Person->DeducePrimaryAddress();
     }
     // Create the Payment Panel
     $this->pnlPayment = new PaymentPanel($this, null, $objAddress, QApplication::$PublicLogin->Person->FirstName, QApplication::$PublicLogin->Person->LastName);
     $this->pnlPayment->SetButtonText('Submit Payment');
     $this->objSignupEntry->RefreshAmounts();
     $this->RefreshForm();
 }
Beispiel #3
0
 protected function btnSubmit_Click($strFormId, $strControlId, $strParameter)
 {
     $this->objSignupEntry->Save();
     $this->CreateChildObject();
     if (!QApplication::$PublicLogin) {
         // Create a communcations entry object or use an existing communcations_entry
         // if user is not logged in
         $txtEmail = $this->GetControl($this->strEmailCtrlId);
         $objCommunicationsEntry = CommunicationListEntry::LoadByEmail($txtEmail->Text);
         if (!$objCommunicationsEntry) {
             $objCommunicationsEntry = new CommunicationListEntry();
             $objCommunicationsEntry->FirstName = $this->objFormQuestionControlArray[0]->Text;
             $objCommunicationsEntry->LastName = $this->objFormQuestionControlArray[1]->Text;
             if ($txtEmail) {
                 $objCommunicationsEntry->Email = $txtEmail->Text;
             }
             $objCommunicationsEntry->Save();
         }
         $this->objSignupEntry->CommunicationsEntryId = $objCommunicationsEntry->Id;
     }
     foreach ($this->objSignupForm->GetFormQuestionArray() as $objFormQuestion) {
         // Only update if this is NOT "InternalFlag"
         if ($objFormQuestion->InternalFlag) {
             continue;
         }
         $strControlId = 'fq' . $objFormQuestion->Id;
         $objFormAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($this->objSignupEntry->Id, $objFormQuestion->Id);
         if (!$objFormAnswer) {
             $objFormAnswer = new FormAnswer();
             $objFormAnswer->SignupEntry = $this->objSignupEntry;
             $objFormAnswer->FormQuestion = $objFormQuestion;
         }
         switch ($objFormQuestion->FormQuestionTypeId) {
             case FormQuestionType::SpouseName:
                 $lstSpouse = $this->GetControl($strControlId . 'id');
                 $txtSpouse = $this->GetControl($strControlId . 'nm');
                 if ($lstSpouse && $lstSpouse->SelectedValue) {
                     $objFormAnswer->TextValue = Person::Load($lstSpouse->SelectedValue)->Name;
                 } else {
                     $objFormAnswer->TextValue = trim($txtSpouse->Text);
                 }
                 break;
             case FormQuestionType::Address:
                 $rblAddress = $this->GetControl($strControlId . 'switch');
                 $txtAddress1 = $this->GetControl($strControlId . 'address1');
                 $txtAddress2 = $this->GetControl($strControlId . 'address2');
                 $txtCity = $this->GetControl($strControlId . 'city');
                 $lstState = $this->GetControl($strControlId . 'state');
                 $txtZipCode = $this->GetControl($strControlId . 'zipcode');
                 if ($rblAddress && $rblAddress->SelectedValue) {
                     $objFormAnswer->AddressId = $rblAddress->SelectedValue;
                     $objFormAnswer->TextValue = $objFormAnswer->Address->AddressFullLine;
                 } else {
                     $objFormAnswer->AddressId = null;
                     $objAddress = new Address();
                     $objAddress->Address1 = trim($txtAddress1->Text);
                     $objAddress->Address2 = trim($txtAddress2->Text);
                     $objAddress->City = trim($txtCity->Text);
                     $objAddress->State = $lstState->SelectedValue;
                     $objAddress->ZipCode = trim($txtZipCode->Text);
                     $objFormAnswer->TextValue = $objAddress->AddressFullLine;
                 }
                 break;
             case FormQuestionType::Age:
                 $txtAge = $this->GetControl($strControlId . 'age');
                 if (strlen(trim($txtAge->Text))) {
                     $objFormAnswer->IntegerValue = $txtAge->Text;
                 } else {
                     $objFormAnswer->IntegerValue = null;
                 }
                 break;
             case FormQuestionType::DateofBirth:
                 $dtxDateOfBirth = $this->GetControl($strControlId . 'dob');
                 if ($dtxDateOfBirth->DateTime) {
                     $objFormAnswer->DateValue = $dtxDateOfBirth->DateTime;
                     // Update the Person Information
                     if (QApplication::$PublicLogin) {
                         $this->objSignupEntry->Person->DateOfBirth = $objFormAnswer->DateValue;
                         $this->objSignupEntry->Person->DobGuessedFlag = false;
                         $this->objSignupEntry->Person->DobYearApproximateFlag = false;
                         $this->objSignupEntry->Person->Save();
                     }
                 } else {
                     $objFormAnswer->DateValue = null;
                 }
                 break;
             case FormQuestionType::Gender:
                 $lstGender = $this->GetControl($strControlId . 'gender');
                 if ($lstGender->SelectedValue === true) {
                     $objFormAnswer->TextValue = 'Male';
                     $objFormAnswer->BooleanValue = true;
                     if (QApplication::$PublicLogin) {
                         $this->objSignupEntry->Person->Gender = 'M';
                         $this->objSignupEntry->Person->Save();
                     }
                 } else {
                     if ($lstGender->SelectedValue === false) {
                         $objFormAnswer->TextValue = 'Female';
                         $objFormAnswer->BooleanValue = false;
                         if (QApplication::$PublicLogin) {
                             $this->objSignupEntry->Person->Gender = 'F';
                             $this->objSignupEntry->Person->Save();
                         }
                     } else {
                         $objFormAnswer->TextValue = null;
                         $objFormAnswer->BooleanValue = null;
                     }
                 }
                 break;
             case FormQuestionType::Phone:
                 $lstPhone = $this->GetControl($strControlId . 'id');
                 $txtPhone = $this->GetControl($strControlId . 'phone');
                 if ($lstPhone && $lstPhone->SelectedValue) {
                     $objFormAnswer->PhoneId = $lstPhone->SelectedValue;
                     $objFormAnswer->TextValue = $objFormAnswer->Phone->Number;
                 } else {
                     if ($strNumber = trim($txtPhone->Text)) {
                         $objFormAnswer->PhoneId = null;
                         $objFormAnswer->TextValue = $strNumber;
                     } else {
                         $objFormAnswer->PhoneId = null;
                         $objFormAnswer->TextValue = null;
                     }
                 }
                 break;
             case FormQuestionType::Email:
                 $lstEmail = $this->GetControl($strControlId . 'id');
                 $txtEmail = $this->GetControl($strControlId . 'email');
                 if ($lstEmail && $lstEmail->SelectedValue) {
                     $objFormAnswer->EmailId = $lstEmail->SelectedValue;
                     $objFormAnswer->TextValue = $objFormAnswer->Email->Address;
                 } else {
                     if ($strNumber = trim($txtEmail->Text)) {
                         $objFormAnswer->EmailId = null;
                         $objFormAnswer->TextValue = $strNumber;
                     } else {
                         $objFormAnswer->EmailId = null;
                         $objFormAnswer->TextValue = null;
                     }
                 }
                 break;
             case FormQuestionType::ShortText:
             case FormQuestionType::LongText:
                 $txtAnswer = $this->GetControl($strControlId);
                 if (strlen($strText = trim($txtAnswer->Text))) {
                     $objFormAnswer->TextValue = $strText;
                 } else {
                     $objFormAnswer->TextValue = null;
                 }
                 break;
             case FormQuestionType::Number:
                 $txtAnswer = $this->GetControl($strControlId);
                 if (strlen($strText = trim($txtAnswer->Text))) {
                     $objFormAnswer->IntegerValue = $strText;
                 } else {
                     $objFormAnswer->IntegerValue = null;
                 }
                 break;
             case FormQuestionType::YesNo:
                 $chkAnswer = $this->GetControl($strControlId);
                 $objFormAnswer->BooleanValue = $chkAnswer->Checked;
                 break;
             case FormQuestionType::SingleSelect:
                 $lstAnswer = $this->GetControl($strControlId);
                 $txtAnswer = $this->GetControl($strControlId . 'other');
                 // No item selected ("-select one-" still selected)
                 if (is_null($lstAnswer->SelectedValue)) {
                     $objFormAnswer->TextValue = null;
                     // "Other" option
                 } else {
                     if ($lstAnswer->SelectedValue === false) {
                         if (strlen($strText = trim($txtAnswer->Text))) {
                             $objFormAnswer->TextValue = $strText;
                         } else {
                             $objFormAnswer->TextValue = null;
                         }
                         // Regular List Selection
                     } else {
                         $objFormAnswer->TextValue = trim($lstAnswer->SelectedValue);
                     }
                 }
                 break;
             case FormQuestionType::MultipleSelect:
                 //GJS - changing to multiple check boxes
                 $chkAnswer = $this->GetControl($strControlId);
                 $objItemsArray = $chkAnswer->GetAllItems();
                 if (count($objItemsArray)) {
                     $strSelectedArray = array();
                     foreach ($objItemsArray as $objItem) {
                         if ($objItem->Selected) {
                             $strSelectedArray[] = $objItem->Name;
                         }
                     }
                     $objFormAnswer->TextValue = implode("\r\n", $strSelectedArray);
                 } else {
                     $objFormAnswer->TextValue = null;
                 }
                 break;
             case FormQuestionType::Instructions:
                 // Don't need to do anything here!
                 break;
             default:
                 throw new Exception('Invalid FormQuestionTypeId: ' . $objFormQuestion->FormQuestionTypeId);
         }
         $objFormAnswer->Save();
     }
     if ($this->objSignupForm->CountFormProducts()) {
         QApplication::Redirect($this->objSignupEntry->PaymentUrl);
     } else {
         $this->objSignupEntry->Complete();
         QApplication::Redirect($this->objSignupEntry->ConfirmationUrl);
     }
 }