<?php
	include("my_functions.php");
	$pagetitle = "Report";
	require('includes/applicationtop.php');
	require('includes/applicationmenu.php');
	
	$err= "";

    $actual_link = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
 
	$parts = explode('jobsreport' , $actual_link);
		 
		
    $fromdate = false;
    $selector = false;
    $cat = $shop = false;
	
	$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"] == 1 || $_SESSION["connectedusergroup"]> 2)
							{
						?>
						<div class="card-body">
							 
							 
							
							<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">
									
                <div class="row">
                  
                  
                 
                    <label for="to">Search customer or job</label>
											<div class="input-group">
												<input type="text"   name='theclient' placeholder='Enter client name or Barcode' class="form-control"    />
												<span class="input-group-btn">
													<button class="btn btn-primary btn-flat"  type="submit" name="getreceiptsbtn" id="getreceiptsbtn">Go!</button>
												</span>
											</div>
										</div><!-- form-group -->
               
				</form>
				<br /><br />
				</div>
            
							
							 
								<?php
									if($err=="" )
									{

                                        
								?>
								  
								 
								<?php
								
								$jobs = array();
								if(isset($_POST['theclient'])){
                                  $search = trim($_POST['theclient']);
								$jobs = 	generalsearch( $from = false , 50 , $search  );
									
								}else {
									//$jobs = 	notcleared(false , 25 ,false );
									$jobs = distcinct_jobs_repost(5, false  );
									 
								}
								
								  
							

								//$jobs = distcinct_jobs_repost($cat, $fromdate  );
 	 
								if(!empty($jobs)){
									$count = 0;

							?>
							<table class="table table-striped table-bordered" id="receiptstable">
								<thead>
									<tr>
										<th>Bar code</th>
										<th class="text-center">Item</th>
										<th class="text-right">Date</th>
										<th class="text-center">Client</th>
										<th class="text-right">Contact</th>
										<th class="text-center">Bill</th>
										<th class="text-right">Balance</th>
										<th class="text-center">type</th>
										<th class="text-right">Owner</th>
										<th class="text-center">Status</th>
										<th class="text-center">Dipatch date</th> 
									</tr>
								</thead>
								<tbody>

								<?php
								 foreach($jobs as $row){
									$bar_code = $row['parent_bar_code'];

									echo '<tr> <td colspan="8"> #'.( $count +=1).' Bar Code: <b>'.$bar_code.' </b> </td>
									
									<td colspan ="2"> <a class="btn btn-primary" href="'.$GLOBALS['base_url'].'thebarcodes.php/'.$bar_code.'" target="blank">  Print bar codes </a></td>
									<td colspan ="2"> <a class="btn btn-info" href="'.$GLOBALS['base_url'].'customreceipt.php/'.$bar_code.'" target="blank">  Get a receipt </a> </td>
									
									</tr>';
									echo barcode_jobs($bar_code);

								 }
									

									?>
									 
								</tbody>
							</table>
							<?php
								}else echo 'No data found';
							 
							?>
								
							 

                                <?php  } ?>
									 
								
								   
								 
										 
								
								</div>
              <!-- /.card-body -->
            </div>
								
								</div>
							</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')?> 
 
 
	</body>
</html>