<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<div class="layout-app">
<div class="container">
<div class="row row-app">
    <div class="col-md-12">
        <div class="col-md-12">
            <div style="clear: both"></div>
                                <br />
                <?php
                    $disply = 'display:none;';
                    if(count($_GET) > 0){
                        $disply = 'display:block;';
                    }
                ?>
                <div class="widget allMagazines">
                    <div class="widget-head">
                        <h4 class="heading">Transaction Reports</h4>
                    </div>
                    <div class="widget-body innerAll inner-2x" style="display: inline-block;">
                        <?php $this->load->view('admin/flashdata_admin'); ?>
                        <form action="" method="GET" id="Singpost_Listing_form">
                            <table class="table table-white table-vertical-center margin-none footable" align="left">
                                <tr>
                                    <td class="col-md-2">From : &nbsp; <input type="text" readonly data-date-format="dd-mm-yyyy" class="form-control date validate[required] text-input" name="from_date" id ="from_date" value="<?php if (!empty($_GET['from_date'])){echo $_GET['from_date'];} ?>"/></th>
                                    <td class="col-md-2">To : &nbsp; <input type="text" readonly data-date-format="dd-mm-yyyy" class="form-control date validate[required] text-input" name="end_date_singList" id="end_date" value="<?php if (!empty($_GET['end_date_singList'])){echo $_GET['end_date_singList'];} ?>"/></th>
                                    <td>
                                        &nbsp; <button type="submit" class="btn btn-primary" style="margin-top: 1.4em;">SEARCH</button>            
                                    </td>
                                </tr>
                            </table>
                            
                        </form>
                    </div>
                </div>
                 
                
        </div>
        <hr />
       
    </div>
</div>

<script src="<?php echo base_url(); ?>assets/library/jquery/jquery.min.js"></script>
<script src="<?php echo base_url();?>assets/js/custom.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_multiselect/js/jquery.multi-select.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_fuelux-radio/fuelux-radio.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_multiselect/multiselect.init.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/subscriber.js"></script>
<script>
    $(document).ready(function() {
        $("#Singpost_Listing_form").validationEngine();
        $('#select_mag').click(function(event) {  //on click
            if(this.checked) { // check select status
                $('.checkbox1').each(function() { //loop through each checkbox
                    this.checked = true;  //select all checkboxes with class "checkbox1"
                });
            }else{
                $('.checkbox1').each(function() { //loop through each checkbox
                    this.checked = false; //deselect all checkboxes with class "checkbox1"
                });
            }
        });

        
        $(".advanced_search").click(function(){
            $('.allMagazines').slideDown();
        });

        $("#sticker").click(function(){
            var chkId = '';
            $('.checkbox1:checked').each(function() {
                chkId += $(this).val() + ",";
            });
            var country_id = parseInt($("#country_name").val());
            chkId = chkId.slice(0,-1);
            $("#ids").val(chkId);
            $("#st_date").val($("#start_date").val());
            $("#end_date").val($("#end_date").val());
            $("#select-country").val($("#country_name").val());

            var all_ids = $("#all_ids").val();
            if (chkId == null || chkId == "") {
                chkId = all_ids;
            }
            var start_date = btoa($("#from_date").val());
            var ids = btoa(chkId);
            var end_date = btoa($("#end_date").val());

            /*var system_base_url = $("#sys_base_url").val();
            var strRedirectPath = system_base_url+"index.php/postings/print_sticker?ids="+ids+"&st_date="+start_date+"&end_date="+end_date+"&country="+country_id;
            window.location.replace(strRedirectPath);*/
        });
        
        $("#donwExls").click(function(){
            var from_date = $('#from_date_').val();
            var status = $('#status_').val();
            var country_name_ = $('#country_name_').val();
            var system_base_url = $("#sys_base_url").val();
            var strRedirectPath = system_base_url+"index.php/postings/saveExls?from_date="+from_date+"&status="+status+"&country_name="+country_name_;
            window.location.replace(strRedirectPath);
        });

        $("#sing_list").click(function(){
            var chkId = null;
            var count = 0;
            $('.chkStatus:checked').each(function() {
                chkId += $(this).val() + ",";
                count++;
            });
            if (chkId == null) {
                alert("Please select at least one magazine to generate listing");
                return false;
            }
            if (count > 5) {
                alert("You can select maximum 5 magazine to generate report");
                return false;
            }
        });

        $("#excel_report").click(function(){
            var chkId = '';
            $('.checkbox1:checked').each(function() {
                chkId += $(this).val() + ",";
            });
            chkId = chkId.slice(0,-1);
            $("#ids").val(chkId);
            $("#st_date").val($("#start_date").val());
            $("#end_date").val($("#end_date").val());

            var all_ids = $("#all_ids").val();
            if (chkId == null || chkId == "") {
                chkId = all_ids;
            }
            var start_date = btoa($("#from_date").val());
            var ids = btoa(chkId);
            var end_date = btoa($("#end_date").val());
            var system_base_url = $("#sys_base_url").val();
            var strRedirectPath = system_base_url+"index.php/postings/GenerateExcel?ids="+ids+"&st_date="+start_date+"&end_date="+end_date;
            window.location.replace(strRedirectPath);
        });

        $("#csv_report").click(function(){
            var chkId = '';
            $('.checkbox1:checked').each(function() {
                chkId += $(this).val() + ",";
            });
            chkId = chkId.slice(0,-1);
            $("#ids").val(chkId);
            $("#st_date").val($("#start_date").val());
            $("#end_date").val($("#end_date").val());

            var all_ids = $("#all_ids").val();
            if (chkId == null || chkId == "") {
                chkId = all_ids;
            }
            var start_date = btoa($("#from_date").val());
            var ids = btoa(chkId);
            var end_date = btoa($("#end_date").val());
            var system_base_url = $("#sys_base_url").val();
            var strRedirectPath = system_base_url+"index.php/postings/GenerateCSV?ids="+ids+"&st_date="+start_date+"&end_date="+end_date;
            window.location.replace(strRedirectPath);
        });
    });
</script>