	<?php $this->load->view("common/header"); ?>
	<!-- end: HEAD -->
       
		<!-- start: CSS REQUIRED FOR THIS PAGE ONLY -->
		<link rel="stylesheet" type="text/css" href="<?php echo asset_url(); ?>plugins/select2/select2.css" />
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/DataTables/media/css/DT_bootstrap.css" />
		<link href="<?php echo asset_url(); ?>plugins/bootstrap-modal/css/bootstrap-modal-bs3patch.css" rel="stylesheet" type="text/css"/>
		<link href="<?php echo asset_url(); ?>plugins/bootstrap-modal/css/bootstrap-modal.css" rel="stylesheet" type="text/css"/>
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/select2/select2.css">


		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/select2/select2.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/datepicker/css/datepicker.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-daterangepicker/daterangepicker-bs3.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/jQuery-Tags-Input/jquery.tagsinput.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/summernote/build/summernote.css">

		<style type="text/css">
			.table > thead:first-child > tr:first-child > th, .table > thead:first-child > tr:first-child > td, .table-striped thead tr.primary:nth-child(2n+1) th {
			    background-color: #428bca;
			    border-color: #357ebd;
			    border-top: 1px solid #357ebd;
			    color: white;
			    text-align: center;
			}

.dataTables_filter {
display: none;
} 
		</style>
		<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
	<!-- end: HEAD -->
	<!-- start: BODY -->
	<body>
		<!-- start: HEADER -->
		<div class="navbar navbar-inverse navbar-fixed-top">
			<!-- start: TOP NAVIGATION CONTAINER -->
			<div class="container">
				<div class="navbar-header">
					<!-- start: RESPONSIVE MENU TOGGLER -->
					<button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
						<span class="clip-list-2"></span>
					</button>
					<!-- end: RESPONSIVE MENU TOGGLER -->
					<!-- start: LOGO -->
					<?php $this->load->view("common/logo"); ?>
					<!-- end: LOGO -->
				</div>
				<div class="navbar-tools">
					<!-- start: TOP NAVIGATION MENU -->
				<?php $this->load->view("common/notifications.php"); ?>
					<!-- end: TOP NAVIGATION MENU -->
				</div>
			</div>
			<!-- end: TOP NAVIGATION CONTAINER -->
		</div>
		<!-- end: HEADER -->
		<!-- start: MAIN CONTAINER -->
		<div class="main-container">
			<div class="navbar-content">
				<!-- start: SIDEBAR -->
				<?php $this->load->view("common/navigation"); ?>
				<!-- end: SIDEBAR -->
			</div>
			<!-- start: PAGE -->
			<div class="main-content">
				<!-- end: SPANEL CONFIGURATION MODAL FORM -->
				<div class="container">
					<!-- start: PAGE HEADER -->
					<div class="row">
						<div class="col-sm-12">
							<!-- start: PAGE TITLE & BREADCRUMB -->
							<ol class="breadcrumb">
								<li>
									<a href="<?php echo base_url('dashboard'); ?>">
										 Dashboard 
									</a>
								</li>
                                <li>
									<a href="#">
										 Product 
									</a>
								</li>
                                
								<li class="active">
									List of Product
								</li>
								<li class="search-box">
									<form class="sidebar-search">
										<div class="form-group">
											<input type="text" placeholder="Start Searching...">
											<button class="submit">
												<i class="clip-search-3"></i>
											</button>
										</div>
									</form>
								</li>
							</ol>
							<div class="page-header">
								<h1>List of Product</h1>
							</div>

                            <p>Please use the table below to navigate or filter the results. </p>
						</div>
					</div>
					<!-- end: PAGE HEADER -->
					<!-- start: PAGE CONTENT 
                    <!-- start grid -->
                    <div class="row">
						<div class="col-md-12">
                        
           <!--start search box-->  
    <div class="panel panel-default">
								<div class="panel-heading">
									 <i class="fa fa-external-link-square"></i>
									Search
									<div class="panel-tools">
										<a class="btn btn-xs btn-link panel-collapse collapses" href="#">
										</a>
										
										<a class="btn btn-xs btn-link panel-refresh" href="#">
											<i class="fa fa-refresh"></i>
										</a>
										<a class="btn btn-xs btn-link panel-expand" href="#">
											<i class="fa fa-resize-full"></i>
										</a>
										<a class="btn btn-xs btn-link panel-close" href="#">
											<i class="fa fa-times"></i>
										</a>
									</div>
								</div>
								<div class="panel-body">
									
                           <!--start search-->                       
