<?php
session_start();
$where 					= " WHERE 1=1 AND id ='".$_REQUEST['id']."'";
$next_page_condition 	= "";
$paging ="";
//$source = $gsi->getEnqQuoteJobStatusById($_REQUEST['id']);
$form_action	= "insert";

if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'insert'){	
	 utility::addslashesOnAllInput(array("query_string","department","referal_parent_mapping_id_pro"));
	 
  if($_REQUEST['page_action_product'] == "add"){		
	
    $pro_id 			= $_REQUEST['pro_id']; 
    $pro_temp_id 			= $_REQUEST['pro_temp_id']; 
    $stock_location 	= $_REQUEST['stock_location']; 
    $stock_ltion_qty 	= $_REQUEST['stock_ltion_qty']; 
    $stock_total_qty 	= $_REQUEST['stock_total_qty']; 
    $stock_re_level 	= $_REQUEST['stock_re_level']; 
    $stock_check_date 	= utility::setFormatedDate($_REQUEST['stock_check_date']); 
    $consumable_location 	= $_REQUEST['consumable_location']; 
	
	$created_on				= date("Y-m-d H:i:s");	
	$created_by				= $_SESSION['user_id'];
	$updated_by				= $_SESSION['user_id'];
	
	$sql="select * from product_stock where pro_id='".$pro_id."' AND stock_location='".$stock_location."'";
	$res=mysqli_query($conn,$sql);
	if(mysqli_num_rows($res)<=0){
    $sql= "INSERT INTO product_stock (pro_id,stock_location,stock_ltion_qty,stock_total_qty,stock_re_level,stock_check_date,consumable_location,created_on,created_by) VALUES('$pro_id','$stock_location','$stock_ltion_qty','$stock_total_qty','$stock_re_level','$stock_check_date','$consumable_location','$created_on','$created_by')";
    mysqli_query($conn,$sql);
	$pro_stock_id = mysqli_insert_id($conn);
	
	 if(count($_REQUEST['department'])>0){
			foreach($_REQUEST['department'] as $key => $department){
				$department                  = $_REQUEST['department'][$key];				

				if($department!=""){
				 $sql1= "INSERT INTO product_stock_dipartment_map (pro_stock_id,department) VALUES('$pro_stock_id','$department')";
					mysqli_query($conn,$sql1);
					
				}
			}
		} 
	       $_SESSION['info_message'] = "Item Stock added sucessfully";
	
	
		}else{?>
			
			<?$_SESSION['info_message'] = "This Stock Location Already Used";
		}
	}else{
	
	$id					= $_REQUEST['id'];
	$pro_id 			= $_REQUEST['pro_id']; 
    $stock_location 	= $_REQUEST['stock_location']; 
    $stock_ltion_qty 	= $_REQUEST['stock_ltion_qty']; 
    $stock_total_qty 	= $_REQUEST['stock_total_qty']; 
    $stock_re_level 	= $_REQUEST['stock_re_level']; 
    $stock_check_date 	= utility::setFormatedDate($_REQUEST['stock_check_date']); 
    $consumable_location 	= $_REQUEST['consumable_location']; 

	$updated_by				= $_SESSION['user_id'];
	

	$sql= "UPDATE product_stock SET pro_id = '$pro_id' ,stock_location = '$stock_location' ,stock_ltion_qty ='$stock_ltion_qty' ,stock_total_qty ='$stock_total_qty' ,stock_re_level ='$stock_re_level' ,stock_check_date ='$stock_check_date',consumable_location ='$consumable_location',updated_by ='$updated_by' WHERE id = $id";
    mysqli_query($conn,$sql);
	
	  if(count($_REQUEST['department'])>0){	
			foreach($_REQUEST['department'] as $key => $parent_product_group_name){	
				$department 				= $_REQUEST['department'][$key];			
				$referal_parent_mapping_id_pro 			= $_REQUEST['referal_parent_mapping_id_pro'][$key];	
				
				if(mysqli_num_rows(mysqli_query($conn,"SELECT * FROM product_stock_dipartment_map WHERE id = '$referal_parent_mapping_id_pro' ")) > 0){
					  $sql1= "UPDATE product_stock_dipartment_map SET department = '$department' WHERE id = '$referal_parent_mapping_id_pro' ";
				}else{
					 $sql1= "INSERT INTO product_stock_dipartment_map (pro_stock_id,department) VALUES('$id','$department')";
				}
				mysqli_query($conn,$sql1);
			}
		}
		$_SESSION['info_message'] = "Item Stock Updated sucessfully";
	} 
	
	header("Location: index?page=view_product_details&from=view_product&pro_temp_id=$pro_temp_id&id=$pro_id");
	exit();


}
###########################################  PAGING WITH PER PAGE  #####################################
$file_name		= "index"; // this is file name which is used during paging  , included at the bottom of the page
$table_name		= "item_management";
$paging_table_name	= $table_name;
$paging_query		= $where;
$join_query_for_paging = "SELECT * FROM $table_name  $where ";
include("paging/paging_query.inc.php");
############################################ END PAGING WITH PER PAGE  #######################################
 $query = "SELECT * FROM $table_name $where ";
