<?php
include("../db/cn.php");
if(isset($_SESSION['user_name']) && isset($_SESSION['user_role'])&& isset($_SESSION['outlet_name'])
&& isset($_SESSION['outlet_address'])) {
    $userName = $_SESSION['user_name'];
    $userRole = $_SESSION['user_role'];
	$outlet_address = $_SESSION['outlet_address'];
	$outlet_name = $_SESSION['outlet_name'];
}

$customer_name = $_GET["customer_name"];
$sale = mysqli_query($connection,"select* from log_user_sales where customer_name = '$customer_name'");
$sale_fetch1 = mysqli_fetch_array($sale);

$cdetail = mysqli_query($connection,"select * from credit_note where cr_name = '$customer_name'");
$cdetail_fetch = mysqli_fetch_array($cdetail);

$lease = mysqli_query($connection,"select * from lease where CcustomerName = '$customer_name'");
$lease_fetch = mysqli_fetch_array($lease);




?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Lease Detail of Customer</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .table-bordered th,
        .table-bordered td {
            border: 1px solid black;
        }
        th, td {
            font-size: 12px;
        }
        .header-table td {
            font-size: 12px;
            font-weight: bold;
        }
        .header-logo {
            width: 100px;
            height: auto;
        }
        .text-small {
            font-size: 8px;
        }
    </style>
</head>
<body>

<div class="container">
    <table class="table table-stripped header-table">
        <tr>
            <td rowspan="3" class="text-center align-middle" style="width: 15%;">
                <!-- Placeholder for the logo -->
                <img src="img/united sales corporation 2.png" width="100" height="80" alt="Logo" class="header-logo">
            </td>
            <td class="text-center" style="width: 70%;font-size:36px;">UNITED SALES CORPORATION</td>
            <td rowspan="3" class="text-center align-middle" style="width: 15%;">
                <!-- Placeholder for the profile image -->
                <!--<img src=" alt="Profile Image" class="header-logo">-->
            </td>
        </tr>
        <tr>
            <td class="text-center">BUREWALA , 0300-7615409</td>
        </tr>
        <tr>
            <td class="text-center">Print Date & Time : <?php echo  date("Y-m-d h:i:sa");?></td>
        </tr>
    </table>

    <table class="table table-bordered">
        <tbody>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Account No</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">A/C Date</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Pending</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Pro Fee</td>
                <td></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">CustCode</td>
                <td><?php echo $lease_fetch["customerCode"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Process Date</td>
                <td><?php echo $lease_fetch["processNo"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Occupation</td>
                <td><?php echo $lease_fetch["occupation"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Plan Advance</td>
                <td></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Process.No</td>
                <td><?php echo $lease_fetch["processNo"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">A/C Balance</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Bus Name</td>
                <td><?php echo $lease_fetch["businessName"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Month Installment</td>
                <td><?php echo $sale_fetch1["per_month"];  ?></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Pre.A/C No</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Runing A/C</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; " >Company</td>
                <td><?php echo $lease_fetch["company"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">ProAdv</td>
                <td></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">No of Sales</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Due Date</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Department</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Advance</td>
                <td></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">No of Guar</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Due Amount</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Designation</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Collection</td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Month. Income</td>
                <td></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Discount</td>
                <td></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Customer Information</td>
                <td colspan="3"><?php echo $lease_fetch["CcustomerName"];?></td>
                <td colspan="2"></td>
                <td colspan="2"></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">S/O or W/O</td>
                <td><?php echo $lease_fetch["soDoWo"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; " colspan="2">Tel.Res</td>
                <td colspan="2"><?php echo $sale_fetch1["customer_phone"]; ?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">House Owner</td>
                <td><?php echo $lease_fetch["houseOwner"];?></td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">CNIC</td>
                <td><?php echo $lease_fetch["cnicNo"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Marital Status</td>
                <td><?php echo $lease_fetch["married"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; " colspan="2">Home Since</td>
                <td><?php echo $lease_fetch["sinceLiving"];?></td>
                <td style="background:#383838;color:#fff; font-weight:600; ">Corporate</td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Res. Address</td>
                <td colspan="7">
                <?php echo $lease_fetch["resAddress"];?>
                </td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Off. Address</td>
                <td colspan="7">
                <?php echo $lease_fetch["offAddress"];?>
                </td>
            </tr>
            <tr>
                <td style="background:#383838;color:#fff; font-weight:600; ">Remarks</td>
                <td colspan="7"></td>
            </tr>
        </tbody>
    </table>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th style="background:#383838;color:#fff; font-weight:600; ">Product & Plan Detail</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Company</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Product</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Model</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">ItemName</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Serial No</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Reg No</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Ins.Price</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Dur</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">M.Inst</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">P.Adv</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">RegFee</th>
            </tr>
        </thead>
        <tbody>
          <?php
		  $sale1 = mysqli_query($connection,"select* from log_user_sales where customer_name = '$customer_name'");
          while($sale_fetch = mysqli_fetch_array($sale1)){
		  ?>
            <tr>
                <td rowspan="2"><?php echo $sale_fetch["product_name"]; ?></td>
                <td><?php echo $sale_fetch["company"]; ?></td><!--prodct_name-->
                <td><?php echo $sale_fetch["product_name"]; ?></td><!--company-->
                <td></td><!--prodct_name-->
                <td><?php echo ""; ?></td><!--model-->
                <td><?php echo $sale_fetch["product_name"]; ?></td><!--item_name-->
                <td><?php echo ""; ?></td><!--serial_no-->
                 <td><?php echo ""; ?></td><!--serial_no-->
                <td><?php echo $sale_fetch["net_total"]; ?></td>
                <td><?php echo $sale_fetch["term"]." Month"; ?></td>
                <td><?php echo $sale_fetch["per_month"]; ?></td>
                <td><?php echo $sale_fetch["down_payment"]; ?></td>
                
            
                
            </tr>
            <?php 
		  }
			?>
        </tbody>
    </table>

    

    <table class="table table-bordered">
        <thead>
            <tr>
                <th style="background:#383838;color:#fff; font-weight:600; ">Guarantors Information</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Guarantor Name & Occupation</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">CNIC & Address</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Res. Address & Business Address</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Tel. Res & Business Tel.</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Relation with Cust. & Bus. Name</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Since Liv</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">No of Guar</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Value</th>
            </tr>
        </thead>
        <tbody>
        <?php
        $lease1 = mysqli_query($connection,"select * from lease where CcustomerName = '$customer_name'");
$lease_fetch1 = mysqli_fetch_array($lease1);

		?>
            <tr>
                <td><?php echo $lease_fetch1["guarName"]; ?></td>
                <td><?php echo "" ?></td>
                <td><?php echo $lease_fetch1["guarCnicNo"]; ?></td>
                <td><?php echo $lease_fetch1["guarAddress"]; ?></td>
                <td><?php echo "" ?></td>
                <td><?php echo $lease_fetch1["guarRelation"]; ?></td>
                <td></td>
                <td>1</td>
                <td></td>
            </tr>
             
            
        </tbody>
    </table>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th style="background:#383838;color:#fff; font-weight:600; ">Installment Collection Detail</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Sr#</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Install. No</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Due Date</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Ledger ID</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Disc</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Balance</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">V.Chg</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">ChrgType</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Rec. Officer</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Paid By</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Who Paid</th>
                <th style="background:#383838;color:#fff; font-weight:600; ">Remarks</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            
        </tbody>
    </table>
</div>

</body>
</html>
