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

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>

<script runat="server">
    String version = WebAppVersion.GetWebAppVersion();

    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>

<%
    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/ag-grid/ag-grid.css") %>" rel="stylesheet" />
<link href="<%= ResolveUrl("~/assets/ag-grid/ag-theme-alpine.css") %>" rel="stylesheet" />
<link href="<%= ResolveUrl("~/app/components/ag-grid/ag-grid-styles.css") %>" rel="stylesheet" />
<link href="<%= ResolveUrl("~/app/pages/mes/" + Path.GetFileNameWithoutExtension(this.Request.PhysicalPath) + "/" + Path.GetFileNameWithoutExtension(this.Request.PhysicalPath) + ".css")%>" rel="stylesheet" />
<link href="<%= ResolveUrl("~/assets/libs/js/backgrid-0.3.5/lib/backgrid.css") %>" rel="stylesheet" />
<link href="<%= ResolveUrl("~/assets/fonts/reboto-font.css") %>" rel="stylesheet" />
<link href="<%= ResolveUrl("~/assets/tailwind/tailwind.min.css") %>" rel="stylesheet" />

<style>
    .content-container { padding-top: 0px !important; }
    #subnavbar-inner { display: none !important; }
    .professional-title {
        font-size: 22px;
        font-weight: 400;
        color: #202124;
        padding-bottom: 1px;
        border-bottom: 1px solid #dadce0;
        margin-bottom: 2px;
        font-family: 'Roboto', Arial, sans-serif;
    }
    .melt-orders-grid-container.ag-theme-alpine {
        height: 75vh;
        border: 1px solid #ccc;
    }
    .ag-root-wrapper.ag-layout-normal.ag-ltr {
        height: 75vh;
    }
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    .spinner {
        animation: spin 1s linear infinite;
        transform-origin: center;
    }
</style>

<h2 class="professional-title">Melt Orders</h2>

<div class="bg-white shadow-md rounded-lg p-2 mb-4">
    <div class="bg-white shadow-md rounded-lg mb-2">
        <div class="flex items-center justify-between flex-wrap">
            <div class="flex items-center space-x-2 mb-2">
                <div class="flex flex-wrap items-center space-x-1">
                    <div class="flex items-center">
                        <label for="meltOrderTbx" class="ml-2 mr-2 text-sm font-medium text-gray-700"><asp:localize runat="server" meta:resourcekey="melt_order_label" /></label>
                        <input type="text" id="meltOrderTbx" class="pl-3 pr-3 py-2 text-base border border-gray-300 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md" style="width:150px; height:37.78px; box-sizing:border-box;" data-bind="value: trim(meltOrderName)" placeholder="<asp:Localize runat=server meta:resourcekey=melt_order_place_holder />" />
                    </div>
                    <div class="flex items-center">
                        <label for="gradeTbx" class="ml-2 mr-2 text-sm font-medium text-gray-700"><asp:localize runat="server" meta:resourcekey="gradeName_label" /></label>
                        <input type="text" id="gradeTbx" class="pl-3 pr-3 py-2 text-base border border-gray-300 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md" style="width:150px; height:37.78px; box-sizing:border-box;" data-bind="value: trim(gradeName)" placeholder="<asp:Localize runat=server meta:resourcekey=grade_place_holder />" />
                    </div>
                    <div class="flex items-center">
                        <label for="materialSizeTbx" class="ml-2 mr-2 text-sm font-medium text-gray-700"><asp:localize runat="server" meta:resourcekey="materialSize_label" /></label>
                        <input type="text" id="materialSizeTbx" class="pl-3 pr-3 py-2 text-base border border-gray-300 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md" style="width:150px; height:37.78px; box-sizing:border-box;" data-bind="value: trim(materialSizeSearch)" placeholder="<asp:Localize runat=server meta:resourcekey=materialSize_place_holder />" />
                    </div>
                </div>
            </div>
            <div class="flex space-x-2 mb-2">
                <button type="button" class="btn-export-to-excel bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-4 rounded flex items-center justify-center" style="height: 36.5px; font-size: 14px;">
                    <span class="excel-export-state fa fa-file-excel-o mr-2"></span>
                    <img class="loading-state hide" style="width:20px;height:20px;" src="<%= ResolveUrl("~/assets/img/spinner20.gif") %>" />
                    <span>Excel</span>
                </button>
                <button id="refreshBtn" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded flex items-center justify-center" style="width: 120px; height: 36.5px; font-size: 14px;" title="<asp:localize runat=server meta:resourcekey=refresh_btn_title />">
                    <div data-bind="classes: { hide: isLoading }">
                        <i class="fa fa-refresh mr-2"></i>
                        <span>Refresh</span>
                    </div>
                    <div data-bind="classes: { hide: not(isLoading) }">
                        <div class="flex items-center">
                            <svg class="h-5 w-5 mr-2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                                <g class="spinner">
                                    <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" fill="none"/>
                                    <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
                                </g>
                            </svg>
                            <span>Loading...</span>
                        </div>
                    </div>
                </button>
            </div>
        </div>
    </div>
    <div class="mx-auto">
        <div class="bg-white shadow-md rounded-lg p-2 mb-4" style="border: 4px solid #ccc;">
            <div class="melt-orders-grid-container ag-theme-alpine w-full" id="melt-orders-grid"></div>
        </div>
    </div>
