if ($balance > 0) {
                    $description = 'Topup';
                }
            }
            $bill_obj->StoreAdvancePaymentToBill($pid, $new_bill_number, 0, $balance, $notes, $description);
            //transfer bill need to be reviewed
            $bill_obj->FlagDepositItems($new_bill_number);
        }
        header("location: billing_tz_edit.php" . URL_APPEND . "&batch_nr=" . $batch_nr . "&bill_number=" . $new_bill_number . "&user_origin=quotation&patient=" . $_REQUEST['patient']);
    } else {
        if ($deletecounter > 0) {
            $message = '<font color=red>' . $deletecounter . ' items deleted for ' . $enc_obj->ShowPID($pid) . '.</font>';
        } else {
            $message = '<font color=red>?' . $LDNothingToDo . ' ' . $enc_obj->ShowPID($pid) . '.</font>';
            header("location: billing_tz_quotation.php" . $URL_APPEND . "?&message=" . urlencode($message) . "&patient=" . $_REQUEST['patient']);
        }
    }
}
// end of if($task=="insert")
if ($debug) {
    echo "<br>nothing to do - just show what we have...<br>";
}
//require_once($root_path.'include/care_api_classes/class_tz_insurance.php');
//$insurance_tz = New Insurance_tz();
// Get actual insurance budget of PID
$matchingContract = $insurance_obj->GetContractMemberFromTimestamp($pid, time());
$matchingBills = $bill_obj->GetBillCostSummaryInTimeframe($pid, $matchingContract['start_date'], time());
$ceiling = $matchingContract['Member']['ceiling'] - $matchingContract['Member']['ceiling_startup_subtraction'];
$used_budget = $matchingBills;
$insurancebudget = $ceiling - $used_budget;
require "gui/gui_billing_tz_quotation_create.php";