var BookingEditReservationForm = function(){};

/***
 * Init the form
 * @returns {undefined}
 */
BookingEditReservationForm.Init = function(){
    Event.AddById("btnSave", "click", BookingEditReservationForm.SaveElement);
};

/***
* Get the Id of element 
*/
BookingEditReservationForm.GetId = function(){
    return Form.GetId("BookingEditReservationFormForm");
};

/*
* Save the Element
*/
BookingEditReservationForm.SaveElement = function(e){
   
    if(Form.IsValid("BookingEditReservationFormForm"))
    {
    let request = new Http("BookingEditReservationForm", "SaveElement");
        request.SetData(Form.Serialize("BookingEditReservationFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

            if(data.status == "error"){
                Form.RenderError("BookingEditReservationFormForm", data.data.message);
            } else{

                Form.SetId("BookingEditReservationFormForm", data.data.Id);
            }
        });
    }
};

