<%@ Page Language="C#" AutoEventWireup="true" UICulture="auto" Culture="auto" meta:resourcekey="PageResource1" %>

<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
<script runat="server">
//@Override this is suggested by Microsoft, overriding the initialize culture function (that is
//automatically called by the aspx.
//Checks if the cookie exists and sets the language correctly, otherwise will fall-back to the default language
//(English).
protected override void InitializeCulture()
{
    HttpCookie lang = Request.Cookies["siteLanguage"]; 
    
    String selectedLanguage = (lang != null) ? lang.Value : "en";
    UICulture = selectedLanguage ;
    Culture = selectedLanguage ;

    Thread.CurrentThread.CurrentCulture = 
        CultureInfo.CreateSpecificCulture(selectedLanguage);
    Thread.CurrentThread.CurrentUICulture = new 
        CultureInfo(selectedLanguage);
    base.InitializeCulture();
}
</script>
<%  
    //this prevents the browser from caching templates. (on IE the templates where cached with the old language
    //too, so the change language was not working, this is a workaround for that).
    
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(DateTime.Now.AddMinutes(-30)); %>

<%--view template starts here (will be appended inside a row-fluid)--%>


<link href="<%= ResolveUrl("~/assets/libs/js/jstree/themes/default/style.css") %>" rel="stylesheet" />

<style>
    .blocker {
        position:absolute;
        top:0; 
        left:0; 
        width:100%;
        height:100%;
        background-color:#ccc; 
        opacity:0.4;
        z-index:99999999; 
    }

    li.node-disabled {
        background-color:#f0f0f0 !important; 
        /*opacity:0.7;*/
        color:#a1a1a1;
    }

    .node-disabled.jstree-default.jstree-wholerow-hovered {
        background: red !important;
    }

    .jstree-themeicon-custom {
        background-color: transparent;
        background-size: 24px !important;
    }
    
    .form-horizontal .control-label {
        float: left;
        width: 80px;
        padding-top: 5px;
        text-align: right;
    }

    .form-horizontal .controls {
        margin-left: 100px;
    }

    .backgrid .align-center-cell {
        text-align: center !important;
    }

    .backgrid .align-left-cell {
        text-align: left !important;
    }

    .backgrid .align-right-cell {
        text-align: right !important;
    }

    .backgrid th.tagId,
    .backgrid td.tagId,
    .backgrid th.counterId,
    .backgrid td.counterId {
        width:150px !important;
        min-width:150px !important;
        max-width:150px !important;
    }

    .backgrid td.tagId,
    .backgrid td.counterId,
    .backgrid td.tagResetValue {
        padding-left: 0px !important;
        padding-right: 0px !important;
        margin: 0px !important;
    }

    .backgrid th.tagResetValue,
    .backgrid td.tagResetValue,
    .backgrid th.tagRealAsDigital,
    .backgrid td.tagRealAsDigital,
    .backgrid th.active,
    .backgrid td.active {
        width: 60px !important;
        min-width: 60px !important;
        max-width: 60px !important;
    }
    
    .backgrid td.tagId select,
    .backgrid td.counterId select {
        width:150px !important;
        margin: 0px !important;
    }
    
    .backgrid td.tagResetValue input {
        margin: 0px !important;
        width: 50px !important;
        min-width: 50px !important;
        max-width: 50px !important;
    }

    .locked-row {
    background-color: #d9d9d9;
    color: #aaa !important;
}

.locked-row:hover {
    background-color: #d9d9d9;
    color: #aaa !important;
}


</style>

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span6">
            <%--<h5><asp:Localize runat="server" meta:resourcekey="lines_and_machines_title" /></h5>--%>
            <div style="margin-bottom:5px;">
                <%--
                <select data-bind="value: typeId, options: types, optionsDefault: { label: '<asp:Localize runat=server meta:resourcekey=all_option_label />', value: '' }" id="selectTypeFilter" name="selectTypeFilter">
                </select>
                <button class="btn btn-mini btn-add-item"><asp:Localize runat="server" meta:resourcekey="add_item_label" /></button>
                --%>

                <%--
                <button class="btn btn-mini btn-add-area"><asp:Localize runat="server" meta:resourcekey="add_area_label" /></button>
                <button class="btn btn-mini btn-add-line"><asp:Localize runat="server" meta:resourcekey="add_line_label" /></button>
                <button class="btn btn-mini btn-add-machine" disabled="disabled"><asp:Localize runat="server" meta:resourcekey="add_machine_label" /></button>
                --%>
            </div>
            <div style="overflow-y:auto;" class="tree">
            </div>
        </div>
        <div class="span6">
            <%--<div class="machine-configuration-messages row-fluid hide">
                <span style="font-size:14px;">Seleccione una máquina para configurar.</span>
            </div>--%>
            <div class="machine-configuration-container row-fluid">
            </div>

            <div class="create-equipment-container row-fluid">
            </div>
        </div>
    </div>
