MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.141.29.162
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/ppcad7no/nstp.in/../sadguruoverseas.com/../thegloriousadventure.com/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/nstp.in/../sadguruoverseas.com/../thegloriousadventure.com/booking.php
<?php
    include_once('admin/config.php');
    if ($_SERVER["REQUEST_METHOD"] === "POST") {
        if (isset($_POST['submit-booking'])) {
            $tour_name=$_POST['tour_name'];
            $pack_cost=$_POST['price'];
            $car_type=$_POST['car_type'];
        }
        
        if (isset($_POST['booking'])) {
            $tour_name=$_POST['tour_name'];
            $name=$_POST['name'];
            $phone=$_POST['phone'];
            $email=$_POST['email'];
            $date=$_POST['date'];
            $car_type=$_POST['car_type'];
            $price=$_POST['price'];
            $date=$_POST['date'];
            date_default_timezone_set('Asia/Kolkata');
            $currentDate = date('Y-m-d');
            $sqli="INSERT INTO `tbl_order`(
                `ord_amount`,
                `ord_ord_name`,
                `ord_pack_type`,
                `ord_person_name`,
                `ord_email`,
                `ord_mobile`,
                `ord_doj`,
                `ord_status`,
                `ord_person_no`,
                `ord_date`) 
                VALUES (
                '$price',
                '$tour_name', 
                '$car_type', 
                '$name',
                '$email',
                '$phone',
                '$date',
                'Not Paid',
                '$ord_person_no',
                '$currentDate')";
            $result = mysqli_query($db, $sqli) or die("Query unsuccessful");
// window.alert('Succesfully Submitted, Please Pay Now!');
	        if($result){
                    echo ("<script>
                     window.alert('Succesfully submitted your query, We will contact you soon!');
                     window.location.href='index.html';
                    </script>");
	        	
	        	mysqli_close($db);
             }else{
                echo"Error ";
            }
        }
    }
?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php include "links.php";?>
    <title>Booking  | <?=$site_name?></title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
    <style>
        .booking-container .container {
            max-width: 800px;
            margin: 20px auto;
            padding: 20px;
            background-color: #fff;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: 5px;
        }

        #bookingForm  h1 {
            text-align: center;
            margin-bottom: 20px;
            color: var(--primary-color);
        }

     
        #bookingForm form {
            margin: 20px;
            display:flex;
            width: 100%;
        }

        #bookingForm label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }

        input[type="text"],
        input[type="date"],
        input[type="email"],
        select {
            width: 100%;
            padding: 10px;
            margin-bottom: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        #bookingForm button {
            width: 100%;
            padding: 10px;
            background-color: var(--primary-color);
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        #bookingForm  button:hover {
            background-color: var(--secondary-color);
        }

        #bookingForm .ticket {
            margin-top: 20px;
            padding: 15px;
            border: 1px solid #ccc;
            background-color: #fff;
        }
     
        #bookingForm .icon {
            color: var(--accent-color);
            font-size: 24px;
            margin-right: 5px;
        }
    </style>
</head>

