</form>			
			<div class="col-md-7">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>Date</th>
							<th>Patient</th>
							<th>Amount</th>
						</tr>
					</thead>
					<tbody>
						<?php 
foreach ($ro4->inpatient_discharged_registrationNo() as $registrationNo) {
    ?>
							<?php 
    $pxRefund = $ro4->inpatient_refund_total($registrationNo, "Cash");
    ?>
							<?php 
    if ($pxRefund > 0) {
        ?>
								<tr>
									<td>
										<?php 
        echo $ro4->formatDate($ro->selectNow("registrationDetails", "dateUnregistered", "registrationNo", $registrationNo));
        ?>
									</td>

									<td>
										<?php 
        $patientNo = $ro->selectNow("registrationDetails", "patientNo", "registrationNo", $registrationNo);
        $lastName = $ro->selectNow("patientRecord", "lastName", "patientNo", $patientNo);
											<td>
												<?php 
    //$bal = round(( round($unpaid,2) - round($cash + $creditCard + $disc ,2) ),2); echo "x".$bal;
    $bal = round(round($unpaid, 2) - round($cash + $creditCard + $disc, 2), 2);
    echo $bal;
    if ($bal > 0) {
        $balTotal += $bal;
    } else {
        //kpg negative wag n isama sa total kc meron nman syang kabanggang account na excess payment
    }
    ?>
											 </td>

											<td>
												<?php 
    $refund = $ro4->inpatient_refund_total($registrationNo, "CASH");
    echo $refund;
    $refundTotal += $refund;
    ?>
											</td>


											<td>
												<?php 
    $grandBal = $bal + $refund;
    echo $grandBal;
    $grandBalTotal += $grandBal;
    ?>
											</td>

											<td>
					<thead>
						<tr>
							<th>Date</th>
							<th>Patient</th>
							<th>Amount</th>
						</tr>
					</thead>
					<tbody>
						<?php 
foreach ($ro4->inpatient_discharged_registrationNo() as $registrationNo) {
    ?>
							<?php 
    $cash = $ro4->inpatient_payment_total($registrationNo, $payment);
    ?>
							<?php 
    $refund = $ro4->inpatient_refund_total($registrationNo, $payment);
    ?>
							<?php 
    $pxCash = $cash - $refund;
    ?>
							<?php 
    $paymentTotal += $pxCash;
    ?>
							<?php 
    if ($pxCash > 0) {
        ?>
								<tr>
									<td>
										<?php 
        echo $ro4->formatDate($ro->selectNow("registrationDetails", "dateUnregistered", "registrationNo", $registrationNo));
        ?>