<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  class="control-label"style="float:right;font-size: 16px">متابعة الصيانة</label>
      </div>
      <div class="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-md-1"style="float:left;  color: #000 ;">
    <button type="button" id="kok" class="btn btn-success btn-xs"> تحديث </button>
    </div>
    </div>
    </div>
  <div class="panel-body"  style="background-color:#00324d;color:#cce5ff;">
    <div class="table-responsive">
      <h4 style="font-weight:bold; color:#ffeae8;">طلبات جديدة</h4>
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                   <th class="text-center" width="6%">حركة</th>
                   <th class="text-center" width="11%">التاريخ</th>
                   <th class="text-center" width="10%">مقدم الطلب</th>
                   <th class="text-center" width="10%">نوع السيارة</th>
                   <th class="text-center" width="10%">لوحة</th>
                   <th class="text-center" width="6%">موديل</th>
                   <th class="text-center" width="46%">وصف الحالة</th>
              </tr>
            </thead>
              <tbody >
  <?php
      include "../actions/dbPDO.php";
              $output = '';
                  $sql =$db->prepare("SELECT ment_request.req_id ,ment_request.car_id, ment_request.ask_date , users.realName , cars.kind , concat(cars.letters , cars.numbers) as numm ,
                      cars.model , ment_request.description from ment_request , users , cars where ment_request.father = users.user_Id
                      AND ment_request.car_id =cars.carid AND ment_request.done = 0 ORDER by ment_request.req_id DESC ");
                  $sql->execute();
         if($sql->rowCount()>0)
                  {
                     while($row = $sql->fetch())
                       {
                            $output .= '
                                 <tr>
                                      <td>
                                      <a href="a\ment_respond.php?id=' . $row['car_id'] . '&req_id=' . $row['req_id'] .'" target ="_blank"><button type="button" class="btn btn-danger btn-xs ">صيانة</button></a>
                                      </td>
                                      <td class="text-center">' . $row['ask_date'] . '</td>
                                      <td>' . $row['realName'] . '</td>
                                      <td>' . $row['kind'] . '</td>
                                      <td>' . $row['numm'] . '</td>
                                      <td class="text-center" >' . $row['model'] . '</td>
                                      <td class="text-center" >' . $row['description'] . '</td>
                                    </tr>  ';
                       }
                  }
                  else
                  {
                       $output .= '<tr><td colspan="7">لا يوجد سجلات ...</td></tr>';
                  }
                  echo $output;
                  ?>
              </tbody>
						<tfoot></tfoot>
          </table>
    </div>  <!-- end of new requests -->
    <div class="table-responsive">
      <h4 style="font-weight:bold; color:#eaffea;">في انتظار الرد</h4>
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                <th class="text-center" width="6%">حركة</th>
                <th class="text-center" width="11%">التاريخ</th>
                <th class="text-center" width="10%">مقدم الطلب</th>
                <th class="text-center" width="10%">نوع السيارة</th>
                <th class="text-center" width="10%">لوحة</th>
                <th class="text-center" width="6%">موديل</th>
                <th class="text-center" width="46%">وصف الحالة</th>
              </tr>
            </thead>
              <tbody>
                <?php
                $output = '';
                  $sql =$db->prepare("select ment_request.req_id ,ment_request.car_id, ment_request.ask_date , users.realName , cars.kind , concat(cars.letters , cars.numbers) as numm ,
                      cars.model , ment_request.description from ment_request , users , cars where ment_request.father = users.user_Id
                      AND ment_request.car_id =cars.carid AND ment_request.done = 1 ORDER by ment_request.req_id DESC ");
                  $sql->execute();
                   if($sql->rowCount()>0)
                  {
                     while($row = $sql->fetch())
                       {
                            $output .= '
                                 <tr>
                                      <td>
                                      <a href="a\ment_respond.php?id=' . $row['car_id'] . '&req_id=' . $row['req_id'] .'" target ="_blank"><button type="button" class="btn btn-danger btn-xs ">صيانة</button></a>
                                      </td>
                                      <td class="text-center">' . $row['ask_date'] . '</td>
                                      <td>' . $row['realName'] . '</td>
                                      <td>' . $row['kind'] . '</td>
                                      <td>' . $row['numm'] . '</td>
                                      <td class="text-center" >' . $row['model'] . '</td>
                                      <td class="text-center" >' . $row['description'] . '</td>
                                    </tr>
                            ';
                       }
                  }
                  else
                  {
                       $output .= '<tr>
                                           <td colspan="7"><h4>لا يوجد سجلات ...</h4></td>
                                      </tr>';
                  }
                  echo $output;
                  ?>
              </tbody>
						<tfoot></tfoot>
          </table>
    </div>  <!-- end of new requests -->
    <div class="table-responsive">
      <h4 style="font-weight:bold; color:#eaffea;">في انتظار قطع غيار</h4>
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                <th class="text-center" width="6%">حركة</th>
                <th class="text-center" width="11%">التاريخ</th>
                <th class="text-center" width="10%">مقدم الطلب</th>
                <th class="text-center" width="10%">نوع السيارة</th>
                <th class="text-center" width="10%">لوحة</th>
                <th class="text-center" width="6%">موديل</th>
                <th class="text-center" width="46%">متطلبات الصيانة</th>
              </tr>
            </thead>
              <tbody>
                <?php
                $output = '';
                  $sql =$db->prepare("select ment_request.req_id , ment_request.car_id, ment_request.ask_date , users.realName , cars.kind , concat(cars.letters , cars.numbers) as numm ,
                      cars.model , ment_request.feedback from ment_request , users , cars where ment_request.father = users.user_Id
                      AND ment_request.car_id =cars.carid AND ment_request.done = 2 ORDER by ment_request.req_id DESC ");
                  $sql->execute();
       if($sql->rowCount()>0)
          {
       while($row = $sql->fetch())
         {
          $output .= '<tr>
                         <td>
                         <a href="a\ment_respond.php?id=' . $row['car_id'] . '&req_id=' . $row['req_id'] .'" target ="_blank"><button type="button" class="btn btn-danger btn-xs ">صيانة</button></a>
                          </td>
                          <td class="text-center">' . $row['ask_date'] . '</td>
                          <td>' . $row['realName'] . '</td>
                          <td>' . $row['kind'] . '</td>
                          <td>' . $row['numm'] . '</td>
                          <td class="text-center" >' . $row['model'] . '</td>
                          <td class="text-center" >' . $row['feedback'] . '</td>
                          </tr>  ';
                       }
                  }
                  else
                  {
                       $output .= '<tr>
                                           <td colspan="7"><h4>لا يوجد سجلات ...</h4></td>
                                      </tr>';
                  }
                  echo $output;
                  ?>
              </tbody>
						<tfoot></tfoot>
          </table>
    </div>  <!-- end of new requests -->
    <div class="table-responsive">
      <h4 style="font-weight:bold; color:#eaffea;">في ورش خارجية</h4>
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                <th class="text-center" width="6%">حركة</th>
                <th class="text-center" width="11%">التاريخ</th>
                <th class="text-center" width="10%">مقدم الطلب</th>
                <th class="text-center" width="10%">نوع السيارة</th>
                <th class="text-center" width="10%">لوحة</th>
                <th class="text-center" width="6%">موديل</th>
                <th class="text-center" width="46%">تعليمات مدير الصيانة</th>
              </tr>
            </thead>
              <tbody>
  <?php
                $output = '';
                  $sql =$db->prepare("SELECT ment_request.req_id , ment_request.car_id, ment_request.ask_date , users.realName , cars.kind , concat(cars.letters , cars.numbers) as numm ,
                      cars.model , ment_request.feedback from ment_request , users , cars where ment_request.father = users.user_Id
                      AND ment_request.car_id =cars.carid AND ment_request.done = 3 ORDER by ment_request.req_id DESC ");
        $sql->execute();
       if($sql->rowCount()>0)
                  {
           while($row = $sql->fetch())
                       {
                $output .= '   <tr>
                                      <td>
                                      <a href="a\ment_respond.php?id=' . $row['car_id'] . '&req_id=' . $row['req_id'] .'" target ="_blank"><button type="button" class="btn btn-danger btn-xs ">صيانة</button></a>
                                      </td>
                                      <td class="text-center">' . $row['ask_date'] . '</td>
                                      <td>' . $row['realName'] . '</td>
                                      <td>' . $row['kind'] . '</td>
                                      <td>' . $row['numm'] . '</td>
                                      <td class="text-center" >' . $row['model'] . '</td>
                                      <td class="text-center" >' . $row['feedback'] . '</td>
                                    </tr>';   }
                  }
                  else
                  {
                       $output .= '<tr>
                                           <td colspan="7"><h5>لا يوجد سجلات ...</h5></td>
                                      </tr>';
                  }
                  echo $output;
                  ?>
              </tbody>
						<tfoot></tfoot>
          </table>
    </div>  <!-- end of new requests -->
    <div class="table-responsive">
      <h4 style="font-weight:bold; color:#eaffea;">تمت الصيانة</h4>
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                <th class="text-center" width="6%">حركة</th>
                <th class="text-center" width="11%">التاريخ</th>
                <th class="text-center" width="10%">مقدم الطلب</th>
                <th class="text-center" width="10%">نوع السيارة</th>
                <th class="text-center" width="10%">لوحة</th>
                <th class="text-center" width="6%">موديل</th>
                <th class="text-center" width="46%">تعليمات مدير الصيانة</th>
              </tr>
            </thead>
              <tbody>
  <?php
                $output = '';
                  $sql =$db->prepare("SELECT ment_request.req_id , ment_request.car_id, ment_request.ask_date , users.realName , cars.kind , concat(cars.letters , cars.numbers) as numm ,
                      cars.model , ment_request.feedback from ment_request , users , cars where ment_request.father = users.user_Id
                      AND ment_request.car_id =cars.carid AND ment_request.done = 4 ORDER by ment_request.req_id DESC LIMIT 9 ");
        $sql->execute();
       if($sql->rowCount()>0)
                  {
           while($row = $sql->fetch())
                       {
                $output .= '   <tr>
                                      <td>
                                      <a href="a\ment_respond.php?id=' . $row['car_id'] . '&req_id=' . $row['req_id'] .'" target ="_blank"><button type="button" class="btn btn-success btn-xs ">صيانة</button></a>
                                      </td>
                                      <td class="text-center">' . $row['ask_date'] . '</td>
                                      <td>' . $row['realName'] . '</td>
                                      <td>' . $row['kind'] . '</td>
                                      <td>' . $row['numm'] . '</td>
                                      <td class="text-center" >' . $row['model'] . '</td>
                                      <td class="text-center" >' . $row['feedback'] . '</td>
                                    </tr>';   }
                  }
                  else{$output .= '<tr><td colspan="7">لا يوجد سجلات ...</td></tr>';}
                  echo $output;
                  ?>
              </tbody>
            <tfoot></tfoot>
          </table>
    </div>  <!-- end of new requests -->
    <!-- <div class="table-responsive">
      <h4 style="font-weight:bold; color:#06A708 ;">مصروفات اليوم</h4>
         <table class="table table-bordered table-hover">
           <thead>
              <tr>
                <th class="text-center" width="8%">حركة</th>
                <th class="text-center" width="30%">اسم الصنف</th>
                <th class="text-center" width="5%">الكمية</th>
                <th class="text-center" width="10%">نوع السيارة</th>
                <th class="text-center" width="10%">لوحة</th>
                <th class="text-center" width="10%">موديل</th>
                <th class="text-center" width="15%">المورد</th>
                <th class="text-center" width="8%">رقم الفاتورة</th>
              </tr>
            </thead>
              <tbody>
                <?php
  //     $today = date("Y-m-d");
  //     $output = '';
  //       $sql = $db->prepare("SELECT line_out_id , item_name , qty , kind , numbers , model , mat_name , invoice_no
  //                             FROM car_ment_v ORDER BY line_out_id DESC LIMIT 50 ");
  //       $sql->execute();
  //  if($sql->rowCount()>0)
  //       {  while($row = $sql->fetch())
  //             {
  //     $output .= ' <tr>
  //                     <td><button idd='. $row['line_out_id'].' class="btn btn-danger btn-xs line_delete">حذف</button></td>
  //                     <td>' . $row['item_name'] . '</td>
  //                     <td>' . $row['qty'] . '</td>
  //                     <td>' . $row['kind'] . '</td>
  //                     <td>' . $row['numbers'] . '</td>
  //                     <td class="text-center" >'. $row['model'] .'</td>
  //                     <td class="text-center" >'. $row['mat_name'] .'</td>
  //                     <td class="text-center" >'. $row['invoice_no'] .'</td>
  //                 </tr>  ';   }
  //       }
  //   else
  //       {  $output .= '<tr> <td colspan="8">لا يوجد سجلات ...</td> </tr>';  }
  //                 echo $output;
                  ?>
              </tbody>
						<tfoot></tfoot>
          </table>
    </div>  -->

     <!-- end of new requests -->
    <script>
    $(".line_delete").click(function(event){
          event.preventDefault();
      var r = confirm("هل انت متأكد من حذف السجل");
      if (r == true) {
        txt = "You pressed OK!";

      var id = $(this).attr("idd");
      $.ajax({
      url     :"wh/itemOut_del.php",
      method  :"POST",
      data    :{id:id},
      success : function(data){
          $('#site').load("includes/ment_manager.php");
      },
        error   :function(result){
          alert(result.statusText);
          }
      });
    }
    });
  </script>
</div>
</div><!-- panel body style -->
