<?php  $this->load->view('staff/common/header.php',$data);
$base_name = $data['base_name'];
$shop = $data['shop'];
$mlm = $data['mlm'];
if($shop == 0){ $dpcol = 'd-none'; } else { $dpcol = ''; }
if($mlm == 0){ $pvcol = 'd-none'; } else { $pvcol = ''; }

?>

    <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-responsive">
							    <table id="key-table" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                    <thead>
                                        <tr>
                                            <th>S.no.</th>
            								<th>Photo</th>
            								<th>Product Name</th>
            								<th>Product Details  (Size,Old Price, Current Price,Quantity)</th>
            								<th>Is Featured?</th>
            								<th>Is Today's  Best Deal?</th>
            								<th>Is Active?</th>
            								<th>Category</th>
            							
                                        </tr>
                                    </thead>


                                        <tbody>
                                        
								<?php if (!empty($product)) {
								    $i=0;
								    foreach ($product as $row) {
									    $i++;
									    $p_id = $row['p_id'];
									?>
								        <tr>
                                            <td><?= $i;?></td>
        									<td>
                                                <?php
                                                    if(!empty($row['p_featured_photo']) && file_exists('./uploads/shop/product/'.$row['p_featured_photo'])){
                                                ?>
                                                    <img src="<?=base_url('uploads/shop/product/'.$row['p_featured_photo']);?>" class="img-fluid" width="60" />
                                                <?php 
                                                    } else{
                                                ?>
                                                    <img src="<?=base_url('uploads/no-image.png');?>" class="img-fluid" width="60" />
                                                <?php
                                                    }
                                                ?>
                                                </td>
                                                <td><?= $row['p_name'];?></td>
                                                <td>
                                                    <?php
                                                    if(!empty($product_size)){
                                                        $y=0;
                                                        foreach($product_size as $row2){
                                                            if($row2['p_id'] == $p_id){
                                                                $y++;
                                                                    echo $y.'. ';
                                                                    echo 'Size: ';
                                                                    echo $row2['size_name'];
                                                                    echo '; Color: ';
                                                                    echo $row2['color_id'];
                                                                    echo '; Old Price: &#8377;';
                                                                    echo $row2['p_old_price'];
                                                                    echo '; Current Price: &#8377;';
                                                                    echo $row2['p_current_price'];
                                                                    echo '; DP Price: &#8377;';
                                                                    echo $row2['p_dp_price'];
                                                                    echo '; PV: &#8377;';
                                                                    echo $row2['p_pv'];
                                                                    echo '; QTY: ';
                                                                    echo $row2['p_qty'];
                                                                    echo '<br>';
                                                            }
                                                        }
                                                    }
                                                    ?>
                                                </td>
        									<td>
        										<?php if ($row['p_is_featured'] == 1) {?>
        											<span class="badge badge-success">Yes</span>
        										<?php } else if ($row['p_is_featured'] == 0) {?>
        											<span class="badge badge-danger">No</span>
        										<?php }?>
        									</td>
        									<td>
        										<?php if ($row['todays_best_deal'] == 1) {?>
        											<span class="badge badge-success">Yes</span>
        										<?php } else if ($row['todays_best_deal'] == 0) {?>
        											<span class="badge badge-danger">No</span>
        										<?php }?>
        									</td>
        									<td>
        										<?php if ($row['p_is_active'] == 1) {?>
        											<span class="badge badge-success">Yes</span>
        										<?php } else if ($row['p_is_active'] == 0) {?>
        											<span class="badge badge-danger">No</span>
        										<?php }?>
        									</td>
        									<td><?='('.$row['tcat_name'].')<br>'.'('.$row['mcat_name'].')<br>'.'('.$row['ecat_name'].')'; ?></td>
        									
        								</tr>
								<?php }?>
								<?php } else {?>
								<tr>
									<td colspan="5" 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('staff/common/footer.php'); ?>

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