[guadec-web] Prevent overbooking



commit 9b62faaeb2c3411319552ef4f85577118cd7c7bd
Author: Pascal Terjan <pterjan gmail com>
Date:   Sun Jul 13 22:40:09 2014 +0000

    Prevent overbooking

 guadec/confirm-payment.php |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/guadec/confirm-payment.php b/guadec/confirm-payment.php
index ee3bd76..102b893 100644
--- a/guadec/confirm-payment.php
+++ b/guadec/confirm-payment.php
@@ -60,8 +60,6 @@ if (!empty($_POST)) {
                where email=%s and payment=%s",
                $email, 'Completed')
        );
-       
-
        if (empty($name) || empty($email)) {
                $errors = true;
        }
@@ -80,6 +78,11 @@ if (!empty($_POST)) {
                        if ($room_type != 'single' && $room_type != 'double') {
                                $errors = true;
                        }
+                        $booked = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM 
wp_guadec2014_registrations WHERE accom = 'YES' AND room=%s", $room_type);
+                       $total_beds = $room_type == 'single' ? 14 : 26;
+                       if ($total_beds <= $booked) {
+                               $errors = true;
+                       }
                }
                $arrive = $_POST['arrival'];
                $depart = $_POST['departure'];
@@ -149,7 +152,7 @@ if (!empty($_POST)) {
        <div> "Invalid Submission. Please go through registration page first."</div>
 <?php else: ?>
        <?php if ($errors == true): ?>
-       <div> "Invalid/Already used email. Please make sure you are not already registered. If you are, and 
want to make certain adjustments to your record, contact our system administration "provide an email address 
here" OR "<a href="https://www.guadec.org/registration-form/";> Go back to Registration </a>
+       <div> "Invalid/Already used email or invalid room type. Please make sure you are not already 
registered. If you are, and want to make certain adjustments to your record, contact contact AT guadec.org OR 
"<a href="https://www.guadec.org/registration-form/";> Go back to Registration </a>
        <?php else: ?>
                <?php //echo $registerInfo; ?>
                <div class="section group">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]