</div>

<script id="new_equipment_modal_template" type="text/x-handlebars-template">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3><asp:Localize runat=server meta:resourcekey=add_equipment_title /></h3>
    </div>
    <div style="max-height:500px;padding-bottom:0;padding-top:0;" <%--class="modal-body"--%>>
        <div style="max-height:500px;padding-bottom:0;overflow-y:inherit;" class="modal-body" >
            <div class="row-fluid">
                <form class="form-horizontal">
                    <div class="control-group">
                        
                        <div style="margin-bottom: 15px">
                            <label class="control-label" style="margin-right:10px;" for="selectModel">
                            <asp:Localize runat="server" meta:resourcekey="model_label" />
                            </label>
                            <div class="controls">
                                    <select  class="selectpicker " <%--data-bind="value: parent, options: models, optionsDefault: { label: '<asp:Localize runat=server meta:resourcekey=select_option_label />', value: '' }"--%> id="selectType" name="selectType" >
                                    </select>
                            </div>
                        </div>
                        <div style="margin-bottom: 15px" >
                            <label class="control-label" for="modelName"><asp:Localize runat="server" meta:resourcekey="name_label" /></label>
                            <div class="controls">
                                <input type="text" data-bind="value: name, events: ['change', 'keyup']" id="modelName" name="inputName">
                            </div>
                        </div>
                        <div class="span12">
                            <div class="jstreePreview" style="height:200px;overflow-y:auto; margin-top:20px;"></div>
                        </div>
                    </div>
                    <%--
                    <div id="sources" class="row-fluid active tab-pane" style="max-height:350px;min-height:350px;overflow-y:auto;">
                        <div class="types-grid-container"></div>
                    </div>
                    --%>
                </form>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <div class="modal-status-msg-container pull-left">
            <div class="modal-status-msg hide" data-bind="toggle: processing,">
                <asp:Localize runat='server' meta:resourcekey='add_equipment_processing_msg' />
                <i class="fa fa-cog fa-spin"></i>
            </div>
        </div>
        <button id="acceptBtn" data-bind="enabled: all(notEquals(processing, true), modelId, name)," class="btn btn-primary">
            <asp:Localize runat='server' meta:resourcekey='add_equipment_accept_btn_label' />
        </button>
        <button data-bind="enabled: notEquals(processing, true)" class="btn" data-dismiss="modal">
            <asp:Localize runat='server' meta:resourcekey='add_equipment_cancel_btn_label' />
        </button>
    </div>

</script>

<script id="assign_equipment_modal_template" type="text/x-handlebars-template">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3><asp:Localize runat=server meta:resourcekey=assign_equipment_title /></h3>
    </div>
    <div style="max-height:500px;padding-bottom:0;padding-top:0;" <%--class="modal-body"--%>>
        <div style="max-height:500px;padding-bottom:0;overflow-y:inherit;" class="modal-body" >
            <div class="row-fluid">
                <form class="form-horizontal">
                    <div class="control-group">
    
                        <div class="span12" data-bind="classes: { hide: all( not(available)) },">
                            <div class="jstreePreview" style="height:350px;overflow-y:auto; margin-top:20px;"></div>
                        </div>
                        <div class="span12" data-bind="classes: { hide: all( not(not(available))) },">
                            <label style="padding-top:5px; text-align:left;"  ><asp:Localize runat="server" meta:resourcekey="no_equipment_available" /></label>  
                        </div>

                    </div>
                    <%--
                    <div id="sources" class="row-fluid active tab-pane" style="max-height:350px;min-height:350px;overflow-y:auto;">
                        <div class="types-grid-container"></div>
                    </div>
                    --%>
                </form>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <div class="modal-status-msg-container pull-left">
            <div class="modal-status-msg hide" data-bind="toggle: processing,">
                <asp:Localize runat='server' meta:resourcekey='add_equipment_processing_msg' />
                <i class="fa fa-cog fa-spin"></i>
            </div>
        </div>
        <button id="acceptBtn" data-bind="enabled: all(notEquals(processing, true), modelId, name)," class="btn btn-primary">
            <asp:Localize runat='server' meta:resourcekey='add_equipment_accept_btn_label' />
        </button>
        <button data-bind="enabled: notEquals(processing, true)" class="btn" data-dismiss="modal">
            <asp:Localize runat='server' meta:resourcekey='add_equipment_cancel_btn_label' />
        </button>
    </div>

