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

    $actual_link = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		$parts = explode('jobreceiptdetails' , $actual_link);
		
    $fromdate = false;
    $selector = false;
	
	$startdatevalid = false;
	
	if(isset($_POST['receipt']))
	{
		if($_SESSION["connectedusergroup"] == 1 || $_SESSION["connectedusergroup"] < 5)
		{
			 $bill     = $_POST["receipt"]; 
            DB::startTransaction();
					 
					 DB::query('DELETE FROM job_receipt WHERE id='.$_POST['receipt'].'');
					
					DB::commit();

                    DB::query('DELETE FROM job_sale_item WHERE receipt='.$_POST['receipt'].'');
                    DB::commit();
			
			 
			 
		 
			 
		}
		else
		{
			$err = $err."Limited Access!<br>";
		}
	} 

        $end = $parts[1];
		 $parts = explode('/' , $end);

        $command =  $parts[1];
        $command2 =  $parts[2]; 
         

        
								 
								  
 
   
?>
			<!-- 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"] > 0)
							{
						?>
						<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">
                            
                               
							
							 
								<?php
									if($err=="" )
									{
										
										$bar_code = job_bar_code_from_id2($command2);
										if(!empty($bar_code)){
										
										 
								?>
								  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
								  <input type="hidden" name="receipt" value="<?= $command2 ?>" />
								 
								  
								  
								  
								  
								  
								 
								 
								 
												 <table class="table table-striped table-boardered  table-hover" id="ziana">
												<thead>
												
												 
												</thead>
								 
								<?php
								
								  
							 
                               echo $job_data =  specific_job($command2);

                              ?>

                              
								
								</table>
                                    <h4> Task details <a href="<?= $GLOBALS['base_url']?>addnewtask/<?= $command2;?>" > Add new task </a></h4>

                                <table class="table table-striped table-boardered  table-hover" id="ziana">
												<thead>
												
												<tr class ='info'>
												<th> Task</th><th>Job </th> <th>Amount</th>    <th>Sub total</th> <th>Action</th> 
												</tr>
												</thead>


											<?php 
											$bar_code = job_bar_code_from_id2($command2);
										job_tasks2($bar_code );

										
												
											?>
                                </table>
								 </form>
										<?php } else echo ' <h4 class="alert alert-warning" >Job deleted </h4>'; ?>

                                </div>
                            </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 -->
		
		<div class="modal" id="waitdialogmodal"  data-backdrop="static">
            <div class="modal-dialog modal-sm">
              <div class="modal-content">
                  <div class="modal-body">
					<div class="text-center">
						<img src="<?php echo $base_url . $ajax_loading_image; ?>" />
					</div>
				  </div>
              </div>
            </div>
        </div>

		 
	
	
	
	
 <?php include ('includes/general_footer.php')?> 
<script src="js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="tableExport.js"></script>
<script type="text/javascript" src="jquery.base64.js"></script>
<script type="text/javascript" src="html2canvas.js"></script>
<script type="text/javascript" src="jspdf/libs/sprintf.js"></script>
<script type="text/javascript" src="jspdf/jspdf.js"></script>
<script type="text/javascript" src="jspdf/libs/base64.js"></script> 
 <link href="css/datepicker.css" rel="stylesheet">
 
<script>
 
		$(function(){
			 
			$('#from').datepicker();
			$('#to').datepicker();
			 
			 
		});
	</script>

	 
		<script src="plugins/bert/storepos.js" type="text/javascript"></script>
		<script src="plugins/bert/store.js" type="text/javascript"></script>
	</body>
</html>