
<script>
    $(document).ready(function() {
        $('select').select2();
        jQuery('.datepicker2').datepicker({
            dateFormat: 'dd-mm-yy',
            changeMonth: true,
            changeYear: true
        });
<?php /* * ****Edited Sayem(11-8-2014)
  $("table.editable").on("click",".edit",function(){
  var eRow   = $(this).parents('tr');
  var eState = $(this).attr('data-state');

  if(eState == null){
  $(this).html('Save');
  eState = 1;
  }
  if(eState == 1)
  $(this).attr('data-state','2');
  else{
  $(this).removeAttr('data-state');
  $(this).html('Edit');
  }
  }); */ ?>

    });
</script>

<script type="text/javascript">

    function deleteRpt(id) {
        if (confirm("Confirm ... ?")) {
            $.ajax({
                type: "POST",
                data: {
                    rowID: id,
                },
                url: "<?php echo base_url() ?>gst03/deleteGSTrpt",
                success: function(data) {
                    location.reload(true);
                }
            });
        }
    }

    function confirmGtRpt(id) {
        if (confirm("Confirm ... ?")) {
            $.ajax({
                type: "POST",
                data: {
                    rowID: id,
                },
                url: "<?php echo base_url() ?>gst03/confirmGtRpt",
                success: function(data) {
                    location.reload(true);
                }
            });
        }
    }

    $(document).ready(function() {
        /* Build the DataTable with third column using our custom sort functions */
        var oTable = $("#oTable").dataTable({
            "iDisplayLength": 10,
            "aLengthMenu": [5, 10, 25, 50, 100],
            "asSorting": ["asc"], "aTargets": [1],
            "sPaginationType": "full_numbers", "aoColumns": [{
                    "bSortable": false},
                null,
                null,
                null,
                null,
                null,
                null, {
                    "bSortable": false}]});
        oTable.fnSort([[1, 'asc']]);
        $("table.editable").on("click", ".edit", function() {
            rRow = $(this).parents("tr");
            ID = $('td:first', $(this).parents('tr')).text();
            $("#row_edit").dialog("open");
        });

        $("table.editable").on("click", ".remove", function() {
            rRow = $(this).parents("tr");
            fldid = $('td:first', $(this).parents('tr')).text();
            $("#row_delete").dialog("open");
        });


    });


    function changeList(obj) {
        var df = $('#selDateFrom').val();
        var dt = $('#selDateTo').val();
        var urls = "<?php echo base_url(); ?>gst03/index/" + df + "/" + dt;
        window.location = urls;
    }



</script>