<div class="col-md-12">

<div class="col-md-2 pull-right" style="margin-top:21px;">
                  <input class="btn btn-primary" value="Search" name="search" id="search" type="submit" onClick="search_by_custum_value()"> 
                  <input name="add_category" value="Reset" class="btn btn-danger" onClick="location.reload()" type="submit">
                  </div> 
                  
                  
<div class="col-sm-3" style="display:none">
<div class="form-group">
<label>Warehouse </label>
<select id="srh_warehouse_id" class="form-control" name="srh_warehouse_id">

<?php 
$ss_warehouse_id=$this->session->userdata('ss_warehouse_id'); 
foreach ($warehouse_list as $row)
{
$sel='';
if($ss_warehouse_id==$row->id)
{
$sel=' selected="selected"';
}
?>  

<option value="<?php echo $row->id; ?>" <?php echo $sel; ?>>
<?php echo $row->name; ?>
</option>
<?php }?>

</select>                                          
</div>
</div>

<div class="col-sm-3 pull-right">
<div class="form-group">
<label>Product Name </label>
<input id="search_name" name="search_name" class="form-control">

</div>
    
</div>

<div class="col-sm-3 pull-left">
<div class="form-group">
<label>Department  </label>

<select class="form-control" id="category" name="category">
    <option value="">-Select-</option>
												
													<?php foreach ($main_category as $key => $category) 
													{
														if($category->cat_name){
															$sel='';
															//if($category->cat_id==3) $sel='selected';
															?>
															
														<option <?php //echo $sel ?> value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_name; ?></option>	
														
														
													<?php 
													}} ?>
												</select>                                        
</div>
</div>

