
<?php 

    /*
    $fondo_topbar = "navbar-dark bg-secondary";
    $fondo_topbar = "navbar-light bg-white";
    $fondo_topbar = "navbar-dark bg-primary";
    */

    //dark theme
    $fondo_topbar = "navbar-dark bg-secondary";
    $fondo_sidebar = 'bg-dark';

    //blue theme
    //$fondo_topbar = "navbar-dark bg-primary";
    //$fondo_sidebar = 'bg-primary';

?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title> <?php echo $this->config->item('sistema'); ?> | <?= $title; ?> </title>

    <!-- Custom fonts for this template-->
    <link href="<?= base_url(); ?>assets/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="<?= base_url(); ?>assets/css/fonts.min.css" rel="stylesheet">

    <!-- Custom styles for this template-->
    <link href="<?= base_url(); ?>assets/css/sb-admin-2.css" rel="stylesheet">

    <!-- Datepicker -->
    <link href="<?= base_url(); ?>assets/vendor/daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- DataTables -->
    <link href="<?= base_url(); ?>assets/vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
    <link href="<?= base_url(); ?>assets/vendor/datatables/buttons/css/buttons.bootstrap4.min.css" rel="stylesheet">
    <link href="<?= base_url(); ?>assets/vendor/datatables/responsive/css/responsive.bootstrap4.min.css" rel="stylesheet">
    <link href="<?= base_url(); ?>assets/vendor/gijgo/css/gijgo.min.css" rel="stylesheet">


      <!-- Select2 -->
    <link href="<?= base_url(); ?>assets/vendor/select2/css/select2.min.css" rel="stylesheet">
    <link href="<?= base_url(); ?>assets/vendor/select2-bootstrap4-theme/select2-bootstrap4.min.css" rel="stylesheet">


    <link rel="icon" type="image/x-icon" href="<?= base_url(); ?>assets/img/favicon2.png">

    <style>
        #accordionSidebar,
        .topbar {
            z-index: 1;
        }
        .tableCellCustomFont{
            font-size: 13px;
            }
    </style>
