<?php include "header.php"; 

$submit=$_POST['submit'];
$id=$_POST['id'];
$vcode=$_POST['vcode'];
$name=$_POST['name'];
$address=$_POST['address'];
$bankname=$_POST['bankname'];
$accountno=$_POST['accountno'];
$ifsccode=$_POST['ifsccode'];
$panno=$_POST['panno'];
$mobileno=$_POST['mobileno'];
$date=$_POST['date'];
$submitdate=$_POST['submitdate'];
$submittime=$_POST['submittime'];
$submit_by=$_POST['submit_by'];
if($submit=='Add Record'){
$query = "INSERT INTO `party` (`id`,`vcode`,`name`,`address`,`bankname`,`accountno`,`ifsccode`,`panno`,`mobileno`,`date`,`submitdate`,`submittime`,`submit_by`,`code`) VALUES ('$id','$vcode','$name','$address','$bankname','$accountno','$ifsccode','$panno','$mobileno','$date','$submitdate','$submittime','$submit_by','$code')";
  mysql_query( $query )
 or die ( "Couldn't add data to \"application\" table: " 
 .mysql_error() );
print "<div>Data Save [ ". mysql_affected_rows() .
" row(s) ] Successfully </div>";
?><script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_party_details.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?php
}


if($submit=='Update'){
$id=$_POST['id'];
$query = "UPDATE party SET vcode='$vcode',name='$name',address='$address',bankname='$bankname',accountno='$accountno',ifsccode='$ifsccode',panno='$panno',mobileno='$mobileno',date='$date',submitdate='$submitdate',submittime='$submittime',submit_by='$submit_by',code='$code' WHERE id='$id'";
 $result = mysql_query( $query );
 if ( ! $result )
die ("Couldn't update: ".mysql_error());
print "<h1>Table Updated ". mysql_affected_rows() .
" row(s) updated</h1>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_party_details.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?php }



$submit=$_GET['submit'];
if($submit=='Delete'){
$id=$_GET['id'];
$query = "DELETE FROM party WHERE id=$id";
$result = mysql_query( $query );
if ( ! $result )
die ("Couldn't deleted: ".mysql_error());
print "<h1>Table deleted ". mysql_affected_rows() .
" row(s) deleted</h1><p>";
?>
<script type="text/javascript">
         <!--
            function Redirect() {
               window.location="feed_party_details.php";
            }
            
            document.write("<h1>You will be redirected to main page in 10 sec.</h1>");
            setTimeout('Redirect()', 1000);
         //-->
      </script>
<?php 
}
?> <section class="content">
      <div class="container-fluid">
                <!-- Page Header -->
                <div class="col-lg-12">
                  
   
    <style type="text/css">
<!--
.style1 {color: }
-->
</style>
<script language='JavaScript'>

function validate()
{
	conf = confirm("Are you sure you want to delete?");
	if (conf)
		return true
	else
		return false;
}

</script><div class="card card-danger">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>

<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    
    <td width="50%" valign="top" align="center"><div align="center">
      <form name="myform" id="myform" method="post" action="feed_party_details.php">
	  <input class="form-control" name="name" placeholder='Name' type="text" id="name" required="required" />
      <textarea name="address" class="form-control" id="address"  cols="15" rows="5" required="required" placeholder='Address'></textarea>
      <input class="form-control" name="bankname" type="text" id="bankname"  placeholder='Bank Name' required="required" />
       <input class="form-control" name="accountno" type="text" id="accountno"  placeholder='Account Number' required="required" />
       <input class="form-control" name="ifsccode" type="text" id="ifsccode" placeholder='IFSC Code' required="required" />
      <input class="form-control" name="panno" type="text" id="panno" placeholder='PAN NO' required="required" />
       <input class="form-control" name="mobileno" type="text" id="mobileno"  required="required" placeholder='Mobile NO' />
       <input class="form-control" name="date" type="input" id="date" placeholder='Date'  required="required" value="<?php echo date('Y-m-d');	?>" />
       <input class="form-control" name="submitdate" type="text" id="submitdate" placeholder='Submit Date'  required="required" value="<?php echo date('Y-m-d');	?>" readonly />
       <input class="form-control" name="submittime" type="text" id="submittime"  required="required"  value="<?php echo date('h-i-s A');  ?>" readonly/>
       <input class="form-control" name="submit_by" type="text" id="submit_by"  value="<?php echo $login_session;  ?>" required="required" readonly />
       <input name="submit" class="btn btn-primary" type="submit" value="Add Record" />
       </form></div></td>
  </tr>
  <tr>
    <td valign="top" align="center"><?php
	 
$query = "SELECT * FROM party where code='$code'";
$numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");


?>
<div style="width:900px;overflow:scroll; text-align:center">
<div class="card card-success">
              <div class="card-header">
                <h3 class="card-title"><?php echo $_GET['title']; ?>?</h3>
              </div>
<?php if($numrows!=""){?>
   <table   cellpadding="1" border="1" cellspacing="1" bgcolor="" align="center" class="table table-bordered table-striped">
 <tr>
	
 <td align="center" valign="top"  class="border"><div align="center"   ><em><strong>S.</strong></em></div></td>
  <td align="center" valign="top"  class="border"><div align="center"   ><em><strong>Party ID</strong></em></div></td>
  <td align="center" valign="top"  class="style1" >Name</td>
  <td align="center" valign="top"  class="style1" >Address</td>
  <td align="center" valign="top"  class="style1" >Bank Name</td>
  <td align="center" valign="top"  class="style1" >Account</td>
  <td align="center" valign="top"  class="style1" >IFSC Code</td>
  <td align="center" valign="top"  class="style1" >PAN No</td>
  <td align="center" valign="top"  class="style1" >Mobile No</td>
  <td align="center" valign="top"  class="style1" >Date</td>
  <td align="center" valign="top"  class="style1" >Submission Date</td>
  <td align="center" valign="top"  class="style1" >Submission Time</td>
  <td align="center" valign="top"  class="style1" >Submit By</td>
  <td align="center" valign="top"  class="style1" >Vechile No</td>
  <td align="center" valign="top"  class="border"><div align="center"    ><em><strong>Update</strong></em></div></td>
 <td align="center" valign="top"  class="border"><div align="center"    ><em><strong>Delete</strong></em></div></td>
 </tr>
<?php 
$counter = 1;?>
 <?php
while ( $a_row = mysql_fetch_row( $result ) )
 {?>
 
 
<form action="feed_party_details.php" enctype="multipart/form-data" method="post">
<input  name="id" type="hidden" value="<?php echo $a_row[0];?>" />
 <tr>
 <td height="20" align="center" valign="top" ><div align="center" ><?php echo $counter;?></div></td>
 <td align="center" valign="top" ><div align="center" ><?php echo $a_row[0];?></div></td>
 <td align="center" valign="top" ><input class="form-control" name="name" type="text" id="name"  value="<?php echo $a_row[2];?>" style="width:150px;" /></td>
 <td align="center" valign="top" ><textarea name="address" class="form-control" id="address" style="width:150px;"><?php echo $a_row[3];?></textarea></td>
 <td align="center" valign="top" ><label>
   <input type="text" class="form-control" name="bankname" id="bankname" value="<?php echo $a_row[4];?>" style="width:150px;">
 </label></td>
 <td align="center" valign="top" ><label>
   <input type="text" class="form-control" name="accountno" id="accountno" value="<?php echo $a_row[5];?>" style="width:150px;">
 </label></td>
 <td align="center" valign="top" ><label>
   <input type="text" class="form-control" name="ifsccode" id="ifsccode" value="<?php echo $a_row[6];?>" style="width:150px;">
 </label></td>
 <td align="center" valign="top" ><label>
   <input type="text" class="form-control" name="panno" id="panno" value="<?php echo $a_row[7];?>" style="width:150px;">
 </label></td>
 <td align="center" valign="top" ><label>
   <input type="text" class="form-control" name="mobileno" id="mobileno" value="<?php echo $a_row[8];?>" style="width:150px;">
 </label></td>
 <td align="center" valign="top" ><label>
   <input type="input" name="date" class="form-control" id="date" value="<?php echo $a_row[9];?>" readonly style="width:150px;">
 </label></td>
 <td align="center" valign="top" ><input class="form-control" name="submitdate" type="text" id="submitdate"  required="required" value="<?php echo date('Y-m-d');	?>" readonly /></td>
 <td align="center" valign="top" ><input class="form-control" name="submittime" type="text" id="submittime"  required="required"  value="<?php echo date('h-i-s A');  ?>" readonly/></td>
 <td align="center" valign="top" ><input class="form-control" name="submit_by" type="text" id="submit_by"  value="<?php echo $login_session;  ?>" required="required" readonly /></td>
 <td align="center" valign="top" ><?php
							$partyid=$a_row[0];
$queryy = "SELECT * FROM vechile where party_id='$partyid' order by id";
$numresultsy=mysql_query($queryy);
$resulty= mysql_query($queryy) or die("Couldn't execute query");
?>
             
                
                <?php
while ( $a_roww = mysql_fetch_row( $resulty ) )
 {?>
                <?php echo '-'.$a_roww[2];?> 
                <?php } ?>           </td>
 <td align="center" valign="top" >

 <input class="btn btn-primary" type="submit"  name="submit" value="Update"  ></td>
 <td align="center" valign="top" >

 <?php if($login_type=='admin'){ ?>
<a href="feed_party_details.php?id=<?php echo $a_row[0];?>&&submit=Delete" onclick='return validate();'><input type="reset" class="btn btn-danger" name="Delete" value="Delete" class="btn btn-danger" /></a><?php } ?></td>
 </tr>
 </form>

   
  <?php $counter++;}?>
  </table>
</div>
   <?php }?>

<?php if($numrows==""){
  echo "<div  style='border:none; text-align:center'><h3 class='logo2'>No Record Found</h3></div>";
}?></td>
  </tr>
</table>
</div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div><?php 

include "footer.php"; ?>