<div class="col-sm-3">                                                       
  <div class="form-group">
											<label class=" control-label" for="form-field-3" >
												Category 
											</label>
											
											
											
											
                                           <!--  <div id="subcat_data">
											<select onChange="" data-placeholder="Select Category to load Subcategories" id="subcategory" class="form-control search-select" name="subcategory">
											<option selected="selected" value=""></option>
											</select>
                                            </div>
                                            -->
                                            
                                            <select id="srh_sub_cat" class="form-control search-select" name="srh_sub_cat">
                                                <option value="">-Select-</option>
											         
											         <?php
											         foreach ($sub_category as $key => $item)
											{
											$sel_com='';
											
											?>
                    <option value="<?php echo $item->sub_cat_id;?>" <?php echo $sel_com;?>><?php echo $item->sub_cat_name;?></option>
                    <?php } ?>
											         
                       
                      </select>
											</div>
										</div>  
										
										<div class="col-sm-3">                                                       
  <div class="form-group">
      
      <label class=" control-label" for="form-field-3" >
												Brand
											</label>
											
											<?php
											
											 //print_r($department_list);
											 ?>
											
											<select id="dep_id" class="form-control search-select" name="dep_id">
											         
											         <?php
											         
											         $sel_s='';
											         $sel_ser='';
											        
											        
											         ?>
											        
											        <option value=""<?php //echo $sel_0; ?>>-Select-</option> 
											        
											          <?php 
											     //department_list
											
											foreach ($department_list as $key => $item)
											{
											$sel_com='';
											 if($product_details->dep_id==$item->department_id){
											             $sel_com='selected';
											         }
											?>
											         <option value="<?php echo $item->department_id;?>" <?php echo $sel_com;?>><?php echo $item->department_name;?></option>
											         <?php } ?>
											         <!-- 
											         <option value="1"<?php echo $sel_s; ?>>Mobile Phone</option>
                        
                        <option value="2"<?php echo $sel_ser; ?>>Service Repair</option>
                        
                        <option value="3"<?php echo $sel_com; ?>>Computer</option> -->
                       
                      </select>
      </div>
      </div>
										
										<div class="col-sm-3">                                                       
  <div class="form-group">
											<label class=" control-label" for="form-field-3" >
												Type 
											</label>
											
											
											
											
                                           <!--  <div id="subcat_data">
											<select onChange="" data-placeholder="Select Category to load Subcategories" id="subcategory" class="form-control search-select" name="subcategory">
											<option selected="selected" value=""></option>
											</select>
                                            </div>
                                            -->
                                            
                                            <select id="subcategory" class="form-control search-select" name="subcategory">
                                                <option value="">-Select-</option>
											         
											         <?php
											         foreach ($type_list as $key => $item)
											{
											$sel_com='';
											
											?>
                    <option value="<?php echo $item->ptype_id;?>" <?php echo $sel_com;?>><?php echo $item->ptype_name;?></option>
                    <?php } ?>
											         
                       
                      </select>
											</div>
										</div>  
										
										
											<div class="col-sm-3">                                                       
  <div class="form-group">
											<label class=" control-label" for="form-field-3" >
												Update Status 
											</label>
											
											
											
											
                                           <!--  <div id="subcat_data">
											<select onChange="" data-placeholder="Select Category to load Subcategories" id="subcategory" class="form-control search-select" name="subcategory">
											<option selected="selected" value=""></option>
											</select>
                                            </div>
                                            -->
                                            
                                            <select id="update_status" class="form-control " name="update_status">
                                                <option value="">-All-</option>
											         
											        
                    <option value="1" >Update</option>
                    <option value="0" >Pending</option>
                   
											         
                       
                      </select>
											</div>
										</div>  
										
										
											<div class="col-sm-3">                                                       
  <div class="form-group">
											<label class=" control-label" for="form-field-3" >
												Update User 
											</label>
											
											<select id="last_update_user" class="form-control search-select" name="last_update_user">
                        <option value="">-- Select  --</option>
                        <?php 

															

															foreach ($rep_list as $row)

															{

															 $sel='';

																 // if($sel_rep_id==$row->user_id)

																  {

																//	 $sel=' selected="selected"';

																  }
															{

															?>
                        <option value="<?php echo $row->user_id;?>"  <?php echo $sel ?>>
                        <?php //echo $row->id.',' ?>
                        <?php echo $row->user_username; ?> [<?php echo $row->user_id; ?>]</option>
                        <?php } }  ?>
                      </select>
											
											
                                         
											</div>
										</div>  
										
										
											<div class="col-sm-3" style="display:none">                                                       
  <div class="form-group">
											<label class=" control-label" for="form-field-3" >
												Show 
											</label>
											
											 <select id="pro_show_no" name="pro_show_no" aria-controls="products_table" class="form-control input-sm"><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select>
											</div>
											</div>

 

<div class="col-sm-3" style="display:none">

                                                      	<div class="form-group">

															<label for="s2id_autogen1">From Date </label>

                                                            <!--<input id="srh_from_date" name="srh_from_date" type='text' class="form-control date-picker" value="<?php echo date('m/d/Y'); ?>" data-bv-field="date"/>-->
                                                            
                   <input id="srh_from_date" name="srh_from_date" type='text' class="form-control date" value="" data-bv-field="date"/>                                         
                                                            

                                                            

														</div>

													</div>
                                                        <div class="col-sm-3" style="display:none">

                                                      	<div class="form-group">

															<label for="s2id_autogen1">To Date </label>

                                                             <input id="srh_to_date" name="srh_to_date" type='text' class="form-control date" value="" data-bv-field="date"/>                                         
                   

                                                            

														</div>

													</div>
                                                    
                                                    
                  
                 
