<?php
include("dbconnect.php");

session_start();
//error_reporting(E_ALL);
error_reporting(E_ERROR | E_PARSE);

require_once 'classUser.php';

$reg_user = new USER();


if(isset($_POST['btn-signup'], $_POST['full_name'],$_POST['phone'],$_POST['email'],$_POST['subject'],$_POST['message']))
{

 if(empty($_POST['full_name']))
 {
 	$error[] = 'Please enter your full name';
 }
 $full_name = trim($_POST['full_name']);


 if(empty($_POST['phone']))
 {
 	$error[] = 'Please enter valid Phone';
 }
 $phone = trim($_POST['phone']);

 if(empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
 {
 	$error[] = 'Please enter valid Email.';
 }
 
 $email = trim($_POST['email']);

 
 if(empty($_POST['subject']))
 {
 	$error[] = 'Please write your subject';
 }

 $subject = trim($_POST['subject']);
 
 
 if(empty($_POST['message']))
 {
 	$error[] = 'Please write your message';
 }

 $message = trim($_POST['message']);
 

 if(count($error) < 1)
 {

 $ip_address=$ip=$_SERVER['REMOTE_ADDR'];
 $language='English';
 
if (isset($_GET['product_id'])){
    // Retrieve the value of the 'product_id' parameter
    $product_id = $_GET['product_id'];
    
	if(is_numeric($product_id))
	{
    // Sanitize the input to prevent XSS attacks
    $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
	}
	
}

 if($reg_user->register($full_name,$phone,$email,$product_id, $subject, $message,$ip_address,$language))
  {   
   
$message1 = "     
 Dear Hazlan General Medical Staff,<br>
Please be noted that  $full_name has sent a message via contact form, incase, 
 To contact the user, here is the the  email (<a href='mailto:$email'>$email</a> ).<br>
 The message is:<br>$message.<br>
Best Regards,<br/>
Hazlan General Medical Auto Email Generation";

   $subject1 = "hazlangeneralmedical.co - New message";
   $reg_user->send_mail('info@hazlangeneralmedical.co',$email,$message1,$subject1);
   
 
 $msg = "
    <div class='alert alert-success'>
    <a href='#' class='close' data-dismiss='alert'>&times;</a>
    <strong>Success!</strong> We will get back to you soon.
     </div>
     ";
  }
  else
  {
   echo "sorry , Query could no execute...";
  }  
  
 
  $_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
    $params = session_get_cookie_params();
    setcookie(session_name(), '', time() - 42000,
        $params["path"], $params["domain"],
        $params["secure"], $params["httponly"]
    );
}

// Finally, destroy the session.
session_destroy();
 }else
 {
	//error 
 print_r($error);
 print_r($_REQUEST);
 }
}
?>


<!DOCTYPE html>
<html lang="en">

  <head> 
  <link rel="icon" href="images/logo.jpeg">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="<?php 
	if(isset($_REQUEST["product_id"])) 
	{  


    $product_id = $_GET['product_id'];
    
	if (is_numeric($product_id)) 
	{ 
  $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
	
	  $stmt = $dbh->prepare("SELECT * FROM products WHERE publish ='Yes' and language='English' and product_id=:product_id"); 
	  $stmt->execute(array(":product_id"=>$product_id));
	   $row=$stmt->fetch(PDO::FETCH_ASSOC);  
	   echo $row['short_description'];	 
	    }  
		
		}
		
	
	?>" />
   
    <meta name="author" content="hazlangeneralmedical.co">
    
	 <!-- Bootstrap Core CSS -->
    

    <title><?php 
	if(isset($_REQUEST["product_id"])) 
	{  


    $product_id = $_GET['product_id'];
    
	if (is_numeric($product_id)) 
	{ 
  $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
  
	  $stmt = $dbh->prepare("SELECT * FROM products WHERE publish ='Yes' and language='English' and product_id=:product_id"); 
	  $stmt->execute(array(":product_id"=>$product_id));
	   $row=$stmt->fetch(PDO::FETCH_ASSOC);  
	   echo $row['product_name'];	 
	    }  
		}		
	
	?></title>

    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/modern-business.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/custom.css?v3" rel="stylesheet">
	
	<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.2.0/ekko-lightbox.min.css" rel="stylesheet" />
	
	
	
  
  
