<?php # # Updates the discount for an test-bill association # include "../includes/db_lib.php"; $lab_config_id = $_SESSION['lab_config_id']; $discount_type = $_REQUEST['sel']; $discount_amount = $_REQUEST['amt']; $discount_id = $_REQUEST['id']; $assoc = BillsTestsAssociationObject::loadFromId($discount_id, $lab_config_id); $assoc->setDiscountType($discount_type); $assoc->setDiscountAmount($discount_amount); $assoc->save($lab_config_id); $bill = Bill::loadFromId($assoc->getBillId(), $lab_config_id); echo json_encode(array("a" => format_number_to_money($assoc->getDiscountedTotal()), "b" => format_number_to_money($bill->getBillTotal($lab_config_id))));
public function getAllAssociationsForBill($lab_config_id) { $id = $this->id; $query_string = "SELECT id FROM `bills_test_association` WHERE `bill_id` = {$id}"; $saved_db = DbUtil::switchToLabConfig($lab_config_id); $retVal = query_associative_all($query_string, $_COUNT); DbUtil::switchRestore($saved_db); $associations = array(); foreach ($retVal as $entry) { $associations[] = BillsTestsAssociationObject::loadFromId($entry['id'], $lab_config_id); } return $associations; }