<?php 
error_reporting(0);
session_start();


if(!isset($_SESSION['admin']) || ($_SESSION['admin'] == "") )
{
	?>
    <script language="javascript">window.location.href="index.php";</script>
    <?php 
}
include "config.php";
?>


<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
 
<meta charset="utf-8">
<title>Invoce List</title>


<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-touch-icon-57x57-precomposed.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-precomposed.png">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/plugins.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/themes.css">
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<style>
.box {
	width: 40%;
	margin: 0 auto;
	padding: 35px;
	border: 2px solid #fff;
	border-radius: 20px/50px;
	background-clip: padding-box;
	text-align: center;
}
/*.button {
  font-size: 1em;
  padding: 10px;
  color: #fff;
  border: 2px solid #06D85F;
  border-radius: 20px/50px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease-out;
}*/
.button:hover {
	background: #06D85F;
}
.overlay {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	background: rgba(0, 0, 0, 0.7);
	transition: opacity 500ms;
	visibility: hidden;
	opacity: 0;
}
.overlay:target {
	visibility: visible;
	opacity: 1;
}
.popup {
	margin: 70px auto;
	padding: 20px;
	background: #fff;
	border-radius: 5px;
	width: 30%;
	position: relative;
	transition: all 5s ease-in-out;
}
.popup h2 {
	margin-top: 0;
	color: #333;
	font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
	position: absolute;
	top: 20px;
	right: 30px;
	transition: all 200ms;
	font-size: 30px;
	font-weight: bold;
	text-decoration: none;
	color: #333;
}
.popup .close:hover {
	color: #06D85F;
}
.popup .content {
	max-height: 30%;
	overflow: auto;
}
 @media screen and (max-width: 700px) {
 .box {
 width: 70%;
}
 .popup {
 width: 70%;
}
}
</style>
</head>
<body>
 
<div id="page-container">

<?php include 'header.php' ?>
<div id="inner-container">
<?php include 'left_menu.php' ?>
<?php 						
		$id = $_GET['reg'];				
		// if((isset($_GET['action'])== 'up_sts')) 
//		{
//  		  $id = $_GET['ids'];
//		  $sts = $_GET['sts'];
//	
//			$qry = "update  tbl_generate_invoice_mst set status='$sts' where invoice_id=$id";
//			mysql_query($qry) or die(mysql_error());
		?>
		
   <!-- <script language="javascript">window.location.href="generate_invoice_list.php";</script>-->
          <?php
//}


  ?>

<div id="page-content">
<ul id="nav-info" class="clearfix">
<li><a href="#"><i class="icon-home"></i></a></li>
<li class="active"><a href=""> Invoice List</a></li>
</ul>
<!--<button id="addRow" class="btn btn-success" onClick="location.href = 'generate_quotation_add.php';"><i class="icon-plus"></i> Generate New Quotation </button>-->
<button id="addRow" class="btn btn-success" onClick="location.href = 'generate_extra_invoice_add.php';"><i class="icon-plus"></i> નવું બિલ બનાવો </button>
<table id="example-datatables" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="span1">Action</th>
<!--<th>Quation No</th>
<th>Quation Date</th>-->

<th>Bill No.</th>
 <th>Bill Date</th>
 <th>Customer Name</th>
 <th>Mobile No.</th>
 <th>City</th>   
 <!-- <th>Qty</th>
   
     <th>Duration</th>  
          
   <th>Personby</th>-->
   <th>Total Amount</th>
   <th>Advance Amount</th>
    <th>Pending Amount</th>
   <!-- <th>Inv. Status</th>-->
     <!--<th>Bill Datail</th>-->
    <!-- <th>Payment Datail</th>-->
   
<!--<th class="hidden-phone hidden-tablet">Status</th>-->
 </tr>