<script src='https://www.google.com/recaptcha/api.js'></script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-124165845-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-124165845-2');
</script>



<style>
.topmenu {

font-size:12px;
text-align:right;
}
.topmenu div {

}
.topmenu a {
margin-left:12px;
text-decoration:none;
}
.sticky-wrapper{
height:auto;
}

     .cse .gsc-control-cse,
     .gsc-control-cse {
      background-color:transparent !important;
	  border: transparent !important;
      padding-right: 0 !important;
    }

</style>




  </head>

  <body>

    <!-- Navigation -->
   
     <nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark fixed-top gradient" >
	 
    <div class="container">
    <a class="navbar-brand" href="index.php"><img src="images/logo.jpeg" style="max-height: 60px;"></a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarColor03">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item ">
              <a class="nav-link" href="index.php">Home</a>
            </li>
			<li class="nav-item active">
              <a class="nav-link" href="products.php">Products</a>
            </li>
			 <li class="nav-item ">
              <a class="nav-link" href="services.php">Services</a>
            </li>
           
			 <li class="nav-item">
              
                <a class="nav-link" href="news.php">News</a>
               
            </li>
            <li class="nav-item">
              <a class="nav-link" href="about.php">About</a>
            </li>
      
			 
            <li class="nav-item ">
              <a class="nav-link" href="contact.php">Contact</a>
            </li>
           
          </ul>
    <div class="col-md-4 text-right" style="color:black; padding-right: 0px;padding:0px;padding-left: 0px;line-height: 0em;">
 <gcse:search class="gsc-control-cse"></gcse:search>
 </div>
  </div>
    </div>
    </nav>

    <!-- Page Content -->
    <div class="container">

      <!-- Page Heading/Breadcrumbs -->
      <br/>
 
 <?php 
 
if(isset($_REQUEST["product_id"])) 
	{  


    $product_id = $_GET['product_id'];
    
	if (is_numeric($product_id)) 
	{ 
  $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
 
 $stmt = $dbh->prepare("SELECT * FROM products WHERE publish ='Yes' and language='English' and product_id=:product_id");
 $stmt->execute(array(":product_id"=>$product_id));
 $row=$stmt->fetch(PDO::FETCH_ASSOC);
   
   
echo"

<a href='product_detail.php?product_id=".$row['product_id']."'><h2 class='mt-4 mb-3'>".$row['product_name']."
       
</h2></a>

   ";
   
	}
	}
?>  
      
     

      <ol class="breadcrumb">
        <li class="breadcrumb-item">
          <a href="index.php">Home</a>
        </li>
        <li class="breadcrumb-item active"> 
		<?php 
 
echo"

".$row['product_name']."

";
?>
</li>
      </ol>

      <div class="row">

        <!-- Post Content Column -->
        <div class="col-lg-8">



 <?php 

 
if(isset($_REQUEST["product_id"])) 
	{  


    $product_id = $_GET['product_id'];
    
	if (is_numeric($product_id)) 
	{ 
  $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
  
 
 $stmt = $dbh->prepare("SELECT * FROM products WHERE publish ='Yes' and language='English' and product_id=:product_id");
 $stmt->execute(array(":product_id"=>$product_id));
 $row=$stmt->fetch(PDO::FETCH_ASSOC);

echo"

<a href='product_detail.php?product_id=".$row['product_id']."'><img class='img-fluid rounded' width='100%' src='images/products/".$row['main_photo']."' alt=''/></a>   ";
	}
	}
?>  
 <hr>

 <?php 
 
if(isset($_REQUEST["product_id"])) 
	{  


    $product_id = $_GET['product_id'];
    
	if (is_numeric($product_id)) 
	{ 
  $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
 
 $stmt = $dbh->prepare("SELECT * FROM products WHERE publish ='Yes' and language='English' and product_id=:product_id");
 $stmt->execute(array(":product_id"=>$product_id));
 $row=$stmt->fetch(PDO::FETCH_ASSOC);
 
 
echo"



              <p style='text-align: justify;'>".$row['description']."</p>

   ";
	}
	}
?>  