</div>

<div class="row-fluid screen-content" id="main-div"></div>


<script id="melt_order_details_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 data-bind="text: format('<asp:Localize runat=server meta:resourcekey=melt_order_details_modal_title />', meltOrderNumber)"></h3>
    </div>
    <div style="max-height: 350px; padding-bottom: 0; padding-top: 0;" class="modal-body">
        <div style="max-height: 300px; padding-bottom: 0;" class="modal-body">
            <div class="row-fluid">
                <div class="form-horizontal text-left">
                    <div class="control-group span6 no-margin-bottom" style="margin-left:0px">
                        <label class="" style="font-weight:bold; display:inline-block;">
                            <asp:Localize runat=server meta:resourcekey=meltOrder_label />
                        </label>
                        <label class="" style="margin-left:10px; display:inline-block;" data-bind="text: trim(meltOrderNumber)"></label>
                    </div>
                    <div class="control-group span6 no-margin-bottom" style="margin-left:0px">
                        <label class="" style="font-weight:bold; display:inline-block;">
                            <asp:Localize runat=server meta:resourcekey=grade_label />
                        </label>
                        <label class="" style="margin-left:10px;display:inline-block;" data-bind="text: trim(gradeName)"></label>
                    </div>
                    <div class="control-group span6 no-margin-bottom" style="margin-left:0px">
                        <label class="" style="font-weight:bold;display:inline-block;">
                            <asp:Localize runat=server meta:resourcekey=heat_size_label />
                        </label>
                        <label class="" style=" margin-left:10px;display:inline-block;" data-bind="text: trim(heatSize)"></label>
                    </div>
                    <div class="control-group span6 no-margin-bottom"  style="margin-left:0px">
                        <label class="" style="font-weight:bold;display:inline-block;">
                            <asp:Localize runat=server meta:resourcekey=material_size_label />
                        </label>
                        <label class="" style=" margin-left:10px;display:inline-block;" data-bind="text: trim(materialSize)"></label>
                    </div>
                    <div class="control-group span6 no-margin-bottom"  style="margin-left:0px">
                        <label class="" style="font-weight:bold;display:inline-block;">
                            <asp:Localize runat=server meta:resourcekey=TWI_label />
                        </label>
                        <label class="" style=" margin-left:10px;display:inline-block;" data-bind="text: trim(hasTWI)"></label>
                    </div>
                    <div class="control-group span6 no-margin-bottom"  style="margin-left:0px">
                        <label class="" style="font-weight:bold;display:inline-block;">
                            <asp:Localize runat=server meta:resourcekey=melt_sequence_label />
                        </label>
                        <label class="" style=" margin-left:10px;display:inline-block;" data-bind="text: trim(meltSequence)"></label>
                    </div>
                    <div class="control-group span12" style="margin-left:0px">
                        <h4><asp:localize runat="server" meta:resourcekey="heats_label" /></h4>
                        <div class="details-grid-container infinite-container" style="margin-bottom:10px"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default btn-cancel" data-dismiss="modal">
            <asp:localize runat="server" meta:resourcekey="close_btn_label" />
        </button>
    </div>
</script>