</thead>
<tbody>
	<?php
		$ure=mysql_query("SELECT * FROM tbl_generate_invoice_mst order by invoice_id DESC");		
		while($urow=mysql_fetch_array($ure)) {
			
			$invoice_id=$urow['invoice_id'];
			$status=$urow['status'];
			$adv_amount1=$urow['adv_amount'];
			$total_amount1=$urow['total_amount'];
		?>  
        <tr>
<td class="span1">
<div class="btn-group">
<?php /*?><a href="weight_add.php?reg=<?php echo $urow[0]; ?>" data-toggle="tooltip" title="Edit" class="btn btn-mini btn-success" style="margin-right:10px;"><i class="icon-pencil"></i></a><?php */?>
<?php echo "<a href='#' data-toggle='tooltip' title='Delete' class='btn btn-mini btn-danger' onclick='del(this,$urow[invoice_id])'>" ?><i class="icon-remove"></i></a></div></td>
<?php /*?><td><?php echo $urow['quotation_no']; ?></td>
<td><?php echo $urow['quotation_date']; ?></td>
<td><?php echo $urow['customername']; ?></td><?php */?>
<td><?php echo $urow['invoice_no']; ?></td>
<td>
<?php $date1=$urow['invoice_date'];
	  echo  $invoice_date=date("d-m-Y", strtotime($date1)); ?>
<?php //echo $urow['invoice_date']; ?></td>

<td><?php echo $urow['customername']; ?></td>
 <td><?php echo $urow['mobile']; ?></td>
 <td><?php echo $urow['city']; ?></td>
  <td>
								 <div align="right">
								<?php echo $urow['total_amount']; ?>.00/-
								<?php 								 
							//	 $query1223 = "SELECT SUM(total_amount) FROM tbl_generate_invoice_detail where invoice_id='$invoice_id'"; 
	  						 //  	 $result1223 = mysql_query($query1223) or die(mysql_error());
							  //   $row1223 = mysql_fetch_array($result1223);
							//	 echo $total_sum =  $row1223['SUM(total_amount)']; 
								 ?></div></td>
                               <td>
                               <div align="right">
                               <?php echo $urow['adv_amount']; ?>.00
                                <?php 								 
								  //$query1224 = "SELECT SUM(cheque_cash_amount) FROM  tbl_customer_payment where invoice_id='$invoice_id'"; 
	  						   	  //$result1224 = mysql_query($query1224) or die(mysql_error());
							      //$row1224 = mysql_fetch_array($result1224);
								 // echo  $total_sum1 =  $row1224['SUM(cheque_cash_amount)']; 
								 ?></div></td>
							<td> <div align="right">
							<?php echo $urow['pending_amount']; ?>.00</div></td>
                           <!-- <td><?php //secho $urow['status']; ?></td>-->
  
<!--<td><div><a href="invoice_detail.php?invoiceid=<?php //echo $urow['invoice_id']; ?>">View</a> /
<a href="generate_invoice_list.php?invoiceid=<?php //echo $urow['invoice_id']; ?>#popup1" name="generate_print">Print</a></div>

</td>-->



<?php /*?> <a href="print_repeat_invoice_with_logo.php?lastinvoice_id=<?php echo $urow['invoice_id']; ?>">Print</a> </div></td>  <?php */?>
<?php
//if($status == 'Running')
 // {
?>
<!--<td><div><a href="payment_add.php?reg=<?php //echo $urow[0]; ?>">Add Payment</a> </div></td>-->
 <?php
// }
// else
// {
 ?>
 <!--<td><div style="color:#339900">Payment Done</div></td>-->
 <?php //} ?>
<?php /*?><td><?php $issued_dates  =  $urow['weight_date'];
           echo $issued_date=date("d-m-Y", strtotime($issued_dates));  ?></td>
           <td><?php echo $urow['amount']; ?></td><?php */?>


  
							
 
<!--<td>-->

            
            <?php 
				//	if($urow['status']=='Confirm')
				//	{
						?>
                      <!-- <img src="images/1.png" />-->
					<?php		//		}
				//	else if($urow['status']=='Running')
				//	{?>
                    <!--<img src="images/2.png"  />-->
                    <?php //}
						?>
							<!--</td>-->
                            </tr>
                           
<?php } ?>
</tbody>
</table>

 <script language="javascript">
function del(obj,id)
{
        if(confirm("Are You Sure To Delete ?"))
        {
            obj.href="generate_invoice_list.php?id="+id;
        }
    
}
</script>
<?php
if(isset($_GET['id']))
	{
		$delquery="select * from  tbl_generate_invoice_mst where invoice_id=".$_GET['id'];
$dusr="delete from  tbl_generate_invoice_mst where invoice_id=$_GET[id]";
		$dre=mysql_query($dusr);
		
		$dusr="delete from  tbl_generate_invoice_detail where invoice_id=$_GET[id]";
		$dre=mysql_query($dusr);
		?>
		
		<script language="javascript">window.location.href="generate_invoice_list.php";</script>
		<?php
	}
	?>	
    
     <?php 
  
$ure=mysql_query("select * from tbl_generate_invoice_mst");
		
		while($row=mysql_fetch_array($ure))
		{
		$cst = $row[2];
		
		if($cst == '0')
		{
		 $dusr="delete from tbl_generate_invoice_mst where invoice_id	= '$cst'";
$dre=mysql_query($dusr);
}
}
?>
</div>
 <?php 
							$invoiceid = $_GET['invoiceid']; 
                            if(isset($_REQUEST['generate_print']))
							{
	 							$invoice_format=$_REQUEST['invoice_format']; 
							?>
			<script>window.location="print_repeat_invoice_with_logo.php?lastinvoice_id=<?php echo $invoiceid; ?>&&invoice_format=<?php echo $invoice_format; ?>";</script>
						<?php } ?>
<div id="popup1" class="overlay">
                            <div class="popup">
                            
                              <a class="close" href="#">&times;</a>
                              <div class="content">
         <form  method="post" >
		  
		  <h4 class="form-box-header">Select Invoice Format</h4>
		  
            <table align="center" cellpadding="0" cellspacing="0" width="100%">
             
              <tr>
                <td width="40%"><div class="wrap">
                    <label class="in_field">Invoice Format</label>
                  </div></td>
               <!-- <td width="60%"><select name="invoice_format">
                    <option value="">--Select Format--</option>
					 <option value="with_header">With Header</option>
					  <option value="without_header">Without Header</option>
                  </select>
                </td>-->
                <td width="60%">
                <select name="invoice_format">
                    <option value="">--Select Format--</option>
					 <option value="1">With Header</option>
					  <option value="2">Without Header</option>
                  </select>
                </td>
              </tr>
			  <tr>
			  <td><br></td>
			  </tr>
              
              <tr>
                <td width="40%">&nbsp;</td>
                <td width="60%">
               <button class="btn btn-success" name="generate_print"><i class="icon-print"></i> Print Invoice</button>
				<!--<button class="btn btn-success" name="generate_print"><i class="icon-print"></i> Print Invoice</button>-->
               
                </td>
              </tr>
			  
			  <tr>
			  <td><br></td>
			  </tr>
			  
            </table>
          </form>
                              </div>
                            </div>
                          </div>
<?php include 'footer.php' ?>
</div>
</div>
<?php include 'profile_popup.php' ?>

<!--[if lte IE 8]><script src="js/helpers/excanvas.min.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/vendor/jquery-1.9.1.min.js"%3E%3C/script%3E'));</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script><script>$(function(){$("#example-datatables").dataTable({aoColumnDefs:[{bSortable:!1,aTargets:[0]}]}),$("#example-datatables2").dataTable(),$("#example-datatables3").dataTable()});</script>
</body>
</html>