<!-- Go to www.addthis.com/dashboard to customize your tools --> <div class="addthis_inline_share_toolbox_5a0q"></div>




<div class="container">
  <div class="row">



 <?php 
 
if(isset($_REQUEST["product_id"])) 
	{  


    $product_id = $_GET['product_id'];
    
	if (is_numeric($product_id)) 
	{ 
  $product_id = htmlspecialchars($product_id, ENT_QUOTES, 'UTF-8');
  
 $query = $dbh->prepare("SELECT * FROM product_photos where Publish='Yes' and product_id=:product_id");
     $query->execute(array(":product_id"=>$product_id));
	
	for($i=0; $row = $query->fetch(); $i++)
	{
		

 

echo"

       <a href='images/products/".$row['photo']."' data-toggle='lightbox' data-gallery='gallery'class='col-md-4'>
         <img src='images/products/".$row['photo']."' class='img-fluid rounded'>

	  </a>";
	  
	  
	  
	  
	}
	}
	}
	
	
	

	
	
?>  



    
</div>
</div>


<br>

<br>


</div>



<br>




        <!-- Sidebar Widgets Column -->
        <div class="col-md-4">

         
          <!-- Categories Widget -->
          <div class="card my-4" style="margin-top:0 !important">
            <h5 class="card-header">Other Products</h5>
            <div class="card-body">
              <div class="row">
                <div class="col-lg-12">
                  <ul class="list-unstyled mb-0">
                    
  <?php $query = $dbh->prepare("SELECT * FROM products where publish='Yes' and language='English' order by rand() desc limit 3");
 $query->execute();   
	 
	for($i=0; $row = $query->fetch(); $i++)
	{ 
	   echo       "<li><a href='product_detail.php?product_id=".$row['product_id']."'>".$row['product_name']."</a>
                    </li>";	
	} 
	
                    ?>
              
                     
                   
                  </ul>
                </div>
                
				
	
				
				
				
              </div>
            </div>
          </div>

          <!-- Side Widget -->
          <div class="card my-4" style="margin-top:0 !important">
            <h5 class="card-header">Order the Product</h5>
            <div class="card-body">
              <div class="row">
                <div class="col-lg-12">
                 
				 
				 
			<form class="form-horizontal" action=" " method="post"  id="reg_form">
  	<div class="error">
                <?php
                // Initialize error array if not already set
                if (isset($_GET['errors'])) {
                    $error = unserialize(urldecode($_GET['errors']));
                } else {
                    $error = array();
                }

                // Check for errors and display them
                if (count($error) > 0) {
                    echo "<ul>";
                    foreach ($error as $v) {
                        echo "<li>$v</li>";
                    }
                    echo "</ul>";
                }
                ?>
            </div>
	
<?php if(!isset($msg))
	 {

	echo"
	
            <div class='row'>
              <div class='col-12 form-group''>
                <input type='text' name='full_name' class='form-control' id='full_name' placeholder='Your Name' data-rule='minlen:4'
                  data-msg='Please enter at least 4 chars' />
                <div class='validation'></div>
              </div>

              <div class='col-12 form-group'>
                <input type='text' name='phone' class='form-controlmobilenumber' id='phone' placeholder='964 XXX XXX XXXX' data-rule='minlen:4'
                  data-msg='Please enter your mobile number' />
                <div class='validation'></div>
              </div>
              <div class='col-12 form-group'>
                <input type='email' class='form-control' name='email' id='email' placeholder='Your Email' data-rule='email'
                  data-msg='Please enter a valid email' />
                <div class='validation'></div>
              </div>
                
     <div class='col-12 form-group'>
                <input type='text' class='form-control' style='display:none;' name='product_id' id='product_id' placeholder='product id from the url' data-rule='minlen.4'
                  data-msg='Please enter the product ID' />
                <div class='validation'></div>
              </div>
             
              
              <div class='col-12 form-group'>
                <input type='text' class='form-control' name='subject' id='subject' placeholder='Subject' data-rule='minlen:4'
                  data-msg='Please enter at least 8 chars of subject' />
                <div class='validation'></div>
              </div>
              <div class='col-12 form-group'>
                <textarea class='form-control' name='message' id='message' rows='5' data-msg='Please write something for us'
                  placeholder='Message'></textarea>
                <div class='validation'></div>
                <div class='text-center'>
                  <button class='btn btn-color btn-rounded' type='submit' name='btn-signup'>Send message</button>
                </div>
              </div>
            </div>";
	 }else
		if(isset($msg)) { echo $msg;	} 
	 ?>
			
          </form>

	

 <div id="recaptcha" class="g-recaptcha" data-sitekey="6LfRg64UAAAAAASY_soMezc3Dn4yEyAHY6pjl2Q-" 
    data-callback="bootstrapValidator" data-size="invisible"></div>
  


		  
				 
				 
            </div>
            <div class="widget">
            

