<div class="content-wrapper" style="min-height: 946px;">
    <section class="content-header">
        <h1>
            <i class="fa fa-line-chart"></i> Cashbook <?php echo $this->lang->line('reports'); ?> <small></small>
        </h1>
        <a href="<?php  echo base_url(); ?>cashbook/cashbooksearch" class="col-md pull-right">Cashbook Statement</a>
        <b style="padding-left:5px;padding-right:5px;" class="pull-right"> | </b>
        <a href="<?php  echo base_url(); ?>cashbook" class="col-md pull-right">Process Cashbook</a>
        <b style="padding-left:5px;padding-right:5px;" class="pull-right"> | </b>
        <a href="<?php  echo base_url(); ?>cashbook_accounts" class="col-md pull-right">Add Cashbook Account</a>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><i class="fa fa-search"></i>
                            <?php echo $this->lang->line('select_criteria'); ?></h3>
                    </div>

                    <form role="form" action="<?php echo site_url('cashbook/cashbooksearch') ?>" method="post" class="">
                        <div class="box-body row">

                            <?php echo $this->customlib->getCSRF(); ?>

                            <div class="col-sm-8 col-md-4">
                                <div class="form-group">
                                    <label for="cashbook">Cashbook Account</label><small class="req"> *</small>
                                    <select id="cashbook" name="cashbook" placeholder="" type="text"
                                        class="form-control">
                                        <option value="select"><?php echo $this->lang->line('select') ?></option>
                                        <?php 
												foreach ($cashbook->result() as $grup) {
												?>
                                        <option value="<?php echo $grup->cashbook_accounts; ?>">
                                            <?php echo $grup->cashbook_accounts; ?></option>
                                        <?php }
											?>
                                    </select>
                                    <span class="text-danger"><?php echo form_error('cashbook'); ?></span>
                                </div>
                            </div>
                            <div class="col-sm-8 col-md-4">
                                <div class="form-group">
                                    <label for="colour">From Date</label><small class="req"> *</small>
                                    <input autofocus="" id="from" name="from" placeholder="" type="date"
                                        class="form-control" value="<?php echo date("Y-m-d")?>" />
                                    <span class="text-danger"><?php echo form_error('from'); ?></span>
                                </div>
                            </div>
                            <div class="col-sm-8 col-md-4">
                                <div class="form-group">
                                    <label for="colour">To Date</label><small class="req"> *</small>
                                    <input autofocus="" id="to" name="to" placeholder="" type="date"
                                        class="form-control" value="<?php echo date("Y-m-d")?>" />
                                    <span class="text-danger"><?php echo form_error('to'); ?></span>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-12">
                                    <button type="submit" name="search" value="search_filter"
                                        class="btn btn-primary btn-sm checkbox-toggle pull-right"><i
                                            class="fa fa-search"></i>
                                        <?php echo $this->lang->line('search'); ?></button>
                                </div>
                            </div>

                    </form>
                </div>
            </div>
            <?php
            if (isset($resultlist)) {
                ?>
            <div class="box box-info" style="padding:5px;">
                <div class="box-header ptbnull">
                    <h3 class="box-title titlefix"><i class="fa fa-users"></i> <?php echo form_error('student'); ?>
                        Learner Report</h3>
                </div>
                <div class="box-body table-responsive">
                    <div class="download_label">Learner Report</div>
                    <table class="table table-striped table-bordered table-hover example" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th><?php echo $this->lang->line('section'); ?></th>
                                <th><?php echo $this->lang->line('admission_no'); ?></th>
                                <th>Learner Name</th>
                                <th><?php echo $this->lang->line('father_name'); ?></th>
                                <th><?php echo $this->lang->line('date_of_birth'); ?></th>
                                <th><?php echo $this->lang->line('gender'); ?></th>
                                <th><?php echo $this->lang->line('category'); ?></th>
                                <th><?php echo $this->lang->line('mobile_no'); ?></th>
                                <th><?php echo $this->lang->line('national_identification_no'); ?></th>
                                <th><?php echo $this->lang->line('local_identification_no'); ?></th>
                                <th><?php echo $this->lang->line('rte'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                if (empty($resultlist)) {
                                    ?>
                            <?php
                                } else {
                                    $count = 1;
                                    foreach ($resultlist as $student) {
                                        ?>
                            <tr>
                                <td><?php echo $student['section']; ?></td>
                                <td><?php echo $student['admission_no']; ?></td>
                                <td>
                                    <a href="<?php echo base_url(); ?>student/view/<?php echo $student['id']; ?>"><?php echo $student['firstname'] . " " . $student['lastname']; ?>
                                    </a>
                                </td>
                                <td><?php echo $student['father_name']; ?></td>
                                <td><?php echo date($this->customlib->getSchoolDateFormat(), $this->customlib->dateyyyymmddTodateformat($student['dob'])); ?>
                                </td>
                                <td><?php echo $student['gender']; ?></td>
                                <td><?php echo $student['category']; ?></td>
                                <td><?php echo $student['mobileno']; ?></td>
                                <td><?php echo $student['samagra_id']; ?></td>
                                <td><?php echo $student['adhar_no']; ?></td>
                                <td><?php echo $student['rte']; ?></td>
                            </tr>
                            <?php
                                        $count++;
                                    }
                                }
                                ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php
            }
            ?>
        </div>
</div>
</section>
</div>

<script type="text/javascript">
function getSectionByClass(class_id, section_id) {
    if (class_id != "" && section_id != "") {
        $('#section_id').html("");
        var base_url = '<?php echo base_url() ?>';
        var div_data = '<option value=""><?php echo $this->lang->line('select'); ?></option>';
        $.ajax({
            type: "GET",
            url: base_url + "sections/getByClass",
            data: {
                'class_id': class_id
            },
            dataType: "json",
            success: function(data) {
                $.each(data, function(i, obj) {
                    var sel = "";
                    if (section_id == obj.section_id) {
                        sel = "selected";
                    }
                    div_data += "<option value=" + obj.section_id + " " + sel + ">" + obj.section +
                        "</option>";
                });
                $('#section_id').append(div_data);
            }
        });
    }
}

$(document).ready(function() {
    var class_id = $('#class_id').val();
    var section_id = '<?php echo set_value('section_id') ?>';
    getSectionByClass(class_id, section_id);
    $(document).on('change', '#class_id', function(e) {
        $('#section_id').html("");
        var class_id = $(this).val();
        var base_url = '<?php echo base_url() ?>';
        var div_data = '<option value=""><?php echo $this->lang->line('select'); ?></option>';
        $.ajax({
            type: "GET",
            url: base_url + "sections/getByClass",
            data: {
                'class_id': class_id
            },
            dataType: "json",
            success: function(data) {
                $.each(data, function(i, obj) {
                    div_data += "<option value=" + obj.section_id + ">" + obj
                        .section + "</option>";
                });
                $('#section_id').append(div_data);
            }
        });
    });
});
</script>