<?php 
session_start();
if(!isset($_SESSION['user'])) {
	header("location: ../index.php");
	exit;
}
include('Pagination.php');
include "../dbconnect.php";

$client_id = '62';
$outlet_id = '1';
if ($_GET['act'] == 'takefb') {
	$outletid = $_GET['outletid'];
	$invoiceid = $_GET['invoiceid'];

	$feedback_details = '';
	$fbdt = array();	

	// details of order info
	$order_info_detail = '';
	$orderinfo = array();
	$qry1 = mysql_query("SELECT * FROM `guest_order_history` WHERE `feedback_done` = 0 AND (OrderStatus != 'Rejected' AND OrderStatus != 'Cancelled') AND `UnitId` = '$outletid' AND `InvoiceId` = '$invoiceid'");
	while ($row1 = mysql_fetch_array($qry1)) {
		$UnitId = $row1['UnitId'];
		$invoiceId = $row1['InvoiceId'];

		$unit_sql1 = mysql_query("SELECT UnitName FROM unit_master WHERE UnitId=$UnitId");
		$unit_row1 = mysql_fetch_assoc($unit_sql1);
		$unit_name1 = $unit_row1['UnitName'];

		$order_info_detail = '<p class="customer-name text-logs" style="font-weight: 800;">'.$row1['FirstName'].' '.$row1['LastName'].'</p><div class="row"><div class="col-lg-6 col-md-6 fb-detail-left"><p class="detail-left text-logs">'.$row1['GuestPhone'].'</p><p class="detail-left text-logs">Sale Date <span class="text-bold">'.date('d-m-Y', strtotime($row1['SaleDate'])).'</span></p></div><div class="col-lg-6 col-md-6 fb-detail-right text-right"><p class="detail-right text-logs">Invoice No. - <span class="text-bold">'.$row1['InvoiceNumber'].'</span></p><p class="detail-right text-logs">Order Source - <span class="text-bold">'.$row1['SourceOfOrder'].'</span></p><p class="detail-right text-logs">Outlet Name - <span class="text-bold">'.$unit_name1.'</span></p></div></div>';
		
		$order_info_detail .= '<table class="table table-striped table-sm table-fb-order"><thead class="thead-default"><tr><th>Item</th><th>Qty</th><th>Price</th></tr></thead><tbody>';
		$odr_qry = mysql_query("SELECT * FROM `sale_item_record` WHERE `UnitId` = '$UnitId' AND `InvoiceId` = '$invoiceId'");
		while ($odr_row = mysql_fetch_array($odr_qry)) {
			$order_info_detail .= '<tr><td>'.$odr_row['ItemName'].'</td><td>'.$odr_row['Quantity'].'</td><td>'.$odr_row['Price'].'</td></tr>';
		}
		$order_info_detail .= '</tbody></table>';
		$sale_qry = mysql_query("SELECT * FROM `sale_record` WHERE `UnitId` = '$UnitId' AND `InvoiceId` = '$invoiceId'");
		$sale_row = mysql_fetch_array($sale_qry);
		$order_info_detail .= '<div class="row"><div class="col-lg-12 text-right"><p>Discount: <span class="text-bold">'.$sale_row['DiscAmt'].'</span></p><p>Total Bill Amount: <span class="text-bold">'.$sale_row['TotalAmt'].'</span></p></div></div>';
	}
	echo $order_info_detail;
}
 ?>