$rs = mysqli_query($conn,$query);
$enq_row = mysqli_fetch_assoc($rs);
$enq_row = utility::validate_crypt_data($enq_row);


$pro_stock_id = utility::getTableFieldById("job","email","id",$job_id);
?>
<style>
.form-group .control-label{
	padding-top:0px;
}
.content{
	min-height: 0px;
}
.content-header h1{
	float:left;
	padding-bottom: 10px;
}
.card-primary{
	color:#dc4d01;
}
</style>
<section class="content-header">
  <div class="container-fluid">
  <div class="row">
  <?
		$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
		if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_item"){ 
			$query_string = str_ireplace("page=view_item_details", "page=view", $query_string);
			//$page_header = "Enquiry Details";
		}else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_product_details"){ 
			$query_string = str_ireplace("page=view_product_details", "page=view_product", $query_string);
			//$page_header = "Quotation Details";
		}else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_funeral"){ 
			$query_string = str_ireplace("page=view_enquiry_progress", "page=view_funeral", $query_string);
			$page_header = "Client Details";
		}else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_jobs_by_search"){ 
			$query_string = str_ireplace("page=view_enquiry_progress", "page=view_jobs_by_search", $query_string);
			$page_header = "Enquiry / Quotation / Client Details";
		}
  ?>
	<div class="col-sm-10">
	  <h1 style="float:left;clear:right;margin-top:0px;padding-bottom: 0;">
		Part Number - <span style="color:#dc4d01;"><? echo $enq_row["part_number"]; ?></span>
	  </h1>
	</div>
  <div class="col-sm-2">
  <? if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "payment"){  ?>
	<button type="button" id="back" name="back" value="back"  style="float:right;" class="btn btn-primary" onclick="window.location.href = '<?=$config->siteURL;?>/payment_management/index?<?=$query_string;?>'">Back</button>
  <? }else{ ?>
	<button type="button" id="back" name="back" value="back"  style="float:right;" class="btn btn-primary" onclick="window.location.href = 'index?<?=$query_string;?>'">Back</button>
  <? } ?>
  
  
  <? if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_funeral"){ ?>
  <a href="index?page=add_funeral&from=view_enquiry_progress&action=edit&j_id=<?=urlencode(utility::app_crypt($_REQUEST['id'],'e'));?>&id=<?=$_REQUEST['id'];?>" style="float:right;margin-right:5px;" class="btn btn-danger">Edit</a>
  <? }else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_celebrant"){ ?>
  <a href="index?page=add_celebrant&from=view_enquiry_progress&action=edit&j_id=<?=urlencode(utility::app_crypt($_REQUEST['id'],'e'));?>&id=<?=$_REQUEST['id'];?>" style="float:right;margin-right:5px;" class="btn btn-danger">Edit</a>
  <? }else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_product" || (isset($_REQUEST["from"]) && $_REQUEST['from'] == "view_product_details")){ ?>
   <a href="index?page=add_product&from=view_product_details&action=edit&&id=<?=$_REQUEST['id'];?>&pro_temp_id=<?=$enq_row['product_template_id'];?>" style="float:right;margin-right:5px;" class="btn btn-success">Edit</a>
  <? 
	}else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_jobs_by_search"){ 
		$is_enquiry = utility::getTableFieldById("job","is_enquiry","id",$_REQUEST['id']);
		$is_celebrant = utility::getTableFieldById("job","is_celebrant","id",$_REQUEST['id']);
		$is_funeral = utility::getTableFieldById("job","is_funeral","id",$_REQUEST['id']);
		if($is_funeral == 1){
  ?>
	<a href="index?page=add_funeral&action=edit&id=<?=$_REQUEST['id'];?>" style="float:right;margin-right:5px;" class="btn btn-danger">Edit</a>
  <? }else if($is_celebrant == 1 && $is_funeral == 0){  ?>
	<a href="index?page=add_celebrant&action=edit&id=<?=$_REQUEST['id'];?>" style="float:right;margin-right:5px;" class="btn btn-danger">Edit</a>
  <? }else if($is_enquiry == 1 && $is_celebrant == 0 && $is_funeral == 0){ ?>
	<a href="index?page=add&action=edit&id=<?=$_REQUEST['id'];?>" style="float:right;margin-right:5px;" class="btn btn-danger">Edit</a>
  <? } ?>
  <? } ?>
  
  <?
	if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_enquiry"){ 
		$query_string = str_ireplace("page=view", "page=view_enquiry_progress", $query_string);
		$is_celebrant_exist = utility::getTableFieldById("job","is_celebrant","id",$_REQUEST['id']);
		if($is_celebrant_exist == 0){
  ?>
	<button type="button" id="add_placement" name="add_placement" style="float:right;margin-right:5px;margin-bottom:5px;" class="hide btn btn-warning" onclick="window.location.href = 'index?action=move_to_quote&<?=$query_string;?>'">Move to Quote</button>
  <? 
	}
	}else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_celebrant"){ 
		$query_string = str_ireplace("page=view_celebrant", "page=view_enquiry_progress", $query_string);
  ?>
	<button type="button" id="add_placement" name="add_placement" style="float:right;margin-right:5px;margin-bottom:5px;" class="btn btn-warning" onclick="window.location.href = 'index?action=move_to_job&<?=$query_string;?>'">Move to Client</button>
  <? 
	}else if(isset($_REQUEST["from"]) && $_REQUEST["from"] == "view_jobs_by_search"){ 
		$query_string = str_ireplace("page=view_jobs_by_search", "page=view_enquiry_progress", $query_string);
		$is_celebrant_exist = utility::getTableFieldById("job","is_celebrant","id",$_REQUEST['id']);
		$is_funeral_exist = utility::getTableFieldById("job","is_funeral","id",$_REQUEST['id']);
		if($is_celebrant_exist == 0){
  ?>
		<button type="button" id="add_placement" name="add_placement" style="float:right;margin-right:5px;margin-bottom:5px;" class="btn btn-warning" onclick="window.location.href = 'index?action=move_to_quote&<?=$query_string;?>'">Move to Quote</button>
  <? 
		}else if($is_funeral_exist == 0){
  ?>
		<button type="button" id="add_placement" name="add_placement" style="float:right;margin-right:5px;margin-bottom:5px;" class="btn btn-warning" onclick="window.location.href = 'index?action=move_to_job&<?=$query_string;?>'">Move to Client</button>
  <? } } ?>
  </div>
  </div>
  </div>
