<?php
require_once("dbconnection.php");





$qurey = "select loan.*,customer.cust_name,customer.cust_contact
FROM loan LEFT OUTER JOIN customer 
on loan.cust_id= customer.cust_id WHERE sup_id IS NULL AND borrow_amount > 0 GROUP BY cust_id";
$r2 = $con->query($qurey);


?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>لیست اوگرایی مشتریان</title>
    <link rel="shortcut icon" type="image/png" href="images/favicon.ico">
	<link href="vendor/jquery-nice-select/css/nice-select.css" rel="stylesheet">
	<link rel="stylesheet" href="vendor/nouislider/nouislider.min.css">
	<!-- Style css -->
    <link href="css/style.css" rel="stylesheet">
    <link href="vendor/sweetalert2/dist/sweetalert2.min.css" rel="stylesheet">
	<link href="vendor/jquery-nice-select/css/nice-select.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="dist/sweetalert.css"> 
    <link href="vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
    <!-- modernizr css -->
    <script src="assets/js/vendor/modernizr-2.8.3.min.js"></script>
     <script>
  document.addEventListener("keydown", function(event) {
    if (event.key === "Escape") {
      // Use a short delay to ensure smooth behavior
      setTimeout(() => {
        window.history.back();
      }, 100);
    }
  });
</script>
    <style>
        table {
            page-break-inside:auto;
        }
        tr{
            page-break-inside:avoid; page-break-after:auto;
        }
        thead{
            display:table-header-group;
        }

        
    </style>
</head>
<body>

<table class="table text-center" dir="rtl">
                                            <thead class="text-uppercase bg-primary">
                                                  <tr style="color:black;" class="table100-head">
                                                  <th>نمبر</th>

                                                <th>اسم مشتری</th>
                                                <th>شماره تماس</th>
                                                <th>مجموعه</th>
                                                <th>رسید</th>
                                                <th>باقی</th>
                                               
                                                
                                                  
                                                        
                                                  
                                                  
                                                    
                                                </tr>
                                            </thead>
                                            <tbody>
                                       
                                                <tr>
                                                <?php
while($row=$r2->fetch_array(MYSQLI_ASSOC))
{
                echo "<td>".$row["l_id"]."</td>";
                echo "<td>".$row["cust_name"]."</td>";
                echo "<td>".$row["cust_contact"]."</td>";
                echo "<td>".$row["total_price"]."</td>";
                echo "<td>".$row["received_amount"]."</td>";
                echo "<td>".$row["borrow_amount"]."</td>";
                
                

   
	echo "</tr>";
}
		?>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    
                    <button id="printpagebutton" class="btn btn-primary" onclick="printpage()" style="
  @media print {
  #printPageButton {
    display: none;` 
  }
}">پرنت</button>
  
<script type="text/javascript">
    function printpage() {
        //Get the print button and put it into a variable
        var printButton = document.getElementById("printpagebutton");
        //Set the print button visibility to 'hidden' 
        printButton.style.visibility = 'hidden';
        //Print the page content
        window.print()
        //Set the print button to 'visible' again 
        //[Delete this line if you want it to stay hidden after printing]
        printButton.style.visibility = 'visible';
    }
</script>
<button class="btn btn-primary" id="back"  onclick="goBack()"></button>
<script>
function goBack() {
  window.history.back();
 


}
</script>
</body>
</html>