</script>

<script id="unassign_equipment_modal_template" type="text/x-handlebars-template">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3><asp:Localize runat=server meta:resourcekey=unassign_equipment_title /></h3>
    </div>
    <div style="max-height:500px;padding-bottom:0;padding-top:0;" <%--class="modal-body"--%>>
        <div style="max-height:500px;padding-bottom:0;overflow-y:inherit;" class="modal-body" >
            <div class="row-fluid">
                <form class="form-horizontal">

                    <div class="control-group">
                        <h4><asp:localize runat="server" meta:resourcekey="location_message_label" /></h4>
                        <label class="control-label" for="selectLocation"><asp:Localize runat="server" meta:resourcekey="location_label" /></label>
                        <div class="controls">
                            <select data-bind="value: locationModelId, options: locations, optionsDefault: { label: '<asp:Localize runat=server meta:resourcekey=select_option_label />', value: null }" id="selectLocation" name="selectLocation">
                            </select>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <div class="modal-status-msg-container pull-left">
            <div class="modal-status-msg hide" data-bind="toggle: processing,">
                <asp:Localize runat='server' meta:resourcekey='add_equipment_processing_msg' />
                <i class="fa fa-cog fa-spin"></i>
            </div>
        </div>
        <button id="acceptBtn" data-bind="enabled: all(notEquals(processing, true))," class="btn btn-primary">
            <asp:Localize runat='server' meta:resourcekey='add_equipment_accept_btn_label' />
        </button>
        <button data-bind="enabled: notEquals(processing, true)" class="btn" data-dismiss="modal">
            <asp:Localize runat='server' meta:resourcekey='add_equipment_cancel_btn_label' />
        </button>
    </div>

</script>

<script id="machine_configuration" type="text/x-handlebars-template">
    <div class="container-fluid">
        <div class="row-fluid">
            <h5><asp:Localize runat="server" meta:resourcekey="configuration_title" /></h5>
        </div>
        <%--<div data-bind="toggle: hasBatchOpened" class="row-fluid batch-opened-message">
            <div class="alert alert-info">
                <span>
                    <asp:Localize runat="server" meta:resourcekey="batch_opened_on_machine_msg" />
                </span>
            </div>
        </div>--%>
        <div style="position:relative;" class="row-fluid">
            <%--<div data-bind="toggle: hasBatchOpened" class="blocker"></div>--%>
            <div class="row-fluid">
                <form id="detailsForm" class="form-horizontal">
                    <div class="control-group">
                        <label class="control-label" for="labelName"><asp:Localize runat="server" meta:resourcekey="name_label" /></label>
                        <div class="controls">
                            {{HBExp '#ifEquals internal true'}}
                                <input type="text" data-bind="value: name, events: ['change', 'keyup']" id="inputName" name="inputName">
                            {{HBExp 'else'}}
                                <label style="padding-top:5px; text-align:left;" data-bind="text: name, " id="labelName"></label>    
                            {{HBExp '/ifEquals'}}
                        </div>
                    </div>
                    {{HBExp '#ifEquals typeName "UNKNOWN"'}}
                    <div class="control-group">
                        <label class="control-label" for="selectType"><asp:Localize runat="server" meta:resourcekey="type_label" /></label>
                        <div class="controls">
                            <select data-bind="value: type, options: typesBinding, optionsDefault: { label: '<asp:Localize runat=server meta:resourcekey=select_option_label />', value: -1 }" id="selectType" name="selectType">
                            </select>
                        </div>
                    </div>
                    {{HBExp 'else'}}
                    <div class="control-group">
                        <label class="control-label" for="labelType"><asp:Localize runat="server" meta:resourcekey="type_label" /></label>
                        <div class="controls">
                            <label style="padding-top:5px; text-align:left;" data-bind="text: typeName, " id="labelType"></label>
                        </div>
                    </div>
                    {{HBExp '/ifEquals'}}

                    {{HBExp '#ifEquals internal true'}}
                    {{HBExp 'else'}}
                    <div class="control-group">
                        <label class="control-label" for="selectStatusCode"><asp:Localize runat="server" meta:resourcekey="status_code_label" /></label>
                        <div class="controls">
                            <label style="padding-top:5px; text-align:left;" data-bind="text: statusName, " id="label1"></label>
                        </div>
                    </div>
                    {{HBExp '/ifEquals'}}
                </form>
            </div>
        </div>

        <div style="margin-top:8px;" class="row-fluid">
            {{HBExp '#ifEquals internal true'}}
                <div class="span6 offset3">
                    <div class="span6">
                        <button disabled="disabled" class="btn btn-primary btn-block btn-save"><asp:Localize runat="server" meta:resourcekey="save_label" /></button>
                    </div>
                    <div class="span6">
                        <button disabled="disabled" class="btn btn-block btn-cancel"><asp:Localize runat="server" meta:resourcekey="cancel_label" /></button>
                    </div>
                </div>
            {{HBExp '/ifEquals'}}
        </div>
    </div>
    
    <script id="actions_cell_template" type="text/x-handlebars-template">
        <div class="text-center">
            <button data-toggle="tooltip" data-placement="bottom" data-cell-action="DELETE" 
                ="<asp:Localize runat=server meta:resourcekey=remove_batch_title />" class="btn btn-cell-action btn-small btn-remove"><i class="fa fa-trash-o"></i></button>
        </div>
    </script>

