// lic : GPL, v2
$page_name = "manage_bills.php";
$db_name = "procrec";
$record_name = "Manage Patient Bills";
include ("lib/freemed.php");
include ("lib/API.php");
freemed_open_db ($LoginCookie);
freemed_display_html_top();
freemed_display_banner();
switch ($action)
{ // master action switch
case "list":
// procduce a list only. Don't acutally process any bills
$query = "SELECT procrec.procbilled,procrec.procdtbilled,
procrec.procbalcurrent,patient.ptlname,patient.ptfname,
patient.id
FROM procrec,patient
WHERE procrec.procbalcurrent > '0'
AND procrec.procpatient = patient.id
ORDER BY patient.ptlname
";
$result = $sql->query($query);
if (!$result)
DIE("Error
");
if ($result)
{
freemed_display_box_top($record_name);
freemed_display_actionbar($page_name, $_ref);
echo "
| Name | Billing Functions | Procedures | Billed | Date Billed | Balance | ||
| $prev_lname, $prev_fname | View/Manage | Patient Ledger | View/Manage | "; if (!$billed) echo " NO  | "; else echo "YES | "; echo "$oldest_bill | "; $total_unpaid += $patient_balance; // add to grand total echo "".bcadd($patient_balance,0,2)." | "; // reset control break $patient_balance = 0.00; //$oldest_bill = $procdtbilled; $oldest_bill = "0000-00-00"; $billed = 1; $prev_patient = $id; $prev_lname = $ptlname; $prev_fname = $ptfname; echo "
| $prev_lname, $prev_fname | View/Manage | Patient Ledger | View/Manage | "; if (!$billed) echo " NO  | "; else echo "YES | "; echo "$oldest_bill | "; $total_unpaid += $patient_balance; // add to grand total echo "".bcadd($patient_balance,0,2)." | "; // end control break // process totals. echo "
| Total | ".bcadd($total_unpaid,0,2)." | ||||||