<?php
	include("my_functions.php");
	$pagetitle = "Invoice data";
	require('includes/applicationtop.php');
	require('includes/applicationmenu.php');
	
	$err= "";
	
	$startdatevalid = false;
	
 
?>
			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
			 

				<!-- Main content -->
				<section class="content">
					<!-- Default card -->
					<div class="card card-primary">
						<?php
							if(  $_SESSION["connectedusergroup"] > 2)
							{
						?>
						<div class="card-body">
							<div id="servererrormessage">
							</div>
							
							<?php
								if($err!="")
								{
							?>
							<div class="alert alert-danger alert-dismissable">
								<i class="fa fa-ban"></i>
								<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><br>
								<?php 
									echo $err; 
								?>
							</div>
							<?php
								}
							?>
							
							<div class="card card-info">
              <div class="card-header">
                <h6 class="card-title"><?= $pagetitle ?></h6>
              </div>
              <div class="card-body">
			  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
									
                
               
				</form>
             
              
								 
								<?php
                                 
                               
									 
                                        $jobs =  Invoicetopups();

                                  

                                    if(!empty($jobs)){
                                        $count = 0;
 
								?>
								<table class="table table-striped table-bordered" id="receiptstable">
									<thead>
										<tr>
											<th>#</th>
											<th  >Receipt No</th>
                                            <th  >Client</th>
											
                                            <th >Bill</th>
                                            <th >Topay</th>
                                            <th >Top up</th> 
                                            <th  >Balance</th>
											
                                            <th >Total</th> 
                                            <th >Date</th> 
                                            <th >Receipt</th> 
										</tr>
									</thead>
									<tbody>

                                    <?php
 
                                     foreach($jobs as $row){
                                        $bar_code = $row['id'];
                                        $topups = topups($bar_code  );
                                        if(!empty($topups)){
                                             $topups = $topups[0]['topup'];

                                        }
                                           //$amount = amount_to_be_not_cleared($bar_code);
                                          

                                        echo '<tr> <td  > #'.( $count +=1).'   </td>
                                        
                                       
                                         
                                            <td>'.$row['receipt_number'].' </td>
                                            <td>'.$row['customer_name'].' </td>
                                            <td>'.number_format($row['bill'] , 2).' </td>
                                            <td>'.number_format( $row['topay'] , 2).' </td>
                                            <td>'.number_format( $row['topup'] , 2).' </td>
                                           
                                            <td>'.number_format( $row['topay']+ $row['topup'] , 2).' </td>
                                            <td>'.number_format($row['newbalance'] , 2).' </td>
                                            <td>'.$row['value_date'].' </td>
                                            
                                            <td  > <form action="'.$GLOBALS['base_url'].'cashsalesregisterreceiptslim_print.php" method="post" >  <input type="hidden"  value="'.$row['id'].'" name="receiptfocus"  /> <button  type="submit" class="btn btn-primary"     >  Print Receipt </button> </form></td>
                                             

                                               </tr>';
                                      

                                     }
                                        

                                        ?>
										 
									</tbody>
								</table>
								<?php
                                    }else echo 'No data found';
								 
								?>
								 
							</div>
						</div><!-- /.card-body -->
						<?php
							}
							else
							{
						?>
						<div class="alert alert-danger alert-dismissable">
							<i class="fa fa-ban-circle"></i><br>
							Limited Access
						</div>
						<?php
							}
						?>
					</div><!-- /.card -->
				</section><!-- /.content -->
			</div><!-- /.content-wrapper -->

			 
		</div><!-- ./wrapper -->
		
		 

	 <?php include ('includes/general_footer.php')?>
		<!-- InputMask -->
		<script src="plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
		<script src="plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
		<script src="plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
		<!-- AdminLTE App -->
	 
		<script src="plugins/bert/storepos.js" type="text/javascript"></script>
		<script>
			$(function() 
			{
				//Datemask2 mm/dd/yyyy
				$("#datemask2").inputmask("mm/dd/yyyy", {"placeholder": "mm/dd/yyyy"});
				//Money Euro
				$("[data-mask]").inputmask();
			});
		</script>
	</body>
</html>