<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color">Purchase Entry List</h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <!-- 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 class="table table-bordered table-striped data_table">
                            <thead>
                                <tr>
                                    <th width="8%">S.No</th>
                                    <th width="15%">Supplier Name</th>
                                    <th width="13%">Invoice No</th>
                                    <th width="15%">Invoice Date</th>
                                    <th width="12%">Total Amount</th>
                                    <th width="12%">Payment Status</th>
                                    <th width="15%">Action</th>
                                </tr>
                            </thead>
                            <tbody>    
                                <?php foreach ($results as $key => $row) :?>
                                    <tr>
                                        <td><?php echo ++ $key;?></td>
                                        <td><?php echo text($row->supplier_name);?></td>
                                        <td><?php echo text($row->invoice_no);?></td>
                                        <td><?php echo date('d-m-Y',strtotime($row->invoice_date));?></td>
                                        <td align="right"><?php echo text($row->total_amount);?></td>
                                        <td><?php echo text($row->payment_status);?></td>
                                        <td class="td_action">
                                            <?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 }?>
                                            <input type="hidden" name="auto_id" class="auto_id" value="<?php echo $row->id;?>" />
                                            <?php if (in_array(3, $permission)) {?>
                                                <a class="label btn btn-primary edit" href="<?php echo $edit_link . $row->id?>" data-otp-ids="<?php echo form_prep(serialize($service_menu_id));?>">
                                                    <span>Edit</span>
                                                </a>
                                            <?php }?>                                            
                                            <?php if( in_array( 4, $permission ) ) :
                                                    if( $row->status == 9 ) :
                                                        ?>
                                                            <a class="label btn btn-danger" onclick="javascript: msgBox('Sorry, Unable to delete! <div>Some of the items are already issued!</div>', 6000, ''); return false;" style="cursor: no-drop;"><span>Delete</span></a>
                                                        <?php
                                                    else :
                                                        ?>
                                                            <a class="label btn btn-danger pop_up_confirm delete" data-confirm="Do you want to delete the Purchase Entry <b><?php echo $row->invoice_no;?></b>?" data-href="<?php echo $delete_link . $row->id?>" data-otp-ids="<?php echo form_prep(serialize($service_menu_id));?>">
                                                                <span>Delete</span>
                                                            </a>
                                                        <?php
                                                    endif;
                                                endif;
                                            ?>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div>
        </div>
        
        <!-- Start Modal -->
        <div class="modal fade" id="otp-dialog" role="dialog">
            <div class="modal-dialog">
                <!-- Modal content-->
                <div class="modal-content">

                    <div class="modal-header" style="background-color: #337AB7;">
                        <button type="button" class="close cancel_popup" data-dismiss="modal" style="color: #FFF;">x</button>
                        <h4 class="modal-title" style="color: #FFF;">OTP</h4>
                    </div>
                    <div class="modal-body col-xs-12" style="margin-bottom: 30px; border-bottom: 1px dotted #1ba;">
                        <form name="m">
                            <input type="hidden" class="hidden_id" />
                            <input type="hidden" class="edit_link" data-edit-link="<?php echo (!empty($edit_link)) ? $edit_link : '';?>" />
                            <ul class="error_container" style="display:block;padding-left: 50%;"></ul>
                            <div class="col-xs-12">
                                <div class="col-xs-3">&nbsp;</div>                        
                                <div class="col-xs-1">
                                    <label style="padding-top: 31%;">OTP</label>
                                </div>
                                <div class="col-xs-6">
                                    <input type="text" class="form-control otp_no" name="otp_no" value="" />
                                </div>
                                <div class="col-xs-3">&nbsp;</div>
                            </div>
                        </form>
                    </div>

                    <div class="modal-footer" style="padding-right: 30px;">
                        <button type="button" class="btn btn-primary otp_btn_cancel" data-dismiss="modal"><i class="fa fa-play-circle-o"></i> Later</button>
                        <button type="submit" id="sbmt-btn" class="btn btn-danger"><i class="fa fa-send"></i> Send</button>
                    </div>
                </div>   <!-- Modal Content -->     
            </div> 
        </div> <!-- OTP Dialog -->
        
        <!-- Start Modal -->
        <div class="modal fade" id="warning-dialog" role="dialog">
            <div class="modal-dialog">
                <!-- Modal content-->
                <div class="modal-content">

                    <div class="modal-header" style="background-color: #337AB7;">
                        <button type="button" class="close cancel_popup" data-dismiss="modal" style="color: #FFF;">x</button>
                        <h4 class="modal-title" style="color: #FFF;">Warning: Mis-match module is found</h4>
                    </div>
                    <div class="modal-body col-xs-12" style="margin-bottom: 30px; border-bottom: 1px dotted #1ba;">
                        <form name="m">
                            <input type="hidden" class="correct_url" name="correct_url" /> 
                            <div class="col-xs-12 warning_content"></div>
                        </form>
                    </div>

                    <div class="modal-footer" style="padding-right: 30px;">
                        <button type="submit" id="sbmt-btn" class="btn btn-danger"><i class="fa fa-history"></i> Redirect Now</button>
                        <button type="button" class="btn btn-primary redirect_btn_cancel" data-dismiss="modal"><i class="fa fa-play-circle-o"></i> Later</button>                        
                    </div>
                </div>   <!-- Modal Content -->     
            </div> 
        </div> <!-- Dialog -->
        
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->
<script type="text/javascript">
    $(document).on('ready', function(){
       /* $('a.delete').on('click', function(){
            
            var redirectURL = $(this).attr('data-href');//$('[name="redirect_url"]').val() || "";
            
            if( redirectURL != '' ) {
                msgBox("Please wait ... Checking for able to delete!", -1, 'info');
                
                var s   = redirectURL.split('/')
                ,   data = {
                    'act' : 'chk-rm',
                    'pid' : s[s.length-1],  

                };
                $.post( baseURL + controller + '/ajax', data, function(){
                    $(this).addClass('pop_up_confirm').trigger('click');
                });
            }else {
                $(this).addClass('pop_up_confirm');
            }
            
        });*/
    })

</script>