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

    $actual_link = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		 
		
    $fromdate = false;
    $selector = false;
    $cat = $type = false;
	
	$startdatevalid = false;
	
	if(isset($_POST['getreceiptsbtn']))
	{
		if($_SESSION["connectedusergroup"] == 1 || $_SESSION["connectedusergroup"] == 3)
		{
 
           $fromdate =  date('Y-m-d', strtotime($_POST['to']));
           $cat =  $_POST['cat'];
           $type =  $_POST['shop'];
			 
		}
		else
		{
			$err = $err."Limited Access!<br>";
		}
	} 
?>
			<!-- 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"] == 3)
							{
						?>
						<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">
									
                <div class="row">

                <div class="col-4">
                  <label for="shop">Job Status</label>
											<select  class="form-control" name="cat" id="cat" data-placeholder="Choose One">
                                            <option value="0">Select</option> 
												 
                                                <option value="3">Dispatch</option>
                                                <option value="5">Waiting</option>
                                                <option value="6">Ready for pickup</option>
												 
											</select>
                  </div>

                  <div class="col-4">
                  <label for="shop">Select Job type</label>
											<select  class="form-control" name="shop" id="shop" data-placeholder="Choose One">
                                            <option value="0">Select</option> 
											 
												<?php
													$shopsdata = DB::query("SELECT rptid  as id , rpt_name as name  FROM repair_jobtypes ");
													
													foreach ($shopsdata as $shoprow)
													{
												?>
												<option <?php if(isset($_POST['shop']) && $shoprow['id']==$_POST['shop']) echo "selected=\"selected\""; ?> value="<?php echo $shoprow['id']; ?>"><?php echo $shoprow['name']; ?></option>
												<?php
													}
												?>
											</select>
                  </div>
                  
                  <div class="col-4">
                    <label for="to">From Date</label>
											<div class="input-group">
											
											 
											
												<input type="text" value="<?php echo isset($_POST['to']) ?  $_POST['to'] : "" ?>" name="to" id="to"  data-date-format="dd-mm-yyyy"  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>
                </div>
				</form>
				</div>
              </div>
              <!-- /.card-body -->
            </div>
							
							 
								<?php
									if($err=="" )
									{

                                        if($cat > 0  or $type > 0 ){
								?>
								  
								  
								  
								  
								  
								  
								 
								 
								 
												 <table class="table table-striped table-boardered  table-hover" id="ziana">
												<thead>
												
												<tr class ='info'>
												<th> #</th><th>Job Description </th> <th>Date </th>    <th>Client</th><th>Phone</th> <th>Charges</th><th>Job type </th> <th>Owner  </th>  	<th>Status </th> 	<th>Pick up date </th> 
												</tr>
												</thead>
								 
								<?php
								
								  
							

                              
                              if($cat == 0){
                                $cat = false;

                              }

                              job_detailz($cat, $fromdate , false , false , $type);
                             

                             
									 
								?>
								
								</table>

                                <?php } } ?>
									 
								
								   
								 
										 
								
								
								
								</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>