<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Main.Master" AutoEventWireup="true" CodeBehind="DuyuruListesi.aspx.cs" Inherits="Giza.Web.Moduller.Duyuru.DuyuruListesi" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHeader" runat="server">
    <link href="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/bootstrap-table.min.css")%>" rel="stylesheet" />
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/bootstrap-table.min.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/locale/bootstrap-table-tr-TR.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/export/bootstrap-table-export.min.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/export/tableExport.min.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/filter-control/bootstrap-table-filter-control.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js")%>"></script>
    <script type="text/javascript">
        function AnaSayfadaYayinlansinMi(value) {
            if (value == "1")
            { return "Evet"; }
            if (value == "0")
            { return "Hayır"; }
        }
        function AktifMi(value) {
            if (value == "1")
            { return "Aktif"; }
            if (value == "0")
            { return "Paif"; }
        }
        
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderBreadcrumbs" runat="server">
    <ol class="breadcrumb" style="margin-bottom: 5px;">
        <li><a href="<%= Page.ResolveUrl("~/AnaSayfa.aspx") %>">Anasayfa</a></li>
        <li><a href="<%= Page.ResolveUrl("~/Moduller/Duyuru/DuyuruListesi.aspx") %>">Duyurular</a></li>
    </ol>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderMain" runat="server">
    <div class="card">
        <div class="card-header">
            <h2>Duyuru Listesi</h2>
            <ul class="actions">
                <li>
                    <asp:HyperLink ID="btnNew" NavigateUrl="DuyuruFormu.aspx" ToolTip="Yeni Duyuru" CssClass="btn btn-danger waves-effect" runat="server" Style="width: auto;" Text="EKLE"></asp:HyperLink>
                </li>
            </ul>
        </div>
        <div class="card-body card-padding">
            <div id="toolbar" style="padding-right: 25px; padding-left: 5px">
                <div id="btnYenile" class="btn bgm-teal waves-effect" onclick="AramaTemizle();">Aramayı Temizle</div>
            </div>
            <div style="overflow-x: auto;">
                <table id="table"
                    data-toggle="table"
                    data-toolbar="#toolbar"
                    data-ajax="getDuyuru"
                    data-search="true"
                    data-search-align="left"
                    data-show-refresh="true"
                    data-show-toggle="false"
                    data-show-columns="true"
                    data-show-export="true"
                    data-minimum-count-columns="2"
                    data-show-pagination-switch="false"
                    data-pagination="true"
                    data-id-field="Id"
                    data-page-list="[10, 25, 50, 100, TÜMÜ]"
                    data-locale="tr-TR"
                    data-show-footer="false"
                    data-side-pagination="server"
                    data-sort-name="DuyuruTarihi"
                    data-sort-order="desc"
                    data-export-types="['excel']"
                    data-export-options='{"fileName": "DuyuruListesi", "worksheetName": "DuyuruListesi1"}'>
                    <thead>
                        <tr>
                            <th data-formatter="editDuyuru" data-switchable="false">İşlemler</th>
                            <th data-field="DuyuruBaslangicTarihi" data-formatter="DateFormat" data-sortable="true">Başlangiç Tarihi</th>
                            <th data-field="DuyuruBitisTarihi" data-formatter="DateFormat" data-sortable="true">Bitiş Tarihi</th>
                            <th data-field="DuyuruBasligi" data-sortable="true">Duyuru Başlığı</th>
                            <th data-field="DuyuruOzeti" data-sortable="true">Duyuru Özeti</th>
                            <th data-field="AnaSayfadaYayinlansinMi" data-sortable="true" data-formatter="AnaSayfadaYayinlansinMi" >Ana Sayfada Yayınlansın Mı?</th>
                            <th data-field="AktifMi" data-sortable="true" data-formatter="AktifMi" >Aktif Mi?</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function getDuyuru(params) {
            var limit = params.data.limit;
            var offset = params.data.offset;
            var search = params.data.search;
            var sort = params.data.sort;
            var order = params.data.order;
            $.ajax({
                url: "<%=Page.ResolveUrl("~/DataService.asmx/GetDuyuruList")%>",
                data: { limit: limit, offset: offset, search: search, sort: sort, order: order },
                success: function (result) {
                    params.success({
                        total: result.total,
                        rows: result.rows
                    });
                }
            });
        }

        function editDuyuru(value, row) {
            return "<a title='Düzenle' class=\"btn bgm-orange waves-effect\" href='DuyuruFormu.aspx?Id=" + row.Id + "'\"> <span style=\"width:6px \" class=\"zmdi zmdi-edit c-white\"> </span> </a> " +
              "<a title='Sil' class=\"btn btn-danger waves-effect\" onclick=\"Delete( " + row.Id + ")\"> <span style=\"width:6px \" class=\"zmdi zmdi-delete c-white\"> </span> </a> ";
        }
        function Delete(Id) {
            swal({
                title: "Seçilen kaydı silmek istiyor musunuz?",
                text: "Kaydı sildikten sonra işlemi geri alamazsınız.",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "Evet",
                cancelButtonText: "Hayır",
                closeOnConfirm: true,
                closeOnCancel: true
            }, function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        type: "GET",
                        dataType: 'json',
                        url: "<%=Page.ResolveUrl("~/DataService.asmx/DeleteDuyuru")%>",
                        data: { Id: Id },
                        success: function (data) {
                            if (data.status == 1) {
                                notify(data.message, "success", "DuyuruListesi.aspx");
                            }
                            else {
                                notify(data.message, "warning");
                            }
                        },
                        error: function (e) {
                            notify("Kayıt silinirken hata oluştu. Hata:" + e.responseText.substring(0, 200) + "...", "danger", "", 10000);
                        }
                    });
                } else {
                    notify("İşlem iptal edildi.", "info");
                }
            });
        }
    </script>
</asp:Content>
