<?php

/* 
 * Author       : Jai K
 * Purpose      : The listing page for Expenses
 * Created On   : 2017-01-25 18:15
 */

?>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><?php echo $title; ?> List</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <?php $general = get_general_setting();?>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <!-- /.box -->
                <div class="box box-primary">
                    <div class="box-body table-responsive">
                    <?php if(!empty($success)) {?>
                        <div class="alert alert-success alert-dismissable">
                            <i class="fa fa-thumbs-o-up"></i>
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                            <h4><?php echo $success;?></h4>
                        </div>
                    <?php }
                    else if(!empty($error)) {?>
                        <div class="alert alert-danger alert-dismissable">
                            <i class="fa fa-thumbs-o-down"></i>
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                            <h4><?php echo $error;?></h4>
                        </div>
                    <?php }?>
                        <div class="row">
                            <div class="left-col action-left-col">
                                <?php if (in_array(2, $permission)) {?>
                                    <a href="<?php echo $add_link?>">
                                        <input type="button" class="btn btn-success btn-sm" value="<?php echo $add_btn?>" />
                                    </a>
                                <?php }?>
                            </div>
                        </div>      
                    </div>
                    <div class="box-body table-responsive">
                        <table id="dt_basic" class="table table-striped table-bordered table-hover" width="100%">
                            <thead>			                
                                <tr>
                                    <th data-class="expand">S.No</th>
                                    <th>Expense Type</th>
                                    <th>Expense Subject</th>
                                    <th>Expense Name</th>
                                    <th>Amount</th>
                                    <th data-hide="phone,tablet">Status</th>
                                    <th data-hide="phone" style="text-align: center; min-width: 225px;" width="15%" >Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                    foreach( $results as $k => $row ) :
                                ?>
                                    <tr>
                                        <td><?php echo ++$k;?></td>
                                        <td><?php echo $row['type_name']; ?></td>
                                        <td><?php echo $row['exp_sub']; ?></td>
                                        <td><?php echo $row['exp_name']; ?></td>
                                        <td align="right"><?php echo number_format( $row['exp_amount'], 2); ?></td>
                                        <td><?php echo $row['status'] == "1" ? 'Active' : 'Inactive';?></td>
                                        <td class="td_action" align="center">
                                            <?php if( in_array(1, $permission) ):?>
                                                <a class="label btn btn-warning view" href="<?php echo $view_link . $row['id']; ?>">
                                                    <span>View</span>
                                                </a>
                                            <?php endif; if( in_array(3, $permission) ) :?>
                                                <a class="label btn btn-primary edit" href="<?php echo $edit_link . $row['id']; ?>">
                                                    <span>Edit</span>
                                                </a>
                                            <?php endif; if (in_array(4, $permission)) :?>
                                                <a class="label btn btn-danger pop_up_confirm delete" data-confirm="Do you want to delete <b><?php echo $row['exp_name'];?></b> expense type?" data-href="<?php echo $delete_link . $row['id']; ?>" >
                                                    <span>Delete</span>
                                                </a>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div><!-- /.box -->
            </div>
        </div>
        
       
        
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->
<script type="text/javascript" src="<?php echo js_url();?>library/datatables.responsive.min.js"></script>
<script src="<?php echo base_url();?>assets/js/library/jquery.dataTables.min.js"></script>
<script>
    $(document).ready(function() {
        /* BASIC ;*/
        var responsiveHelper_dt_basic = undefined;
        
        var breakpointDefinition = {
            tablet : 1024,
            phone : 480
        };

        $('#dt_basic').dataTable({
            "autoWidth" : true,
            "preDrawCallback" : function() {
                // Initialize the responsive datatables helper once.
                if (!responsiveHelper_dt_basic) {
                    responsiveHelper_dt_basic = new ResponsiveDatatablesHelper($('#dt_basic'), breakpointDefinition);
                }
            },
            "rowCallback" : function(nRow) {
                responsiveHelper_dt_basic.createExpandIcon(nRow);
            },
            "drawCallback" : function(oSettings) {
                responsiveHelper_dt_basic.respond();
            }
        });
        $('select[name="dt_basic_length"], input[type="search"]').removeClass();
        $('input[type="search"]').css('-webkit-appearance','textfield');      
	    /* END BASIC */
    });
</script>