</div> 
<!--end search-->           
                                    
								</div>
							</div>
    
    <!--end search box-->               
                        
                        
                        
							<!-- start: DYNAMIC TABLE PANEL -->
							<div class="panel panel-default">
								<div class="panel-heading">
									<i class="fa fa-external-link-square"></i>
									Product List
								</div>
								<div class="panel-body">
								    <div id="error"></div>
                                    <?php 
									
									//echo "ss_group_id:".$this->session->userdata('ss_group_id');
									?>
                                    <div <?php if ($this->session->userdata('ss_group_id')==1) echo ''; else echo 'style="display:none"'; ?> >
                                    <?php //if ($this->session->userdata('ss_group_id')==1)
									{ ?>
                                     <h6>  <label class="checkbox-inline" style="font-family:'Arial Black', Gadget, sans-serif:14px; " for="costbox">Hide Product Cost :</label>
<input checked type="checkbox" id="costbox" onClick="costhide()"></h6>
</div>
<?php }?>
									<table width="100%" class="table table-bordered table-condensed table-hover table-striped dataTable" id="products_table">
										<thead>
								            <tr>
												<th>Product Image</th>
												<th>Product ID</th>
												<th>Update</th>
												<th class="col-sm-8" >Product Name</th>
												<th>Department</th>
												<th>Category</th>
												<th>Cash Price</th>	
                                               <!--  <th>Wholesale Price</th>	
                                                <th>Credit Price</th>										-->		
												<th id="td_cost">Product Cost</th>
												<th>All War. Qty.</th>
												
												
												<th>Action</th>
								            </tr>
								        </thead>
								        <tfoot>
												<th>Product Image</th>
												<th>Product ID</th>
												<th>Update</th>
												<th>Product Name</th>
												<th>Department</th>
												<th>Category</th>
												<th>Cash Price</th>
											<!-- 	<th>Product Cost</th>
												<th>Credit Price</th> -->
												<th id="td_cost">Product Cost</th>
												<th> Quantity</th>
												<th>Action</th>
								            </tr>
								        </tfoot>
									</table>
								</div>
							</div>
							<!-- end: DYNAMIC TABLE PANEL -->
						</div>
					</div>

                    <!-- end grid -->
                    
					
			</div>
			<!-- end: PAGE -->
		</div>
		<!-- end: MAIN CONTAINER -->
		<!-- start: FOOTER -->
		<div class="footer clearfix">
			<div class="footer-inner">
				<?php date("Y");?> Developed by: Sallelanka Solutions (pvt) Ltd.
			</div>
			<div class="footer-items">
				<span class="go-top"><i class="clip-chevron-up"></i></span>
			</div>
		</div>
		<!-- end: FOOTER -->
		<!-- start: RIGHT SIDEBAR -->
		<!-- end: RIGHT SIDEBAR -->
		<div id="event-management" class="modal fade" tabindex="-1" data-width="760" style="display: none;">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">Event Management</h4>
					</div>
					<div class="modal-body"></div>
					<div class="modal-footer">
						<button type="button" data-dismiss="modal" class="btn btn-light-grey">
							Close
						</button>
						<button type="button" class="btn btn-danger remove-event no-display">
							<i class='fa fa-trash-o'></i> Delete Event
						</button>
						<button type='submit' class='btn btn-success save-event'>
							<i class='fa fa-check'></i> Save
						</button>
					</div>
				</div>
			</div>
		</div>

		<!-- start ajax model -->
		<div id="ajax-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" style="display: none;"></div>
		<!-- end ajax model -->

		<!-- start: MAIN JAVASCRIPTS -->
		<?php $this->load->view("common/footer"); ?>
		<!-- end: MAIN JAVASCRIPTS -->
		<script type="text/javascript" src="<?php echo asset_url();?>/js/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="<?php echo asset_url();?>/js/dataTables.bootstrap.min.js"></script>
        <script>
		
	
		
		function search_by_custum_value(){
	//alert();
	products_load();
}
			jQuery(document).ready(function() {
				//TableData.init();
				products_load();
				
				
			
costhide();
//	alert(status);

$("#srh_sub_cat").select2();
$("#subcategory").select2();
$("#dep_id").select2();
$("#last_update_user").select2();
//last_update_user
	
			});
			
			
			
