Beispiel #1
0
<?php

require_once "classes/bookingshelper.class.php";
require_once "classes/db.class.php";
$db = new Db();
if ($_POST) {
    $bookings_id = (int) $_POST["bookings_id"];
    $statii_id = (int) $_POST["statii_id"];
    if ($bookings_id == 0) {
        $result = "Please include bookings_id";
    } else {
        if (!BookingsHelper::bookingExistsById($db, $bookings_id)) {
            $result = "Could not find booking with id {$bookings_id}";
        } else {
            if ($statii_id == 0) {
                $result = "Please include statii_id";
            } else {
                if (!BookingsHelper::statusExistsById($db, $statii_id)) {
                    $result = "Could not find status with id {$statii_id}";
                } else {
                    $updateResult = $db->update("bookings_id", $bookings_id, "i", "bookings", array("statii_id"), array($statii_id), "i");
                    $result = $updateResult === false ? "Could not update booking with id {$bookings_id} to have status with id {$statii_id}" : "success";
                }
            }
        }
    }
} else {
    $result = "No post data";
}
echo $result;
            }
        }
    }
}
if (!$error) {
    $_SESSION["aps_range"] = $_POST ? $range : 10;
    $_SESSION["aps_range_start"] = $_POST && $range == 50 ? $range_start : "";
    $_SESSION["aps_range_end"] = $_POST && $range == 50 ? $range_end : "";
    // render results
    $tday = date("Y-m-d");
    $tdayStart = $tday . " 00:00:00";
    $tmrwStart = date("Y-m-d", time() + 60 * 60 * 24) . " 00:00:00";
    $dayAfterTmrwStart = date("Y-m-d", time() + 60 * 60 * 24 * 2) . " 00:00:00";
    $thisYearWeek = date("Y") . date("W");
    $nextYearWeek = date("Y", time() + 60 * 60 * 24 * 7) . date("W", time() + 60 * 60 * 24 * 7);
    $qBeef = BookingsHelper::getRowQueryBeef();
    // defaults to today
    switch ($range) {
        default:
        case 10:
            // today
            $qw = "\nWHERE\n b.statii_id != '6'\n AND\n(b.meet >= '{$tdayStart}' and b.meet < '{$tmrwStart}')\nOR\n(b.arrive >= '{$tdayStart}' and b.arrive < '{$tmrwStart}')\nAND\nb.statii_id != '6'\n";
            $qt = "\n(b.meet >= '{$tdayStart}' and b.meet < '{$tmrwStart}') AS use_depart,\n(b.arrive >= '{$tdayStart}' and b.arrive < '{$tmrwStart}') AS use_arrive\n";
            break;
        case 20:
            // tomorrow
            $qw = "\nWHERE\nb.statii_id != '6'\nAND\n(b.meet >= '{$tmrwStart}' and b.meet < '{$dayAfterTmrwStart}')\nOR\n(b.arrive >= '{$tmrwStart}' and b.arrive < '{$dayAfterTmrwStart}')\nAND b.statii_id != 6\n";
            $qt = "\n(b.meet >= '{$tmrwStart}' and b.meet < '{$dayAfterTmrwStart}') AS use_depart,\n(b.arrive >= '{$tmrwStart}' and b.arrive < '{$dayAfterTmrwStart}') AS use_arrive\n";
            break;
        case 30:
            // this week
Beispiel #3
0
                                                     $values[] = Utils::truncate(Utils::insertStrip($flight), 255);
                                                     // doesn't have seconds
                                                     $values[] = $depart . ":00";
                                                     $values[] = $arrive . ":00";
                                                     $values[] = $suggested_time_datetime->getString();
                                                     $values[] = $payment_methods_id;
                                                     $values[] = $statii_id;
                                                     $types = "sssssssssssii";
                                                     $insertResult = $db->insert("bookings", $keys, $values, $types);
                                                     $submitSuccess = $insertResult;
                                                     if ($insertResult === false) {
                                                         $error = "Could not request booking";
                                                     } else {
                                                         $message = "Your booking has been requested. Please check your email ({$email}) for confirmation.";
                                                         $iid = $db->insertID();
                                                         $emailConfirmResult = BookingsHelper::sendConfirmationEmails($db, $iid, $email);
                                                         $message .= !$emailConfirmResult ? " Could not send confirmation email - please email " . Constants::EMAIL_INFO . " with your booking id: {$iid}." : "";
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #4
0
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    $booking = BookingsHelper::getBookingRowById($db, $bid);
    if ($booking === false) {
        $error = "Could not find booking with id {$bid}";
    }
}
if ($error) {
    if (!$submitted) {
        $tt->insertSlot("FORM_CONTENT", "");
    }
    $tt->insertSlot("MESSAGE", "<span class='feedback_negative'>{$error}</span>");
} else {
    $tt->insertSlot("MESSAGE", "");
}
$tt->insertSlot("FIRST_NAME_VALUE", $submitted ? $_POST["first_name"] : $booking["first_name"]);
$tt->insertSlot("LAST_NAME_VALUE", $submitted ? $_POST["last_name"] : $booking["last_name"]);
$tt->insertSlot("EMAIL_VALUE", $submitted ? $_POST["email"] : $booking["email"]);