<?php
require_once "../admin/private/initialize.php";
$_SESSION['url'] = $_SERVER['REQUEST_URI'];

if (isset($_GET['company'])) {

    $vendors = Vendor::find_by_cat_url($_GET['company']);

    $contact = ContactProfile::find_vendor($vendors->id);

    $business = BusinessProfile::find_vendor_id($vendors->id);

    $others = OtherProfile::find_vendor_id($vendors->id);

    $plans = Order::find_vender($vendors->id);

    $s_p = Product::find_vendor_id($vendors->id);

    if ($plans) {

        $plan_details = Plan::find_by_id($plans->premium_id);
    }

    $title = ucfirst(strtolower($vendors->vendor_company)) . ' in ' . strtolower($vendors->city) . ', ' . strtolower($vendors->vendor_state) . ', india - Worldsindia';

    $s_description = ucfirst(strtolower($vendors->vendor_company)) . ' is registered company with Worldsindia.' . ' ' . ucfirst(strtolower($vendors->vendor_company)) . ' is a leading suppliers, exporters, wholesaler, & manufacturers of ' . strtolower($s_p->product_name) . ' in ' . strtolower($vendors->city) . ', ' . strtolower($vendors->vendor_state) . ', india.';
    $s_keywords = strtolower($vendors->vendor_company) . ', suppliers, manufacturers, exporters, ' . strtolower($s_p->product_name) . ', india, ' . strtolower($vendors->vendor_state);
}

if(is_post_request()){

 $name = htmlentities($database->escape_string($_POST['name']));
 $email = htmlentities($database->escape_string($_POST['email']));
 $subject = htmlentities($database->escape_string($_POST['subject']));
 $phone = htmlentities($database->escape_string($_POST['phone']));
 $message = htmlentities($database->escape_string($_POST['message']));

 $contact = new CatalogContact();
 $contact->vendor_id = $vendors->id;
 $contact->name = $name; 
 $contact->email = $email;
 $contact->phone = $phone;
 $contact->subject = $subject;
 $contact->message = $message;
 $contact->status = '0';
 $contact->created_at = $time;
 $result = $contact->save();

 if($result == true){

    $session->message('Your query submitted successfully');

    redirect_to($base_url.$_GET['company'].'/contact');

 }

}

?>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<?php echo $v ?>">
    <title><?php echo $title ?></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <meta name="description" content="" />
    <meta name="keywords" content="">
    <meta name="author" content="" />
    <meta name="MobileOptimized" content="320">
    <!-- favicon links -->
 	<link rel="icon" href="../../assets/images/favicon.png" type="image/png" />
    <!-- main css -->
    <link rel="stylesheet" href="css/fonts.css" />
    <link rel="stylesheet" href="css/flaticon.css" />
    <link rel="stylesheet" href="css/bootstrap.css" />
    <link rel="stylesheet" href="css/custom_animation.css" />
    <link rel="stylesheet" href="css/font-awesome.css" />
    <link rel="stylesheet" href="css/jquery.fancybox.min.css" />
    <link rel="stylesheet" href="js/plugin/owl/owl.carousel.css" />
    <link rel="stylesheet" href="css/style.css" media="screen" />
    <link rel="stylesheet" href="css/colors/default.css" id="colors" />
</head>

<body>
    <style>
@media screen and (max-width: 768px) {
    .contact_wrapper {
        margin-top: 10px;
    }
    .row {
        flex-direction: column; /* Stack items vertically */
        align-items: center; /* Center items */
    }
    .col-lg-4, .col-md-4, .col-sm-4 {
        width: 100%; /* Make columns full width */
        margin-bottom: 15px; /* Add space between boxes */
    }
    .contact_box {
        width: 90%; /* Reduce width for better fit */
        height: auto; /* Allow dynamic height */
        padding: 15px; /* Adjust padding */
    }
    .contact_map iframe {
        height: 300px; /* Reduce map height */
    }
    .contact_form_wrapper .hm_form {
        padding: 20px;
    }
    .contact_form_wrapper input, .contact_form_wrapper textarea {
        width: 100%; /* Ensure full width for input fields */
    }
    .con_btn button {
        width: 100%; /* Make the submit button full width */
    }
}
</style>


    <!--main wrapper start-->
    <div id="wrapper">
        <!--top_header start-->
        <div class="hm_home_style1">
            <!-- Top Bar -->
            <?php include 'includes/top-bar.php' ?>
            <!-- Top Bar Ends -->
            <!--menu start-->
            <?php include 'includes/header.php' ?>
            <!--banner start-->
            <div class="hm_bread_wrapper">
                <div class="container">
                    <div class="row">
                        <div class="col-lg-12 col-md-12">
                            <h1 style="color: #272d58;">contact</h1>
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a  style="color: #272d58;" href="<?php echo $base_url . $_GET['company'] ?>">Home</a></li>
                                <li class="breadcrumb-item active">contact</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
     <style>
.contact_wrapper {
    margin-top: 20px; /* Optional: add margin above the contact section */
}

.contact_box {
    display: flex;
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    border: 2px solid #4f575a; 
    border-radius: 8px; 
    padding: 20px; 
    height: 200px; 
    text-align: center; 
    transition: box-shadow 0.3s; 
    margin-left: 13px;
}


.contact_box:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Optional: add shadow on hover */
}