<div id="content">                        
    <div class="wrap">
        <div class="head">
            <div class="info">
                <!--<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
                    <?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>-->
                <ul class="breadcrumb">
                    <li><a href="#"><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                    <li><a href="<?php echo base_url(); ?>ap/home"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                    <li class="active"><?php echo $this->lang->line('title1') ?></li>
                </ul>
            </div>
            <div class="search">
                <form action="<?php echo base_url() ?>admin/search" method="post">
                    <input name="search_text" type="text" placeholder="search..."/>                                
                    <button type="submit"><span class="i-magnifier"></span></button>
                </form>
            </div>                        
        </div><!-- head --> 
        <div class="content">
            <div class="wrap">                    
                <div class="row-fluid">
                    <div class="span12">
                        <div class="block">
                            <div class="head">
                                <h2><?php echo $this->lang->line('taxableperiodpara') ?></h2>
                            </div><!-- head -->
                            <div class="content np">    
                                <div class="controls-row"><!-- Row 4-->
                                    <div class="span5 tac">
                                        <div class="span2 tar"><?php echo form_label($this->lang->line('dateFrom')); ?></div>
                                        <div class="input-prepend">
                                            <span class="add-on"><i class="i-calendar"></i></span>
                                            <?php
                                            $data = array(
                                                'name' => 'selDateFrom',
                                                'id' => 'selDateFrom',
                                                'type' => 'text',
                                                'class' => 'input-small datepicker2 financhk',);
                                            $js = '';
                                            echo form_input($data, date("d-m-Y", strtotime($dateFrom)), $js);
                                            ?>       
                                        </div>
                                    </div>
                                    <div class="span5 tac">
                                        <div class="span2 tar"><?php echo form_label($this->lang->line('dateTo')); ?></div>
                                        <div class="input-prepend">
                                            <span class="add-on"><i class="i-calendar"></i></span>
                                            <?php
                                            $data = array(
                                                'name' => 'selDateTo',
                                                'id' => 'selDateTo',
                                                'type' => 'text',
                                                'class' => 'input-small datepicker2 financhk',);
                                            $js = '';
                                            echo form_input($data, date("d-m-Y", strtotime($dateTo)), $js);
                                            ?>       
                                        </div>
                                    </div>
                                    <div class="span2 tac">
                                        <?php
                                        $data = array(
                                            'name' => 'mysubmit',
                                            'class' => 'btn-form btn-success-form');
                                        $js = "onClick='changeList()'";
                                        echo form_button($data, $this->lang->line('submit'), $js);
                                        ?>
                                    </div>
                                </div><!-- End Row 4-->
                            </div><!-- content -->
                            <div class="head">
                                <h2><?php echo $this->lang->line('titlelist'); ?></h2>
                                <div class="side fr">
                                    <a href="<?php echo base_url(); ?>gst03/gstTransactionSummary" class="btn-icon btn-warning-form" title="Add New"><span class="i-plus-2"></span></a>
                                </div>                                    
                            </div>
                            <div class="content np table-sorting">
                                <table cellpadding="0" cellspacing="0" width="100%" id="oTable" class="editable">
                                    <thead>
                                        <tr>
                                            <th style="display:none"></th>
                                            <th class="tac">#</th>
                                            <th><?php echo $this->lang->line('taxablePeriodStartEnd'); ?></th>
                                            <th><?php echo $this->lang->line('dueDate'); ?></th>
                                            <th><?php echo $this->lang->line('submissionDate'); ?></th>
                                            <th class="tac"><?php echo $this->lang->line('amendment'); ?></th>
                                            <th class="tac"><?php echo $this->lang->line('submitBy'); ?></th>
                                            <th><?php echo $this->lang->line('action'); ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $bil = 0;
                                        if ($datatbls) {
                                            foreach ($datatbls as $datatbl):
                                                $bil++
                                                ?>
                                                <tr>
                                                    <td style="display:none" ><?php echo $datatbl->ID; ?></td>	
                                                    <td class="tac"><?php echo $bil; ?></td>
                                                    <td><?php echo date("d-m-Y", strtotime($datatbl->B3a)) . $this->lang->line('to') . date("d-m-Y", strtotime($datatbl->B3b)); ?></td>
                                                    <td><?php echo date("d-m-Y", strtotime($datatbl->B4)); ?></td>
                                                    <td><?php echo date("d-m-Y", strtotime($datatbl->D24)); ?></td>
                                                    <td class="tac"><?php if ($datatbl->ammendment == 0) echo $this->lang->line('no');
                                        else echo $this->lang->line('yes'); ?></td>
                                                    <td><?php echo $datatbl->D20; ?></td>
                                                    <td class="tac">
                                                        <?php if ($datatbl->updateAble == 1) { ?>
                                                        <button title="Delete this report !" <?php echo'onclick="deleteRpt(' . $datatbl->ID . ')"'; ?> class="btn-icon btn-mini btn-danger-form ">
																<span class="i-trashcan"></span>
														</button>
                                                        <button title="Confirm" <?php echo 'onclick="confirmGtRpt(' . $datatbl->ID . ')"';  ?>  class="btn-icon btn-mini btn-success-form ">
																<span class="i-checkmark-3"></span>
														</button>
                                                        <?php } ?>
                                                        <a title="Print tax statement report" href="<?php echo base_url(); ?>gst03/getGstRpt/<?php echo $datatbl->ID; ?>" class="btn-icon btn-mini btn-success-form " target="_blank">
															<span class="i-printer"></span>
														</a>
														<a title="Export tax statement" href="<?php echo base_url(); ?>gst03/returnGstFile/<?php echo $datatbl->ID; ?>" class="btn-icon btn-mini btn-warning-form " target="_blank">
															<span class="i-download-3"></span>
														</a>
                                                    </td>	
                                                </tr>
    <?php endforeach;
}
?>
                                    </tbody>
                                </table>                                         
                            </div><!-- content -->
                        </div><!-- block -->
                    </div><!-- span12 -->
                </div><!-- row-fluid -->	
            </div><!-- wrap -->
        </div><!-- content -->
        </div>
        </div>
        </div>
        </div>
        <div class="dialog" id="row_edit" style="display: none;" title="<?php echo $this->lang->line('edit'); ?> ?">
            <p><?php echo $this->lang->line('message2'); ?></p>
        </div>  
        <div class="dialog" id="row_delete" style="display: none;" title="<?php echo $this->lang->line('delete'); ?> ?">
            <p><?php echo $this->lang->line('message1'); ?></p>
        </div>  

