Exemple #1
0
$payables = $grandTotal;
if ($ro->getRegistrationDetails_type() == "OPD" || $ro->getRegistrationDetails_type() == "walkin") {
    if ($chargeStatus == "UNPAID") {
        if ($totalPaid >= $payables) {
            for ($x = 0; $x < $countz; $x++) {
                //add to collectionReport table
                $ro->addCollectionReport($registrationNo, $cashierPaid[$x], $shift, "OPD", $ro->getItemNo_total($cashierPaid[$x]), $orNO, "OPD", $username, date("H:i:s"), $datePaid, $paidVia);
                //$natira = $totalPaid - $ro->getItemNo_total($cashierPaid[$x]);
                $cashPaid = $ro->getItemNo_total($cashierPaid[$x]) + $ro->selectNow("patientCharges", "cashPaid", "itemNo", $cashierPaid[$x]);
                $cashUnpaid = $ro->getItemNo_total($cashierPaid[$x]);
                //$cashPaid = $totalPaid;
                if ($paidVia == "Cash") {
                    //check kung meron ng payment sa collectionReport table ung charges
                    if ($ro->selectNow("collectionReport", "collectionNo", "itemNo", $cashierPaid[$x]) != "") {
                        $totalCashPaid = $cashPaid + $ro->selectNow("collectionReport", "amountPaid", "itemNo", $cashierPaid[$x]);
                        $ro->paymentManager($cashierPaid[$x], "PAID", $username, $cashPaid, $datePaid, date("H:i:s"), "0");
                    } else {
                        $ro->paymentManager($cashierPaid[$x], "PAID", $username, $cashPaid, $datePaid, date("H:i:s"), "0");
                    }
                } else {
                    if ($ro->selectNow("patientCharges", "title", "itemNo", $cashierPaid[$x]) == "PROFESSIONAL FEE") {
                        $payablesPF = $ro->selectNow("patientCharges", "doctorsPF", "itemNo", $cashierPaid[$x]);
                        $totalCreditCard = $cashPaid + $payablesPF;
                        $ro->paymentManager_creditCard_PF($cashierPaid[$x], "PAID", $username, $totalCreditCard, $datePaid, date("H:i:s"), "0", $payablesPF);
                        $ro->editNow("patientCharges", "itemNo", $cashierPaid[$x], "doctorsPF", "0");
                    } else {
                        if ($ro->selectNow("patientCharges", "title", "itemNo", $cashierPaid[$x]) == "OT") {
                            $otShare = $ro->selectNow("patientCharges", "otShare", "itemNo", $cashierPaid[$x]);
                            $totalCreditCard = $cashPaid + $otShare;
                            $ro->paymentManager_creditCard($cashierPaid[$x], "PAID", $username, $totalCreditCard, $datePaid, date("H:i:s"), "0");
                        } else {