<select id="entry_type_id" class="form-control" data-sponsor-id="<?php echo \OutSpokane\FestivalEntry::ENTRY_TYPE_SPONSOR; ?> "> <?php foreach ($entry_types as $entry_type_id => $entry_type) { ?> <option value="<?php echo $entry_type_id; ?> "> <?php echo $entry_type; ?> - $<?php echo number_format(\OutSpokane\FestivalEntry::getEntryTypePrice($entry_type_id), 2); ?> </option> <?php } ?> </select> </div> </div> <?php if (strtolower($this->getAttribute('corner_booth')) == 'yes') { ?> <div class="row" id="corner-booth-container"> <div class="col-md-3"> <label for="corner_booth">Upgrade to Corner Booth</label>
/** * */ public function handleNewAjaxEntry() { $response = array('success' => 1, 'error' => ''); if (wp_verify_nonce($_POST['entry_nonce'], 'entry-nonce')) { if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $response['success'] = 0; $response['error'] = 'The email address you entered is not valid'; } elseif ($_POST['form'] == 'donation' && (preg_replace('/[^0-9\\.]/', '', $_POST['donation_amount']) == '' || preg_replace('/[^0-9\\.]/', '', $_POST['donation_amount']) == 0)) { $response['success'] = 0; $response['error'] = 'Please enter a valid donation amount'; } elseif ($_POST['form'] == 'sponsorship' && (preg_replace('/[^0-9\\.]/', '', $_POST['amount']) == '' || preg_replace('/[^0-9\\.]/', '', $_POST['amount']) == 0)) { $response['success'] = 0; $response['error'] = 'Please enter a valid sponsorship amount'; } else { switch ($_POST['form']) { case 'cruise': $subject = 'Cruise'; $entry = new CruiseEntry(); $entry->setQty($_POST['qty'])->setPricePerQty(CruiseEntry::PRICE_PER_TICKET)->setPaymentMethodId(Entry::PAYMENT_METHOD_CARD); break; case 'festival': $subject = 'Pride Festival'; $entry = new FestivalEntry(); $entry->setQty(1)->setDescription($_POST['description'])->setEntryTypeId($_POST['entry_type_id'])->setPriceForCornerBooth(FestivalEntry::CORNER_BOOTH_FEE)->setPricePerQty($entry->getEntryTypePrice($_POST['entry_type_id']))->setIsCornerBooth($_POST['entry_type_id'] == FestivalEntry::ENTRY_TYPE_SPONSOR ? FALSE : $_POST['corner_booth']); break; case 'murder_mystery': $subject = 'Murder Mystery'; /** @var MurderMysteryEntry $entry */ $entry = new MurderMysteryEntry(); $entry->setIsUpgraded($_POST['is_upgraded'])->setVegetarianQty($_POST['vegetarian_qty']); if ($_POST['is_sponsor'] == 1) { $entry->setQty(1)->setIsSponsor(TRUE)->setPricePerQty($entry->isUpgraded() ? MurderMysteryEntry::UPGRADED_TABLE_PRICE : MurderMysteryEntry::TABLE_PRICE); } else { $entry->setQty($_POST['qty'])->setIsSponsor(FALSE)->setPricePerQty($entry->isUpgraded() ? MurderMysteryEntry::UPGRADED_TICKET_PRICE : MurderMysteryEntry::TICKET_PRICE); } break; case 'donation': $subject = 'Donation'; $entry = new Donation(); $entry->setDonationAmount(preg_replace('/[^0-9\\.]/', '', $_POST['donation_amount'])); break; case 'flag': $subject = 'Flag Handle'; $entry = new FlagHandle(); $entry->setColor($_POST['color'])->setMessage($_POST['message'])->setPricePerQty($_POST['color'] == 'Black' ? FlagHandle::PRICE_PER_HANDLE_BLACK : FlagHandle::PRICE_PER_HANDLE_OTHER)->setQty(1); break; case 'sponsorship': $subject = 'Sponsorship'; $entry = new Sponsorship(); $entry->setAmount(preg_replace('/[^0-9\\.]/', '', $_POST['amount']))->setPosition($_POST['position'])->setLocalPosition($_POST['local_position'])->setUrl($_POST['url'])->setLevelFromAmount()->setLocalFirstName($_POST['local_first_name'])->setLocalLastName($_POST['local_last_name'])->setLocalAddress($_POST['local_address'])->setLocalCity($_POST['local_city'])->setLocalState($_POST['local_state'])->setLocalZip($_POST['local_zip'])->setLocalEmail($_POST['local_email'])->setLocalPhone($_POST['local_phone'])->setQty(1); break; default: /* 'parade' */ $subject = 'Pride Parade'; $entry = new ParadeEntry(); $entry->setEntryTypes(stripslashes($_POST['entry_types']))->setFloatParkingSpaces($_POST['float_parking_spaces'])->setFloatParkingSpaceCost(ParadeEntry::FLOAT_PARKING_SPACE_COST)->setDonationAmount(preg_replace('/[^0-9\\.]/', '', $_POST['donation_amount']))->setDescription($_POST['description'])->setNeedsAmpedSound($_POST['needs_amped_sound'])->setGroupSize(preg_replace('/\\D/', '', $_POST['group_size']))->setQty(1); } $entry->setEntryYear($_POST['entry_year'])->setOrganization($_POST['organization'])->setFirstName($_POST['first_name'])->setLastName($_POST['last_name'])->setEmail($_POST['email'])->setPhone($_POST['phone'])->setAddress($_POST['address'])->setCity($_POST['city'])->setState($_POST['state'])->setZip($_POST['zip'])->setCreatedAt(time())->setUpdatedAt(time())->create(); $fields = array('Entry Year', 'Organization', 'First Name', 'Last Name', 'Email', 'Phone', 'Address', 'City', 'State', 'Zip', 'Qty'); $subject = 'OutSpokane Receipt - ' . $entry->getEntryYear() . ' ' . $subject; $body = ' <p>Thank you! Below are the details of your transaction:</p> <table> <tr> <td><strong>Title:</strong></td> <td>' . $entry->getEntryYear() . ' ' . $subject . '</td> </tr>'; if ($_POST['form'] == 'flag') { $body .= ' <tr> <td><strong>Embroidered Name:</strong></td> <td>' . $entry->getMessage() . '</td> </tr> <tr> <td><strong>Color:</strong></td> <td>' . $entry->getColor() . '</td> </tr>'; } foreach ($fields as $field) { $body .= ' <tr> <td><strong>' . $field . ':</strong></td> <td>' . $entry->getRaw(strtolower(str_replace(' ', '_', $field))) . '</td> </tr>'; } $body .= ' <tr> <td><strong>Total:</strong></td> <td>$' . number_format($entry->getTotal(), 2) . '</td> </tr> </table> <p>View the complete details of your transaction here:</p> <p><a href="https://outspokane.org' . $_POST['path'] . '?txid=' . $entry->getCreatedAt() . '-' . $entry->getId() . '">https://outspokane.org' . $_POST['path'] . '?txid=' . $entry->getCreatedAt() . '-' . $entry->getId() . '</a></p>'; $headers = array('Content-Type: text/html; charset=UTF-8', 'From info@outspokane.org'); wp_mail($_POST['email'], $subject, $body, $headers); wp_mail('*****@*****.**', 'BCC: ' . $subject, $body, $headers); $response['txid'] = $entry->getCreatedAt() . '-' . $entry->getId(); } } else { $response['success'] = 0; $response['error'] = 'There was a problem. Please try again.'; } header('Content-Type: application/json'); echo json_encode($response); exit; }