$today = date("d/m/Y"); // Bill id from get first, not post. if ($_GET['id']) { $id = $_GET['id']; } // now check the posted value if (!$id && $_POST['billid']) { $id = $_POST['billid']; } // Not loaded, or different to what is already loaded. if (isset($_POST['bill_id']) && $id != $_POST['bill_id']) { // echo "reset id to POST<br/>"; $id = $_POST['bill_id']; } if (isset($_POST['bill_search'])) { $tmp = get_bill_id($_POST['bill_search']); if ($tmp > 0) { $id = $tmp; $_POST['bill_id'] = $tmp; } } // Booking id if ($_GET['bid']) { $bid = $_GET['bid']; } // Reservation id if ($_GET['rid']) { $rid = $_GET['rid']; } // transaction id if ($_GET['tid']) {
/** * Create the bill for the reservation. * @ingroup RES_MANAGEMENT * @param $resid [in] The reservation ID. * @param $userid [in] The booking agent id. * @param $guestid [in] The guest id. */ function create_reservation_bill($resid, $userid, $guestid) { global $conn; if (!$conn) { $conn = connect_Hotel_db(HOST, USER, PASS, DB, PORT); } if (!$conn) { return 0; } // Get next invoice number $invno = get_nextdocumentno(1, 2, 1); $sql = "INSERT INTO bills (book_id, billno, reservation_id, date_billed, created_by, guestid, status) values(0,"; $sql .= "'" . $invno . "',"; $sql .= strip_specials($resid) . ","; $sql .= "now(),"; $sql .= strip_specials($userid) . ","; $sql .= strip_specials($guestid) . ","; $sql .= "1)"; $stmt = $conn->prepare($sql); $results = $stmt->execute(); $bill_id = 0; if ($results) { $bill_id = get_bill_id($invno); //echo "bill id: ".$bill_id."<br/>"; $sql2 = "update reservation set bill_id = " . $bill_id . " where reservation_id = " . strip_specials($resid); $stmt2 = $conn->prepare($sql2); $results = $stmt2->execute(); //echo $sql2; } return $bill_id; }