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

<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/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>
    <link href="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-select/dist/css/bootstrap-select.css") %>" rel="stylesheet" />
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-select/dist/js/bootstrap-select.js") %>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js")%>"></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/Kullanici/KullaniciListesi.aspx") %>">Kullanıcılar</a></li>
    </ol>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderMain" runat="server">
    <div class="card">
        <div class="card-header">
            <h2>Kullanıcı Listesi</h2>
            <ul class="actions">
                <li>
                    <asp:HyperLink ID="btnNew" NavigateUrl="KullaniciFormu.aspx" ToolTip="Yeni Kullanıcı" 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="getKullanici"
                    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="KullaniciAdi"
                    data-sort-order="asc"
                    data-export-types="['excel']"
                    data-export-options='{"fileName": "KullaniciListesi", "worksheetName": "KullaniciListesi1"}'>
                    <thead>
                        <tr>
                            <th data-formatter="getEditDeleteLink" data-switchable="false">İşlemler</th>
                            <th data-field="GrupAdi" data-sortable="true">Grup Adı</th>
                            <th data-field="KullaniciAdi" data-sortable="true">Kullanıcı Adı</th>
                            <th data-field="TamAdi" data-sortable="true">Tam Adı</th>
                            <th data-field="MailAdresi" data-sortable="true">Email</th>
                            <th data-field="VarsayilanSirketi" data-sortable="true">Şirket Veritabanı Adı</th>
                            
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function getKullanici(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/GetKullaniciList")%>",
                data: { limit: limit, offset: offset, search: search, sort: sort, order: order },
                success: function (result) {
                    params.success({
                        total: result.total,
                        rows: result.rows
                    });
                }
            });
        }
        function getEditDeleteLink(value, row) {
            return "<a title='Düzenle' class=\"btn bgm-orange waves-effect\" href='KullaniciFormu.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/DeleteKullanici")%>",
                        data: { Id: Id },
                        success: function (data) {
                            if (data.status == 1) {
                                notify(data.message, "success", "KullaniciListesi.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>