</section>
<?
	
	$query1 = "SELECT * FROM  job_enquiry_mapping WHERE job_id ='".$_REQUEST['id']."' ";
	$rs1 = mysqli_query($conn,$query1);
	$enq_row1 = mysqli_fetch_assoc($rs1);
	$enq_row_mapp = utility::validate_crypt_data($enq_row1);
?>
<section class="content">
	<div class="container-fluid">
	<div class="row">
		<div class="col-lg-12 no-padding">
		<div class="row">
			<!----------------------- Message ------------------------------->
			      <?php if(isset($_SESSION['info_message'])) { ?>
						<script>
							$(document).ready(function(){
								Toastify({
									text: "<?php echo $_SESSION['info_message']; ?>",duration: 4000,close: true,gravity: "top",position: 'right',backgroundColor: "#28a745",style: {borderBottom: "3px solid white",},
								}).showToast();
								<?php unset($_SESSION['info_message']); ?>
							});
						</script>
					<?}?>
			<!----------------------- End Message ------------------------------->
			<!-- general form elements -->
			<? 
				$col_width = 12;
			?>
			<div class="col-lg-4 col-md-4 col-sm-12" style="/* min-height:700px; */">
              <div class="scrollbar-default box box-warning card" style="height: 310px;overflow: hidden;overflow-y: scroll;">
                 <div class="box-body">
					<? //if($enq_row["is_funeral"] != 1){ ?>
					<h4 class="" style="margin-top: 0; margin-bottom: 0;color:#9c4893;">General</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
					<div class="">
					  <div class="col-sm-12">
					  <label for="Name" class=" control-label"> Part Number : </label>
						<span class="text-bold  text-primary"><?=$enq_row['part_number'];?></span>
					  </div>
					</div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Product Description</label>
						<?php echo $enq_row["product_description"]
								
						?>
					  </div>
					</div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Part Status</label>
						<?php echo $enq_row["part_status"]
								
						?>
					  </div>
					</div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Usual Source</label>
						<?php echo $enq_row["usual_source"]
								
						?>
					  </div>
					</div>
					
                  </div> 
				  <div class="box-body">
					<? //if($enq_row["is_funeral"] != 1){ ?>
					<h4 class="" style="margin-top: 0; margin-bottom: 0;color:#9c4893;">Manufacture</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
					<div class="">
					  <div class="col-sm-12">
					  <label for="Name" class=" control-label"> Drawing Number </label>
						<span class="text-bold  text-primary"><?=$enq_row['drawing_number'];?></span>
					  </div>
					</div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Drawing Issue</label>
						<?php echo $enq_row["drawing_issue"]
								
						?>
					  </div>
					</div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Part Weight</label>
						<?php echo $enq_row["net"]
								
						?>
					  </div>
					</div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Recycle Code</label>
						<?php echo $enq_row["recycle_code"]
								
						?>
					  </div>
					</div>
                  </div>
              </div><!-- /.box -->
            </div><!-- /.box -->
			
			<div class="col-lg-4 col-md-4 col-sm-12" style="/* min-height:700px; */">
              <div class=" scrollbar-default box box-success card" style="height: 310px;overflow: hidden;overflow-y: scroll;">
					<div class="row"> 
					
						<div class="col-12"> 
						 <div class="col-sm-12">
						  <label for="" class=" control-label">Barcode</label><br/>
							<?php 
							$barcode = $enq_row['scrap_percent'];
							if ($barcode != '') {
								$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
								$img = base64_encode($generator->getBarcode($barcode, $generator::TYPE_CODE_128));
								$src_img = "data:image/png;base64," . $img;
								echo '<img src="data:image/png;base64,' . $img . '"/>
									  <input type="button" class=" btn btn-primary" style="margin-left:20px;" value="Print Barcode" onclick="print_barcode();"/>
									  <br/><span style="font-size:14px;font-weight:500;position:relative;">'.$barcode.'</span>';
							} else {
								echo "No Barcode Value";
							}
							?>
                          <script type="text/javascript">
							function print_barcode(){
								var WinPrint = window.open('', '', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');
								WinPrint.document.write('<div style="text-align:center;"><?php echo $enq_row["part_number"];?><br/><br/><img src="<?php echo $src_img;?>"/><br/><span style="font-size:14px;font-weight:500;position:relative;"><?php echo $barcode;?></span></div>');
								WinPrint.document.close();
								WinPrint.focus();
								WinPrint.print();
								WinPrint.close();
							}
						</script>
								
					    </div>
							<div id="" class="mt-2">
								<?
								
								$dir = "../product_images/";
								$result = mysqli_query($conn, "SELECT id, product_image FROM item_images WHERE product_id='" . $enq_row['id'] . "'");
								?>
								<div class=" table-responsive" style="height: auto;">
									<? if($result>0){ ?>
									<div class="box box-primary" id="overflow_div">
									<!-- Start  records header -->
									<table id="example1" class="table table-bordered table-striped">
										<thead>
											<tr>
												<th>Item Images</th>
												
											</tr>
										</thead>
										<tbody>
										<?php
											while ($row = mysqli_fetch_assoc($result)) {
												$row = utility::validate_crypt_data($row);
												$product_images = $row['product_image'];
												$product_images_id = $row['id'];

												if (is_file($dir . $product_images)) {
													$image_src = "../" . $dir . $product_images;
												} else {
													$image_src = "placeholder.png";
												}
											?>
										<!-- Start data -->
										<tr id="image_record_no_<?=$row['id'];?>">
												<td>
													<a href="<?= $image_src ?>" target="_blank">
														<img id="image-item" src="<?= $image_src ?>" width="100">
													</a>
												</td>
												<td>
													<span href="" class="image_delete" alt="<?=$row['id'];?>" data-product_image="<?=$row['product_image'];?>" style="color:#007bff;cursor:pointer"><i class="fa fa-fw fa-trash text-danger"></i></span>
													<i class="fas fa-sync-alt fa-spin" style="display:none;" id="delete_image_load_<?=$row['id'];?>"></i>
													<i class="fa fa-check" id="delete_image_done_<?=$row['id'];?>" style="color:#bad23a;font-size: 20px;display:none;"></i>
												</td>
										</tr>
										<!-- End data -->
										<? }?>
										
										</tbody>
									</table>
									</div>
									<? }else{ ?>
									<div class="box box-primary p-15">No Images found...</div>
									<? } ?>
								</div>					
							</div>
						</div>
					</div>
              </div><!-- /.box -->
            </div><!-- /.box -->
			
			<div class="col-lg-4 col-md-4 col-sm-12" style="/* min-height:700px; */">
              <div class=" scrollbar-default box box-success card" style="height: 310px;overflow: hidden;overflow-y: scroll;">
                
                  <div class="box-body">
					<h4 class="" style="margin-top: 0; margin-bottom: 0;color:#9c4893;">Pricing</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class="control-label">Standard Cost (£)</label>
							<? echo ($enq_row["standard_cost_ebq"]); ?>
						  </div>
						</div>
						  <div class="">
							  <div class="col-sm-10">
							  <label for="" class=" control-label">Sale Price</label>
								<? echo $enq_row["unit_cost"]; ?>
							  </div>
						</div>
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class=" control-label">Preferred Suppiler</label>
							<?php echo $gsi->getSuppliersById($enq_row["type_2"]); ?>
						  </div>
						</div>
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class=" control-label">Purchase Lead Time</label>
							<?php echo $enq_row["uom"]; ?>
						  </div>
						</div>
					   <div class="">
					      <div class="col-sm-10">
							  <label for="" class=" control-label">Purchase Price</label>
								<?php echo $enq_row["scrap_value"]?>
						  </div>
					   </div>
					   
					  
                  </div><!-- /.box-body -->
                <div class="box-body">
					<h4 class="" style="margin-top: 0; margin-bottom: 0;color:#9c4893;">Warehousing</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class="control-label">Pack Quantity</label>
							<? echo ($enq_row["pack_quantity"]); ?>
						  </div>
						</div>
						  <div class="">
							  <div class="col-sm-10">
							  <label for="" class=" control-label">Pack Weight</label>
								<? echo $enq_row["pack_weight"]; ?>
							  </div>
						</div>
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class=" control-label">Pallet Quantity</label>
							<?php echo ($enq_row["nominal_code_sales"]); ?>
						  </div>
						</div>
						
					  
                  </div><!-- /.box-body -->
               
              </div><!-- /.box -->
            </div>
			
		</div>
		</div>
	</div>
	</div>
</section>	

<section class="content">

	
  <div class="row ">
	<div class="col-lg-12">
	<div class="card card-success card-tabs">
	<div class="card-header p-0 pt-1 border-bottom-0">
		<ul class="nav nav-tabs" id="main_products_quotations_tabs" role="tablist">
		<li class="nav-item active">
		<a class="nav-link  text-dark text-bold" id="custom-tabs-three-home-tab" data-toggle="pill" href="#custom-tabs-three-home" role="tab" aria-controls="custom-tabs-three-home" aria-selected="true">Bill Of Materials</a>
		</li>
		
		<li class="nav-item ">
		<a class="nav-link text-dark text-bold" id="instalation_tabs1-tab" data-toggle="pill" href="#instalation1_tabs" role="tab" aria-controls="instalation_tabs1" aria-selected="false">Inventory</a>
		</li>
		
		<li class="nav-item hide">
		<a class="nav-link text-dark text-bold" id="instalation_tabs2-tab" data-toggle="pill" href="#instalation_tabs2" role="tab" aria-controls="instalation_tabs2" aria-selected="false">Supplier</a>
		</li>
		<li class="nav-item hide">
		<a class="nav-link text-dark text-bold" id="instalation_tabs3-tab" data-toggle="pill" href="#instalation_tabs3" role="tab" aria-controls="instalation_tabs3" aria-selected="false">Orders</a>
		</li>
		</ul>
	</div>
	<div class="card-body">
		<div class="tab-content" id="main_products_quotations_tabsContent">
			<div class="tab-pane fade active show" id="custom-tabs-three-home" role="tabpanel" aria-labelledby="custom-tabs-three-home-tab">
				
				<? $product_id = $enq_row['id'];
				
				  include("view_product_group.inc.php");?>
			</div>
			
			<div class="tab-pane fade " id="instalation1_tabs" role="tabpanel" aria-labelledby="instalation1_tabs-tab">
				<?$frontEndURL = $config->frontEndURL; include("add_inventory_with_ajax.inc.php");?>
			</div>
			
			<div class="tab-pane fade " id="instalation_tabs2" role="tabpanel" aria-labelledby="instalation_tabs2-tab">
				<section class="content-header ">
					<h4 style="float:right;">
						<a href="" data-toggle="modal" data-target="#myModal" class="btn btn-primary add_new_task" alt="<?=$_REQUEST['id'];?>" data-company_reference="<?=ucwords($enq_row['client_aggrement']);?>">Add</a>
						
					</h4>
					
				</section>
				<?//$frontEndURL = $config->frontEndURL;include("add_product_supplier.inc.php"); ?>
				<? 
				$query = "SELECT * FROM assign_product_supplier WHERE  pro_id= '".$_REQUEST['id']."' ORDER BY id DESC LIMIT $eu, $limit";
				$sql=mysqli_query($conn,$query);
				$result=mysqli_num_rows($sql);
				if($result>0){?>
					<div class="table-responsive">
					 <table id="example1" class="table table-bordered table-striped">
						<thead>
						  <tr>
							<th>Item </th>
							<th>Supplier </th>
							<th>Supplier Code</th>
							<th>Price</th>
							<th>Amount</th>
							<th>UOM</th>
							<th>Edit</th>
						  </tr>
						</thead>
						<tbody>
							<?
								while($row =mysqli_fetch_array($sql)){ 
								$row=utility::validate_crypt_data($row);
							?>
						  <tr>
						  
							<td><?php echo $gsi->getProductMainById($row['pro_id']);?></td>
							<td><?php echo $gsi->getSuppliersById($row['sup_id']);?></td>
							<td><?php echo $row['supplier_code'];?></td>
							<td><?php echo $row['price'];?></td>
							<td><?php echo $row['purchaseAmount'];?></td>
							<td><?php echo ucfirst($row['purchaseUOM']);?></td>
							<td> 
								<a href="" data-toggle="modal" data-target="#myModal" class="edit_task" alt="<?=$row['id'];?>" data-client_id="<?=$row['sup_id'];?>"><i class="fa fa-fw fa-edit text-primary"></i></a>
							</td>
						  </tr>
							<? } ?>
							
						</tbody>
					 </table>
					 </div>
					 <? }else{ ?>
						No Supplier found...
					 <? } ?>
			</div>
			<div class="tab-pane fade " id="instalation_tabs3" role="tabpanel" aria-labelledby="instalation_tabs3-tab">
				<?//$frontEndURL = $config->frontEndURL;include("add_product_stock_location.inc.php"); ?><h1>Pending</h1>
			</div>
	   </div>
	</div>
	</div>
 </div>
 </div>

</section>
<style>
	#overflow_div::-webkit-scrollbar
    {
      width: 5px;  /* for vertical scrollbars */
      height: 5px; /* for horizontal scrollbars */
    }
 
    #overflow_div::-webkit-scrollbar-track
    {
      background:#E7E8E9;
    }
 
    #overflow_div::-webkit-scrollbar-thumb
    {
      background: #3c8dbc;
    }
	#overflow_div{
		height:300px;
		overflow-y: auto;
	}
