System.Extend.Booking.tableDateTimeEdit = function (replaceType,Id,argsObj){	var selector = "";    var type = "";    if(replaceType == "startTime"){		selector = "#BookingTableTimeStart"+Id;        type = "time";	}else if(replaceType == "endTime"){		selector = "#BookingTableTimeEnd"+Id;        type = "time";	}else if(replaceType == "date"){        selector = "#BookingTableDate"+Id;        type = "date";    }        this.args = {        selector: selector,        id: Id,        type: type,        controllerPath: System.Env.siteUrl + "controller_admin.php",        controllerAction: "action=BookingTableDateTimeReplace&replaceType="+replaceType,        tdAction: "onClick='javascript: System.Extend.Booking.tableDateTimeEdit("+'"'+replaceType+'",'+Id+")'",        datetimepicker: { 			changeMonth: true,			changeYear: true,			currentText: 'Now',			showButtonPanel: true,			showAnim: 'fadeIn',			duration: 200,			dateFormat: "dd.mm.yy",            separator: " // ",            timeFormat: "hh:mm:ss",            showSecond: false,            stepHour: 1,            stepMinute: 30,            stepSecond: 59,            hourMin: 08        }    }        for(i in argsObj){this.args[i] = argsObj[i];}           new System.UI.Table.dateTimeEdit(this.args);}System.Extend.Booking.statusChange = function(id,selector){        System.UI.Table.statusChange({        controllerPath: System.Env.siteUrl + "controller_admin.php",        controllerAction: "action=BookingTableStatusChange",        selector: selector,        id: id    });}System.Extend.Booking.statusChangeGroup = function(checkSelector,statusSelector,newStatus){    System.UI.Table.statusChangeGroup({        controllerPath: System.Env.siteUrl + "controller_admin.php",        controllerAction: "action=BookingTableStatusChangeGroup",        checkSelector: checkSelector,        statusSelector: statusSelector,        status: newStatus    });}System.Extend.Booking.TimeTableCalendar = function(itemId,argsObj){        var self = this;    this.intervalID = '';    this.ReservationWindow = {};    this.ID = System.generateID();        var Date = new System.Date().get();	var MsgTranslations = new System.Translations({id:"System",container:"Msg"});    var currentDate = Date['day'] + "." + Date['month'] + "." + Date['year'];    this.dateText = currentDate;       this.startTime = '';    this.endTime = '';    this.note = '';    var currentTime = Date['hour'] + ":" + Date['minute'] + ":" + Date['second'];    var tableID = "BookingTimeTable"+this.ID;    var tableSelector = "#"+tableID;    var tableLoaderID = "BookingTimeTableLoader"+this.ID;    var tableLoaderSelector = "#"+tableLoaderID;    var html = '<div class="UI-table-wrap" id="BookingTimeTableWrap'+this.ID+'" >';    html += '<div class="UI-table-top" style="height:20px;">';    html += '</div>';    html += '<div class="UI-table-loader" id="'+tableLoaderID+'" style="height:30px;"></div>';        html += '<div class="UI-table" id="'+tableID+'"></div>';    html += '</div>';        this.tableInstance = {};            this.args = {        selfArgs: this,        autoInit: true,        selector: "",        calendarLoaderSelector: "",        calendarSelector: "",        noteSelector: "",        langCode: System.Env.langCode,        controllerPath: System.Env.siteUrl + "controller.php",        loaderCss: "margin: 0 auto;margin-top:50px;width:32px;margin-bottom:50px;",        onDateSelect: function(date){},        refreshIntervalEnable: true,        refreshInterval: 120,        tableArgs: {            controllerScriptPath : "controller.php",                 paginate : false,            tableHolderID: tableID,            loaderHolderID : tableLoaderID,            itemsCheckSelector: "td.UI_table-cell-check",            controllerActionTable : "action=GetBookingTimeTableContent&date=" + self.dateText + "&itemId=" + itemId,            showLoader: true,            onError: function(){                return false;            }        }    }    for(i in argsObj){this.args[i] = argsObj[i];}        this.args.tableArgs.refreshIntervalEnable = this.args.refreshIntervalEnable;    this.args.tableArgs.refreshInterval = this.args.refreshInterval;    this.onDateSelect = function(){        self.args.onDateSelect.call(this,self.dateText);    }    this.init = function(){        self.tableHtml();        self.initTable();        jQuery(self.args.calendarLoaderSelector).fadeOut(150);        self.initCalendar();    }        this.initCalendar = function(){        jQuery.datepicker.setDefaults(jQuery.datepicker.regional[self.args.langCode]);        jQuery(self.args.calendarSelector).datepicker({                dateFormat: "dd.mm.yy",                onBeforeShowDay: function(date){                    //alert(date);            },            onSelect: function(dateText, inst){                             self.update(dateText);                self.onDateSelect();                                   //alert("update");            }        });            }        this.tableHtml = function(){        jQuery(self.args.selector).html(html);         }        this.initTable = function(){        self.tableInstance = new System.UI.Table(self.args.tableArgs);          }            this.update = function(dateText){                //jQuery(self.args.selector).html("<div style='"+self.args.loaderCss+"'>"+System.UI.Elements.Loaders["32Red"]+"</div>");                self.dateText = dateText;                self.tableInstance.args.controllerActionTable = "action=GetBookingTimeTableContent&date=" + self.dateText + "&itemId=" + itemId;                self.tableInstance.reset();    }            this.reservation = function(){        if(System.Env.User.quest){            System.UI.Windows.Msg("<p class='sys-msg-err'>"+MsgTranslations["warning_log_in_to_continue"]+"</p>",true);        }else{            var values = self.tableInstance.checkedItemsValues();            self.note = jQuery(self.args.noteSelector).val();            //var Reservation = {};                        if(values.length > 1){                self.startTime = values[0];                var startTimeArray = self.startTime.split(";");                self.startTime = startTimeArray[0];                self.endTime = values[values.length - 1];                var endTimeArray = self.endTime.split(";");                self.endTime = endTimeArray[1];            }else{                var timeArray = values[0].split(";");                self.startTime = timeArray[0];                self.endTime = timeArray[1];            }                        var html = "<div style='padding:20px;border:1px dotted #666;background:#fff;font-size:12px;'>";			html += "<div><strong>"+self.args.itemName+"</strong></div><br/>";			html += "<div><strong>User:</strong> "+System.Env.User.name+" "+System.Env.User.last_name+"</div>";            html += "<div><strong>Datum:</strong> "+self.dateText+"</div>";            html += "<div><strong>Vrijeme:</strong> "+self.startTime+" - "+self.endTime+"</div>";            html += "<div><strong>Napomena:</strong> "+self.note+"</div>";            html += "</div>";            var buttons = {                "Potvrdi" : function(){                    self.makeReservation();                }            }            var args = {                title: 'Potvrda rezervacije:',                buttons: buttons,                modal: true            }            self.ReservationWindow = new System.UI.Window(html,args);        }    }        this.makeReservation = function(){        self.ReservationWindow.close();                var ProgressWindow = new System.UI.Windows.Progress({showClose:false});        jQuery.ajax({            url: self.args.controllerPath,             type: "POST",            data: "action=BookingMakeReservation&userId=" + self.args.userId + "&itemId=" + self.args.itemId + "&startTime=" + self.startTime + "&endTime=" + self.endTime + "&date=" + self.dateText + "&note=" + self.note,             success: function(data){                if(System.trim(data) == 'error_access_denied'){					ProgressWindow.destroy();									System.UI.Windows.Msg("<p class='sys-msg-err'>"+MsgTranslations[data]+"</p><p>"+MsgTranslations['text_log_in']+"</p>",true);				}else{					ProgressWindow.destroy();					System.UI.Windows.Msg(data,true);				}                self.tableInstance.reset();            },            error: function(jqXHR, textStatus, errorThrown){                System.UI.Windows.Msg(errorThrown);            }                        });    }        if(this.args.autoInit){        this.init();    }    }System.Extend.Booking.courtStatus = function(argsObj){        var self = this;        this.args = {        selector: "",        id: "",        controllerPath: System.Env.siteUrl + "controller_admin.php"            }        for(i in argsObj){this.args[i] = argsObj[i];}            jQuery(self.args.selector).html(System.UI.Elements.Loaders["LoaderFBSmallGrey"]);       jQuery.ajax({        url: self.args.controllerPath,         type: "GET",        dataType: 'json',        data: "action=GetBookingItemData&id=" + self.args.id,         success: function(data){            jQuery(self.args.selector).html(data['status']);                    },        error: function(jqXHR, textStatus, errorThrown){            alert(errorThrown);        }           });}System.Extend.Booking.PublicAdministration = function(argsObj){        var self = this;        this.ID = System.generateID();    this.tableID = "BookingPublicAdminTable"+this.ID;    this.toolbarID = "BookingPublicAdminToolbar"+this.ID;    this.loaderID = "BookingPublicAdminLoader"+this.ID;    this.paginationID = "BookingPublicAdminPagination"+this.ID;    this.html = '<div id="BookingPublicAdminTableWrap'+this.ID+'">';    this.html += '<table class="UI-table-top" style="padding-top:10px;">';    this.html += '<tr>';    this.html += '<td><div class="UI-table-toolbar" id="'+self.toolbarID+'"></div></td>';    this.html += '<td><div class="UI-table-loader" id="'+self.loaderID+'"></div></td>';    this.html += '<td style="float:right;"><div class="UI-table-pagination" id="'+self.paginationID+'"><div></div></td>';        this.html += '</tr>';    this.html += '</table>';    this.html += '<div class="UI-table" id="'+this.tableID+'"></div>';    this.html += '</div>';        if(typeof(argsObj.tableArgs == 'undefined')){argsObj.tableArgs = {};}        this.args = {        paginate: false,        instanceName: ''    }        var tableArgsObj = argsObj.tableArgs;        for(i in argsObj){self.args[i] = argsObj[i];}        this.InstanceWindow = new System.UI.Window(self.html,{modal:true,width:800});            var tableArgs = {                        controllerScriptPath: 'controller.php',                        paginate: self.args.paginate,                        tableHolderID : self.tableID,                        loaderHolderID: self.loaderID,                        paginationHolderID: self.paginationID,                        itemsCheckSelector: "td.UI_table-cell-check",                        controllerActionTable : "action=BookingTableContent&catId="+self.args.catId+"&itemId="+self.args.itemId+"&userId="+System.Env.User.id+"&tableId="+self.tableID,                        controllerActionItemsDelete : "action=BookingTableItemsDel&itemId="+self.args.itemId,                        controllerActionPagination: "action=BookingTablePagination&tableObj="+self.args.instanceName+".InstanceTable&catId="+self.args.catId+"&itemId="+self.args.itemId,                        onError: function(){self.InstanceWindow.close();}    }    for(i in tableArgsObj){tableArgs[i] = tableArgsObj[i];}        self.args.tableArgs = tableArgs;           this.InstanceTable = new System.UI.Table(self.args.tableArgs);}
