<?php
	include("includes/dbconfig.php");
	 
	include('Aira_settings.php');
	$pagetitle = "Feedback";
	require('includes/applicationtop.php');
	require('includes/applicationmenu.php');
	//customersfeedback.php
	 
	 
	 
?>
			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
				<!-- Content Header (Page header) -->
				<section class="content-header">
					<h1>Dashboard</h1>
					<ol class="breadcrumb">
					</ol>
				</section>

				<!-- Main content -->
				<section class="content">
					 
					 
					
					 
					
					 
					 <?php 
					 $feedback = DB::query('
					 SELECT  fd_id,  recomendation, 
capture_date, 
f.receipt_number, p.feedback as prices, t.feedback as timeliness , s.feedback as service_rates, r.feedback as recommend_rate, rct.customer_id, c.name, c.phone, c.email FROM `feedbackdata` as f left join feedback  as p on (f.prices= p.feed_back_id) left JOIN feedback as t on (t.feed_back_id = f.timeliness) left JOIN feedback as s on (s.feed_back_id = f.service_rate) left JOIN feedback as r on (r.feed_back_id = f.recommend)   left join cash_receipt as rct on  rct.receipt_number = f.receipt_number   left join customers as c on  c.id = rct.customer_id   order by fd_id DESC
					 
' );
				
				 
 
					?>
					
					<div class="card card-info">
						<div class="card-header  ">
							<h3 class="card-title">Customer's Responses</h3>
							 
						</div><!-- /.box-header -->
						<div class="card-body"> 
								 
								
								<?php if(DB::count() >0)
										{
											
											?>
								
								<table id="example1" class="table table-bordered table-hover">
                
									<thead>
										<tr>
										
										
											 <tr><th> #</th><th> Receipt</th> <th>Date </th><th> Name</th><th> Email</th> <th> Prices</th><th>Time </th><th>Service </th><th>Likely to recomend </th> <th>Customer Recomendation</th>  </tr> 
										</tr>
									</thead>
									<tbody>
									<?php 
									$i =0;
									 foreach($feedback as $row){
										echo '<tr> <td>'.($i +=1).'</td><td>'.$row['receipt_number'].'</td><td>'.$row['capture_date'].'</td><td>'.$row['name'].'</td><td>'.$row['email'].'</td><td class="nav-link">'.$row['prices'].'</td><td>'.$row['timeliness'].'</td>
										<td>'.$row['service_rates'].'</td><td>'.$row['recommend_rate'].'</td><td>'.$row['recomendation'].'</td></tr>';
									}
									 
								 
									
									?>
									 
									</tbody>
									 
								</table>
										<?php } ?>
							</div><!-- /.table-responsive -->
							
							
							
						</div><!-- /.box-body -->
				 
						<?php  ?>
				</section><!-- /.content -->
			</div><!-- /.content-wrapper -->

			 
		</div><!-- ./wrapper -->
		
		
      <div class="modal fade" id="Success">
        <div class="modal-dialog">
          <div class="modal-content ">
            <div class="modal-header bg-warning">
              <h4 class="modal-title">Confirm action</h4>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span></button>
            </div>
            <div class="modal-body">
              <p id =''>Are you sure you want to cancel this order</p>
            </div>
			<input type='hidden' id='Control' />
            <div class="modal-footer justify-content-between">
			
              <button type="button" class="btn btn-danger" data-dismiss="modal">No</button>
              <button type="button"   class="btn btn-success Cancel_proceed">Yes</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>

			<?php include ('includes/general_footer.php')?>
		<script>
		function Order_details(){
			 
			 var order =  $("input[name='Web_orders']:checked").val();
			  
			 
			 $.ajax({
		type: "POST",
		url: "process_web_order_start.php",
		data: {itemcode: order },
		 
		success: function(data){  
			 
			window.location.href = "process_online_order.php";
			 
			  
		}
		});
		
		
		
		}
		
			//Process_order
			$(".Process_order").click(function() {
			var order = $(this).val();
			 $.ajax({
				type: "POST",
				url: "process_web_order_start.php",
				data: {itemcode: order },
				 
				success: function(data){  
					 
					window.location.href = "process_online_order.php";
					 
					  
				}
		});
			 
		});
		
		 $(".Cancel_order").click(function() {
			var order = $(this).val();
			
			 $('#Control').val(order);
			  $('#Success').modal('show');
		 
			return false;  
			 
			 
		});
		 
		 $(".Cancel_proceed").click(function() {
			 
			
			 var order = $('#Control').val();
			  $('#Success').modal('hide');
			 
			 
			    $.ajax({
				type: "POST",
				url: "cancel_online_order.php",
				data: {itemcode: order },
				 
				success: function(data){  
					 
					window.location.href = "dashboard.php";
					 
					  
				}
		});
			 
		 });
		
		
		</script>
	</body>
</html>