<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GPMAssetAllocation.aspx.cs" Inherits="OlympiaIntranet.GPMAssetAllocation" %>

<%@ Register Assembly="DevExpress.XtraCharts.v23.2.Web, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraCharts.Web" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.XtraCharts.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraCharts" TagPrefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style>
        html {
            width: 100%;
            height: 100%;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
    <script>
        function ExportChartToPdf(e) {
            e.processOnServer = false;
            var chartPrintOptions = clientChart.GetPrintOptions();
            chartPrintOptions.SetSizeMode('Stretch');
            chartPrintOptions.SetLandscape(true);
            const date = new Date();
            var fileName = 'GPM_AssetAllocation_' + date.toLocaleDateString();
            clientChart.SaveToDisk('pdf', fileName);
        }
        function OnFirstEndCallback(s, e) {
            //clientgridLookupLinea.GetGridView().Refresh();
            //clientgridLookupConsulente.GetGridView().Refresh();

            // azzera eventuale selezione in gridLookupLinea
            clientgridLookupLinea.SetValue(null);

            // azzera eventuale selezione in gridLookupConsulente 
            //clientgridLookupConsulente.SetValue(null);

            // azzera eventuale selezione in gridLookupAdvisor 
            //clientgridLookupAdvisor.SetValue(null);

        }
        //function OnFirstEndCallbackAdvisor(s, e) {
        //    // azzera eventuale selezione in gridLookupLinea
        //    clientgridLookupLinea.SetValue(null);
        //}
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <table>
            <tr>
                <td>
                    <div>
                        <dx:ASPxFormLayout ID="ASPxFormLayout1" runat="server" ColCount="2" EnableTheming="True" Theme="Aqua" ColumnCount="2">
                            <Items>
                                <dx:LayoutGroup Caption="Filtri Selezione" ColCount="5" ColSpan="1" ColumnCount="5">
                                    <Items>
                                        <dx:LayoutItem Caption="Gestore" ColSpan="1">
                                            <LayoutItemNestedControlCollection>
                                                <dx:LayoutItemNestedControlContainer runat="server">
                                                    <dx:ASPxGridLookup ID="gridLookupGestore" runat="server" Theme="Aqua" DataSourceID="SqlDSGestori" DropDownStyle="DropDownList" EnableTheming="True" KeyFieldName="Gestore" TextFormatString="{0}" OnValueChanged="gridLookupGestore_ValueChanged">
                                                        <ClientSideEvents EndCallback="OnFirstEndCallback" />
                                                        <GridViewProperties>
                                                            <SettingsBehavior AllowFocusedRow="True" AllowSelectSingleRowOnly="True" EnableRowHotTrack="True" />
                                                            <SettingsPager Mode="ShowAllRecords">
                                                            </SettingsPager>
                                                        </GridViewProperties>
                                                    </dx:ASPxGridLookup>
                                                </dx:LayoutItemNestedControlContainer>
                                            </LayoutItemNestedControlCollection>
                                        </dx:LayoutItem>
<%--                                        <dx:LayoutItem Caption="Consulente" ColSpan="1" Visible="false">
                                            <LayoutItemNestedControlCollection>
                                                <dx:LayoutItemNestedControlContainer runat="server">
                                                    <dx:ASPxGridLookup ID="gridLookupConsulente" ClientInstanceName="clientgridLookupConsulente" runat="server" Theme="Aqua" DataSourceID="SqlDSConsulenti" DropDownStyle="DropDownList" EnableTheming="True" KeyFieldName="Consulente" TextFormatString="{0}">
                                                        <GridViewProperties>
                                                            <SettingsBehavior AllowFocusedRow="True" AllowSelectSingleRowOnly="True" EnableRowHotTrack="True" />
                                                            <SettingsPager Mode="ShowAllRecords">
                                                            </SettingsPager>
                                                        </GridViewProperties>
                                                    </dx:ASPxGridLookup>
                                                </dx:LayoutItemNestedControlContainer>
                                            </LayoutItemNestedControlCollection>
                                        </dx:LayoutItem>--%>
<%--                                        <dx:LayoutItem Caption="Advisor" ColSpan="1">
                                            <LayoutItemNestedControlCollection>
                                                <dx:LayoutItemNestedControlContainer runat="server">
                                                    <dx:ASPxGridLookup ID="gridLookupAdvisor" ClientInstanceName="clientgridLookupAdvisor" runat="server" Theme="Aqua" DataSourceID="SqlDSAdvisor" DropDownStyle="DropDownList" EnableTheming="True" KeyFieldName="Advisor" TextFormatString="{0}" OnValueChanged="gridLookupAdvisor_ValueChanged">
                                                        <ClientSideEvents EndCallback="OnFirstEndCallbackAdvisor" />
                                                        <GridViewProperties>
                                                            <SettingsBehavior AllowFocusedRow="True" AllowSelectSingleRowOnly="True" EnableRowHotTrack="True" />
                                                            <SettingsPager Mode="ShowAllRecords">
                                                            </SettingsPager>
                                                        </GridViewProperties>
                                                    </dx:ASPxGridLookup>
                                                </dx:LayoutItemNestedControlContainer>
                                            </LayoutItemNestedControlCollection>
                                        </dx:LayoutItem>--%>
                                        <dx:LayoutItem Caption="Linea di Gestione" ColSpan="1">
                                            <LayoutItemNestedControlCollection>
                                                <dx:LayoutItemNestedControlContainer runat="server">
                                                    <dx:ASPxGridLookup ID="gridLookupLinea" ClientInstanceName="clientgridLookupLinea" runat="server" Theme="Aqua" DataSourceID="SqlDSLinee" DropDownStyle="DropDownList" EnableTheming="True" KeyFieldName="Linea" TextFormatString="{0}">
                                                        <GridViewProperties>
                                                            <SettingsBehavior AllowFocusedRow="True" AllowSelectSingleRowOnly="True" EnableRowHotTrack="True" />
                                                            <SettingsPager Mode="ShowAllRecords">
                                                            </SettingsPager>
                                                        </GridViewProperties>
                                                    </dx:ASPxGridLookup>
                                                </dx:LayoutItemNestedControlContainer>
                                            </LayoutItemNestedControlCollection>
                                        </dx:LayoutItem>
                                        <dx:LayoutItem Caption="Genera Grafico" ColSpan="1">
                                            <LayoutItemNestedControlCollection>
                                                <dx:LayoutItemNestedControlContainer runat="server">
                                                    <dx:ASPxButton ID="buttonGeneraGrafici" runat="server" Theme="Aqua" OnClick="buttonGeneraGrafici_Click">
                                                        <Image IconID="chart_chart_16x16">
                                                        </Image>
                                                    </dx:ASPxButton>
                                                </dx:LayoutItemNestedControlContainer>
                                            </LayoutItemNestedControlCollection>
                                        </dx:LayoutItem>
                                        <dx:LayoutItem Caption="Esporta in Pdf" ColSpan="1">
                                            <LayoutItemNestedControlCollection>
                                                <dx:LayoutItemNestedControlContainer runat="server">
                                                    <%--                                                    <dx:ASPxButton ID="buttonEsportaPdf" runat="server" Theme="Aqua" AutoPostBack="True" OnClick="buttonEsportaPdf_Click">
                                                        <Image IconID="export_exporttopdf_16x16">
                                                        </Image>
                                                    </dx:ASPxButton>--%>
                                                    <dx:ASPxButton ID="buttonEsportaPdf" runat="server" AutoPostBack="False" OnClick="buttonEsportaPdf_Click" Theme="Aqua">
                                                        <ClientSideEvents Click="function(s, e) { ExportChartToPdf(e); }" />
                                                        <Image IconID="export_exporttopdf_16x16">
                                                        </Image>
                                                    </dx:ASPxButton>
                                                </dx:LayoutItemNestedControlContainer>
                                            </LayoutItemNestedControlCollection>
                                        </dx:LayoutItem>
                                    </Items>
                                </dx:LayoutGroup>
                            </Items>
                        </dx:ASPxFormLayout>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div>
                        <dx:WebChartControl ID="fullStackedBarChart" ClientInstanceName="clientChart" runat="server" CrosshairEnabled="True" Height="720px" Width="1280px" RenderFormat="Svg" EnableViewState="False" AppearanceNameSerializable="Gray">
                        </dx:WebChartControl>
                    </div>
                </td>
            </tr>
        </table>

        <asp:SqlDataSource ID="SqlDSGestori" runat="server" ConnectionString="Data Source=26.69.45.60;Initial Catalog=FirstSolutionDB;Persist Security Info=True;User ID=sa;Password=Skyline72" SelectCommand="GDN_GPM_Gestori1" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:SessionParameter Name="user" SessionField="user" />
                <asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
<%--        <asp:SqlDataSource ID="SqlDSConsulenti" runat="server" ConnectionString="Data Source=26.69.45.60;Initial Catalog=FirstSolutionDB;Persist Security Info=True;User ID=sa;Password=Skyline72" SelectCommand="GDN_GPM_Consulenti" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:SessionParameter Name="cod_ges" SessionField="cod_ges" />
                <asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>--%>
<%--        <asp:SqlDataSource ID="SqlDSAdvisor" runat="server" ConnectionString="Data Source=26.69.45.60;Initial Catalog=FirstSolutionDB;Persist Security Info=True;User ID=sa;Password=Skyline72" SelectCommand="GDN_GPM_Advisor" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:SessionParameter Name="cod_ges" SessionField="cod_ges" />
                <asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>--%>
        <asp:SqlDataSource ID="SqlDSLinee" runat="server" ConnectionString="Data Source=26.69.45.60;Initial Catalog=FirstSolutionDB;Persist Security Info=True;User ID=sa;Password=Skyline72" SelectCommand="GDN_GPM_Linee3" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:SessionParameter Name="cod_ges" SessionField="cod_ges" />
<%--                <asp:SessionParameter Name="cod_adv" SessionField="cod_adv" />--%>
                <asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </form>
</body>
</html>

