<?php
require_once(__DIR__."/../includes/sysinit.php");
include("booking.php");
$_booking = new Booking; //new class instance
$_booking->hddnBookingId		= $_POST['hddnBookingId'] ?? 0;
$_booking->selClientId			= $_POST['selClientId'] ?? 0;
$_booking->edtBookingDate		= $_POST['edtBookingDate'] ?? 0;
$_booking->txtBookingTime		= $_POST['txtBookingTime'] ?? '0';
$_booking->txtBookingNote		= $_POST['txtBookingNote'] ?? '';
$_booking->cbScheduleActive		= ($_POST['cbScheduleActive'] ?? 0) === "true" ? 1 : 0;
$_booking->selTeamId			= $_POST['selTeamId'] ?? 0;
$_booking->selBuildingId				= $_POST['selBuildingId'] ?? 0;

$_booking->serviceItems			= json_decode(($_POST['serviceItems'] ?? ''), true);

$_booking->eventDate			= $_POST['eventDate'] ?? '';
$_booking->serviceList			= json_decode(($_POST['serviceList'] ?? ''), true);
$_booking->params				= json_decode(($_POST['params'] ?? ''), true);
$_booking->scheduleOnly			= $_POST['scheduleOnly'] ?? 0;
$_booking->hddnBsId				= $_POST['hddnBsId'] ?? 0;
$_booking->hddnServiceId		= $_POST['hddnServiceId'] ?? 0;
$_booking->selPMId				= $_POST['selPMId'] ?? 0;
$_booking->txtComment			= $_POST['txtComment'] ?? '';
$_booking->edtCashAmount		= $_POST['edtCashAmount'] ?? 0;

//Recurring Options:
$_booking->cbActive				= ($_POST['cbActive'] ?? 0) === 'true' ? 1 : 0;
$_booking->cbRecurring			= ($_POST['cbRecurring'] ?? 0) === 'true' ? 1 : 0;
$_booking->edtDayNumber 		= $_POST['edtDayNumber'] ?? 0;
$_booking->selRepeatCycle 		= $_POST['selRepeatCycle'] ?? 0;
$_booking->selMonthType			= $_POST['selMonthType'] ?? 0;
$_booking->selMonthWeekCycle 	= $_POST['selMonthWeekCycle'] ?? 0;
$_booking->lstDOW				= json_decode(($_POST['lstDOW'] ?? 0), true); //JSON.stringify(lstDOW);
$_booking->lstDOM				= json_decode(($_POST['lstDOM'] ?? 0), true); //JSON.stringify(lstDOM);
$_booking->footerDesc			= $_POST['footerDesc'] ?? '';

if ($_POST['action']=='0') $_booking->addBooking();
if ($_POST['action']=='1') $_booking->addBooking();
if ($_POST['action']=='2') $_booking->viewBooking();
if ($_POST['action']=='3') $_booking->editBooking();
if ($_POST['action']=='4') $_booking->deleteBooking();
if ($_POST['action']=='5') $_booking->saveSchedule();
if ($_POST['action']=='6') $_booking->filterScheduleByTeam();
if ($_POST['action']=='7') $_booking->cancelScheduledItem();
if ($_POST['action']=='8') $_booking->updateServices();
if ($_POST['action']=='9') $_booking->addServiceTransaction();
if ($_POST['action']=='10') $_booking->addServiceComment();
if ($_POST['action']=='11') $_booking->showNextOccurrence();
if ($_POST['action']=='12') $_booking->addPayment();
if ($_POST['action']=='13') $_booking->savePlanner();
if ($_POST['action']=='14') $_booking->SMSNotify();
if ($_POST['action']=='15') $_booking->sendSingleSMS();
unset($_booking);