</style>
<script type="text/javascript">
			

$(document).ready(function() {
	$(".add_new_task").click(function(){	
		//$("#myModalLabel").text("Website");
		var company_reference = $(this).attr("data-company_reference");	
		$("#myModalLabel").html("Asign Item to supplier");
		var hide_top_left = "&hide_top=1&hide_left=1";
		var from = "&from=view_enquiry_progress";
		var pro_id = $(this).attr("alt");
		$('.modal-dialog').css({"max-width":"65%"});
		$(".modal_iframe").attr("src","<?=$config->frontEndURL?>/admin/supplier_management/index?page=add_product&pro_id="+pro_id+hide_top_left+from);
	});
	$(".edit_task").click(function(){
		//$("#myModalLabel").text("Website");
		var company_reference = $(this).attr("data-company_reference");	
		$("#myModalLabel").html("Edit Supplier ");
		var hide_top_left = "&hide_top=1&hide_left=1";
		var sup_id = $(this).attr("data-client_id");	
		var from = "&from=view_enquiry_progress";
		var task_id = $(this).attr("alt");	
		$('.modal-dialog').css({"max-width":"65%"});
		$(".modal_iframe").attr("src","<?=$config->frontEndURL?>/admin/supplier_management/index?page=add_product&action=edit&id="+task_id+"&sup_id="+sup_id+hide_top_left+from);
	});
	
	$(".close_button").click(function(){
		$(".modal_iframe").attr("src","");
		location.reload();
	});
    $('#main_products_quotations_tabs a').click(function (e) {
        localStorage.setItem('selectedTab', $(e.target).attr('href'));
    });

    // On page load
    $(document).ready(function() {
        var selectedTab = localStorage.getItem('selectedTab');
        if (selectedTab) {
            $('#main_products_quotations_tabs a[href="' + selectedTab + '"]').tab('show');
        }
    }); 

    $("#submit").on("click", function(event) {
        event.preventDefault();
        $('#main_products_quotations_tabs a[href="#instalation_tabs"]').tab('show');
        // $('#custom-tabs-three-home-tab').css('background-color', 'green');
    });
	$('#ShowModal1').on('show.bs.modal', function (e) {
	  create_group_tree1(e.relatedTarget.attributes.alt.value);
   })
	
   function create_group_tree1(id) {
    $.ajax({
        url: site_url + "/modules/daynmic_product_management/index.php?page=ajax_actions&action=get_group_list&id=" + id,
        method: "POST",
        dataType: "json",
        success: function(data) {
            $('#group_tree1').treeview({
                data: data,
                levels: 1,
                collapseIcon: "fa fa-angle-down",
                expandIcon: "fa fa-angle-right",
                nodeIcon: "fa fa-share-alt-square",
                showBorder: false,
                enableLinks: true,
                <?php if($enq_row['current_product_range'] == 1) : ?>
                    backColor: '#1e732d',
                    color: 'white',
                <?php else : ?>
                    backColor: 'white',
                    color: 'black',
                <?php endif; ?>
				 <?php if($enq_row['part_checked'] == 0) : ?>
                   
                    color: 'red',
                <?php endif; ?>
                preventUnselect: true,
                showTags: true
            });
        },
        error: function(jqXHR, textStatus, errorThrown) {
            alert("Something went wrong");
        }
    });
	}
		<?php if($enq_row['current_product_range'] == 1){ ?>
			$('#group_tree1').on('mouseenter', '.list-group-item', function() {
				$(this).css({
					'cursor': 'pointer',
					'background-color': '#7dc0c6' // Change to desired hover background color
				});
			});

			$('#group_tree1').on('mouseleave', '.list-group-item', function() {
				$(this).css({
					'cursor': 'auto',
					'background-color': '#1e732d'
				});
			});
			
		<?php } ?>
		
		
	$(".image_delete").click(function(){	
		if(confirm('Are you sure! You want to delete') == true){
			var imageid = $(this).attr("alt");
			var product_image = $(this).attr("data-product_image");
			if(imageid != ""){
				$('#delete_image_load_'+imageid).show();
				var form_data   = {'imageid':imageid,'product_image':product_image};       
				$.ajax({
					async: true,
					type: "POST",
					//url: site_url+"/modules/item_management/index.php?page=ajax_actions&action=delete_item_images",
					url: site_url+"/item_management/index?page=ajax_actions&action=delete_item_images",
					data: form_data,
					success: function(result){    
						var resultObj = jQuery.parseJSON(result); 
						if(resultObj.status == "success"){
							$('#delete_image_done_'+imageid).show();
							$('#delete_image_load_'+imageid).hide();
							
							setTimeout(function() {
								$('#delete_image_done_'+imageid).hide();
								$('#image_record_no_'+imageid).remove();
							},1000);
						}
					}
				});
			}
		}else{
			return false;
		}
	});
});

</script>