<%@ Page Title="" Language="C#" MasterPageFile="~/Master/Cecam.Master" AutoEventWireup="true" CodeBehind="wfViagemDiariaAdiantamento.aspx.cs"
    Inherits="Cecam.PortalTransparencia.Web.Pages.wfViagemDiariaAdiantamento" %>

<%@ Register Src="~/UserControls/ucDownload.ascx" TagPrefix="uc" TagName="Download" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphConteudo" runat="server">
    <div class="cabecalho">
        Diárias, Viagens e Adiantamentos
    </div>
    <asp:UpdatePanel ID="uppDiariaViagemAdiantamento" runat="server">
        <ContentTemplate>
            <dx:ASPxRoundPanel ID="rpnCadastro" runat="server">
                <PanelCollection>
                    <dx:PanelContent>
                        <ul class="form1col">
                            <li>
                                <span class="titulo">*Exercício:</span>
                                <ccn:ComboBox runat="server" ID="cbxExercicio" OnDataSearch="cbxExercicio_DataSearch" OnValueChanged="cbxExercicio_ValueChanged" AutoPostBack="true"
                                    ValidationGroup="DiariaViagemAdiantamento" IsRequired="true" />
                            </li>
                        </ul>
                        <ul class="form1col">
                            <li>
                                <span class="titulo">*Período:</span>
                                <ccn:DateEdit runat="server" ID="detInicial" ValidationGroup="DiariaViagemAdiantamento" IsRequired="true"
                                    CalendarProperties-EnableYearNavigation="true" AllowNull="false" />
                                <span class="titulo">a</span>
                                <ccn:DateEdit runat="server" ID="detFinal" ValidationGroup="DiariaViagemAdiantamento" IsRequired="true"
                                    CalendarProperties-EnableYearNavigation="true" AllowNull="false" />
                            </li>
                        </ul>
                        <ul class="form1col">
                            <li>
                                <span class="titulo">*Tipo:</span>
                                <ccn:ComboBox ID="cbxTipo" runat="server" Width="57.5%" ValidationGroup="DiariaViagemAdiantamento" IsRequired="true" AutoPostBack="true"
                                    TextField="Text" ValueField="Value" OnDataSearch="cbxTipo_DataSearch" OnValueChanged="cbxTipo_ValueChanged"/>
                            </li>

                            <li id="liStatus" runat="server" visible="true">
                                <span class="titulo">*Status Adiantamento:</span>
                                <ccn:ComboBox ID="cbxStatusAdiantamento" runat="server" Width="57.5%" ValidationGroup="DiariaViagemAdiantamento" IsRequired="true"  AutoPostBack="true"
                                    TextField="Text" ValueField="Value" OnDataSearch="cbxStatusAdiantamento_DataSearch" OnValueChanged="cbxStatusAdiantamento_ValueChanged" />
                            </li>

                            <li>
                                <ccn:LinkedSearch ID="lksFornecedor" runat="server" LabelCaption="Credor/Fornecedor:" PopupCaption="Credores/Fornecedores" KeyFieldName="Id"
                                    ValueFieldName="CNPJ" Width="20%|15%|40%" TextFieldName="Descricao" ColumnCaption="CNPJ|Descrição" ColumnFieldName="CNPJ|Descricao"
                                    ColumnWidth="20%|80%" OnDataSearch="lksFornecedor_DataSearch" IsAccentInsensitiveFilter="true" />
                                <br />
                                <span style="padding-left: 190px;">*Consulta por CPF/CNPJ/Razão Social</span>
                            </li>
                        </ul>
                    </dx:PanelContent>
                </PanelCollection>
            </dx:ASPxRoundPanel>
            <ul class="botoes">
                <li>
                    <ccn:Button ID="btnPesquisar" SkinID="Pesquisar" runat="server" ValidationGroup="DiariaViagemAdiantamento" OnClick="btnPesquisar_Click" />
                </li>
                <li>
                    <%--<ccn:Button ID="btnLimpar" SkinID="Limpar" runat="server" OnClick="btnLimpar_Click" ClientSideEvents-Click="function(s, e){popDoctoFiscal.Show();}" />--%>
                    <ccn:Button ID="btnLimpar" SkinID="Limpar" runat="server" OnClick="btnLimpar_Click" />
                </li>
            </ul>
            <asp:UpdatePanel runat="server">
                <ContentTemplate>
                    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" HeaderText="DiariaViagemAdiantamentos">
                        <PanelCollection>
                            <dx:PanelContent>
                                <li style="float: left;">
                                    <asp:Label runat="server" ID="lblFiltro"></asp:Label>
                                </li>
                                <li style="float: right;">
                                    <asp:Label runat="server" Text="Exportar Listagem: pdf, txt, jpg, csv e URI" />
                                    <ccn:Button runat="server" ID="btnExportar" Image-Url="~/UI/img/bt-exportar.png" ToolTip="Exportar" ClientEnabled="false"
                                        OnClick="btnExportar_Click" />
                                </li>
                                <ccn:GridView runat="server" ID="gvwDiariaViagemAdiantamento" OnDataSearch="gvwDiariaViagemAdiantamento_DataSearch" Width="100%"
                                    OnDataCommand="gvwDiariaViagemAdiantamento_DataCommand">
                                    <Columns>
                                        <ccn:GridCommandCustomColumn ButtonId="Detalhes" Name="Detalhes" ButtonType="Image" Width="3%" VisibleIndex="0"
                                            ImageUrl="~/UI/img/ico-detalhe.png" />
                                        <ccn:GridDataColumn FieldName="CodigoEmpenho" Caption="Empenho" Width="10%" />
                                        <ccn:GridDataColumn FieldName="DataEmissao" Caption="Data" Width="10%" />
                                        <ccn:GridDataColumn FieldName="CpfCnpj" Caption="CPF/CNPJ" Width="15%" />
                                        <ccn:GridDataColumn FieldName="NomeResponsavel" Caption="Responsável" Width="15%" />
                                        <ccn:GridDataColumn FieldName="MotivoViagem" Caption="Descrição" Width="15%" />
                                        <ccn:GridDataSpinTextColumn Caption="Utilizado (R$)" FieldName="ValorUtilizado" Width="10%" DisplayFormatString="#,##0.00"
                                            Precision="18|2" />
                                        <ccn:GridDataSpinTextColumn Caption="Devolvido (R$)" FieldName="ValorDevolvido" Width="10%" DisplayFormatString="#,##0.00"
                                            Precision="18|2" Visible="false" />
                                        <ccn:GridDataColumn FieldName="Periodo" Caption="Período" Width="10%" Visible="false" />
                                        <ccn:GridCommandCustomColumn ButtonId="DocFiscal" Name="DocFiscal" Caption ="Docto. Fiscal" ButtonType="Image" Width="3%" VisibleIndex="10"
                                            ImageUrl="~/UI/img/ico-detalhe.png" />
                                    </Columns>
                                    <Settings ShowFooter="True" />
                                    <TotalSummary>
                                        <dx:ASPxSummaryItem FieldName="ValorUtilizado" DisplayFormat="Total: {0:#,##0.00}" SummaryType="Sum" />
                                        <dx:ASPxSummaryItem FieldName="ValorDevolvido" DisplayFormat="Total: {0:#,##0.00}" SummaryType="Sum" />
                                    </TotalSummary>
                                </ccn:GridView>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxRoundPanel>
                </ContentTemplate>
            </asp:UpdatePanel>
            <uc:Download ID="ucFormatoDownload" runat="server" Titulo="Download" OnSucess="ucFormatoDownload_Sucess" />

            <div id="divPopup">
                    <asp:UpdatePanel ID="uppDoctoFiscal" runat="server" UpdateMode="Always">
                        <contenttemplate>
                            <dx:ASPxPopupControl ClientInstanceName="popDoctoFiscal"
                                ID="pcDoctoFiscal" 
                                Width="900px"
                                CloseAction="CloseButton" 
                                HeaderText="DOCUMENTO FISCAL." 
                                runat="server" 
                                AllowDragging="true"
                                DragElement="Header"
                                PopupHorizontalAlign="WindowCenter"
                                PopupVerticalAlign="WindowCenter"
                                EnableHierarchyRecreation="True">
                                <ContentCollection>
                                    <dx:PopupControlContentControl ID="pcContentControl" runat="server">
                                        <div style="padding: 20px">

                                        <ccn:GridView runat="server" ID="gvwDoctoFiscal" OnDataSearch="gvwDoctoFiscal_DataSearch" Width="100%" EnableTheming="False" OnPageIndexChanged="gvwDoctoFiscal_PageIndexChanged">
                                            <Columns>
                                                <ccn:GridDataColumn FieldName="Documento" Caption="Documento Fiscal" Width="10%" />
                                                <ccn:GridDataColumn FieldName="Serie" Caption="Série" Width="5%" />
                                                <ccn:GridDataColumn FieldName="DescricaoDocumentoTipo" Caption="Tipo Docto Fiscal" Width="10%" />
                                                <ccn:GridDataColumn FieldName="DataEmissao" Caption="Data" Width="10%" />
                                                <ccn:GridDataSpinTextColumn Caption="Valor Nota" FieldName="ValorNota" Width="12%" DisplayFormatString="#,##0.00"
                                                    Precision="18|2" />
                                                <ccn:GridDataSpinTextColumn Caption="Valor Glosado" FieldName="ValorGlosado" Width="12%" DisplayFormatString="#,##0.00"
                                                    Precision="18|2" />
                                                <ccn:GridDataSpinTextColumn Caption="Valor Considerado" FieldName="ValorConsiderado" Width="12%" DisplayFormatString="#,##0.00"
                                                    Precision="18|2" />

                                                <ccn:GridDataColumn FieldName="Observacao" Caption="Observação" Width="19%"/>
                                            </Columns>
                                            <Settings ShowFooter="True" />
                                            <TotalSummary>
                                                <dx:ASPxSummaryItem FieldName="ValorNota" DisplayFormat="Total: {0:#,##0.00}" SummaryType="Sum" />
                                                <dx:ASPxSummaryItem FieldName="ValorGlosado" DisplayFormat="Total: {0:#,##0.00}" SummaryType="Sum" />
                                                <dx:ASPxSummaryItem FieldName="ValorConsiderado" DisplayFormat="Total: {0:#,##0.00}" SummaryType="Sum" />
                                            </TotalSummary>
                                        </ccn:GridView>

                                        </div>
                                        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ContainerElementID="" runat="server" ClientInstanceName="LoadingPanel" Modal="True" Text=" Carregando Documentos Fiscais..." />
                                    </dx:PopupControlContentControl>
                                </ContentCollection>
                            </dx:ASPxPopupControl>
                        </contenttemplate>
                    </asp:UpdatePanel>
                </div>
        </ContentTemplate>

    </asp:UpdatePanel>
</asp:Content>