<body>

    <?php include "header.php";?>

    <div class="breadcrumb breadcrumb-style-one">
        <div class="container">
            <div class="col-lg-12 text-center">
                <h2 class="breadcrumb-title">Book Your Tour</h2>
                <ul class="d-flex justify-content-center breadcrumb-items">
                    <li class="breadcrumb-item"><a href="<?php echo $wspath?>">Home</a></li>
                    <li class="breadcrumb-item active">Book Now</li>
                </ul>
            </div>
        </div>
    </div>
    <section id="booking">
        <div class="container">
        <h1><i class="fa fa-car text-warning"></i> Quick Enquiry for <?php echo $tour_name;?> </h1>
        <form id="bookingForm" action="#" method="POST" onsubmit="return validateForm()">
            <div class="row py-4 my-4" style="box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;">
                <div class="col-md-12 pkg_nm mb-4"><?php echo $tour_name;?> - <span> Rs.<?= $pack_cost?>/-</span></div>
        
                <div class="col-lg-6">
                    <label for="tour_name">TOUR NAME <span style="color:red;">*</span></label>
                    <input type="text" name="tour_name" value="<?php echo $tour_name;?>" readonly>
                </div>
                <div class="col-lg-6">
                    <label for="name">NAME <span style="color:red;">*</span></label>
                    <input type="text" name="name" placeholder="Your Name" required>
                    <span id="nameError" class="error"></span>
                </div>
                <div class="col-lg-6">
                    <label for="phone">MOBILE NO <span style="color:red;">*</span></label>
                    <input type="text" name="phone" maxlength="10" placeholder="Mobile Number" required>
                    <span id="phoneError" class="error"></span>
                </div>
                <!--<div class="col-lg-6">-->
                <!--    <label for="email">EMAIL ID <span style="color:red;">*</span></label>-->
                <!--    <input type="email" name="email" placeholder="Your Email" required>-->
                <!--    <span id="emailError" class="error"></span>-->
                <!--</div>-->
                <!--<div class="col-lg-6">-->
                <!--    <label for="date">Date of Travel <span style="color:red;">*</span></label>-->
                <!--    <input type="date" name="date" id="date" required min="<?php echo date('Y-m-d'); ?>">-->
                <!--    <span id="dateError" class="error"></span>-->
                <!--</div>-->
                <div class="col-lg-6">
                    <label for="destination">Select Person<span style="color:red;">*</span></label>
                    <select name="no_of_person" id="no_of_person" onChange="calculate_fare(this.value,'<?=$pack_cost?>')" required>
                        <option value="">Choose Person</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                    </select>
                    <span id="personError" class="error"></span>
                </div>
                <!--<div class="col-lg-6">-->
                <!--    <label for="fare">Booking Amount</label>-->
                <!--    <input type="text" name="pack_cost" id="pack_cost" readonly value="<?=$pack_cost?>">-->
                <!--</div>-->
                <div class="col-lg-12">
                    <button class="w-100 py-2 bg-primary border-0 text-white" type="submit" name="booking" id="submitBtn" disabled>
                        <i class="fa fa-check text-warning"></i> Enquiry Now
                    </button>
                    <!--<button class="w-100 py-2 bg-primary border-0 text-white" type="button" id="submitBtn" onclick="pay_now()" disabled>-->
                    <!--    <i class="fa fa-check text-warning"></i> Pay Now-->
                    <!--</button>-->
                </div>
            </div>
        </form>
        </div>
    </section>
    
    <?php include "inner-footer.php";?>
    
    <?php include "footer.php"?>
    
    <script>
    function validateForm() {
        let isValid = true;

        // Get form elements
        const name = document.forms["bookingForm"]["name"].value;
        const phone = document.forms["bookingForm"]["phone"].value;
        // const email = document.forms["bookingForm"]["email"].value;
        // const date = document.forms["bookingForm"]["date"].value;
        const no_of_person = document.forms["bookingForm"]["no_of_person"].value;

        // Validate name
        if (name === "") {
            document.getElementById("nameError").innerText = "Name is required";
            isValid = false;
        } else {
            document.getElementById("nameError").innerText = "";
        }

        // Validate phone
        const phoneRegex = /^[0-9]{10}$/;
        if (!phoneRegex.test(phone)) {
            document.getElementById("phoneError").innerText = "Invalid phone number";
            isValid = false;
        } else {
            document.getElementById("phoneError").innerText = "";
        }

        // Validate number of persons
        if (no_of_person === "") {
            document.getElementById("personError").innerText = "Please select number of persons";
            isValid = false;
        } else {
            document.getElementById("personError").innerText = "";
        }

        // Enable or disable submit button based on validation
        document.getElementById("submitBtn").disabled = !isValid;

        return isValid;
    }

    // Add event listeners to form elements to validate on input
    document.getElementById("bookingForm").addEventListener("input", validateForm);

    // Initial validation check
    validateForm();
</script>
   <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
    function calculate_fare(person, fare) {
        var cost = person * fare;
        document.getElementById("pack_cost").value = cost;
    }

    function pay_now() {
    let form = document.getElementById('bookingForm');
    let formData = new FormData(form);
    let pack_cost = formData.get('pack_cost');

    let options = {
        "key": "rzp_live_7qQjTzujqTHh3C", 
        "amount": pack_cost * 100,
        "currency": "INR",
        "name": "Tour Booking",
        "description": "Payment for your tour booking",
        "handler": function (response) {
            formData.append('transaction_id', response.razorpay_payment_id);
            let successForm = document.createElement('form');
            successForm.action = 'thanks.php';
            successForm.method = 'POST';

            // Append form data
            formData.forEach((value, key) => {
                let input = document.createElement('input');
                input.type = 'hidden';
                input.name = key;
                input.value = value;
                successForm.appendChild(input);
            });

            document.body.appendChild(successForm);
            successForm.submit();
        },
        "prefill": {
            "name": formData.get('name'),
            "contact": formData.get('phone')
        },
        "theme": {
            "color": "#3399cc"
        }
    };

    let rzp1 = new Razorpay(options);
    rzp1.on('payment.failed', function (response){
        // Create a form to send data to failed.php
        let failureForm = document.createElement('form');
        failureForm.action = 'failed.php';
        failureForm.method = 'POST';

        // Append form data
        formData.forEach((value, key) => {
            let input = document.createElement('input');
            input.type = 'hidden';
            input.name = key;
            input.value = value;
            failureForm.appendChild(input);
        });

        document.body.appendChild(failureForm);
        failureForm.submit();
    });

    rzp1.open();
}

</script>

    <script>
    document.addEventListener('DOMContentLoaded', function () {
        document.querySelector('form').addEventListener('submit', function (e) {
            var valid = true;

            var phoneInput = document.querySelector('input[name="phone"]');
            if (!/^\d{10}$/.test(phoneInput.value)) {
                setError(phoneInput, 'Please enter a valid 10-digit mobile number.');
                valid = false;
            } else {
                clearError(phoneInput);
            }
            
           

          

            var carTypeInput = document.querySelector('select[name="car_type"]');
            if (carTypeInput.value === '') {
                setError(carTypeInput, 'Please choose Person.');
                valid = false;
            } else {
                clearError(carTypeInput);
            }

            if (!valid) {
                e.preventDefault();
            }
        });

        function setError(input, message) {
            input.classList.add('is-invalid');
            var errorElement = document.createElement('div');
            errorElement.className = 'invalid-feedback';
            errorElement.innerText = message;
            input.parentNode.appendChild(errorElement);
        }

        function clearError(input) {
            input.classList.remove('is-invalid');
            var errorElement = input.parentNode.querySelector('.invalid-feedback');
            if (errorElement) {
                errorElement.parentNode.removeChild(errorElement);
            }
        }
    });
</script>


</body>
    
</html>

MMCT - 2023