<?php
include('db_connection.php');
$Mainclass=new DB_Controller();
$Mainclass->Check_Login();

$Page_Url=$_SERVER['REQUEST_URI'];
$Ex=explode("/",$Page_Url);
$Page=end($Ex);
$Ex1=explode('?',$Page);
$Page2=$Ex1[0];

?>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>


<nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
      </li>
      
    </ul>

    <!-- SEARCH FORM -->
   

    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
    

<?php 

$today = date('Y-m-d');

$rate_num_check = $Mainclass->num_check("gold_rate_master","SLN","DATE(Entry_Date)='".$today."'");

?>

<?php 
if($rate_num_check==0){
?>
      <span style="margin-right: 50px;font-family: serif;color: #6c757d;margin-top: 6px; font-family: 'Roboto', sans-serif; font-size:14px;">No gold rate has been recorded for today.</span>

<?php } ?>   

<?php 
if($rate_num_check>0){


if($Page=='new-stn.php' || $Page=='pending-stn.php' || $Page=='completed-stn.php' || $Page=='scan-product.php' || $Page=='view-gold-grn.php'){


$rate_14k = $Mainclass->Fetch_individual_data("gold_rate_master","Dealer_Rate","DATE(Entry_Date)='".$today."' and Karat='14K' order by SLN desc limit 1");
$rate_18k = $Mainclass->Fetch_individual_data("gold_rate_master","Dealer_Rate","DATE(Entry_Date)='".$today."' and Karat='18K' order by SLN desc limit 1");
$rate_22k = $Mainclass->Fetch_individual_data("gold_rate_master","Dealer_Rate","DATE(Entry_Date)='".$today."' and Karat='22K' order by SLN desc limit 1");


$gold_rate_14k=$rate_14k['Dealer_Rate'];
$gold_rate_18k=$rate_18k['Dealer_Rate'];
$gold_rate_22k=$rate_22k['Dealer_Rate'];


}

else{

$rate_14k = $Mainclass->Fetch_individual_data("gold_rate_master","Selling_Rate","DATE(Entry_Date)='".$today."' and Karat='14K' order by SLN desc limit 1");
$rate_18k = $Mainclass->Fetch_individual_data("gold_rate_master","Selling_Rate","DATE(Entry_Date)='".$today."' and Karat='18K' order by SLN desc limit 1");
$rate_22k = $Mainclass->Fetch_individual_data("gold_rate_master","Selling_Rate","DATE(Entry_Date)='".$today."' and Karat='22K' order by SLN desc limit 1");

$gold_rate_14k=$rate_14k['Selling_Rate'];
$gold_rate_18k=$rate_18k['Selling_Rate'];
$gold_rate_22k=$rate_22k['Selling_Rate'];

}



?>
      <span style="margin-right: 50px;font-family: serif;color: #6c757d;margin-top: 6px; font-family: 'Roboto', sans-serif; font-size:14px;">Gold Rate as on <span style="font-weight:600;"> <?php echo date('d-m-y',strtotime($today)) ?> </span>| 14K : <span style="font-weight:600;"><?php echo $gold_rate_14k?></span> | 18K : <span style="font-weight:600;"><?php echo $gold_rate_18k?></span>  | 22K : <span style="font-weight:600;"><?php echo $gold_rate_22k;?></span> </span>

<?php } ?>      

    <img src="dist/img/logo-web.png" width="120">
    
    </ul>
  </nav>
<input type="hidden" name="agent_contact" id="agent_contact" value="<?php echo $_COOKIE['Agent_Contact'];?>">  
<div class="modal fade" id="modal-default">
        <div class="modal-dialog">
        <div id="showmodal_data">
          <!--<div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title" style="font-weight:600;">9999999999 Calling...</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <p><b>Last Calling Date :02-08-2022</b> </br></br>
              
            <b>Last Calling Purpose / Reason</b> </br> 
             Lorem Ipsum is simply dummy text of the printing and typesetting industry.</br></br>
             <b>Ticket No : </b>00000000</br>
             <b>Ticket Status : </b>Lorem Ipsum is simply dummy text of the printing and typesetting industry
              
              </p>
            </div>
            <div class="modal-footer justify-content-between"  style="float:right !important; text-align:right;">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="button" class="btn btn-primary" style="float:right; font-weight:600;"><i class="fas fa-phone nav-icon" style="margin-right:6px; "></i> RECEIVE</button>
            </div>
          </div>-->
          <!-- /.modal-content -->
          </div>
        </div>
        <!-- /.modal-dialog -->
      </div>