<?php  $this->load->view('master/common/header.php',$data);
$base_name = $data['base_name'];
?>

    <div class="content">
        
        <!-- Start Content-->
        <div class="container-fluid">
            
            <!-- start page title -->
            <div class="row">
                <div class="col-12">
                    <div class="page-title-box">
                        <div class="page-title-right">
                            <ol class="breadcrumb m-0">
                                <li class="breadcrumb-item"><a href="javascript: void(0);"><?= $base_name;?></a></li>
                                <li class="breadcrumb-item active text-capitalize"><?= $page;?></li>
                            </ol>
                        </div>
                        <h4 class="page-title text-uppercase"><?= $page;?></h4>
                    </div>
                </div>
            </div>     
            <!-- end page title --> 

            <div class="row">
                <div class="col-md-12 col-xl-12">
                    <div class="card-box">
                        <div class="row">
                            <div class="col-sm-12">
							    <table id="key-table" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                    <thead>
                                        <tr>
                                            <th>#</th>
        									<th>Photo</th>
        									<th>Name</th>
        									<th>Mid Category</th>
        									<th>Top Category</th>
        									<th>Status</th>
        									<th>Action</th>
                                        </tr>
                                    </thead>


                                        <tbody>
                                        
								<?php if (!empty($end_category)) {?>
									<?php foreach ($end_category as $row) {?>
								        <tr>
                                            <td><?php echo $row['ecat_id'];?></td>
        									<td>
        									    
        									    <?php
        									    if(!empty($row['ecat_pic']) && file_exists('./uploads/shop/end_category/'.$row['ecat_pic'])){ ?>
        									    <img src="<?=base_url('uploads/shop/end_category/'.$row['ecat_pic']);?>" class="img-fluid" width="60" />
        									    <?php }
        									    else{
        									        ?>
        									        <img src="<?=base_url('uploads/no-image.png');?>" class="img-fluid" width="60" />
        									        <?php
        									    }
        									    
        									    ?>
        									</td>
        									<td><?php echo $row['ecat_name'];?></td>
        									<td>
        									    <?php  $id = $row['mcat_id'];?>
        									
                                                <?php 
                                                    for ($x=0; $x<count($mid_category); $x++) {
                                                        if($mid_category[$x]['mcat_id'] == $id){
                                                            echo $mid_category[$x]['mcat_name'];
                                                        }
                                                    } 
                                                ?>
        									</td>
        									<td>
                                                <?php 
                                                    $id = $row['tcat_id'];
                                                    for ($x=0; $x<count($top_category); $x++) {
                                                        if($top_category[$x]['tcat_id'] == $id){
                                                            echo $top_category[$x]['tcat_name'];
                                                        }
                                                    } 
                                                ?>
        									</td>
        									<td>
        										<?php if ($row['status'] == 1) {?>
        											<span class="badge badge-success">Active</span>
        										<?php } else {?>
        											<span class="badge badge-danger">Block</span>
        										<?php }?>
        									</td>
        									<td class="text-center">
        									    <div class="row">
        									        <div class="col-sm-12"><a href="<?php echo base_url().'master/end_category/edit/'.$row['ecat_id'];?>" class="btn btn-primary btn-sm" title="Edit"><i class="far fa-edit"></i> Edit</a></div>
        									        <!--<div class="col-sm-6 text-left">
        									            <form class="form-horizontal" onsubmit="return deleteend_category();" action="<?= base_url('master/action/delete');?>" method="post" enctype="multipart/form-data">
                                                            <input type="hidden" name="table" value="tbl_end_category" />
                                                            <input type="hidden" name="page" value="end_category" />
                                                            <input type="hidden" name="id" value="<?=$row['ecat_id'];?>" />
                                                            <input type="hidden" name="column" value="ecat_id" />
                                                            
                                                            <button type="submit" class="btn btn-danger btn-sm" title="Delete">Delete</button>
                										</form>
        									        </div>-->
        									    </div>
        									</td>
        								</tr>
								<?php }?>
								<?php } else {?>
								<tr>
									<td colspan="4" class="text-center">Records Not Found</td>
								</tr>
								<?php }?>
							</tbody>
							</table>
							</div>
					    </div>
					</div>
				</div>
				<!-- /.col-md-6 -->
			</div>
			<!-- /.row -->
		</div>
		<!-- /.container-fluid -->
	</div>
	<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php $this->load->view('master/common/footer.php'); ?>

<script type="text/javascript">
	function deleteend_category() {
		if (confirm("Are You Sure You Want TO Delete End Category?")) {
            return true;
		}
		return false;
	}
</script>