<div  class="panel panel-primary" id="main_supp">
  <div class="panel-heading clearfix"style="font-size:1.2em;">
  <div class="row" style="padding:4px;">
      <div class="col-xs-4 col-md-3"style="float:right;">
        <label for="supp_name" class="control-label"style="float:right;font-size: 16px">بحث و تعديل بيانات الموردين</label>
      </div>
      <div class="col-xs-4 col-md-2"style="float:left;  color: #000 ;">
      <input type="text" id="nn" name="nn" class="form-control" name="nn" placeholder="ابحث بالرقم">
      </div>
      <div class="col-xs-12 col-md-3"style="float:left;  color: #000 ;">
          <input type="text" class="form-control" id="tt" name="tt" placeholder="ابحث بالاسم">
          </div>
      <input type="hidden" id="vwv" name="vwv" style="width:20; color:#000 ;">
      <div class="col-xs-3 col-md-3"style="float:left;  color: #000 ;">
    <a href="a/suppUpdate.php"target="_blank" id="v5" hidden><button type="button" class="btn btn-success"> تحديث </button></a>
    <a href="a/suppUpdate.php"target="_blank" id="v6" hidden><button type="button" class="btn btn-info ">عقود الشركة</button></a>
    </div>
    </div>
    </div>
  <div class="panel-body"  style="background-color:#00324d;color:#cce5ff;">
    <?php
 include "../actions/dbPDO.php";
 $output = '';
 $sql =$db->prepare("select supp_id, supp_name , boss, sales,casher from supplycomp order by supp_id desc");
      $sql->execute();

 $output .= '
      <div class="table-responsive">
           <table class="table table-bordered table-hover">
                <tr>
                     <th class="text-center" width="15%">حركة</th>
                     <th class="text-center" width="25%">اسم الشركة</th>
                     <th class="text-center" width="20%">المدير</th>
                     <th class="text-center" width="20%">البائع</th>
                     <th class="text-center"  width="20%">المحصل</th>
                    </tr>';
  if($sql->rowCount()>0)
    {
  while($row =  $sql->fetch())
                         {
           $output .= '
                <tr>
                     <td class="text-center">
                     <a href="a/suppUpdate.php?id=' . $row['supp_id'] . '"target="_blank"><button type="button" class="btn btn-success btn-xs">تحديث</button></a>
                     <a href="a/suppCont.php?id=' . $row['supp_id'] . '"target="_blank"><button type="button" class="btn btn-info btn-xs">عقود الشركة</button></a>
                     </td>
                     <td class="text-center">' . $row['supp_name'] . '</td>
                     <td class="text-center">' . $row['boss'] . '</td>
                     <td class="text-center">' . $row['sales'] . '</td>
                     <td class="text-center">' . $row['casher'] . '</td>
                  </tr>
           ';
      }

 }
 else
 {
      $output .= '<tr>
                          <td colspan="5">لا يوجد سجلات ...</td>
                     </tr>';
 }
 $output .= '</table>


      </div>';
 echo $output;
 ?>
</div>
</div>
<!-- panel body style -->
<?php
include "../actions/dbPDO.php";
$output = array();
    $query =$db->prepare("SELECT supp_id , supp_name from supplycomp
              union(select supp_id, company_owner from supplycomp)
              union(select supp_id, boss from supplycomp)
              union(select supp_id, sales_master from supplycomp)
              union(select supp_id, sales from supplycomp)
              union(select supp_id, cash_master from supplycomp)
              union(select supp_id, casher from supplycomp)
              union(select supp_id, address from supplycomp)
              union(select supp_id, comm from supplycomp)");
  $query->execute();
 if($query->rowCount()>0)
   {
     $i=0;
 while($row =  $query->fetch())
     {$output[$i] = array( "value" => $row["supp_name"], "data" => $row["supp_id"]);      $i++ ;}
    }
    else { $output[0]= 'لا يوجد شركة بهذا الاسم';}
    // search by any number phone fax id licenes
    $number_out = array();
        $number_query =$db->prepare("SELECT supp_id , boss_jawal from supplycomp
                  union(select supp_id, master_jawal from supplycomp)
                  union(select supp_id, sales_jawal from supplycomp)
                  union(select supp_id, cash_jawal from supplycomp)
                  union(select supp_id, ca_jawal from supplycomp)
                  union(select supp_id, fax from supplycomp)
                  union(select supp_id, phone from supplycomp)");
      $number_query->execute();
     if($number_query->rowCount()>0)
        {
          $d=0;
             while($row =  $number_query->fetch())
             {$number_out[$d] = array( "value" => $row["boss_jawal"], "data" => $row["supp_id"]);      $d++ ;}
        }
        else { $number_out[0]= 'هذا الرقم غير موجود بالشركات';}
?>
<script>
$(document).ready(function(){
  var arr=  JSON.parse('<?php echo json_encode($output) ; ?>');

  $('#tt').autocomplete({
	 lookup: arr,
   maxHeight : 200,
   onSelect: function(suggestion) {$('#v5').attr("href", "a/suppUpdate.php?id="+(suggestion.data)).show(); $('#v6').attr("href", "a/suppCont.php?id="+(suggestion.data)).show();},
  //  onHint: function (hint) {$('#supp_name_x').val(hint);},$.cookie('ddy',tt);
    onInvalidateSelection: function() {$('#supp_val').html('You selected: none');}
  })
    var numm=  JSON.parse('<?php echo json_encode($number_out) ; ?>');
$('#nn').autocomplete({
 lookup: numm,
 maxHeight : 200,
 onSelect: function(suggestion) {$('#v5').attr("href", "a/suppUpdate.php?id="+(suggestion.data)).show(); $('#v6').attr("href", "a/suppCont.php?id="+(suggestion.data)).show();},
//  onHint: function (hint) {$('#supp_name_x').val(hint);},
//  onInvalidateSelection: function() {$('#supp_val').html('You selected: none');}
})
})

</script>
