  <!-- Main content -->
   <link rel="stylesheet" href="css/bootstrap.min.css">

<style type="text/css">
		tfoot input {
			width: 100%;
			padding: 3px;
			box-sizing: border-box;
		}
	</style>
   
    <link rel="stylesheet" href="css/bootstrap.min.css"> 
    <!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">-->
 
    <link  href="vendor/new/multi/jquery.dataTables.min.css" rel="stylesheet" type="text/css"> 
	<script src="vendor/new/multi/jquery-3.5.1.js" ></script>
	<script src="vendor/new/multi/jquery.dataTables.min.js" ></script>
<?php
require_once("./connection_sql.php");
?>

<style>

    .view-cell{
        background-color: red;
        color: white; 
    }
    .table-hover tbody tr:hover td {
        background: aqua;
    }
</style>
<section class="content" onload="search1();">

    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">ALL LIST</h3>
        </div>
        <form role="form" class="form-horizontal">
            <div class="box-body"> 
                <div class="panel-body" style="overflow-x: auto">
                     
                <table width="100%" class="table table-striped table-bordered table-hover" id="example" style="width:auto">
                    <thead> 

                     <tr class="danger">
                        <th>#</th>
                        <th style="background-color:#ffeb00">JOB NO</th>
                        <th>DAG NO</th>
                        <th>DAG DATE</th>   
                        <th>DAG CUSTOMER</th>
                        <th>MAKE</th> 
                        <th>SIZE</th> 
                        <th>BELT</th> 
                        <th>SERIAL NO</th>  
                        <th>AD PAY</th>  
                        <th>AMOUNT</th>  
                        <th>REPAIR</th>  
                        <th>TOTAL</th>  
                        <th>SEND DATE</th> 
                        <th>FINISH</th>   
                        <th>INVOICE NO</th>  
                        <th>INVOICE DATE</th>  
                        <th>INVOICE CUSTOMER</th>  
                        <th>TYPE</th>   
                         <th>WARRENTY</th>   
                         <th>REMARK</th> 
                    </tr>
                </thead>


                <tbody>
                    <?php
                    $i=1;
                    include './connection_sql.php';

                    if($_SESSION['company']==""){
                        $sql = "select * from dag_item WHERE   cancel='0'";
                    }else{
                        $sql = "select * from dag_item WHERE  cancel='0'  and company='".$_SESSION['company']."' ";
                    }


                    foreach ($conn->query($sql) as $row) {
                         $sqlsal = "SELECT CUS_NAME,SDATE FROM s_salma where REF_NO='".$row['invno']."'";
                        $resultsal = $conn->query($sqlsal);
                    
                        $rowsal = $resultsal->fetch();

                        ?>
                        <tr>
                            <td ><?php echo $i; ?></td>
                            <td onclick="upjobno('<?php echo $row['refno']; ?>','<?php echo $row['serialno']; ?>');" style="background-color:#ffeb00"><?php echo $row['jobno']; ?></td> 
                            <td onclick="name(this)"><?php echo $row['refno']; ?></td> 
                            <td onclick="name(this)"><?php echo $row['sdate']; ?></td>   
                            <td onclick="name(this)"><?php echo $row['cusname']; ?></td>   
                            <td onclick="name(this)"><?php echo $row['marker']; ?></td>   
                            <td onclick="name(this)"><?php echo $row['size']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['belt']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['serialno']; ?></td> 
                            <td onclick="name(this)"><?php echo $row['adpayment']; ?></td> 
                            
                           <?php  if($row['flag']=='7'){
                            ?>
                             <td onclick="name(this)"><?php echo $row['amount1']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['repair1']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['total1']; ?></td>  
                             <?php
                            }else{
                                ?>
                                 <td onclick="name(this)"><?php echo $row['amount']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['repair']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['total']; ?></td>  
                            <?php }?>
                            
                           
                            <td onclick="name(this)"><?php echo $row['onhand_date']; ?></td>  
                            <td onclick="name(this)"><?php echo $row['pro_date']; ?></td> 
                            <td onclick="name(this)"><?php echo $row['invno']; ?></td>  
                            <td onclick="name(this)"><?php echo $rowsal['SDATE']; ?></td>  
                            <td onclick="name(this)"><?php echo $rowsal['CUS_NAME']; ?></td>  
                            <?php
                             if($row['reject']=='0'){
                                 if($row['flag']=='0'){
                                     echo "<td style='background-color:yellow'>ONHAND </td>"; 
                                }else if($row['flag']=='1'){
                                    echo "<td style='background-color:#acdcf3'>PRODUCTION</td>"; 
                                }else if($row['flag']=='2'){
                                     echo "<td style='background-color:#1ef51e'>COMPLETE</td>"; 
                                }else if($row['flag']=='3'){
                                     echo "<td style='background-color:#1ef51e'>OTHER COMPANY SEND</td>"; 
                                }else if($row['flag']=='5'){
                                     echo "<td style='background-color:#1ef51e'>OTHER COMPANY RECEIVED</td>"; 
                                }else if($row['flag']=='6'){
                                     echo "<td style='background-color:#1ef51e'>ONHAND TRANSFER PENDING</td>"; 
                                }else if($row['flag']=='7'){
                                     echo "<td style='background-color:#eabf5d'>INVOICED</td>"; 
                                }
                             }else{
                                if($row['flag']=='7'){
                                     echo "<td style='background-color:red'>REJECTED & INVOICED</td>"; 
                                }else{
                                    echo "<td style='background-color:red'>REJECTED</td>"; 
                                }
                                 
                             }
                            
                            
                           
                            ?>
                             <td onclick="name(this)"><?php echo $row['warrenty']; ?></td>   
                             <td onclick="name(this)" ><?php echo $row['remark']; ?></td>  
                            
                        </td>   


                    </tr>

                    <?php
                    $i= $i+1;
                }
                ?>
            </tbody>
        </table>

    </div>

    <!-- =============================== -->

  
<!-- =============================== -->



</div>
</form>
</div>
</div>
</div>
</section>

<script src="js/all_list.js"></script>
 

<script type="text/javascript">
 $(document).ready(function() {
         
      var table =  $('#example').DataTable( {
            dom: 'Bfrtip',  
            lengthChange: true,
            fixedHeader: true,
            responsive: true,
            "deferRender": true,
            "pageLength": 10,
            
            buttons: ['pageLength',
                {
                    extend: 'print',
                    customize: function ( win ) {
                         $(win.document.body).find('table').addClass('printer');
     
                        
                    }
                }
            ]
        } );
        
            table.on( 'order.dt search.dt', function () {
            table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                cell.innerHTML = i+1;
            } );
             } ) 
              $('div.dataTables_filter input', table.table().container()).focus();
          table.buttons().container()
          .appendTo( '#example_wrapper .col-md-6:eq(0)' );
    } );
</script>