.row {
    display: block;
}
@media (min-width: 768px) {
    .row {
        display: flex;
        justify-content: space-between;
    }
}
.col-lg-4, .col-md-4, .col-sm-4 {
    flex: 1; /* Make all columns equal width */
    margin: 0 10px; /* Optional: add margin between columns */
}
</style>
<style>
    .contact_box:before {
    background: #3f51b5;
</style>
           <div class="contact_wrapper">
    <div class="container">
        <div class="row">
            <?php if (isset($_SESSION['message'])) { ?>
            <div class="text-center" id="message" style="margin-bottom: 15px; font-size: 26px; color: #157ed2;">
                <?php echo display_session_message(); ?>
            </div>
            <?php } ?>
            <div class="col-lg-4 col-md-4 col-sm-4">
                <div class="contact_box">
                    <i class="fa fa-user" aria-hidden="true"></i>
                    <h2>Name:</h2>
                    <p><?php echo $vendors->vendor_name ?></p>
                </div>
            </div>
            <div class="col-lg-4 col-md-4 col-sm-4">
                <div class="contact_box">
                    <i class="fa fa-envelope" aria-hidden="true"></i>
                    <h2>Email:</h2>
                    <p><a href="mailto:<?php echo $vendors->vendor_email ?>"><?php echo $vendors->vendor_email ?></a></p>
                </div>
            </div>
            <div class="col-lg-4 col-md-4 col-sm-4">
                <div class="contact_box">
                    <i class="fa fa-map-marker" aria-hidden="true"></i>
                    <h2>Address:</h2>
                    <p><?php echo $vendors->address; ?>, <?php echo $vendors->city; ?>,<br><?php echo $vendors->vendor_country; ?>, <?php echo $vendors->vendor_state; ?> - <?php echo $vendors->zip_code; ?></p>
                </div>
            </div>
        </div>
    </div>
</div>

            <!--contact form wrapper-->
        <div class="contact_form_wrapper" style="background-color: #4f575a;">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-6 col-md-6 padding_left padding_right">
                            <?php
$full_address = $vendors->address . ', ' . $vendors->city . ', ' . $vendors->vendor_state . ', ' . $vendors->vendor_country . ', ' . $vendors->zip_code;
$encoded_address = urlencode($full_address);
$map_src = "https://www.google.com/maps?q={$encoded_address}&output=embed";
?>
                            <div class="contact_map">
            <iframe 
                src="<?php echo $map_src; ?>" 
                width="100%" 
                height="600" 
                frameborder="0" 
                style="border:0;" 
                allowfullscreen="" 
                loading="lazy" 
                referrerpolicy="no-referrer-when-downgrade">
            </iframe>
        </div>
                        </div>
                        <div class="col-lg-6 col-md-6 padding_right padding_left">
                            <div class="hm_form" style="background-color: #4f575a;">
                                <div class="col-lg-10 col-md-12">
                                    <h1>send a message</h1>
                                    <form class="form-inline" method="post" action="send">
                                        
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="name" name="name" placeholder="Name" required>
                                        </div>
                                        <div class="form-group">
                                            <input type="email" class="form-control" id="email" name="email" placeholder="Email" required>
                                        </div>
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="number" name="number" placeholder="Phone" required>
                                        </div>
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="subject" name="subject" placeholder="Subject" required>
                                        </div>
                                        <input type="hidden" name="vendor_company_name" value="<?php echo $_GET['company'] ?>">
                                        <div class="form-group">
                                            <input type="text" class="form-control" id="subject" name="company_name" placeholder="Company Name" required>
                                        </div>
                                        <div class="form-group textarea">
                                            <textarea class="form-control" rows="3" id="message" name="message" placeholder="Message" required></textarea>
                                        </div>
                                        <div class="con_btn">
                                            <button type="submit" class="hm_btn" name="quote_request" >submit</button>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
              </div>
            </div>
            <!--footer start-->
            <?php include 'includes/footer.php' ?>
            <!-- Footer End -->
            <!--popup inquiry form-->
            <div class="hm_login_form_overlay">
                <div class="hm_login_form">
                    <div class="hm_login_header">
                        <h1>Send Inquiry</h1>
                        <span class="login_close"><i class="fa fa-times" aria-hidden="true"></i></span>
                    </div>
                    <div class="login_fields">
                      <form action="">
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="name">Name</label>
                            <input type="text" class="form-control" id="name" placeholder="Buyer Full Name Here">
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="email">Email</label>
                            <input type="email" class="form-control" id="email" placeholder="Your Official/Personal Email">
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="mobile">Mobile Number</label>
                            <input type="text" class="form-control" id="mobile" placeholder="Buyer Contact Number">
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="company">Company Name</label>
                            <input type="email" class="form-control" id="email" placeholder="Your Company Name">
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="quantity">Quantity</label>
                            <input type="text" class="form-control" id="quantity" placeholder="Quantity">
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="form-group">
                            <label for="Unit">Unit</label>
                            <select class="form-control" name="unit" required>
                              <option>Select Unit</option>
                              <option value="Pcs">Piece(s)/Pcs</option>
                              <option value="Carton">Carton</option>
                              <option value="Dozen">Dozen</option>
                              <option value="m">Meter(s)/m</option>
                              <option value="t">Metric Ton/t</option>
                              <option value="Kg">Kilogram/Kg</option>
                          </select>
                          </div>
                        </div>
                        <div class="col-md-12">
                          <div class="form-group">
                            <label for="requirement_detail">Requirement Details:</label>
                            <textarea class="form-control" rows="5" id="requirement_detail" placeholder="Kindly write detail requirement of your here & do also mention payment mode option."></textarea>
                          </div>
                        </div>
                        <a href="#" class="inquiry-btn cool">Send Enquiry</a>
                      </form>
                    </div>
                </div>
            </div>
        </div>
        <!--main wrapper-->
    </div>

    <!--script-->
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/wow.min.js"></script>
    <script type="text/javascript" src="js/plugin/owl/owl.carousel.min.js"></script>
    <script type="text/javascript" src="js/jquery.fancybox.min.js"></script>
    <script type="text/javascript" src="js/switcher.js"></script>
    <script type="text/javascript" src="js/custom.js"></script>

</body>

</html>