
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">


    <title><?php echo $_GET['type']?> REPORT</title>

    <style>
        .center {
            text-align: center;
        }

        .right {
            text-align: right;
        }

        .tb  { 
           border: 1px solid black;


           border-collapse: collapse;
       }
       .tb td  {

           border-top: 1px solid black;
           border-left: 1px solid black;
        font-size:18px;

           border-collapse: collapse;
       }
       .tb th  {

           border-top: 1px solid black;
           border-left: 1px solid black;


           border-collapse: collapse;
       }

       .tb1 {

           border: 1px solid #000000;
       }

   </style>

</head>
<?php
require_once ("connection_sql.php");

 

$sql_invpara = "SELECT * from invpara";
$result_invpara = $conn->query($sql_invpara);
$row_invpara = $result_invpara->fetch(); 



?>
<body>
    <table width="1050px;" cellspacing="0" border="0">

        <tr>
            <th class="center"  colspan=5 ><?php echo $row_invpara['COMPANY']?></th>
        </tr> 
        
        <tr> 
            <th class='center' colspan='5'> <?php echo $_GET['type']?> REPORT</th> 
        </tr>
        <tr> 
        <?php 
         if($_GET['check'] =="on"){?>
            <th class='center' colspan='5'>DATE WISE  <?php echo $_GET['dtfrom']?> To  <?php echo $_GET['dtto']?> </th> 
           <?php } ?>
        </tr>
        <tr> 
        <?php 
         if($_GET['cuscode'] !=""){?>
            <th class='center' colspan='5'>CUSTOMER WISE - <?php echo $_GET['cusname']?>  </th> 
           <?php } ?>
        </tr>
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td align="right">&nbsp;</td>
        </tr>
        
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        
        <tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
       
    </table>
