<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/SIG/Interfaces/MaestroStarSoft.Master" CodeBehind="Default.aspx.vb" Inherits="SGHweb._Default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        function abrirVentanaDescargar() {
            var accion = getParameterByName('accion');
            var software = getParameterByName('software');
            var datePickerDesde = $find("<%=DPDesde.ClientID%>");
            var datePickerHasta = $find("<%=DPHasta.ClientID%>");
            var desde = datePickerDesde.get_dateInput().get_selectedDate().format("dd/MM/yyyy");
            var hasta = datePickerHasta.get_dateInput().get_selectedDate().format("dd/MM/yyyy");;
            //alert(accion + ' - ' + software + ' - ' + desde + ' - ' + hasta);
            if ((accion == "Compras" || accion == "Ventas") && software == "Ergosoft") {
                //alert(accion + ' - ' + software)
                ruta_reporte = "../frm_ReporteComprasVentas.aspx?desde=" + desde + "&hasta=" + hasta + "&tipo=" + accion;
                window.open(ruta_reporte);
            } else {
                //window.open('GenerarDescargar.aspx?accion=' + accion + '&software=' + software + '&desde=' + desde + '&hasta=' + hasta);
                GenerarAlerta('information', 'Descargando Reporte...');
                loadIframe('iFrame','GenerarDescargar.aspx?accion=' + accion + '&software=' + software + '&desde=' + desde + '&hasta=' + hasta);
            }
            
        }
        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
            return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        }

        function loadIframe(iframeName, url) {
            var $iframe = $('#' + iframeName);
            if ($iframe.length) {
                $iframe.attr('src', url);
                return false;
            }
            return true;
        }
    </script>
    <script type='text/javascript'>
        $(window).load(function () {
            $("#iFrame").ready(function () {
                //alert('iFrame loaded!');
                console.log('Iframe Carga Completa!');
            });
        });
    </script>
    <style>
        .botonblue { 
            border:1px solid #25729a; 
            -webkit-border-radius: 3px; 
            -moz-border-radius: 3px;
            border-radius: 3px;
            font-size:12px;
            font-family:arial, helvetica, sans-serif; 
            padding: 10px 10px 10px 10px; 
            text-decoration:none; 
            display:inline-block;
            text-shadow: -1px -1px 0 rgba(0,0,0,0.3);
            font-weight:bold; 
            color: #FFFFFF;
            background-color: #3093c7; 
            background-image: linear-gradient(to bottom, #3093c7, #1c5a85);
            margin-top:10px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server">
        <telerik:RadPageView ID="RadPageView1" runat="server" Selected="true">
            <center>
        <h1>
            <asp:Label ID="lblTitulo" runat="server" Text=""></asp:Label></h1>
            <br />
        <table>
            <tr>
                <td>Desde:</td>
                <td>
                    <telerik:RadDatePicker ID="DPDesde" Runat="server" Skin="WebBlue">
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" EnableWeekends="True" FastNavigationNextText="&amp;lt;&amp;lt;" Skin="WebBlue"></Calendar>
                        <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy" LabelWidth="40%">
                            <EmptyMessageStyle Resize="None"></EmptyMessageStyle>
                            <ReadOnlyStyle Resize="None"></ReadOnlyStyle>
                            <FocusedStyle Resize="None"></FocusedStyle>
                            <DisabledStyle Resize="None"></DisabledStyle>
                            <InvalidStyle Resize="None"></InvalidStyle>
                            <HoveredStyle Resize="None"></HoveredStyle>
                            <EnabledStyle Resize="None"></EnabledStyle>
                        </DateInput>
                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                    </telerik:RadDatePicker>
                </td>
                <td>Hasta:</td>
                <td>
                    <telerik:RadDatePicker ID="DPHasta" Runat="server" Skin="WebBlue">
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" EnableWeekends="True" FastNavigationNextText="&amp;lt;&amp;lt;" Skin="WebBlue"></Calendar>
                        <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy" LabelWidth="40%">
                            <EmptyMessageStyle Resize="None"></EmptyMessageStyle>
                            <ReadOnlyStyle Resize="None"></ReadOnlyStyle>
                            <FocusedStyle Resize="None"></FocusedStyle>
                            <DisabledStyle Resize="None"></DisabledStyle>
                            <InvalidStyle Resize="None"></InvalidStyle>
                            <HoveredStyle Resize="None"></HoveredStyle>
                            <EnabledStyle Resize="None"></EnabledStyle>
                        </DateInput>
                        <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                    </telerik:RadDatePicker>
                </td>
            </tr>
        </table>
        
        <asp:Button ID="btnGenerar" runat="server" Text="Generar & Descargar" class="botonblue" OnClientClick="abrirVentanaDescargar();" ></asp:Button>
    </center>
        </telerik:RadPageView>
        
    </telerik:RadMultiPage>
    
    
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>

    <iframe id="iFrame" src="#" width="0" height="0" frameborder="0"></iframe>
</asp:Content>