<div class="g-recaptcha"
          data-sitekey="6LcyZ3AUAAAAAITCprlUsyDQCWNdXb9PtZKUfglj"
          data-callback="onSubmit"
          data-size="invisible">
    </div>
                </div>
                
              </div>
            </div>
          </div>

        </div>

      </div>
      <!-- /.row -->

    </div>
    <!-- /.container -->

    <!-- Footer -->
     <?php
		include("footer.php");
?>


    <!-- Bootstrap core JavaScript -->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
	 <!-- Contact Form JavaScript File -->
	 
  <script src="contactform/contactform.js"></script>

  <!-- Template Custom JavaScript File -->
  <script src="assets/js/custom.js"></script>

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.4.5/js/bootstrapvalidator.min.js'></script>
	
	
<script>
  (function() {
    var cx = 'a5dd05eba34294ef0';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
  
  window.onload = function(){
document.getElementById('gsc-i-id1').placeholder = 'Search this website ...';
};
</script>

<!-- WhatsHelp.io widget -->
<script type="text/javascript">
    (function () {
        var options = {
            facebook: "1385089458207746", // Facebook page ID
            call_to_action: "Message us", // Call to action
            position: "right", // Position may be 'right' or 'left'
        };
        var proto = document.location.protocol, host = "whatshelp.io", url = proto + "//static." + host;
        var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = url + '/widget-send-button/js/init.js';
        s.onload = function () { WhWidgetSendButton.init(host, proto, options); };
        var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
    })();
</script>



<script type="text/javascript">
   $(document).ready(function() {
    $('#reg_form').bootstrapValidator({
        // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later
        feedbackIcons: {
            valid: 'fa fa-thumbs-o-up',
            invalid: 'fa fa-times',
            validating: 'fa fa-refresh'
        },
        fields: {
            full_name: {
                validators: {
                        stringLength: {
                        min: 3,
                    },
                        notEmpty: {
                        message: 'Please supply your first name'
                    }
                }
            },
			
           
            phone: {
                validators: {
                    notEmpty: {
                        message: 'Please supply your phone number'
                    },
                   
                }
            },
            
                 subject: {
                validators: {
                    notEmpty: {
                        message: 'Please supply a headline'
                    },
                   
                }
            },
			
			     message: {
                validators: {
                    notEmpty: {
                        message: 'Please write your message content'
                    },
                   
                }
            },
			
			
	
    	
			
	 email: {
                validators: {
                    notEmpty: {
                        message: 'Please supply your email address'
                    },
                    emailAddress: {
                        message: 'Please supply a valid email address'
                    }
                }
            },
					
	
		}
            
            
        })
		
		
	
        .on('success.form.bv', function(e) {
            $('#success_message').slideDown({ opacity: "show" }, "slow") 
			// Do something ...
                $('#reg_form').data('bootstrapValidator').resetForm();
 
            // Prevent form submission
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target);

            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
 
            // Use Ajax to submit form data
            $.post($form.attr('action'), $form.serialize(), function(result) {
                console.log(result);
				 grecaptcha.reset();
            }, 'json');
			
			
        });
});
 
</script>






<script>



$(document).on("click", '[data-toggle="lightbox"]', function(event) {
  event.preventDefault();
  $(this).ekkoLightbox();
});
</script>



 <?php
  include("js/custom_en.js");
  ?>




<!-- /WhatsHelp.io widget -->


<!-- Go to www.addthis.com/dashboard to customize your tools --> 

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.2.0/ekko-lightbox.min.js"></script>


<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5b76a109d69a33e5"></script>
  </body>

</html>