</script>

<script id="create_equipment" type="text/x-handlebars-template">
    <div class="container-fluid">
        <div class="row-fluid">
            <h5><asp:Localize runat="server" meta:resourcekey="create_equipment_title" /></h5>
        </div>
        <%--<div data-bind="toggle: hasBatchOpened" class="row-fluid batch-opened-message">
            <div class="alert alert-info">
                <span>
                    <asp:Localize runat="server" meta:resourcekey="batch_opened_on_machine_msg" />
                </span>
            </div>
        </div>--%>
        <div style="position:relative;" class="row-fluid">
            <%--<div data-bind="toggle: hasBatchOpened" class="blocker"></div>--%>
            <div class="row-fluid">
                <form id="createForm" class="form-horizontal">
                    <div class="control-group">
                        <label class="control-label" for="labelName"><asp:Localize runat="server" meta:resourcekey="name_label" /></label>
                        <div class="controls">
                                <input type="text" data-bind="value: name, events: ['change', 'keyup']" id="createName" name="inputName">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="labelType"><asp:Localize runat="server" meta:resourcekey="type_label" /></label>
                        <div class="controls">
                            <label style="padding-top:5px; text-align:left;" data-bind="text: typeName, " id="createLabelType"></label>
                        </div>
                    </div>
                   <%-- <div class="control-group">
                        <label class="control-label" for="selectStatusCode"><asp:Localize runat="server" meta:resourcekey="status_code_label" /></label>
                        <div class="controls">
                            <label style="padding-top:5px; text-align:left;" data-bind="text: statusName, " id="label1"></label>
                        </div>
                    </div>--%>
                </form>
            </div>
        </div>

        <div style="margin-top:8px;" class="row-fluid">
            <div class="span6 offset3">
                <div class="span6">
                    <button disabled="disabled" class="btn btn-primary btn-block btn-save"><asp:Localize runat="server" meta:resourcekey="save_label" /></button>
                </div>
                <div class="span6">
                    <button disabled="disabled" class="btn btn-block btn-cancel"><asp:Localize runat="server" meta:resourcekey="cancel_label" /></button>
                </div>
            </div>
        </div>
    </div>
    
</script>

<script id="subnavbar_controls" type="text/x-handlebars-template">
    <div class="span12">
        <div class="subnavbar-toolbar form-inline">
            <button class="btn btn btn-mini btn-add-item" style="margin:0; float:left; margin-left:10px; margin-top:5px;" disabled>
                <asp:Localize runat="server" meta:resourcekey="add_item_label" />
            </button>

            <button class="btn btn-mini btn-collapse-tree btn-tree" style="margin:0; float:left; margin-left:10px; margin-top:5px;" type="button">
                <span class="collapse"> <asp:Localize runat="server" meta:resourcekey="collapse_tree" /> </span>
            </button>

            <button class="btn btn-mini btn-expand-tree btn-tree hide" style="margin:0; float:left; margin-left:10px; margin-top:5px;" type="button">
                <span class="expand"><asp:Localize runat="server" meta:resourcekey="expand_tree" /></span>
            </button>
        </div>

        <%--<div class="subnavbar-toolbar form-inline">
            <div style="margin-left:10px; margin-top: 5px; float:right;" class="control-group form-inline">
                <select style="width:200px;" data-bind="value: integer(typeId), options: types, optionsDefault: { label: '<asp:Localize runat=server meta:resourcekey=type_combo_all_option_label />', value: '' }, enabled: hasTypes,"></select>
            </div>
            <div id="cg_search" style="margin-top: 5px; float:right;" class="control-group form-inline">
                <label class="control-label" style="margin-right:2px;" for="searchTerm_input">
                    <asp:Localize runat="server" meta:resourcekey="search_input_label" />
                </label>
                <input type="text" id="searchTbx" data-bind="value: trim(search), events: ['change', 'keyup']," class="input-medium">
            </div>
        </div>--%>
    </div>
</script>
