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

<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>
    <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>
    <link href="<%= Page.ResolveUrl("~/Content/vendors/bootgrid/jquery.bootgrid.css") %>" rel="stylesheet" />
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/bootstrap-select/dist/js/i18n/defaults-tr_TR.min.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/input-mask/input-mask.js") %>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/bower_components/jquery-autoNumeric/autoNumeric.js") %>"></script>

    <link href="<%=Page.ResolveUrl("~/Content/vendors/daterangepicker/daterangepicker.css")%>" rel="stylesheet" />
    <script src="<%=Page.ResolveUrl("~/Content/vendors/daterangepicker/moment.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/vendors/daterangepicker/daterangepicker.js") %>"></script>

    <link href="<%= Page.ResolveUrl("~/Content/css/imageviewer.css")%>" rel="stylesheet" />
    <script src="<%= Page.ResolveUrl("~/Content/js/imageviewer/imageviewer.js")%>"></script>
    <script src="<%= Page.ResolveUrl("~/Content/js/imageviewer/imageviewer.min.js")%>"></script>

    <link href="<%=Page.ResolveUrl("~/Content/css/giza.css")%>" rel="stylesheet" />
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
            min-height: 100%;
            font-family: Helvetica, sans-serif;
            vertical-align: baseline;
        }

        .inner {
            width: 62.5%;
            margin: 0 auto;
            padding-top: 20%;
        }

        /* ==========================================================================
   Sections
   ========================================================================== */




        .section {
        }

        #section-one {
            background: #73d2e5;
        }

        #section-two {
            background: #57b8d9;
        }

        #section-three {
            background: #3d9ccc;
        }

        #section-four {
            background: #2680bf;
        }

        #section-five {
            background: #1262b2;
        }

        /* ==========================================================================
   Section Navigation
   ========================================================================== */




        #section-menu {
            position: fixed;
            top: 50%;
            right: 0;
            z-index: 3000;
            text-transform: uppercase;
            -webkit-transition: all ease 0.1s;
            transition: all ease 0.1s;
        }

            #section-menu.freeze {
                right: -95px;
            }

        .touch #section-menu {
            display: none;
        }

        #section-menu ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        #section-menu li {
        }

        #section-menu a {
            float: right;
            clear: both;
            display: block;
            height: 2em;
            line-height: 2em;
            text-decoration: none;
            padding: 0 8px;
            background: rgba(0,0,0,0.5);
            color: #fff;
            white-space: nowrap;
            -webkit-transition: all ease 0.1s;
            transition: all ease 0.1s;
        }

        #section-menu.freeze a {
            float: none;
            width: 128px;
        }

        #section-menu a:hover,
        #section-menu a:focus {
            background: rgba(0,0,0,0.75);
            font-size: 1.2em;
        }

        #section-menu a span {
            display: none;
            font-weight: 700;
            position: relative;
            width: 32px;
            left: -8px;
            text-align: center;
            background: rgba(0,0,0,0.1);
        }

        #section-menu a.active {
            background: #000;
            font-size: 1.4em;
            font-weight: 700;
        }

        #section-menu.freeze a span {
            display: inline-block;
        }

        #section-menu a.active span {
            display: inline-block;
            background: #000;
        }

            #section-menu a.active span:before {
                content: '';
                position: absolute;
                width: 100%;
                height: 100%;
                left: 0;
                background: #f80;
            }

        #section-menu.freeze a.active span:before {
            display: none;
        }
    </style>
    <script type="text/javascript">
        //$(document).ready(function () {
        //    DateRangePickerLoad();
        //});

        function DateRangePickerLoad() {

            var start = moment().startOf('month');
            var end = moment().endOf('month');

            function cb(start, end) {
                $('.reportrange span').html(start.format('D MMMM YYYY') + ' - ' + end.format('D MMMM YYYY'));
            }

            $('.reportrange').daterangepicker({
                startDate: start,
                endDate: end,
                ranges: {
                    'Bugün': [moment(), moment()],
                    'Dün': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                    'Son 7 Gün': [moment().subtract(6, 'days'), moment()],
                    'Son 30 Gün': [moment().subtract(29, 'days'), moment()],
                    'Bu Ay': [moment().startOf('month'), moment().endOf('month')],
                    'Geçen Ay': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
                }
            }, cb);

            cb(start, end);

            $('.reportrange').on('apply.daterangepicker', function (ev, picker) {
                //ToList();
            });

        };
    </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/TekEkran/TekEkranIzleme.aspx") %>">Tek Ekran Izleme</a></li>
    </ol>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderMain" runat="server">

    <asp:HiddenField ID="hdnSelectedReportID" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hdnSelectedTableName" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hdnSelectedDDID" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hdnSelectedDatabaseName" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hdnSelectedValue" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hdnSearchText" ClientIDMode="Static" runat="server" />




    <asp:Literal ID="ltrlDivs" runat="server"></asp:Literal>

    <nav id="section-menu">
        <ul>
        </ul>
    </nav>

    <div style="display: none">
        SelectedReportID :
    <div id="divSelectedReportID"></div>
        </br>
    divSelectedTableName :
    <div id="divSelectedTableName"></div>
        </br>
    divSelectedDDID :
    <div id="divSelectedDDID"></div>
        </br>
    divSelectedDatabaseName:
    <div id="divSelectedDatabaseName"></div>
        </br>
    divSelectedValue:
    <div id="divSelectedValue"></div>
        </br>
    </div>
    <div class="modal fade" id="PagePreviewListModal" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header" style="background-color: #00a9a1;">
                    <h4 class="modal-title" style="color: #FFF;">Ön İzleme</h4>
                </div>
                <div class="modal-body" style="padding: 0px;">
                    <img id="imgPreviewDocument" src="<%=Page.ResolveUrl("~/Content/img/notifications.png")%>" alt="Resim Yüklenemedi" style="width: 50%; height: 35%; margin-left: 25%;" />
                </div>
                <div class="modal-footer" style="background-color: #00a9a1;">
                    <button type="button" class="btn bgm-teal waves-effect" data-dismiss="modal">Kapat</button>
                </div>
            </div>
        </div>
    </div>


    <script type="text/javascript">

        function Goster() {

            $("#divSelectedReportID").html($('#hdnSelectedReportID').val());
            $("#divSelectedTableName").html($('#hdnSelectedTableName').val());
            $("#divSelectedDDID").html($('#hdnSelectedDDID').val());
            $("#divSelectedDatabaseName").html($('#hdnSelectedDatabaseName').val());
            $("#divSelectedValue").html($('#hdnSelectedValue').val());
        }

        function GridGetir(DDID, SelectedValue) {

            $('#hdnSelectedValue').val(SelectedValue);
            var databaseName = $('#hdnSelectedDatabaseName').val();
            //alert(databaseName);
            $.ajax({
                url: "<%=Page.ResolveUrl("~/DataService.asmx/GetDashboardGridText")%>",
                data: { DDID: DDID, databaseName: databaseName },
                success: function (result) {
                    $('#hdnSelectedDDID').val(result.DDID);
                    $('#hdnSelectedTableName').val(result.TableName);
                    $('#hdnSelectedReportID').val(result.ReportID);
                    $('#' + result.GridBlok).html(result.TableHtml);

                    $('#GridBlok_' + DDID).data('selectedvalue', SelectedValue);
                    if (SelectedValue != "") {
                        $('#RaporAltBaslik_' + DDID).text(result.KolonIsmi + " : " + SelectedValue + " olan kayıtlar listelenmektedir.");
                    }
                    DateRangePickerLoad();
                    if (!result.FiltreZorunlu) {
                        ToList();
                    }
                    smoothScroll(document.getElementById("GridBlok_" + result.DDID));
                    $("#menuitem_GridBlok_" + result.DDID).css("display", "block");
                }
            });
            Goster();

        }
        $(document).ready(function () {
            $('.grid').on('click', function (e) {
                var tiklananclassname = e.target.className;
                //alert(tiklananclassname);
                //console.log(tiklananclassname);
                if (
                    tiklananclassname.indexOf('secim') >= 0
                    || tiklananclassname.indexOf('size') >= 0
                    || tiklananclassname.indexOf('islem') >= 0
                    || tiklananclassname.indexOf('zmdi') >= 0
                    || tiklananclassname.indexOf('resim') >= 0
                    || tiklananclassname.indexOf('input') >= 0
                    || tiklananclassname.indexOf('aret') >= 0
                    || tiklananclassname.indexOf('dropdown') >= 0
                    || tiklananclassname.indexOf('bootstrap-table') >= 0
                    || tiklananclassname == ""

                    ) return;
                //alert(".grid2" + $('#' + e.currentTarget.id).data('selectedvalue'));

                var ilkdiv = $('#' + e.currentTarget.id).data('ilkdiv');
                var selectedvalue = $('#' + e.currentTarget.id).data('selectedvalue');
                var reportid = $('#' + e.currentTarget.id).data('reportid');
                var ddid = $('#' + e.currentTarget.id).data('ddid');
                var tablename = $('#' + e.currentTarget.id).data('tablename');

                if (ilkdiv == "1") {
                    $('#hdnSelectedValue').val("");
                } else
                    $('#hdnSelectedValue').val(selectedvalue);


                $('#hdnSelectedTableName').val(tablename);
                $('#hdnSelectedReportID').val(reportid);
                $('#hdnSelectedDDID').val(ddid);
                $("#" + tablename).bootstrapTable("refresh");
            });
            Goster();

        });




        function ajaxRequest(params) {
            //console.log(params.data);
            var limit = params.data.limit;
            var offset = (params.data.offset / limit) + 1;
            var search = params.data.search;
            var sort = params.data.sort;
            var order = params.data.order;
            var databaseName = $('#hdnSelectedDatabaseName').val();
            var TableName = $('#hdnSelectedTableName').val();
            var DashboardRaporMu = 1;
            var DDSecilenDeger = $('#hdnSelectedValue').val();
            var DDID = $('#hdnSelectedDDID').val();
            var ReportId = $('#hdnSelectedReportID').val();
            var searchText = $('#hdnSearchText').val();

            $.ajax({
                url: "<%=Page.ResolveUrl("~/DataService.asmx/GetDynamicReportList")%>",
                data: { limit: limit, offset: offset, search: search, sort: sort, order: order, databaseName: databaseName, ReportId: ReportId, DashboardRaporMu: DashboardRaporMu, DDID: DDID, DDSecilenDeger: DDSecilenDeger, searchText: searchText },
                success: function (result) {
                    //console.log(result);
                    var list = new Array();
                    $.each(result.rows, function (index, value) {
                        var obj = new Object();
                        $.each(value, function (i, v) {
                            //parametreli gönderilen kolon adlarını süzmek için
                            var keyValue = v.Key;
                            var splited = keyValue.split(':');
                            if (splited.length > 1) {
                                keyValue = splited[0];
                            }
                            obj[keyValue] = v.Value;

                        });
                        list.push(obj);

                    });
                    params.success({
                        total: result.total,
                        rows: list
                    });

                    $('[data-toggle="tooltip"]').tooltip();
                    GridRenkAyarla();
                    //$("#" + TableName).bootstrapTable('hideColumn', 'RENKKODU');
                    $("#" + TableName).bootstrapTable();
                }
            });
            Goster();
        }

        function ToList() {


            var limit = 0;
            var offset = 1;
            var search = "";
            var sort = "";
            var order = "";
            var databaseName = $('#hdnSelectedDatabaseName').val();
            var DashboardRaporMu = 1;
            var ReportId = $('#hdnSelectedReportID').val();
            var DDSecilenDeger = $('#hdnSelectedValue').val();
            var DDID = $('#hdnSelectedDDID').val();
            var TableName = $('#hdnSelectedTableName').val();
            var searchText = "";

            var data = $('#AramaDiv_' + DDID + ' > .col-sm-3 > .form-group > .fg-line > input');
            //var data = $('.fg-line_' + DDID + ' > input');

            var array = new Array();
            $.each(data, function (index, input) {
                var text = $(input).val();
                if (text != "") {
                    var tipi = $(input).data('tipi');
                    if (tipi != "") {
                        if (tipi == "decimal") {
                            text = text.trim();
                            var parseText = text.replace(",", ".");
                            text = parseText;
                        }
                        else if (tipi == "datetime") {

                            var ikiliTarih = text;
                            var islenenText = '';
                            //var baslangicTarihi = text.split('-')[0].trim();
                            //var bitisTarihi = text.split('-')[1].trim();

                            //var baslangicTarihi = $(input).data('daterangepicker').startDate._i
                            //var bitisTarihi = $(input).data('daterangepicker').endDate._i
                            for (var Ind = 0; Ind < 2; Ind++) {
                                islenenText = ikiliTarih.split('-')[Ind].trim();
                                var column = islenenText.split(".");
                                column.reverse();
                                var parseText = "";
                                for (var i = 0; i < column.length; i++) {
                                    if (i == 0)
                                    { parseText = column[i]; }
                                    else
                                    { parseText = parseText + "-" + column[i]; }
                                }

                                if (Ind == 0) {
                                    text = parseText;
                                } else {
                                    text += " / " + parseText
                                }
                            }
                        }
                    }
                    array.push({ kolonAdi: input.name, kolonDegeri: text.toUpperCase(), tip: tipi })
                }
            });
            if (array.length != 0) {

                for (var i = 0; i < array.length; i++) {
                    if (array[i].tip == "datetime") {
                        var baslangicTarihi = array[i].kolonDegeri.split('/')[0].trim();
                        var bitisTarihi = array[i].kolonDegeri.split('/')[1].trim();

                        if (i != array.length - 1) {
                            searchText = searchText + " [" + array[i].kolonAdi + "] BETWEEN '" + baslangicTarihi + "' and '" + bitisTarihi + "' AND";
                        }
                        else {
                            searchText = searchText + " [" + array[i].kolonAdi + "] BETWEEN '" + baslangicTarihi + "' and '" + bitisTarihi + "' ";
                        }
                    }
                    if (array[i].tip == "nvarchar" || array[i].tip == "varchar") {

                        if (i != array.length - 1) {
                            searchText = searchText + " UPPER([" + array[i].kolonAdi + "]) LIKE '" + "%" + array[i].kolonDegeri + "%' AND";
                        }
                        else {
                            searchText = searchText + " UPPER([" + array[i].kolonAdi + "]) LIKE '" + "%" + array[i].kolonDegeri + "%'";
                        }
                    }
                    else if (array[i].tip != "datetime" && array[i].tip != "nvarchar" && array[i].tip != "varchar") {
                        if (i != array.length - 1) {
                            searchText = searchText + " UPPER([" + array[i].kolonAdi + "]) LIKE '" + "%" + array[i].kolonDegeri + "%' AND";
                        }
                        else {
                            searchText = searchText + " UPPER([" + array[i].kolonAdi + "]) LIKE '" + "%" + array[i].kolonDegeri + "%'";
                        }
                    }
                }
                $('#hdnSearchText').val(searchText);
            }
            else {
                $('#hdnSearchText').val('');
            }

            $.ajax({
                type: "POST",
                url: "<%=Page.ResolveUrl("~/DataService.asmx/GetDynamicReportList")%>",
                data: { limit: limit, offset: offset, search: search, sort: sort, order: order, databaseName: databaseName, ReportId: ReportId, DashboardRaporMu: DashboardRaporMu, DDID: DDID, DDSecilenDeger: DDSecilenDeger, searchText: searchText },
                success: function (response) {
                    //console.log(response);
                    var data = response.rows;
                    $("#" + TableName).bootstrapTable('destroy');
                    $("#" + TableName + " thead tr").html('');
                    $.each(data, function (index, value) {
                        var eklenecekmi = true;
                        if (index == 0) {
                            $.each(value, function (index, property) {
                                var splited = property.Key.split(':');
                                var kolonadi = splited[0];
                                var datafield = ' data-field="' + kolonadi + '" ';

                                if (kolonadi == "RENKKODU") {
                                    eklenecekmi = false;
                                }

                                //tr etiketleri
                                var sorttabletext = "";
                                var dataformatter = "";

                                if (splited.length > 1) {

                                    var ozelliktext = splited[1];
                                    var ozellikler = ozelliktext.split(',');

                                    $.each(ozellikler, function (index, deger) {

                                        var ozellik = deger.split('=');

                                        if (ozellik.length > 1) {

                                            //'Fisno:stil=genis100,arama=evet,gizli=hayir,resim=evet,video=hayir,siralama=hayir'
                                            if (ozellik[0] == 'gizli' && ozellik[1] == "evet") {
                                                eklenecekmi = false;
                                            }

                                            if (ozellik[0] == 'siralama' && ozellik[1] == 'evet') {
                                                sorttabletext = " data-sortable='true' ";
                                            }

                                            if (ozellik[0] == 'resim' && ozellik[1] == 'evet') {
                                                dataformatter = " data-formatter='editLink' ";
                                            }

                                            if (ozellik[0] == 'video' && ozellik[1] == 'evet') {
                                                dataformatter = " data-formatter='editLinkVideo' ";
                                            }
                                        }
                                    });
                                }

                                if (eklenecekmi) {
                                    var tr = $('<th' + datafield + sorttabletext + dataformatter + '>' + kolonadi + '</th>');
                                    $("#" + TableName + " thead tr").append(tr);
                                }
                                eklenecekmi = true;
                                //var name = property.Key.split('_');
                                //var kolonadi = property.Key;
                                //var tr = "";
                                //var sorttable = " data-sortable='true' ";
                                //var widthstyle = "";
                                //var colarr = ["FileDataBase64", "FileDataBase64Vid", "İŞLEMLER", "RENKKODU", "ALT RAPORLAR", "DETAY"];

                                //if (name.length == 1) {

                                //    if ($.inArray(kolonadi, colarr) > -1) {
                                //        sorttable = '';
                                //        widthstyle = " data-width='130px' ";
                                //    }

                                //    if (name[0].indexOf("FileDataBase64") == -1) {
                                //        tr = $('<th ' + sorttable + widthstyle + ' data-field="' + property.Key + '">' + name + '</th>');
                                //    }
                                //}
                                //else if (name.indexOf("GIZLI") != -1) {
                                //    return true;

                                //}
                                //else {
                                //    if (name[0] == 'img') {

                                //        tr = $('<th   ' + sorttable + widthstyle + ' data-formatter="editLink">' + name[1] + '</th>');
                                //    } else
                                //        if (name[0] == 'vid') {

                                //            tr = $('<th   ' + sorttable + widthstyle + ' data-formatter="editLinkVideo">' + name[1] + '</th>');
                                //        }
                                //        else {
                                //            tr = $('<th  ' + sorttable + widthstyle + '  data-field="' + property.Key + '">' + name[1] + '</th>');
                                //        }
                                //}
                                //$("#" + TableName + " thead tr").append(tr);
                            });
                        }
                    });
                    if (data.length == 0) {
                        var tr = $('<th data-field="Sonuc" align="left">Sonuc</th>');
                        $("#" + TableName + " thead tr").append(tr);
                    }
                    $("#" + TableName).bootstrapTable("destroy");
                    $("#" + TableName).bootstrapTable();

                },
                error: function (xhr) {
                    console.log(xhr.responseText);
                }
            });
            Goster();
        }



        function GridRenkAyarla() {
            $('.table').on('click-row.bs.table', function (row) {
                console.log(row.cust_id);
            });
        }

        function rowStyle(row, index) {
            var backcolor = "";
            var color = "";
            if (row.RENKKODU != null) {

                var splited = row.RENKKODU.split(';')
                backcolor = splited[0];
                color = splited[1];
            }
            return {
                css: { "background-color": backcolor, "color": color, }
            };
        }


        function editLink(value, row, index) {
            var table = $('#hdnSelectedTableName').val();
            var row = $('#' + table).bootstrapTable('getData')[index];
            if (row.FileDataBase64 != null) {
                return "<a title='Resim' class=\"btn bgm-green waves-effect resim\" onclick=\"Preview(" + index + ")\"> <span class=\"zmdi zmdi-collection-image-o c-white\"> </span> </a> ";
            } else
                return "<a title='Resim' disabled class=\"btn bgm-gray waves-effect\" onclick=\"Preview(" + index + ")\"> <span class=\"zmdi zmdi-more c-white\"> </span> </a> ";
        }
        function ButonIslemYap(raporId, secilenSatirDegeri, hangiButon) {
            swal({
                title: "İşleme devam etmek istiyor musunuz?",
                text: "Devam ederseniz değişiklik geri alınamaz",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "Devam Et",
                cancelButtonText: "İptal",
                closeOnConfirm: true,
                closeOnCancel: true
            }, function (isConfirm) {
                if (isConfirm) {

                    notify("İşlem Yapılıyor...", "info");
                    var databaseName = $('#hdnSelectedDatabaseName').val();
                    $.ajax({
                        type: "POST",
                        url: '<%=Page.ResolveUrl("~/DataService.asmx/ButonSqlCalistir")%>',
                        data: { raporId: raporId, secilenSatirDegeri: secilenSatirDegeri, hangiButon: hangiButon, databaseName: databaseName },
                        success: function (result) {
                            var gelenStatus = result.status;
                            var gelenMesaj = result.message;

                            if (gelenStatus == 1) {
                                $("#" + $('#hdnSelectedTableName').val()).bootstrapTable('refresh');

                                notify(gelenMesaj, "success");
                            }
                            else
                                if (gelenStatus == 0)
                                    notify(gelenMesaj, "warning");


                            //console.log(result.sqlscript);
                        },
                        error: function (e) {
                            notify("İşlem yapılırken hata oluştu. Hata:" + e.responseText.substring(0, 200) + "...", "danger", 10000);
                        }
                    });
                } else {
                    notify("İşlem iptal edildi.", "info");
                }
            });
        }
        //function Preview(index) {
        //    var table = $('#hdnSelectedTableName').val();
        //    var row = $('#' + table).bootstrapTable('getData')[index];
        //    var src = '';
        //    src = 'data:image/* ;base64,' + row.FileDataBase64;
        //    document.getElementById('imgPreviewDocument').src = src;
        //    document.getElementById('imgPreviewDocument').title = escape(row.FileName);
        //    $('#PagePreviewListModal').modal('show');
        //}

        function Preview(index) {
            var table = $('#hdnSelectedTableName').val();
            var row = $('#' + table).bootstrapTable('getData')[index];
            if (row.FileDataBase64 != null) {
                var src = 'data:image/* ;base64,' + row.FileDataBase64;
                var viewer = ImageViewer();
                viewer.show(src, src);
            } else
                notify("Seçilen kaydın resim verisi bulunmadığından görüntülenemiyor", "info");
        }

    </script>

    <script>jQuery(function ($) {

    var html = $('html');
    var viewport = $(window);
    var viewportHeight = viewport.height();


    var scrollMenu = $('#section-menu');
    var timeout = null;

    function menuFreeze() {
        if (timeout !== null) {
            scrollMenu.removeClass('freeze');
            clearTimeout(timeout);
        }

        timeout = setTimeout(function () {
            scrollMenu.addClass('freeze');
        }, 2000);
    }
    scrollMenu.mouseover(menuFreeze);


    /* ==========================================================================
	   Build the Scroll Menu based on Sections .scroll-item
	   ========================================================================== */

    var sectionsHeight = {}, viewportheight, i = 0;
    var scrollItem = $('.scroll-item');
    var bannerHeight;

    function sectionListen() {
        viewportHeight = viewport.height();
        bannerHeight = (viewportHeight);
        $('.section').addClass('resize').css('height', bannerHeight);
        scrollItem.each(function () {
            sectionsHeight[this.title] = $(this).offset().top;
        });
    }
    sectionListen();
    viewport.resize(sectionListen);
    viewport.bind('orientationchange', function () {
        sectionListen();
    });

    var count = 0;

    scrollItem.each(function () {
        var anchor = $(this).attr('id');

        var title = $(this).attr('title');
        count++;
        $('#section-menu ul').append('<li style="display:none;" id="menuitem_' + anchor + '" ><a id="nav_' + title + '" href="#' + anchor + '"><span>' + count + '</span> ' + title + '</a></li>');
    });
    function menuListen() {
        var pos = $(this).scrollTop();
        pos = pos + viewportHeight * 0.625;
        for (i in sectionsHeight) {
            if (sectionsHeight[i] < pos) {
                $('#section-menu a').removeClass('active');
                $('#section-menu a#nav_' + i).addClass('active');;
                var newHash = '#' + $('.scroll-item[title="' + i + '"]').attr('id');
                if (history.pushState) {
                    history.pushState(null, null, newHash);
                } else {
                    location.hash = newHash;
                }
            } else {
                $('#section-menu a#nav_' + i).removeClass('active');
                if (pos < viewportHeight - 72) {
                    history.pushState(null, null, ' ');
                }
            }
        }
    }
    scrollMenu.css('margin-top', scrollMenu.height() / 2 * -1);

    /* ==========================================================================
	   Smooth Scroll for Anchor Links and URL refresh
	   ========================================================================== */

    scrollMenu.find('a').click(function () {
        var href = $.attr(this, 'href');
        $('html').animate({
            scrollTop: $(href).offset().top - 80
        }, 500, function () {
            window.location.hash = href;
        });
        return false;
    });


    /* ==========================================================================
	   Fire functions on Scroll Event
	   ========================================================================== */


    function scrollHandler() {
        menuListen();
        menuFreeze();
    }
    scrollHandler();
    viewport.on('scroll', function () {
        scrollHandler();
        //			window.requestAnimationFrame(scrollHandler);
    });
});
    </script>
</asp:Content>
