<script type="text/javascript" src="<?php echo base_url();?>assets/js/category.js"></script>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color">Category 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="10%">S.No</th>
                                    <th width="20%">Category Name</th>
                                    <th width="25%">Category Name (T)</th>
                                    <th width="15%">Image</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->category_name);?></td>
                                        <td><?php echo (!empty($row->tamil_name)) ? '<span class="lang-tamil">' . $row->tamil_name . '</span>' : 'N/A';?></td>
                                        <td>
                                            <?php if ((!empty($row->image)) && (file_exists(FCPATH . DIR_CATEGORY_IMAGE . $row->image))) { 
                                            $image_url = base_url() . DIR_CATEGORY_IMAGE . $row->image;
                                            $alt = $row->image;   
                                            } 
                                            else {
                                                $image_url = base_url() . NO_IMG;
                                                $alt = 'Image not found!';
                                            }
                                            ?>
                                            <img src="<?php echo $image_url;?>" style="width:50px; height:50px;" />
                                        </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 edit_otp" 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)) {?>
                                                <?php $row_exists = $this->category_model->category_exists_in_item($row->id);?>
                                                <a class="label btn btn-danger pop_up_confirm delete delete_otp" data-confirm="Do you want to delete the Category <b><?php echo $row->category_name;?></b>?" data-href="<?php echo $delete_link . $row->id?>" data-otp-ids="<?php echo form_prep(serialize($service_menu_id));?>" <?php echo ($row_exists == 1) ? ' disabled' : '';?> >
                                                    <span>Delete</span>
                                                </a>
                                            <?php }?>
                                        </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 $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 -->