• File: view-product.php
  • Full Path: /home/aaryhspitl/domains/aaryawomenshospital.com/private_html/103.117.180.2/bootstrap/view-product.php
  • File size: 6.88 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php
include "header.php";
include "sidebar.php";
?>

<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
	<!-- Content Header (Page header) -->
	<section class="content-header">
	  <h1>
	    Manage Product
	    <a href="add-product.php" class="btn btn-primary pull-right" style="margin-top:-5px;"><i class="fa fa-plus"></i>&nbsp;Add Product</a>
	    <!--<small>...</small>-->
	  </h1>
	  
	</section>
<section class="content">
		<div class="row">
			<div class="col-sm-12">
				<div class="box">
				
					<div class="box-body">
						<?php if(isset($_SESSION['msg']) && $_SESSION['msg']=='data_uploaded') { ?>
	                  	<div class="row">
			                <div class="col-sm-6">
				                <div class="alert alert-success alert-dismissible">
			                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="fa fa-close"></i></button>
			                    Product Added successfully!!.
			                   </div>
		                  	</div>
	                  	</div>
	                  	<?php 
	                  	$_SESSION['msg'] = '';
	                  	} 
	                ?>
	                
						 <?php if(isset($_SESSION['msg']) && $_SESSION['msg']=='data_updated') { ?>
	                  	<div class="row">
			                <div class="col-sm-6">
				                <div class="alert alert-success alert-dismissible">
			                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="fa fa-close"></i></button>
			                    Product Updated successfully!!.
			                   </div>
		                  	</div>
	                  	</div>
	                  	<?php 
	                  	$_SESSION['msg'] = '';
	                  	} 
	                ?>
	                
					<?php if(isset($_SESSION['msg']) && $_SESSION['msg']=='status_changed') { ?>
	                  	<div class="row">
			                <div class="col-sm-6">
				                  <div class="alert alert-success alert-dismissible">
			                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="fa fa-close"></i></button>
			                   	Status changed successfully!!.
			                  	</div>
		                  	</div>
	                  	</div>
	                  	<?php 
	                  	
	                  	$_SESSION['msg'] = '';
	                  	} ?>
	                  	
	                  	<?php if(isset($_SESSION['msg']) && $_SESSION['msg']=='delete_data') { ?>
	                  	<div class="row">
			                <div class="col-sm-6">
				                <div class="alert alert-success alert-dismissible">
			                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
			                   	Product Deleted !!.
			                  	</div>
		                  	</div>
	                  	</div>
	                  	<?php 
	                  	
	                  	$_SESSION['msg'] = '';
	            	} ?>
	            	
					  <table id="employee-role-table" class="table table-bordered table-striped">
						<thead>
						  <tr>
							<th># Id</th>
							<!--<th>Category</th>-->
							<!-- <th>Brand</th> -->
							<th>Product Name</th>
							<!--<th>Product Code</th>-->							
							<th>Image</th>
							<!--<th>Min Price</th>-->
							<!--<th>View Images</th>-->
							<th>Edit</th>
							<th>Status</th>
							<th>Delete</th>
						  </tr>
						</thead>
						<tbody>
						<?php
						 //$fetch_product=mysqli_query($con,"SELECT `pr`.*,`cat`.`category_name`,`bnd`.`brand` FROM `spc_product` AS `pr` LEFT JOIN `spc_category` AS `cat` ON `pr`.`category_id`=`cat`.`category_id` LEFT JOIN `spc_brand` AS `bnd` ON `pr`.`brand_id`=`bnd`.`brand_id` ORDER BY `pr`.`product_id` DESC") or die(mysqli_error($con));
						 $fetch_product=mysqli_query($con,"SELECT * FROM `spc_product` ") or die(mysqli_error($con));
							$i=1;
							if(mysqli_num_rows($fetch_product)>0) {
							while($data = mysqli_fetch_array($fetch_product)) {
								//print_r($data); exit;
						?>
						  <tr>
							  <td><?php echo $i;?></td>
							  <!--<td><?php //echo $data['category_name'];?></td>-->
							  <!-- <td><?php //echo $data['brand'];?></td> -->
							  <td><?php echo $data['product_name'];?></td>
							  <!--<td><?php //echo $data['product_code'];?></td>-->							  							  							  

							  <td><?php
							  $productImg = "Product Images";
							   $imgfileSource = ".." . DIRECTORY_SEPARATOR . $productImg . DIRECTORY_SEPARATOR . $data['image'];
			    				if(file_exists($imgfileSource)){ ?>
								<img src="<?php echo $imgfileSource; ?>" style="width:150px; height:150px;" /><?php } ?>
								</td>
							
							 <!-- <td>Rs.<?php //echo productminprice($con,$data['product_id']); ?></td> -->
							 <!--<td>Rs. <?php //echo $data['original_price'];?></td>-->
							 
							<!-- <td>
							  <a href="product-images.php?id=<?php //echo base64_encode($data['product_id']); ?>" class="btn btn-primary" style="margin-right:2px;margin-bottom:6px;" title="View Images"><i class="fa fa-image"> Images</i></a>
							</td>-->
							
							  <td><a href="edit-product.php?action=edit&id=<?php echo base64_encode($data['product_id']);?>" class="btn btn-default" style="margin-right:2px;margin-bottom:6px;" title="Edit"><i class="fa fa-pencil"> Edit</i></a>
							  
							  <td>
							<?php if($data['status']=="1"){?>
							<a title="Click here to Disable Record" class="show-pointer"><span class="label label-success statusButton" id="<?php echo base64_encode($data['product_id']);?>">Active</span></a>	
						<?php	}
						 if($data['status']=="0"){?>
							<a title="Click here to Active This Record" class="show-pointer"><span class="label label-warning statusButton" id="<?php echo base64_encode($data['product_id']);?>">Deactive</span></a>	
						<?php	}?>
							</td>
							
							<td><a title="Click here to Delete This Record" class="show-pointer"><span class="label label-danger deleteButton" id="<?php echo base64_encode($data['product_id']);?>">Delete</span></a></td>
							 </tr>
						<?php
							$i++;
							} 
						}
						?>
						</tbody>
					  </table>
					</div><!-- /.box-body -->
				  </div><!-- /.box -->
			</div>
		</div>
	</section>
</div>	

<script>
$(".deleteButton").click(function() {
	var dataid = $(this).attr('id');
	if(confirm("Do you really want to delete this record?")) {
		window.location = "product-process.php?action=delete&id="+dataid;
	}
});
$(".statusButton").click(function() {
	var dataid = $(this).attr('id');
	if(confirm("Do you really want to change the status of this record?")) {
		window.location = "product-process.php?action=status&id="+dataid;
	}
});

$(function () {
	$('#employee-role-table').DataTable({
	  "paging": true,
	  "lengthChange": true,
	  "searching": true,
	  "ordering": true,
	  "info": true,
	  "autoWidth": false
	});
});
</script>

<?php
include "footer.php";
?>