<%{
	relatedBills = Purchase_Order_Bill[ID == input.con.toLong()];
	//relatedBills = Bills[Bill_Id1.Internal_Invoice_ID == main.Internal_Invoice_ID && Vendor_Name == main.CP_Name];
	totalPaid = 0;
	// 	 relatedBills = Bills[Bill_Id1.Internal_Invoice_ID == main.Internal_Invoice_ID && Vendor_Name == main.CP_Name && Internal_System_ID == main.ID.toString()];
	allSubformDetails = list();
	for each  related in relatedBills
	{
		totalPaid = totalPaid + related.Grand_Total;
		if(related.Payment_Details != null)
		{
			for each  subformRow in related.Payment_Details
			{
				allSubformDetails.add(subformRow);
			}
		}
	}
	%>
<html>
<head>
<style>
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            background: linear-gradient(135deg, #e3f2fd, #bbdefb);
            color: #333;
        }

        .container {
            max-width: 800px;
            margin: 30px auto;
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #42a5f5, #1e88e5);
            color: #fff;
            text-align: center;
            padding: 20px 0;
            font-size: 28px;
            font-weight: bold;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        .content {
            padding: 20px;
        }

        .content p {
            margin: 10px 0;
            font-size: 16px;
            line-height: 1.8;
        }

        .content p strong {
            color: #444;
        }

        input[type="checkbox"] {
            display: none;
        }

        label {
            display: block;
            margin: 20px auto;
            background: #42a5f5;
            color: #fff;
            padding: 10px 20px;
            text-align: center;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            transition: background 0.3s ease;
            width: fit-content;
        }

        label:hover {
            background: #1e88e5;
        }

        label:active {
            background: #1565c0;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .subform {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }

        input[type="checkbox"]:checked ~ .subform {
            max-height: 500px;
            padding: 10px;
        }

        .subform h3 {
            font-size: 20px;
            color: #1e88e5;
            margin-bottom: 10px;
        }

        .subform table {
            width: 100%;
            border-collapse: collapse;
        }

        .subform table th, .subform table td {
            padding: 12px 10px;
            border: 1px solid #ddd;
            text-align: left;
            font-size: 14px;
        }

        .subform table th {
            background: #42a5f5;
            color: #fff;
            text-align: center;
        }

        .subform table tbody tr:hover {
            background: #f1f8e9;
            cursor: pointer;
        }

        .scrollable {
            max-height: 300px;
            overflow-y: auto;
            border: 1px solid #ddd;
            border-radius: 6px;
        }

        .scrollable::-webkit-scrollbar {
            width: 8px;
        }

        .scrollable::-webkit-scrollbar-thumb {
            background: #42a5f5;
            border-radius: 6px;
        }

        .scrollable::-webkit-scrollbar-thumb:hover {
            background: #1e88e5;
        }

        .footer {
            text-align: center;
            font-size: 14px;
            margin-top: 20px;
            padding: 10px;
            color: #666;
            background: #f0f0f0;
            border-top: 1px solid #ddd;
        }

        /* Additional styling for Paid and Need to Pay */
        .amount-container {
            margin-top: 20px;
            display: flex;
            justify-content: space-between;
            padding: 10px;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 8px;
        }

        .amount {
            font-size: 18px;
            font-weight: bold;
        }

        .paid {
            color: green;
        }

        .need-to-pay {
            color: red;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            Bills Information
        </div>
        <div class="content">
            <p><strong>Bill No:</strong> <%=relatedBills.Purchase_Bill_Number%></p>
            <p><strong>Vendor Name:</strong> <%=relatedBills.Vendor_Name.Account_Name%></p>
            <p><strong>Total Amount:</strong> ₹<%=relatedBills.Grand_Total%></p>
        </div>

<input type="checkbox" id="toggleSubform" />
        <label for="toggleSubform">View Payment Details</label>
        <div class="subform">
            <div class="scrollable">
                <table>
                    <thead>
                        <tr>
							<th>UTR Number</th>
						    <th>Payment Number</th>
                            <th>Payment Amount</th>
                            <th>Payment Date</th>
                        </tr>
                    </thead>
                    <tbody>
<%
	for each  subformRow in allSubformDetails
	{
		tec = Payment_Details_Subform[ID == subformRow];
		%>
<tr>
							  <td><%=tec.Reference_Number%></td>
						     <td><%=tec.Payment_Number%></td>
                            <td><%=tec.Payment_Amount%></td>
                            <td><%=tec.Payment_Date%></td>
                        </tr>
<%
	}
	%>
</tbody>
                </table>
            </div>
          
        </div>

    </div>
</body>
</html>
<%

}%>