Files
BE_IBL/application/controllers/mockup/fo/booking/Setting.php
2026-04-15 15:24:34 +07:00

80 lines
2.0 KiB
PHP

<?php
class Setting extends MY_Controller
{
var $db_smartone;
public function index()
{
echo "SETTING BOOKING API";
}
public function __construct()
{
parent::__construct();
$this->db_smartone = $this->load->database("onedev", true);
}
function get_booking_today()
{
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$sql = "SELECT booking_today.*
FROM booking_today
WHERE BookingTodayIsActive = 'Y'
ORDER BY BookingTodayID DESC
LIMIT 1";
$query = $this->db_smartone->query($sql);
if (!$query) {
$this->db_smartone->trans_rollback();
$this->sys_error_db('select booking today error', $this->db_smartone);
exit;
}
$row = $query->row_array();
$result = array("records" => $row);
$this->sys_ok($result);
}
function update_booking()
{
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_smartone->trans_begin();
$prm = $this->sys_input;
$userId = $this->sys_user['M_UserID'];
$bookingId = $prm["bookingId"];
$bookingDefault = $prm["bookingDefault"];
$sql = "UPDATE booking_today
SET BookingTodayDefault = ?,
BookingTodayLastUpdated = NOW(),
BookingTodayUserID = ?
WHERE BookingTodayID = ?";
$qry = $this->db_smartone->query($sql, [
$bookingDefault,
$userId,
$bookingId
]);
if (!$qry) {
$this->db_smartone->trans_rollback();
$this->sys_error_db("update booking today error", $this->db_smartone);
exit;
}
$this->db_smartone->trans_commit();
$result = array(
"total" => 1
);
$this->sys_ok($result);
}
}