function costhide(){
	var table = $('#products_table').DataTable();
	if($("#costbox").is(':checked')){
	
	
	/*alert( 'Column index 3 is '+
	(table.column( 3 ).visible() === true ? 'visible' : 'not visible')
	);*/
	
	var status =(table.column( 7 ).visible() === true ? 'visible' : 'not visible');
	if(status=='visible'){
	table.column( 7 ).visible( false );
	
	//	alert(status);
	}else {
	table.column( 7 ).visible( true );
	
	//	alert(status);
	}
	
	}
	else{
	table.column( 7 ).visible( true );
	}
	}


			function products_load() {
				var category=$("#category").val();
					var srh_sub_cat=$("#srh_sub_cat").val();
						var subcategory=$("#subcategory").val();
					var search_name=$("#search_name").val();
						var dep_id=$("#dep_id").val();
						
							var update_status=$("#update_status").val();
								var last_update_user=$("#last_update_user").val();
							var pro_show_no=$("#pro_show_no").val();
					    $('#products_table').DataTable({
							
							"processing": true,
					        "serverSide": true,
					        "ajax": "<?php echo base_url('products/get_list_product')?>?category="+category+"&search_name="+search_name+"&srh_sub_cat="+srh_sub_cat+"&subcategory="+subcategory+"&dep_id="+dep_id+"&pro_show_no="+pro_show_no+"&update_status="+update_status+"&last_update_user="+last_update_user,
					        "bDestroy": true,
					        "iDisplayLength": 25,
					        "aLengthMenu": [[25, 50, 100, 250, 500], [25, 50, 100, 250,500]]
					    });

					}
			function print_barcode (product_id) {
				window.open('products/single_barcode/'+product_id, 'sma_popup', 'width=900,height=600,scrollbars=yes,menubar=yes,status=no,resizable=yes,screenx=0,screeny=0');
			}

			function product_delete(product_id) {

				var r = confirm("Are you sure you want to delete this item !");
				if (r == true) {
					products_load();
					$.ajax({
					    url : "<?php echo base_url('products/delete_product'); ?>",
					    type: "POST",
					    data : {product_id:product_id},
					    success: function(data)
					    {
	                            var obj = jQuery.parseJSON(data);
	                            if (obj.status==0) 
	                                {
	                                    $('div#error').html('<div class="alert alert-block alert-danger fade in"><button type="button" class="close" data-dismiss="alert">×</button><h4 class="alert-heading"><i class="fa fa-times-circle"></i> Error!</h4>'+obj.validation+'</div>');
	                                } 
	                                else
	                                {
	                                    set_message('Product notice!','Product permanent deleted successfully');
										products_load();
	                                };
					    }
	    			});
				}

			}
			
			
function enable_product(prouct_id){
	
	jQuery.ajax({
		type: "POST",
		url: "<?php echo base_url().'products/enable?product_id='?>"+prouct_id,
		cache: false,
		success: function(response)
       {
			displayNotice('page','Successfully Enabled !!');
			setTimeout(function(){
				//products_load();
			//	req.ajax.reload();
			products_load();
				}, 1000);
			}
		
		});	
	}
	
	
function disable_product(prouct_id){

	jQuery.ajax({
		type: "POST",
		url: "<?php echo base_url().'products/disable?product_id='?>"+prouct_id,
		cache: false,
		success: function(response)
       {
//		var price = $('#'+count).val();
//		var twoPlacedFloat = parseFloat(price).toFixed(2)
//		$('#'+count).val(twoPlacedFloat);
		displayNotice('page','Successfully Disabled !!');
//		setTimeout(resetfun(),30000);
 //location.reload();
		setTimeout(function(){
		//	req.ajax.reload();
		products_load();
			}, 1000);
		//products_load();
	    	}
		});
	
	}
	
		</script>
	</body>
	<!-- end: BODY -->
</html>