</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">

        <!-- Sidebar -->
        <ul class="navbar-nav bg-white sidebar sidebar-light accordion shadow-sm" id="accordionSidebar">

            <!-- Sidebar - Brand -->
            <a class="sidebar-brand d-flex text-white align-items-center justify-content-center <?= $fondo_sidebar; ?> " href="<?= base_url('dashboard'); ?>">
                <div class="sidebar-brand-icon">
                    <img src="<?= base_url(); ?>assets/img/icono_gris3.png" alt="Logo" style="width: 100%; height: 100%;">
                </div>
                <div class=" mx-3" style="text-transform: none; font-family: 'Calibri' ; font-size:20px;" > <?php echo $this->config->item('sistema'); ?> </div>
            </a>

            <!-- Nav Item - Dashboard -->
            <li class="nav-item">
                <a class="nav-link" href="<?= base_url('dashboard'); ?>">
                    
                    <span> <strong> MENÚ PRINCIPAL </strong> </span>
                </a>
            </li>


            <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------
            SEGURIDAD
            ------------------------------------------------------------------------------------------------------------------------------------------------------------------------>

            <?php if (is_admin()) : ?>
                <!-- Divider -->
                <hr class="sidebar-divider">

                <!-- Heading -->
                <div class="sidebar-heading">
                    Seguridad
                </div>

                <!-- Nav Item -->
                <li class="nav-item">
                    <a class="nav-link pb-0" href="<?= base_url('user'); ?>">
                        <i class="fas fa-fw fa-user-cog"></i>
                        <span>Mantenedor Usuarios</span>
                    </a>
                </li>

                <!-- Nav Item 
                <li class="nav-item">
                    <a class="nav-link pb-0" href="<?= base_url('user_access'); ?>">
                    <i class="fas fa-user-shield"></i>
                        <span>Mantenedor Permisos</span>
                    </a>
                </li>
                -->

                
                <!-- Nav Item -->
                <li class="nav-item">
                    <a class="nav-link " href="<?= base_url('entidades'); ?>">
                        <i class="fas fa-fw fa-building"></i>
                        <span>Mantenedor Entidades</span>
                    </a>
                </li>

                <!-- Nav Item 
                <li class="nav-item">
                    <a class="nav-link" href="<?= base_url('log_report'); ?>">
                        <i class="fas fa-fw fa-print"></i>
                        <span>Informe LOG</span>
                    </a>
                </li>
                -->




                
            <?php endif; ?>

            
            <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------
            SALIR
            ------------------------------------------------------------------------------------------------------------------------------------------------------------------------>

            <hr class="sidebar-divider">


                <!-- Heading -->
            <div class="sidebar-heading">
                Salir
            </div>

                <!-- Nav Item -->
                <li class="nav-item">
                <a class="nav-link" href="<?= base_url('logout'); ?>">
                    <i class="fas fa-fw fa-power-off"></i>
                    <span>Logout</span>
                </a>
            </li>

            
            <!-- Divider -->
            <hr class="sidebar-divider d-none d-md-block">

            <!-- Sidebar Toggler (Sidebar) -->
            <div class="text-center d-none d-md-inline">
                <button class="rounded-circle border-0" id="sidebarToggle"></button>
            </div>

        </ul>
        <!-- End of Sidebar -->

        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">

            <!-- Main Content -->
            <div id="content">

                <!-- Topbar -->
                <nav class="navbar navbar-expand topbar mb-4 static-top shadow-sm  <?= $fondo_topbar; ?> " >

                    <!-- Sidebar Toggle (Topbar) -->
                    <button id="sidebarToggleTop" class="btn btn-link bg-transparent d-md-none rounded-circle mr-3">
                        <i class="fa fa-bars text-white"></i>
                    </button>

                    <!-- Topbar Navbar -->
                    <ul class="navbar-nav ml-auto">


                        <div class="topbar-divider d-none d-sm-block"></div>

                        <!-- Nav Item - User Information -->
                        <li class="nav-item dropdown no-arrow">
                            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <img class="img-profile rounded-circle mr-2" src="<?= base_url() ?>assets/img/avatar/<?= userdata('foto'); ?>">
                            <span class="mr-2 d-none d-lg-inline small text-white">
                                     <?= strtoupper( userdata('username') ); ?> <br/> <strong>  <?= entitydata(); ?>  </strong>
                                </span>
                            </a>
                            <!-- Dropdown - User Information -->
                            <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
                                <a class="dropdown-item" href="<?= base_url('profile'); ?>">
                                    <i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400"></i>
                                    Perfil
                                </a>
                                <a class="dropdown-item" href="<?= base_url('profile/setting'); ?>">
                                    <i class="fas fa-cog fa-sm fa-fw mr-2 text-gray-400"></i>
                                    Modificar Perfil
                                </a>
                                <a class="dropdown-item" href="<?= base_url('profile/password'); ?>">
                                    <i class="fas fa-lock fa-sm fa-fw mr-2 text-gray-400"></i>
                                    Cambiar Password
                                </a>
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                                    <i class="fas fa-power-off fa-sm fa-fw mr-2 text-gray-400"></i>
                                    Logout
                                </a>
                            </div>
                        </li>

                    </ul>

                </nav>
                <!-- End of Topbar -->

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <?php if ($this->uri->segment(1) != 'dashboard') { ?>

                        <!-- Page Heading -->
                        <h1 class="h3 mb-4 text-gray-800"><?= $title; ?></h1>

                    <?php } ?>

                    <?= $contents; ?>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->

            <!-- Footer -->
            <footer class="sticky-footer bg-light">
                <div class="container my-auto pull-right">
                    <div class="copyright text-center">
                        <span>  <?php echo $this->config->item('sistema'); ?> <?php echo $this->config->item('version'); ?> </span>
                        - 
                        <span> <strong> Fecha: </strong> <?php echo $this->config->item('fecha_proceso'); ?> </span>
                    </div>
                </div>
            </footer>
            <!-- End of Footer -->

        </div>
        <!-- End of Content Wrapper -->

    </div>
    <!-- End of Page Wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">¿Seguro que desea salir del sistema?</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">x</span>
                    </button>
                </div>
                <div class="modal-body">Presione "Logout" para salir del sistema.</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancelar</button>
                    <a class="btn btn-danger" href="<?= base_url('logout'); ?>">Logout</a>
                </div>
            </div>
        </div>
    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="<?= base_url(); ?>assets/vendor/jquery/jquery.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="<?= base_url(); ?>assets/vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="<?= base_url(); ?>assets/js/sb-admin-2.min.js"></script>

    <!-- Datepicker -->
    <script src="<?= base_url(); ?>assets/vendor/daterangepicker/moment.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/daterangepicker/daterangepicker.min.js"></script>

    <!-- Page level plugins -->
    <script src="<?= base_url(); ?>assets/vendor/datatables/jquery.dataTables.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/dataTables.bootstrap4.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/jszip/jszip.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/pdfmake/pdfmake.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/pdfmake/vfs_fonts.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/buttons/js/buttons.html5.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/buttons/js/buttons.print.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/buttons/js/buttons.colVis.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?= base_url(); ?>assets/vendor/datatables/responsive/js/responsive.bootstrap4.min.js"></script>
    
    <!-- Datepicker Gijgo -->
    <script src="<?= base_url(); ?>assets/vendor/gijgo/js/gijgo.min.js"></script>

    <!-- Select2 -->
    <script src="<?= base_url(); ?>assets/vendor/select2/js/select2.full.min.js"></script>

    <!-- Custom Scripts -->
    <script type="text/javascript">
        $(document).ready(function() {


            //Initialize Select2 Elements
            $('.select2').select2()

            //Initialize Select2 Elements
            $('.select2bs4').select2({
                theme: 'bootstrap4'
            })

            //Initialize DataTables Elements
            var table = $('.DataTable').DataTable({
                buttons: ['print', 'excel', 'pdf'],
                buttons: [
                    {
                        extend: 'excel',
                        text: '<i class="fas fa-fw fa-file-excel"></i> Excel',
                        className: 'btn btn-sm btn-primary'
                    },
                    {
                        extend: 'pdf',
                        text: '<i class="fas fa-fw fa-file-pdf"></i> PDF',
                        className: 'btn btn-sm btn-primary'
                    },
                    {
                        extend: 'print',
                        text: '<i class="fas fa-fw fa-print"></i> Print',
                        className: 'btn btn-sm btn-primary'
                    }
                ],
                dom: "<'row px-2 px-md-4 pt-2'<'col-md-3'l><'col-md-5 text-center'B><'col-md-4'f>>" +
                    "<'row'<'col-md-12'tr>>" +
                    "<'row px-2 px-md-4 py-3'<'col-md-5'i><'col-md-7'p>>",
                lengthMenu: [
                    [5, 10, 25, 50, 100, -1],
                    [5, 10, 25, 50, 100, "All"]
                ],
                columnDefs: [{
                    targets: -1,
                    orderable: false,
                    searchable: false
                }],
                order: [[0, 'desc']]
            });

            table.buttons().container().appendTo('#dataTable_wrapper .col-md-5:eq(0)');


        });
    </script>
    

    <?php if ($this->uri->segment(1) == 'dashboard') : ?>
        <!-- Chart -->
        <script src="<?= base_url(); ?>assets/vendor/chart.js/Chart.min.js"></script>

        <script type="text/javascript">
            // Set new default font family and font color to mimic Bootstrap's default styling
            Chart.defaults.global.defaultFontFamily = 'Nunito', '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
            Chart.defaults.global.defaultFontColor = '#858796';

            function number_format(number, decimals, dec_point, thousands_sep) {
                // *     example: number_format(1234.56, 2, ',', ' ');
                // *     return: '1 234,56'
                number = (number + '').replace(',', '').replace(' ', '');
                var n = !isFinite(+number) ? 0 : +number,
                    prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
                    sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
                    dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
                    s = '',
                    toFixedFix = function(n, prec) {
                        var k = Math.pow(10, prec);
                        return '' + Math.round(n * k) / k;
                    };
                // Fix for IE parseFloat(0.55).toFixed(0) = 0;
                s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
                if (s[0].length > 3) {
                    s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
                }
                if ((s[1] || '').length < prec) {
                    s[1] = s[1] || '';
                    s[1] += new Array(prec - s[1].length + 1).join('0');
                }
                return s.join(dec);
            }

            // Area Chart Example
            var ctx = document.getElementById("myAreaChart");
            var myLineChart = new Chart(ctx, {
                type: 'line',
                data: {
                    labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
                    datasets: [{
                            label: "Total Incoming Items",
                            lineTension: 0.3,
                            backgroundColor: "rgba(78, 115, 223, 0.05)",
                            borderColor: "rgba(78, 115, 223, 1)",
                            pointRadius: 3,
                            pointBackgroundColor: "rgba(78, 115, 223, 1)",
                            pointBorderColor: "rgba(78, 115, 223, 1)",
                            pointHoverRadius: 3,
                            pointHoverBackgroundColor: "#5a5c69",
                            pointHoverBorderColor: "#5a5c69",
                            pointHitRadius: 10,
                            pointBorderWidth: 2,
                            data: <?= json_encode($cbm); ?>,
                        },
                        {
                            label: "Total Out-Goings",
                            lineTension: 0.3,
                            backgroundColor: "rgba(231, 74, 59, 0.05)",
                            borderColor: "#e74a3b",
                            pointRadius: 3,
                            pointBackgroundColor: "#e74a3b",
                            pointBorderColor: "#e74a3b",
                            pointHoverRadius: 3,
                            pointHoverBackgroundColor: "#5a5c69",
                            pointHoverBorderColor: "#5a5c69",
                            pointHitRadius: 10,
                            pointBorderWidth: 2,
                            data: <?= json_encode($cbk); ?>,
                        }
                    ],
                },
                options: {
                    maintainAspectRatio: false,
                    layout: {
                        padding: 5
                    },
                    scales: {
                        xAxes: [{
                            time: {
                                unit: 'date'
                            },
                            gridLines: {
                                display: false,
                                drawBorder: false
                            },
                            ticks: {
                                maxTicksLimit: 7
                            }
                        }],
                        yAxes: [{
                            ticks: {
                                maxTicksLimit: 5,
                                padding: 10,
                                // Include a dollar sign in the ticks
                                callback: function(value, index, values) {
                                    return number_format(value);
                                }
                            },
                            gridLines: {
                                color: "rgb(234, 236, 244)",
                                zeroLineColor: "rgb(234, 236, 244)",
                                drawBorder: false,
                                borderDash: [2],
                                zeroLineBorderDash: [2]
                            }
                        }],
                    },
                    legend: {
                        display: false
                    },
                    tooltips: {
                        backgroundColor: "rgb(255,255,255)",
                        bodyFontColor: "#858796",
                        titleMarginBottom: 10,
                        titleFontColor: '#6e707e',
                        titleFontSize: 14,
                        borderColor: '#dddfeb',
                        borderWidth: 1,
                        xPadding: 15,
                        yPadding: 15,
                        displayColors: false,
                        intersect: false,
                        mode: 'index',
                        caretPadding: 10,
                        callbacks: {
                            label: function(tooltipItem, chart) {
                                var datasetLabel = chart.datasets[tooltipItem.datasetIndex].label || '';
                                return datasetLabel + ': ' + number_format(tooltipItem.yLabel);
                            }
                        }
                    }
                }
            });

            // Pie Chart Example
            var ctx = document.getElementById("myPieChart");
            var myPieChart = new Chart(ctx, {
                type: 'doughnut',
                data: {
                    labels: ["Incoming Goods", "Out Goods"],
                    datasets: [{
                        data: [<?= $causas2; ?>, <?= $causas3; ?>],
                        backgroundColor: ['#1BC88A', '#e74a3b'],
                        hoverBackgroundColor: ['#5a5c69', '#5a5c69'],
                        hoverBorderColor: "rgba(234, 236, 244, 1)",
                    }],
                },
                options: {
                    maintainAspectRatio: false,
                    tooltips: {
                        backgroundColor: "rgb(255,255,255)",
                        bodyFontColor: "#858796",
                        borderColor: '#dddfeb',
                        borderWidth: 1,
                        xPadding: 15,
                        yPadding: 15,
                        displayColors: false,
                        caretPadding: 10,
                    },
                    legend: {
                        display: false
                    },
                    cutoutPercentage: 80,
                },
            });
        </script>
    <?php endif; ?>


    <?php if ($this->uri->segment(1) == 'report') : ?>
    
        <script type="text/javascript">
            $(function() {
        
                var start = moment().subtract(29, 'days');
                var end = moment();

                function cb(start, end) {
                    $('#tangal').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
                }

                $('#tanggal').daterangepicker({
                    startDate: start,
                    endDate: end,
                    ranges: {
                        'Today': [moment(), moment()],
                        'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                        'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                        'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                        'This Month': [moment().startOf('month'), moment().endOf('month')],
                        'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
                        'This Year': [moment().startOf('year'), moment().endOf('year')],
                        'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]
                    }
                }, cb);

                cb(start, end);
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causascortesuprema' && $this->uri->segment(2) == 'add' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'/*,
                    iconsLibrary: 'fontawesome',
                    minDate: new Date(),
                    maxDate: function() {
                        var date = new Date();
                        date.setMonth(date.getMonth() + 1);
                        return new Date(date.getFullYear(), date.getMonth(), date.getDate());
                    },
                    showOtherMonths: true,
                    selectOtherMonths: true,   
                    showOnFocus: true,
                    showRightIcon: true */
                });
    

               
            });

            $(document).ready(function() {


                
            });

        </script>

    <?php endif; ?>

    
    <?php if ( $this->uri->segment(1) == 'causascortesuprema' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                             
                //Initialize DataTables Elements
                var table = $('#tableAdjuntos').DataTable({                    
                    lengthMenu: [
                        [5, 10, 25, 50, 100, -1],
                        [5, 10, 25, 50, 100, "All"]
                    ],
                    
                    columnDefs: [
                        {
                            targets: -1,
                            orderable: false,
                            searchable: false
                        },
                        {targets: [0], className: "tableCellCustomFont" },
                        {targets: [1], className: "tableCellCustomFont"},
                        {targets: [2], className: "tableCellCustomFont"},
                        {targets: [3], className: "tableCellCustomFont"},
                        {targets: [3], className: "tableCellCustomFont"},
                        
                    ],

                    order: [[0, 'desc']]

                });

                //table.buttons().container().appendTo('#dataTable_wrapper .col-md-5:eq(0)');

            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causascorteapelaciones' && $this->uri->segment(2) == 'add' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

                $('#fecha_ubicacion').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causascorteapelaciones' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

                $('#fecha_ubicacion').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });               

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causasfamilia' && $this->uri->segment(2) == 'add' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'/*,
                    iconsLibrary: 'fontawesome',
                    minDate: new Date(),
                    maxDate: function() {
                        var date = new Date();
                        date.setMonth(date.getMonth() + 1);
                        return new Date(date.getFullYear(), date.getMonth(), date.getDate());
                    },
                    showOtherMonths: true,
                    selectOtherMonths: true,   
                    showOnFocus: true,
                    showRightIcon: true */
                });


            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causasfamilia' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causaslaboral' && $this->uri->segment(2) == 'add' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causaslaboral' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causaspenal' && $this->uri->segment(2) == 'add' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causaspenal' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causascivil' && $this->uri->segment(2) == 'add' )  : ?>

        <script type="text/javascript">
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });

            });

            $(document).ready(function() {
                
                
            });

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'causascivil' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">

            var base_url = "<?php echo base_url(); ?>";
                
            $(function() {
                
                $('#fecha_ingreso').datepicker({
                    uiLibrary: 'bootstrap4',
                    format: 'yyyy-mm-dd'
                });
                
                $id_causa = $('#id_causa_hidden').val();
               
                manageTable = $('#tableLitigantes').DataTable({
                    ajax: base_url + 'causascivil/fetchLitigantesCausasCivil/'+$id_causa,
                    buttons: ['print', 'excel', 'pdf'],
                    buttons: [
                        {
                            extend: 'excel',
                            text: '<i class="fas fa-fw fa-file-excel"></i> Excel',
                            className: 'btn btn-sm btn-primary'
                        },
                        {
                            extend: 'pdf',
                            text: '<i class="fas fa-fw fa-file-pdf"></i> PDF',
                            className: 'btn btn-sm btn-primary'
                        },
                        {
                            extend: 'print',
                            text: '<i class="fas fa-fw fa-print"></i> Print',
                            className: 'btn btn-sm btn-primary'
                        }
                    ],
                    dom: "<'row px-2 px-md-4 pt-2'<'col-md-3'l><'col-md-5 text-center'B><'col-md-4'f>>" +
                        "<'row'<'col-md-12'tr>>" +
                        "<'row px-2 px-md-4 py-3'<'col-md-5'i><'col-md-7'p>>",
                    lengthMenu: [
                        [5, 10, 25, 50, 100, -1],
                        [5, 10, 25, 50, 100, "All"]
                    ],
                    columnDefs: [{
                        targets: -1,
                        orderable: false,
                        searchable: false
                    }],
                    order: [[0, 'desc']]
                });


            });

            $(document).ready(function() {
                

            });


            function funcRefreshLitigantesModificaTable()
            {
                manageTable.ajax.reload(null, false); 
            }

            function funcDelLitigantesCausasCivil($id)
            {

                $resp = confirm('Seguro de eliminar al Litigante?');

                if (!$resp)
                {
                    return;
                }

                $.ajax({
                    url: base_url + 'causascivil/delLitigantesCausasCivil/',
                    type: 'post',
                    data: {     id: $id 
                            ,   '<?php echo $this->security->get_csrf_token_name(); ?>' : $('#id_csrf_token_hash').val(),
                            }, 
                    dataType: 'json',
                    success:function(response) {

                        if ( response.status=="ok")
                        {
                            alert("Litigante eliminado correctamente");                            
                        }
                        else{
                            alert("Problemas al eliminar Litigante, " + response.message);
                        }

                        $('#id_csrf_token_hash').val(response.csrf_hash);

                        manageTable.ajax.reload(null, false); 
                    
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        //  alert(errorThrown);
                        alert("Problemas al eliminar Litigante, " + response.message);
                    },
                });
                
            }


            function funcEditLitigantesCausasSelecciona($id)
            {

                $('#viewLitigantesModificaModal').modal('hide');

                $('#viewLitigantesModificaSeleccionModal').modal('show');

                $.ajax({
                    url: base_url + 'causascivil/editLitigantesCausasSelecciona/',
                    type: 'post',
                    data: {     id: $id 
                            ,   '<?php echo $this->security->get_csrf_token_name(); ?>' : $('#id_csrf_token_hash').val(),
                            }, 
                    dataType: 'json',
                    success:function(response) {

                        if ( response.status=="ok")
                        {
  
                            $('#id_litigante2').val(response.id_litigante).change();
                            $('#id_tipo_litigante2').val(response.id_tipo_litigante).change();

                            if (response.notificacion_whatsapp ==1){
                                $('#notificacion_whatsapp2').prop('checked', true );
                            }
                            else {
                                $('#notificacion_whatsapp2').prop('checked', false );
                            }

                            if (response.notificacion_email ==1){
                                $('#notificacion_email2').prop('checked', true );
                            }
                            else {
                                $('#notificacion_email2').prop('checked', false );
                            }

                        }
                        else{
                            alert("Problemas al seleccionar Litigante, " + response.message);
                        }
                    
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        //  alert(errorThrown);
                        alert("Problemas al seleccionar Litigante, " + response.message);
                    },
                }); 
            
            }

            function funcAddLitigantesCausas()
            {
                
                $id_litigante = $('#id_litigante').val();
                $id_causa = $('#id_causa_hidden').val();
                $id_tipo_litigante = $('#id_tipo_litigante').val();
                
                $notificacion_whatsapp = $('#notificacion_whatsapp').prop('checked');
                $notificacion_email = $('#notificacion_email').prop('checked');

                if ( $id_litigante==null || $id_litigante=="" || $id_litigante=="0" ){
                    alert("Debe seleccionar un Litiganet.");
                    return false;
                }

                if ( $id_tipo_litigante==null || $id_tipo_litigante=="" || $id_tipo_litigante=="0" ){
                    alert("Debe seleccionar un Tipo de Litiganet.");
                    return false;
                }

                $.ajax({
                    url: base_url + 'causascivil/addLitigantesCausas/',
                    type: 'post',
                    data: {     id_causa: $id_causa
                            ,   id_litigante: $id_litigante 
                            ,   id_tipo_litigante: $id_tipo_litigante 
                            ,   notificacion_whatsapp: $notificacion_whatsapp
                            ,   notificacion_email: $notificacion_email
                            ,   '<?php echo $this->security->get_csrf_token_name(); ?>' : $('#id_csrf_token_hash').val(),
                            }, 
                    dataType: 'json',
                    success:function(response) {

                        if ( response.status=="ok")
                        {
                            alert("Litigante incorporado correctamente");
                            
                            $('#viewLitigantesModal').modal('hide');

                            $('#viewLitigantesModificaModal').modal('show');

                        }
                        else{
                            alert("Problemas al incorporar Litigante, " + response.message);
                        }

                        $('#id_csrf_token_hash').val(response.csrf_hash);

                        manageTable.ajax.reload(null, false); 
                    
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        //  alert(errorThrown);
                        alert("Problemas al incorporar Litigante, " + response.message);
                    },
                }); 

            }

        </script>

    <?php endif; ?>


    <?php if ( $this->uri->segment(1) == 'user' && $this->uri->segment(2) == 'edit' )  : ?>

        <script type="text/javascript">
            $(function() {
               

            });

            $(document).ready(function() {
                
                
            });

            function funcPassword()
            {
                
                if ($("#password").prop('disabled') == true) {
                    $("#password").prop('disabled', false);
                } else {
                    $("#password").prop('disabled', true);
                }


            }
            
        </script>

    <?php endif; ?>


</body>

</html>