<?php
    require_once __DIR__ . '/../magic/auth.php';

    $auth = bdr_require_privilege([20, 36, 30], 'branch.php', 'branch.php');
    $user = $auth['user_id'];
    $father = $auth['user_id'];
    $branch = $auth['branch'];
    $conn = $auth['conn'];
    $db = $auth['conn'];
    $role = 0;
    $roleQuery = $conn->prepare('SELECT role FROM users WHERE user_id = ? LIMIT 1');
    $roleQuery->execute([$father]);
    if ($row = $roleQuery->fetch(PDO::FETCH_ASSOC)) {
        $role = $row['role'];
    }
    ?>
    <!DOCTYPE html>
    <html lang="ar" dir="rtl">
    <head>
    	<meta charset="utf-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    	<meta name="robots" content="index,follow">
    	<meta name="author" content="سامح دياب">
    	<link rel="icon" href="../images/perfect.ico">
    	<title> بحث عن سيارة </title>
    	<link rel="stylesheet" href="../dist/css/bootstrap.css"/>
      <link rel="stylesheet" href="../css/font-awesome.min.css"/>
    	<link rel="stylesheet" href="myCar.css"/>
    	<script src="../js/jquery.js"></script>
      <script src="../dist/js/umd/popper.min.js"></script>
    	<script src="../dist/js/bootstrap.js"></script>
    </head>
<body style="background-color:#270c0c ; color:#cce5ff;">
  <!-- <div class="navbar navbar-inverse bg-inverse bg-faded sticky-top"> -->
		<div class="container-fluid fixed-top" style="background-color:black ;">
    <div class="form-row align-items-center">
      <div class="col">
      <div class="btn-group btn-group-lg" style="font-weight:bold;" role="group" aria-label="...">
        <button type="button" id="home" style="font-weight:bold;font-size:2rem;" class="btn btn-success">اليوم</button>
        <button type="button" id="at_rent" style="font-weight:bold;font-size:2rem;" class="btn btn-info">ساري</button>
        <button type="button" id="debt_contracts" style="font-weight:bold;font-size:2rem;" class="btn btn-danger">مديون</button>
        <button type="button" id="car_search" style="font-weight:bold;font-size:2rem;" class="btn btn-outline-secondary">بحث سيارة </button>
        <?php 
        if($role == 1){
          echo '<button type="button" id="log" style="font-weight:bold;padding:5px;font-size:2rem;" class="btn btn-secondary">سجلات</button>';
        }
        ?>
      </div>
    </div>
  </div>
		</div>
	<!-- </div> -->
  <br /><br /><br /><br /><br />
  <form method="post" id="car_form" name="car_form">
  <div class="form-row align-items-center">
    <div class="col-6">
      <p style="font-weight:bold;font-size:1.4rem;float:left;">بحث برقم السيارة </p>
    </div>
    <div class="col-3">
      <input type="number" id="car_no" name="car_no" placeholder="ارقام فقط" style="font-weight:bold;font-size:1.4rem;max-width:100px;" />
    </div>
    <div class="col-3">
      <button class="btn btn-success" id="car_sr" style="font-weight:bold;font-size:1.7rem;" >بحث</button>
    </div>
  </div>
  <div class="form-row align-items-center">
  <div class="col-6">
    <p style="font-weight:bold;font-size:1.4rem;float:left;">بحث برقم السيارة </p>
  </div>
  <div class="col-3">
  <input type="file" accept="image/*;capture=camera">
</div>
</div>
</form>
</div>
<br /><br />

<div id="re_car"></div>
</br />
<div id='br_save'></div>

  <script>
  $(document).ready(function(){
    $("#home").click(function(event){
      event.preventDefault();
        window.open("home.php", '_self');
    });
    $("#at_rent").click(function(event){
      event.preventDefault();
        window.open("at_rent.php", '_self');
    });

    $("#debt_contracts").click(function(event){
      event.preventDefault();
        window.open("debt_contracts.php", '_self');
    });

    $("#car_sr").click(function(event){
      event.preventDefault();
      $.ajax({
        url     : "car_sr.php",
        method  : "POST",
        data    :$("#car_form").serialize(),
        success : function(data){
        $("#re_car").html(data);
      },
        error   :function(result){
          alert(result.statusText);
          }
      });
    });
    $("#log").click(function(event){
      event.preventDefault();
        window.open("log_manager.php", '_self');
    });
  });
  </script>

</body>
</html
