function ShowOpenInv($CUST) {
global $db;
$sql = "SELECT * FROM Orders WHERE Order_Status = '1'
AND Company_ID = '$CUST'
AND Invoice_Total <> '0'
AND (Invoice_Total - Payment_Total) <> '0' ";
$q = $db->query($sql);
if (PEAR::isError($q)) {
showError ($q);
exit;
}
$numRows = $q->numRows();
print "<table width='100%' border='0' cellspacing='0' cellpadding='2'><tr>
<td class='tdTabColumns' width='50'>Invoice No</td>
<td class='tdTabColumns' width='100'>Date</td>
<td class='tdTabColumns'>Header</td>
<td class='tdTabColumns' width='120' align='right'>Total Invoiced</td>
<td class='tdTabColumns' width='120' align='right'>Total Payments</td>
<td class='tdTabColumns' width='120' align='right'>Shortfall</td>
<td class='tdTabColumns' width='32' align='right'>Pay now</td>
</tr>";
while ($row = $q->fetchRow()) {
if ($_class == "trLine1") {
$_class = "trLine2";
} else {
$_class = "trLine1";
};
$inv_no = $row['Invoice_No'];
$inv_date = $row['Order_Date'];
$inv_head = $row['Order_Header'];
$inv_total = $row['Invoice_Total'];
$inv_payment = $row['Payment_Total'];
$shortfall = $inv_total - $inv_payment;
$shortfall = number_format ($shortfall, 2, '.','') ;
print "<tr class='$_class' ONMOUSEOVER=\"this.className='mOver'\" ONMOUSEOUT=\"this.className='$_class'\" >\n";
print "<td class='tdTabDetail'>$inv_no</td>";
print "<td class='tdTabDetail'>$inv_date</td>";
print "<td class='tdTabDetail'>$inv_head</td>";
print "<td class='tdTabDetail' align='right'>$inv_total</td>";
print "<td class='tdTabDetail' align='right'>$inv_payment</td>";
print "<td class='tdTabDetail' align='right' id='ivalue$inv_no'>$shortfall</td>";
print "<td class='tdTabDetail'><input name='icb$inv_no' id='icb$inv_no' type='checkbox' value='1' onclick=\"alter('$inv_no')\"></td>";
print "</tr>";
}
print "</table>";
}
<script type="text/javascript">
function alter(colo){
if (document.getElementById('icb'+colo).checked) {
document.getElementById('ipay_amount').value = ((document.getElementById('ipay_amount').value)*1 + (document.getElementById('ivalue'+colo).innerHTML)*1);
} else {
document.getElementById('ipay_amount').value = ((document.getElementById('ipay_amount').value)*1 - (document.getElementById('ivalue'+colo).innerHTML)*1);
}
}
</script>
print "<input name='ipay_amount' id='ipay_amount' size='11.2' maxlength='11.2' $InputStyle value='0.00' >";
Hi, I got it all working with the checkboxes. I only have 2 problems with the system at the moment :
1. The numbers for some reason pick up numerous decimal values when adding and subtracting (eg : 54827.01000000001). But my numbers which are being worked with are all 2 decimals ?
2. How do I get the value in the ipay_total text box on post (when I view the source html it still shows 0.00 but in the browser it shows the amount)?
PS : I have included only the code parts which are effected.
Thanks for your help.