<%@ Import Namespace="Seven.Front" %>
<%@ Import Namespace="Seven.Front.Globals" %>
<%@ Import Namespace="Seven.Front.Objects" %>

<%@ Page Language="C#" MasterPageFile="Model.Master" AutoEventWireup="true" CodeBehind="InformeDiarioAnualGraficoGrafico.aspx.cs" Inherits="Seven.Front.InformeDiarioAnualGrafico" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cpHeader" runat="server">

    <title><%=L.TIT("InformeDiarioAnual") %> (<%=L.LBL("LblGENGrafico") %>)</title>

    <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
    <script language="javascript" type="text/javascript" src="js/jquery.jqplot.min.js"></script>
    <link rel="stylesheet" type="text/css" href="js/jquery.jqplot.css" />
    <script type="text/javascript" src="js/plugins/jqplot.dateAxisRenderer.min.js"></script>
    <script type="text/javascript" src="js/plugins/jqplot.canvasTextRenderer.min.js"></script>
    <script type="text/javascript" src="js/plugins/jqplot.canvasAxisTickRenderer.min.js"></script>
    <script type="text/javascript" src="js/plugins/jqplot.categoryAxisRenderer.min.js"></script>
    <script type="text/javascript" src="js/plugins/jqplot.barRenderer.min.js"></script>
    <script type="text/javascript" src="js/plugins/jqplot.highlighter.min.js"></script>

    <script type="text/javascript">

        function obtenerImagen() {
            var imgData = $('#grafico').jqplotToImageStr({});
            var imgElem = $('<img/>').attr('src', imgData);
            $('#ImagenGrafico').html('');
            $('#ImagenGrafico').append(imgElem);
            $("#dlgExportar").dialog('open');
        }

        (function ($) {
            $.jqplot.euroFormatter = function (format, val) {
                if (!format) {
                    format = '%.1f';
                }
                return '' + numberWithCommas($.jqplot.sprintf(format, val));
            };

            function numberWithCommas(x) {
                return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
            }
        })(jQuery);

    </script>

    <script type="text/javascript">

        $(document).ready(function () {

            $("#dlgCargando").dialog({
                autoOpen: false,
                show: "fade",
                hide: "curtain",
                resizable: false,
                height: 100,
                width: 270,
                modal: true,
                dialogClass: 'no-close'
            });

            $("#SevenMenu").accordion("option", "active", 4);

            $("#EnlaceMaestro").focus();

            $('#cbMoneda').val(<%=FrontMoneda %>);
            $('#cbUsuario').val(<%=FrontUsuario %>);

            $(".eligeFechaHotel").datepicker({
                showOn: "button",
                buttonImage: "css/Themes/Fall/calendar.png",
                buttonImageOnly: true,
                firstDay: 0,
                changeYear: true, 
                changeMonth: true,
                maxDate: new Date(<%=fecha_hotelera.Year %>, <%=fecha_hotelera.Month %> - 1, <%=fecha_hotelera.Day %>)
            });

            $("#dlgExportar").dialog({
                autoOpen: false,
                show: "fade",
                hide: "curtain",
                resizable: false,
                height: 550,
                width: 950,
                modal: true
            });

            <% if (!String.IsNullOrEmpty(DataLines))
               { %>

            <% Response.Write(DataLines); %>

            $('#grafico').html('');
 
            var plot1 = $.jqplot('grafico', [line1, line2, line3], {
                title: '<%=L.TIT("InformeDiario") + " (" + Ejercicio + ") - " +  Moneda 
                    + " - " + L.LBL("LblFDKReconstruirPronost") + ": " + String.Format("{0:d}", FrontFechaPronost) + ", " + L.LBL("LblGENUser") + ": " + Usuario %>',
                //series:[{renderer:$.jqplot.BarRenderer}],
                axesDefaults: {
                    tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
                    tickOptions: {
                        angle: 0,
                        fontSize: '8pt'
                    }
                },
                axes: {
                    xaxis: {
                        renderer: $.jqplot.CategoryAxisRenderer
                    },
                    yaxis: {
                        tickOptions: {formatString:'%.2f', formatter: $.jqplot.euroFormatter}
                    }
                },
                series:[
                      {label:'<%=L.LBL("LblGENIngresoReal") %>', color: 'lavender', renderer: $.jqplot.BarRenderer, rendererOptions: { highlightMouseDown: true }}, 
                      {label:'<%=L.LBL("LblGENIngresoPronost") %>', color: 'blue'}, 
                      {label:'<%=L.LBL("LblFDKIngRealPV") %>', color: 'purple'}
                ],
                highlighter: {
                    show: true,
                    sizeAdjust: 7.5,
                    tooltipAxes: 'y'
                },
                legend: { show:true, location: 'ne', placement: 'outside' }
            });

            <% } %>

        });

    </script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cpPrincipal" runat="server">

    <div id="SevenBreadcrumb" class="ui-state-default">
        <table style="width: 100%; white-space: nowrap;">
            <tr>
                <td>
                    <div class="SevenEnlaces" onclick="window.location.href='Menu.aspx#M5';" style="cursor: pointer;">
                        <table>
                            <tr>
                                <td>
                                    <img src="img/application-icon-large.png" />
                                </td>
                                <td>
                                    <%=L.LBL("LblGENMenuTactil") %>
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
                <td>&nbsp;</td>
                <td>
                    <a href="../Inicio.aspx"><%=L.LBL("LblGENInicio") %></a>
                    <img src="../img/arrow.png" alt="" />
                    <a href="#"><%=L.TIT("InformeDiarioAnual") %> (<%=L.LBL("LblGENGrafico") %>)</a>
                </td>
                <td style="width: 100%;"></td>
                <td>
                    <%=L.LBL("LblGENLanguage") %>
                </td>
                <td>
                    <!-- #include file="LanguageCombo.html" -->
                </td>
            </tr>
        </table>

    </div>

    <div id="SevenPrincipal">

        <div id="SevenMedio">

            <div id="SevenInterno" style="width: 900px; height: 700px;">

                <div id="dlgExportar" title="Exportar a Imagen PNG" style="text-align: center;padding-top: 25px">
                    <table style="width: 100%;">
                        <tr>
                            <td style="width: 100%;">
                                Para guardar la imagen del gráfico, de click derecho en el grafico y luego click en 'Guardar imagen como...':
                            </td>
                        </tr>
                    </table>
                    <br />
                    <div id="ImagenGrafico"></div>
                </div>

                <div id="dlgCargando" title="<%=L.LBL("LblGENLoading") %>" style="text-align: center; padding-top: 25px">
                    <img src="img/cargando2.gif" alt="<%=L.LBL("LblGENLoading") %>" />
                </div>

                <div id="HiddenHive">
                </div>

                <br />

                <table>
                    <tr>
                        <td>
                            <span class="SevenTitulo"><%=L.TIT("InformeDiarioAnual") %> (<%=L.LBL("LblGENGrafico") %>)</span>
                        </td>
                        <td>&nbsp;&nbsp;&nbsp;</td>
                        <%--<td>
                            <div class="SevenEnlaces">
                                <table>
                                    <tr>
                                        <td>
                                            <a href="#" onclick="window.open('http://mysevenmanuales.jimdo.com/front-desk/4-9-estad%C3%ADsticas-de-explotacion/', '_blank');" id="A1">
                                                <img src="../img/question.png" />
                                                <%=L.LBL("LblGENHelp") %>
                                            </a>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>--%>
                    </tr>
                </table>

                <br />

                <table>
                    <tr>
                        <td><%=L.LBL("LblGENMoney") %>: </td>
                        <td>
                            <%=cbMoneda %>
                        </td>
                        <td><%=L.LBL("LblGENAno") %>: </td>
                        <td>
                            <input type="text" id="txtAno" name="txtAno" value="<% Response.Write(FrontAno); %>" />
                        </td>
                    </tr>
                </table>

                <table>
                    <tr>
                        <td><%=L.LBL("LblFDKReconstruirPronost") %>: </td>
                        <td>
                            <input type="text" id="txtFechaPronost" name="txtFechaPronost" class="eligeFechaHotel" value="<% Response.Write(String.Format("{0:dd/MM/yyyy}", FrontFechaPronost)); %>" />
                        </td>
                        <td>
                            <%=L.LBL("LblGENUser") %>:
                        </td>
                        <td>
                            <%=cbUsuario %>
                        </td>
                        <td>
                            <table style="width: 100%;">
                                <tr>
                                    <td style="width: 100%;"></td>
                                    <td>
                                        <button type="button" onclick="$('#dlgCargando').dialog('open'); window.location.href='InformeDiarioAnualGrafico.aspx?y=' + $('#txtAno').val() + '&m=' + $('#cbMoneda').val() + '&f=' + $('#txtFechaPronost').val() + '&o=' + $('#cbUsuario').val();">
                                            <table>
                                                <tr>
                                                    <td>
                                                        <img src="img/magnifier16.png" alt="<%=L.LBL("LblGENVer") %>" /></td>
                                                    <td><%=L.LBL("LblGENVer") %></td>
                                                </tr>
                                            </table>
                                        </button>
                                    </td>
                                    <td></td>
                                    <td>
                                        <table style="width: 100%;">
                                            <tr>
                                                <td style="width: 100%;"></td>
                                                <td>
                                                    <button type="button" onclick="obtenerImagen();" >
                                                        <table><tr><td><img src="img/image-export.png" alt="Imagen" /></td><td><%=L.LBL("LblGENExportarImgPNG") %></td></tr></table>
                                                    </button>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>

                <br />

                <table>
                    <tr>
                        <td>
                            <div id="grafico" style="width:800px; height:400px;">
                                <span style="font-size: 16pt; font-style: italic; white-space: normal;">
                                    <br /><br /><br /><br /><br /><br />
                                    <%=L.MSG("DIARIOGRAFICO") %>
                                </span>
                            </div>
                        </td>
                    </tr>
                </table> 

                <br />

                <table class="SevenMsgExito">
                    <tr>
                        <td style="font-size: 10pt; text-align: justify; white-space: normal;">
                            <%=L.REP("DIARIOANUALINFO1") %>
                            <br /><br />
                            <%=L.REP("ESEXINFO4") %>
                            <br /><br />
                            <%=L.REP("DIARIOANUALUSR") %>
                        </td>
                    </tr>
                </table>
            </div>

        </div>

    </div>

</asp:Content>
