<?php
require_once "../magic/session_config.php";
bdr_start_session();
ob_start();
$father 	= $_SESSION["user_id"];
$role 	  = $_SESSION["role"];
?>
<div  class="panel panel-primary" id="newCar">
  <div class="panel-heading"style="font-size:1.2em;">صلاحيات المستخدمين</div>
  <div class="panel-body" style="background-color:#00324d; color:#cce5ff;" >
<form method="post" class="form-horizontal">
      <br />
        <div class="row" style="padding:4px;">
          <div class="col-md-3"style="float:right;padding:2px;">
            <label for="namm" class="control-label"style="float:right;margin:5px;"> باسم المستاجر <span style="float:right;margin-left:10px;"><button id="namm_a"  type="button" class="btn btn-success btn-xs "> بحث </button></span></label>
            <input type="text" class="form-control" style="float:right;" id="namm" name="namm" placeholder="اسم المستأجر"/>
          </div>
          <div class="col-md-2"style="float:right;padding:2px;">
            <label for="numb" class="control-label"style="float:right;margin:5px;">برقم <span style="float:right;margin-left:10px;"><button id="numb_a" type="button" class="btn btn-success btn-xs "> بحث </button></span></label>
            <input type="number" class="form-control" style="float:right;" id="numb" name="numb" placeholder="هوية رخصة جوال" />
          </div>
        <div class="col-md-4"style="float:right;padding:2px;">
          <label for="ad" class="control-label"style="float:right;margin:5px;">جهة العمل و العنوان <span style="float:right;margin-left:10px;"><button id="ad_a"  type="button" class="btn btn-success btn-xs "> بحث </button></span></label>
          <input type="text" class="form-control" style="float:right;" id="ad" name="ad" placeholder="اي رقم في بيانات المستأجر" />
        </div>
      </div>
</form>
<br />
    <div class="table-responsive">
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                   <th class="text-center" width="8%">كود</th>
                   <th class="text-center" width="26%">الاسم</th>
                   <th class="text-center" width="10%">رقم الجوال</th>
                   <th class="text-center" width="30%">العنوان</th>
                   <th class="text-center" width="10%">جوال 2</th>
                   <th class="text-center" width="8%">الفرع</th>
                   <th class="text-center" width="8%">الحالة</th>
              </tr>
            </thead>
              <tbody id="myTable">
                <?php
                 include "../actions/dbPDO.php";
                 $where = "";
                 if($role > 2){
                  $where = " AND users.user_Id > 99 ";
                 }
                  $output = '';
                  $sql =$db->prepare("SELECT users.user_Id , users.realName , users.phone1 , users.address , users.phone2 ,users.active , branches.b_name
                                            FROM users , branches WHERE  users.branch = branches.branchID AND users.active = 1 $where");
                  $sql->execute();
                   if($sql->rowCount()>0)
                  {
                     while($row = $sql->fetch())
                       {
                    $output .= '<tr>
                                    <td>
                                    <a href="acc/user_update.php?id='.$row['user_Id'].'" target="_blank"><button type="button" class="btn btn-success btn-xs ">تحديث</button></a>
                                    </td>
                                    <td >' . $row['realName'] . '</td>
                                    <td class="text-center" >' . $row['phone1'] . '</td>
                                    <td>' . $row['address'] . '</td>
                                    <td class="text-center">' . $row['phone2'] . '</td>
                                    <td class="text-center" >' . $row['b_name'] . '</td>
                                    <td class="text-center" >' . $row['active'] . '</td>
                                </tr>  ';
                       }
                  }
    else { $output .= '<tr><td colspan="7">لا يوجد سجلات ...</td></tr>'; }
                  echo $output;
                  ?>
              </tbody>
						<tfoot></tfoot>
          </table>
    </div>
</div>
</div>
