<? 
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.php'; </script>";
 return;
}
include("test.php");
include("../opendb.php");
include ("../test.php");
$re1=mysqli_query($db,"select distinct(invno),shilglnm,shipgstn from sap_einvoice where brcode='$brcode' and doctype = 'Tax Invoice' order by entrydate desc,invno desc limit 50");
$sss="select distinct(invno),customer,tin from spareinvoice where brcode='$brcode' and doctype = 'Tax Invoice' order by invno desc limit 50";
//echo $sss;
?>
<link rel="stylesheet" href="../css/form.css" type="text/css" />
<style>
    table.report 
    {
        width:60%;
    }
</style>
<center>
<form action='sap_spareinvoicejsonnew.php' method='POST' onSubmit="return valid()" id="sapupfrm" name="sapupfrm">
<table cellspacing=1 cellpadding=2 class='report' >
    <tr height=21><td colspan=4 align=center bgcolor='steelblue'><FONT COLOR=white><B>Spare Invoice</td></tr>
    <th>Sl No.</th>
              <th>Invno</th>
              <th>Customer</th>
               
               <th>Select All<input name="selectall" value="0" onclick="un_check_category();" type="checkbox" /></th>
    

</td></tr>
<?php
$i=1;
        
                while($row = mysqli_fetch_array($re1)) 
					{
					  
					$count_no++; ?> 
<tr><tr >
                <td align="center" width="20%"><? echo $count_no ?></td><td width="20%"><input type=text name='invnovl[<? echo $i ?>]' value='<? echo $row['invno']?>' size=15 readonly style="border: none;
    background: transparent;"> </td><td width="30%"><? echo $row['1']?>

</td><td align="right" width="20%"><input type="checkbox" name="del[]" id="del[]" value="<? echo $row['invno']?>"  /></td></tr>

<?
$i++;
}
?>




<input type="hidden" name="deleterec" value="" />
<input type="hidden" name="doaction" value="" />

<tr><td colspan=4 align=center bgcolor='lightsteelblue'>
<input type=button value='Save' name='sv' onclick="return deleteRecords(document.sapupfrm);"> <input type=button value='Cancel'>
</td></tr>
</table>
</form>


</td></tr></table>
<script>
function un_check_category()
{
  for (var i = 0; i < document.sapupfrm.elements.length; i++) {
    var e = document.sapupfrm.elements[i];
            if ((e.name != 'allbox') && (e.type == 'checkbox')) {
e.checked = document.sapupfrm.selectall.checked;
    }
  }
}
function deleteRecords(formname)
{
        var chks = document.getElementsByName('del[]');

        var hasChecked = false;
        // Get the checkbox array length and iterate it to see if any of them is
//selected
        for (var i = 0; i < chks.length; i++)
        {
                if (chks[i].checked)
                {
                        hasChecked = true;
                        break;
                }
        }
        // if ishasChecked is false then throw the error message
        if (!hasChecked)
        {
                alert("Woops! You forgot to select record(s)");
                return false;
        }
        var agree=confirm("Are you sure you want to upload to the selected recored(s)?");
 	if(agree==true)
 	{
        	formname.deleterec.value="delete";
    		formname.submit();
 	}
	else
		return false;
}
</script>