<!--==================================================================================-->
    <?php 
    if($_GET['type']=="REMAINING"){
        ?>
                <table class="tb"   >
               

                <tr >
        
                    <th width="30px;">NO</th>
                    <th >BATTERY TYPE</th>
                    <th >SERIAL NO</th>
                    <th >ARN NO</th>
                    <th >ARRIVAL DATE</th>
                    <th >STROAGE PERIOD</th>  
                    <th >WARRENTY EX.DATE</th>
                </tr>
                <?php
                $i=1;  
                $part="";
                $BAL=0;
                $sql1 = "Select * from warrenty_details  where cancel='0' and invno is null ";  

                $sql1.=" order by  description,arndate";

                foreach ($conn->query($sql1) as $row1) {
                    $date1 = date("Y-m-d");
                    $date2 = $row1["arndate"]; 
                    $diff = abs(strtotime($date2) - strtotime($date1));
                    $days = floor($diff / (60*60*24));

                    ?>
                    <tr style="font-size:13px;">
         
        
                        <td class="center"><?php echo $i ?></td>
                        
                        
                        <td class="left" ><?php echo $row1['description']; ?> </td>
                        <td class="left" ><?php echo $row1['barcode']; ?> </td>
                        <td class="left" ><?php echo $row1['arnno']; ?> </td>
                        <td class="left" ><?php echo $row1['arndate']; ?> </td>
                        <td class="center" ><?php echo $days; ?> </td> 
                        <td class="left" ><?php echo $row1['expdate']; ?> </td>
                    </tr>
                    <?php
                    $i=$i+1; 
                }
                ?>
         
             
             
             
           
            
        </table>
  <?php  }
    
    ?>
   
     
    <!--==================================================================================-->
    <?php 
    if($_GET['type']=="RISK"){
        ?>
                <table class="tb"   >
                <tr >
        
                    <th width="30px;">NO</th>
                    <th >BATTERY TYPE</th>
                    <th >SERIAL NO</th>
                    <th >ARN NO</th>
                    <th >ARRIVAL DATE</th>
                    <th >STROAGE PERIOD</th>  
                    <th >WARRENTY EX.DATE</th>
                    <th >INV.No</th>
                    <th >INV.DATE</th>
                    <th >CUS NAME</th>
                </tr>
                <?php
                $i=1;  
                $part="";
                $BAL=0;
                $sql1 = "Select * from warrenty_details  where cancel='0' ";  

                if($_GET['cuscode']!=""){
                     $sql1.=" and cuscode='".$_GET['cuscode']."'"; 
                }
                
                $sql1.=" order by  description,arndate";
               
                
                
                foreach ($conn->query($sql1) as $row1) {
                    if($row1['invno'] !=""){ 
                        $date1 = $row1["invdate"];
                        $date2 = date("Y-m-d"); 
                        $diff = abs(strtotime($date2) - strtotime($date1));
                        $days = floor($diff / (60*60*24)); 

                        if($days >= 153){?>
                            <tr style="font-size:13px;"> 
                                <td class="center"><?php echo $i ?></td> 
                                <td class="left" ><?php echo $row1['description']; ?> </td>
                                <td class="left" ><?php echo $row1['barcode']; ?> </td>
                                <td class="left" ><?php echo $row1['arnno']; ?> </td>
                                <td class="left" ><?php echo $row1['arndate']; ?> </td>
                                <td class="center"><?php echo $days; ?> </td> 
                                <td class="left" ><?php echo $row1['expdate']; ?> </td>
                                <td class="left" ><?php echo $row1['invno']; ?> </td>
                                <td class="left" ><?php echo $row1['invdate']; ?> </td>
                                <td class="left" ><?php echo $row1['cuscode'].'-'.$row1['cusname']; ?> </td>
                            </tr>
                     <?php   } ?>

 <?php

                    }else{ 
                        $date1 = $row1["arndate"];
                        $date2 = date("Y-m-d"); 
                        $diff = abs(strtotime($date2) - strtotime($date1));
                        $days = floor($diff / (60*60*24)); 

                          if($days >= 153){?>
                            <tr style="font-size:13px;"> 
                                <td class="center"><?php echo $i ?></td> 
                                <td class="left" ><?php echo $row1['description']; ?> </td>
                                <td class="left" ><?php echo $row1['barcode']; ?> </td>
                                <td class="left" ><?php echo $row1['arnno']; ?> </td>
                                <td class="left" ><?php echo $row1['arndate']; ?> </td>
                                <td class="center"><?php echo $days; ?> </td> 
                                <td class="left" ><?php echo $row1['expdate']; ?> </td>
                                <td class="left" ><?php echo $row1['invno']; ?> </td>
                                <td class="left" ><?php echo $row1['invdate']; ?> </td>
                                <td class="left" ><?php echo $row1['cuscode'].'-'.$row1['cusname']; ?> </td>
                            </tr>
                           <?php   }  

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

    <!--==================================================================================-->
    <?php 
    if($_GET['type']=="DEALERPOINT"){
        ?>
                <table class="tb"  >
                  
                <tr >
        
                    <th width="30px;">NO</th>
                    <th >BATTERY TYPE</th>
                    <th >SERIAL NO</th>
                    <th >ARN NO</th>
                    <th >ARRIVAL DATE</th>
                    <th >STROAGE PERIOD</th>  
                    <th >WARRENTY EX.DATE</th>
                    <th >INV.No</th>
                    <th >INV.DATE</th>
                    <th >CUS NAME</th> 
                    <th >ACTION</th>
                </tr>
                <?php
                $i=1;  
                $part="";
                $BAL=0;
                $sql1 = "Select * from warrenty_details  where cancel='0' and invno IS NOT NULL";  
                if($_GET['cuscode']!=""){
                     $sql1.=" and cuscode='".$_GET['cuscode']."'"; 
                }
                if($_GET['check'] =="on"){ 
                     $sql1.=" and invdate='".$_GET['dtfrom']."' and invdate='".$_GET['dtto']."' "; 
                }
              
                $sql1.=" order by  description,arndate";
                
                
                foreach ($conn->query($sql1) as $row1) {
                    $date1 = date("Y-m-d");
                    $date2 = $row1["invdate"]; 
                    $diff = abs(strtotime($date2) - strtotime($date1));
                    $days = floor($diff / (60*60*24)); 
                    ?>
                    <!-- <tr style="font-size:13px;">
         
        
                        <td class="center"><?php echo $i ?></td> 
                        <td class="left" ><?php echo $row1['description']; ?> </td>
                        <td class="left" ><?php echo $row1['barcode']; ?> </td>
                        <td class="left" ><?php echo $row1['arnno']; ?> </td>
                        <td class="left" ><?php echo $row1['arndate']; ?> </td>
                        <td class="center" ><?php echo $days; ?> </td> 
                        <td class="left" ><?php echo $row1['expdate']; ?> </td>
                        <td class="left" ><?php echo $row1['invno']; ?> </td>
                        <td class="left" ><?php echo $row1['invdate']; ?> </td>
                        <td class="left" ><?php echo $row1['cuscode'].'-'.$row1['cusname']; ?> </td> 
                        <td class="left" >
                            <input type="date" placeholder="SOLD DATE" id="solddate" name="solddate"   class="form-control dt input-sm">
                            <input type="text" placeholder="REMARK" id="remark" name="remark"     class="form-control">
                            <button><a onclick="upbattery('<?php echo $row1['barcode']; ?>');" class="btn btn-primary btn-sm">
                                <span class="fa fa-print"></span> &nbsp; UPDATE
                                </a>
                            </button>
                             
                        </td>
                    </tr> -->
                    <?php
                    $i=$i+1; 
                }
                ?>
         
             
             
             
           
            
        </table>
  <?php  }
    
    ?>
   
    
    <!--===================================================================================-->
    
 <!-- Main content -->
 
    <link rel="stylesheet" href="css/bootstrap.min.css"> 
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css"> 
    <script language="JavaScript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script language="JavaScript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script language="JavaScript" src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
    <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>-->
     
<script src="https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.5/js/buttons.print.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.0/js/buttons.colVis.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;
    }
    .printer table{
    counter-reset: rowNumber;
}
 
.printer tr {
    counter-increment: rowNumber;
}
 
.printer tr td:first-child::before {
    content: counter(rowNumber);
    min-width: 1em;
    margin-right: 0.5em;
}
</style>

<input type="text" id="solddate1">
<input type="text" id="remarkl">
    <table width="90%" class="table table-striped table-bordered table-hover" id="dataTables-example" style="width:auto">
                    <thead> 

                     <tr class="danger"> 
                     <th  >NO</th>
                    <th >BATTERY TYPE</th>
                    <th >SERIAL NO</th>
                    <th >ARN NO</th>
                    <th >ARRIVAL DATE</th>
                    <th >STROAGE PERIOD</th>  
                    <th >WARRENTY EX.DATE</th>
                    <th >INV.No</th>
                    <th >INV.DATE</th>
                    <th >CUS NAME</th> 
                    <th >SOLD DATE</th>
                    <th >REMARK</th>
                    <th >UPDATE</th>
                    </tr>
                </thead>


                <tbody>
                    <?php
                    $i=1;  
                $part="";
                $BAL=0;
                $sql1 = "Select * from warrenty_details  where cancel='0' and invno IS NOT NULL";  
                if($_GET['cuscode']!=""){
                     $sql1.=" and cuscode='".$_GET['cuscode']."'"; 
                }
                if($_GET['check'] =="on"){ 
                     $sql1.=" and invdate='".$_GET['dtfrom']."' and invdate='".$_GET['dtto']."' "; 
                }
              
                $sql1.=" order by  description,arndate";

                    foreach ($conn->query($sql1) as $row) {
                    $date1 = date("Y-m-d");
                    $date2 = $row1["invdate"]; 
                    $diff = abs(strtotime($date2) - strtotime($date1));
                    $days = floor($diff / (60*60*24)); 

                        ?>
                        <tr>
                        <td class="center"><?php echo $i ?></td> 
                        <td class="left" ><?php echo $row1['description']; ?> </td>
                        <td class="left" ><?php echo $row1['barcode']; ?> </td>
                        <td class="left" ><?php echo $row1['arnno']; ?> </td>
                        <td class="left" ><?php echo $row1['arndate']; ?> </td>
                        <td class="center" ><?php echo $days; ?> </td> 
                        <td class="left" ><?php echo $row1['expdate']; ?> </td>
                        <td class="left" ><?php echo $row1['invno']; ?> </td>
                        <td class="left" ><?php echo $row1['invdate']; ?> </td>
                        <td class="left" ><?php echo $row1['cuscode'].'-'.$row1['cusname']; ?> </td> 
                        <td onclick="name(this)"  >
                                <input type="date" placeholder="SOLD DATE" id="solddate" name="solddate"   class="form-control dt input-sm">  
                        </td> 
                        <td onclick="name(this)"  > 
                                <input type="text" placeholder="REMARK" id="remark" name="remark"     class="form-control"> 
                        </td>   
                         <td onclick="name(this)"  > 
                                <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-fullscreen"></span> &nbsp;UPDATE</button>
                        </td>         


                    </tr>

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




<script>



    function name(subNode) {


        var row = subNode.parentNode;
 
        var cell_0 = row.cells[0].innerHTML; 
        var cell_1 = row.cells[1].innerHTML; 
        var cell_2 = row.cells[2].innerHTML; 
        var cell_3 = row.cells[3].innerHTML; 
        var cell_4 = row.cells[4].innerHTML; 
        var cell_5 = row.cells[5].innerHTML; 
        var cell_6 = row.cells[6].innerHTML; 
        var cell_7 = row.cells[7].innerHTML; 
        var cell_8 = row.cells[8].innerHTML; 
        var cell_9 = row.cells[9].innerHTML; 
        var cell_10 = row.cells[10].innerHTML;   
        var cell_11 = row.cells[11].innerHTML

         document.getElementById("solddate1").value=cell_10;  
         document.getElementById("remarkl").value=cell_11; 
         
 
    }



</script>

<script type="text/javascript">
                $(document).ready(function() {
          var table = $('#dataTables-example').DataTable( {
             lengthChange: true,
            fixedHeader: true,
            responsive: true,
            "deferRender": true, 
             "order": [[ 0, 'asc' ]], 
              dom: 'Bfrtip',
        lengthMenu: [[ 25, 50,100, -1 ],[ '25 rows', '50 rows', '100 rows', 'Show all' ]],
         "pageLength": -1,
        buttons: [
            'pageLength'
        ]
              

        } );

$('div.dataTables_filter input', table.table().container()).focus();
          table.buttons().container()
          .appendTo( '#example_wrapper .col-md-6:eq(0)' );
           
      } );
 
        </script>






    <!-- =================================================================== -->
    
    
<div style='height:12px;'></div>
<table width="750px;">
    <tr>
        <td> </td>
        <td>Prepared By:  .................     </td>
        <td></td> 
        <td class="center">Checked By:   .................</td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td  align="right">&nbsp;&nbsp;&nbsp;&nbsp;Authorised By:.................</td>
    </tr>
</table>
<!-- ************************************************************************** -->
</body>

</html>

<script>
    function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    } catch (e) {
// Internet Explorer
try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

 
 function upbattery(cdate) {
 
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Browser does not support HTTP Request");
        return;
    }
     
    var msg = confirm("Do you want to UPDATE this ! ");
    if (msg == true) {
        var url = "battery_status_data.php";
        var params ="Command="+"upbattery";    
        params = params + "&id=" + cdate; 

        xmlHttp.open("POST", url, true);

        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", params.length);
        xmlHttp.setRequestHeader("Connection", "close");

        xmlHttp.onreadystatechange=item_del;

        xmlHttp.send(params);  

    }
}


function item_del() {

    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
        alert(xmlHttp.responseText);
        setTimeout("location.reload(true);", 500);
    }
}


</script>

