<?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		= "product_main";
$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_product"){ 
			$query_string = str_ireplace("page=view_product_details", "page=view_product", $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;">
		Item Template Name - <span style="color:#dc4d01;"><? echo $gsi->getProductTempateById($enq_row["product_template_id"]); ?></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;">
                <form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_placement&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
                  <div class="box-body">
					<? //if($enq_row["is_funeral"] != 1){ ?>
					<div class="">
                      <div class="col-sm-12">
                      <label for="Company Name" class=" control-label">Item Name :</label>
						<? echo $enq_row["name"]; ?>
                      </div>
                    </div>
					<div class="">
					  <div class="col-sm-12">
					  <label for="Name" class=" control-label"> Part Number : </label>
						<span class="text-bold  text-primary"><?=$p_name = utility::getTableFieldById("product_name","group_number","id",$enq_row['part_number_id']);?></span>
					  </div>
					</div>
					<div class="">
                      <div class="col-sm-12">
                      <label for="Company Name" class=" control-label">Part Number Category :</label>
						<?php echo $gsi->getCategoryById($enq_row["part_number_category"]);?>
                      </div>
                    </div>
					<? //} ?>
					
					<div class="">
					  <div class="col-sm-12">
					  <label for="" class="control-label">Part Number Revision :</label>
						<?php echo $enq_row["part_number_revision"]
								
						?>
					  </div>
					</div>
					
					 <div class=" ">
						  <div class="col-sm-12">
						  <label for="" class=" control-label">Bill of Materials :</label>
						  <?if($enq_row['part_number_id'] !=''){?>
						  <a href='#' data-toggle='modal' class="p-1 btn-success" data-target='#ShowModal1' id="" alt="<?=$enq_row['part_number_id']?>"><?=$p_name = utility::getTableFieldById("product_name","group_number","id",$enq_row['part_number_id']);?></a><?}?>
						  </div>
					  </div>
					 <?$sql = "SELECT parent_id FROM product_link WHERE child_id = '".$enq_row['part_number_id']."'";
						$result = mysqli_query($conn, $sql);

						// Checking if we have any rows
						if (mysqli_num_rows($result) > 0) {
							?>
							<div class="mt-1">
								<div class="col-sm-10">
									<label for="" class="control-label">Where Used :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
									<?php
									// Loop through the rows
									while ($row = mysqli_fetch_assoc($result)) {
										?>
										<a href='#' data-toggle='modal' class="p-1 btn-info" data-target='#ShowModal' id="" alt="<?= $row['parent_id'] ?>"><?= $gsi->getProductGroupById($row['parent_id']);?></a>
										<?php
									}
									?>
								</div>
							</div>
							<?php
						} else {?>
					    	<div class="">
							    <div class="col-sm-10">
									<label for="" class="control-label">Where Used :</label>
									  Not Used
								</div>
							 </div>
						<?}?>
					  
					<div class=" hide">
                      <div class="col-sm-10">
                        <label for="" class=" control-label">Item Group Name :</label>
						<? echo $gsi->getProductGroupById($enq_row["product_group"]); ?>
                      </div>
                    </div>
					<div class=" hide">
                      <div class="col-sm-10">
                      <label for="" class=" control-label"> Item Short Code :</label>
						<? echo ($enq_row["product_group_short_code"]); ?>
                      </div>
                    </div>
					<div class=" hide">
					  <div class="col-sm-10">
					  <label for="" class=" control-label">Item Groups List :</label>
						<?php //echo $gsi->getParentProductGroupById($enq_row["parent_product_groups"]); ?>
					  </div>
					</div>
                  </div><?php
						$fetch_attr = "SELECT * FROM product_attributes WHERE pro_template_id ='".$_REQUEST['pro_temp_id']."' ORDER BY id";		   
						$sql_attr = mysqli_query($conn, $fetch_attr);
						$result_attr = mysqli_num_rows($sql_attr);

						if($result_attr > 0) {?>
						<div class="text-primary col-lg-12">
						<strong>Attributes Fields</strong>
							<hr style="background-color:#fa4a14; height:0.9px;">
						</div>
						<div class="row">
							<?php while($row = mysqli_fetch_array($sql_attr)) { 
								$row = utility::validate_crypt_data($row);
								$product_id = $enq_row['id']; 
								$attribute_id = $row['id'];
								$fetch_attr_value = "SELECT pro_attr_value FROM product_attributes_value WHERE product_id = '$product_id' AND pro_attr_id = '$attribute_id'";
								$sql_attr_value = mysqli_query($conn, $fetch_attr_value);
								$row_attr_value = mysqli_fetch_assoc($sql_attr_value);
								$existing_value = isset($row_attr_value['pro_attr_value']) ? $row_attr_value['pro_attr_value'] : '';

								?>
								<div class="col-lg-12">
								 <div class="col-sm-12">
									<label class="control-label"><?= ucwords($row['attribute_name']); ?> :</label>
									<?php if ($row['data_type'] == 'INTEGER') { ?>
										<span><?= $existing_value ?></span>
									<?php } else if ($row['data_type'] == 'TEXT') { ?>
										<span><?= $existing_value ?></span>
									<?php } else if ($row['data_type'] == 'DATETIME') { ?>
										<span><?= $existing_value ?></span>
									<?php } else { ?>
										<span><?= $existing_value ?></span>
									<?php } ?>
								</div>
								</div>
							<?php } ?>
						</div>
					<?php } ?>
<!-- /.box-body -->
                </form>
              </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;">
                <form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_placement&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
                  <div class="box-body">
					 
						<div class="">
						  <div class="col-sm-10">
						  <label for="Profession" class=" control-label">Stock Part :</label>
							<?php echo ($enq_row["stock_part"]==1) ? "Yes" : "No"; ?>
						  </div>
						</div>
						  <div class="">
						  <div class="col-sm-10">
						  <label for="" class="control-label">Is Taxable :</label>
							<?php echo ucfirst(Keycode::getkeycodeById($enq_row["is_taxable"]));?>
						  </div>
						</div>
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class="control-label">Sales Item Code :</label>
							<? echo ($enq_row["sales_item_code"]); ?>
						  </div>
						</div>
						  <div class="">
							  <div class="col-sm-10">
							  <label for="" class=" control-label">Sales Price :</label>
								<? echo $enq_row["sales_price"]; ?>
							  </div>
						</div>
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class=" control-label">Currency :</label>
							<?php echo $gsi->getCurrencyById($enq_row["currency"]); ?>
						  </div>
						</div>
						<div class="">
						  <div class="col-sm-10">
						  <label for="" class=" control-label">Costing Method :</label>
							<?php echo Keycode::getkeycodeById($enq_row["costing_method"]); ?>
						  </div>
						</div>
					   <div class=" hide">
					      <div class="col-sm-10">
							  <label for="" class=" control-label">Labour Hours :</label>
								<?php echo $enq_row["labour_hours"]?>
						  </div>
					   </div>
					  <div class=" hide"> 
						 <div class="col-sm-10">
							  <label for="" class=" control-label">Labour Total Cost :</label>
								<?php echo $enq_row["labour_hours_total_parts"] ?>
						  </div>
					   </div>
					 <div class=" hide">
					    <div class="col-sm-10">
						  <label for="" class=" control-label">Components Costs :</label>
							<?php echo $enq_row["components_costs"] ?>
					    </div>
					 </div>
					 <div class=" hide">
						   <div class="col-sm-10">
							  <label for="" class=" control-label">Total Cost</label>
								<?php echo ($enq_row["total_cost"]==8) ? "Yes" : "No"; ?>
						  </div>
					  </div>
					 
					  <div class="">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Part Checked :</label>
							<?php echo ($enq_row["part_checked"]==1) ? "Yes" : "No"; ?>
						</div>
					  </div>
					  <?if($enq_row["part_checked"]==1){?>
					  <div class="">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Part Checked Date :</label>
							<?php echo utility::getFormatedDate($enq_row['part_checked_date'])?>
						</div>
					  </div>
					  <?}else if($enq_row["part_checked"]==2){?>
					  <div class="">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Part Attention Notes :</label>
							<?php echo $enq_row["part_attention_notes"]?>
						</div>
					  </div>
					  <?}?>
					   <div class="">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Current Item Range :</label>
							<?php echo ($enq_row["current_product_range"]==1) ? "Yes" : "No"; ?>
						</div>
					   </div>
					   <div class="">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Is Active :</label>
							<?php echo ($enq_row["is_active"]==1) ? "Yes" : "No"; ?>
						</div>
					   </div>
                  </div><!-- /.box-body -->
                </form>
              </div><!-- /.box -->
            </div>
			
			<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;">
                <form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_placement&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
                  <div class="box-body">
					  <div class="form-group">
					   <div class="col-sm-10">
						  <label for="" class=" control-label">Barcode</label><br/>
							<?php 
								$barcode =$enq_row['barcode'];
								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.'"/>';}else{ echo"No Barcode Value";}?>
					    </div>
					  </div>
					  <div class="">
					 <div class="col-sm-12">
						  <label for="" class=" control-label">Description External : </label>
							<?php echo $enq_row["description_external"]?>
					  </div>
					  </div>
					 <div class="">
					    <div class="col-sm-12">
						  <label for="" class=" control-label">Description Internal :</label>
							<?php echo $enq_row["description_internal"]?>
					    </div>
					  </div>
					  <?if($enq_row['qr_code']!=''){?>
					   <div class=" form-group">
						<div class="col-sm-10">
						  <label for="" class=" control-label">QR Code :</label>
							<?php
							if($enq_row['qr_code']==''){
								$qr_code="no_image.png";
							}else{
								$qr_code=$enq_row['qr_code'];
							}?>
								<a href="../../product_images/<?php echo $qr_code;?>"
								target='blank'><img
								src="../../product_images/<?php echo $qr_code;?>"
								id="product_image_preview" name="product_image_preview"
								width="100px;" style="margin-top:10px;"></a>
						</div>
					   </div>
					  <?}if($enq_row['image1']!=''){?>
					   <div class="form-group ">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Image 1 :</label>
							<?php
							if($enq_row['image1']==''){
								$image1="no_image.png";
							}else{
								$image1=$enq_row['image1'];
							}?>
								<a href="../../product_images/<?php echo $image1;?>"
								target='blank'><img
								src="../../product_images/<?php echo $image1;?>"
								id="product_image_preview" name="product_image_preview"
								width="100px;" style="margin-top:10px;"></a>
						</div>
					   </div>
					  <?}if($enq_row['image2']!=''){?>
					   <div class=" form-group">
						<div class="col-sm-10">
						  <label for="" class=" control-label">Image 2 :</label>
							<?php
							if($enq_row['image2']==''){
								$image2="no_image.png";
							}else{
								$image2=$enq_row['image2'];
							}?>
								<a href="../../product_images/<?php echo $image2;?>"
								target='blank'><img
								src="../../product_images/<?php echo $image2;?>"
								id="product_image_preview" name="product_image_preview"
								width="100px;" style="margin-top:10px;"></a>
						</div>
					   </div>
					  <?}?>
                  </div><!-- /.box-body -->
                </form>
              </div><!-- /.box -->
            </div><!-- /.box -->
		</div>
		</div>
	</div>
	</div>
	
  <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">
		<a class="nav-link active 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 hide">
		<a class="nav-link text-dark text-bold" id="instalation_tabs-tab" data-toggle="pill" href="#instalation_tabs" role="tab" aria-controls="instalation_tabs" aria-selected="false">Extra Info</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">
		<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">
		<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">
				<?include("view_product_group.inc.php");?>
			</div>
			<div class="tab-pane fade hide" id="instalation_tabs" role="tabpanel" aria-labelledby="instalation_tabs-tab">
				<?$frontEndURL = $config->frontEndURL;include("add_extra_info_with_ajax.inc.php"); ?>
			</div>
			<div class="tab-pane fade " id="instalation1_tabs" role="tabpanel" aria-labelledby="instalation1_tabs-tab">
				<?$frontEndURL = $config->frontEndURL;include("add_product_stock_location.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>
				
			</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>

<div class="modal fade" id="ShowModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable" role="document" style="width:75%; max-width:80%">
	<div class="modal-content">
	  <div class="modal-header">
		<h5 class="modal-title" id="exampleModalScrollableTitle" style="float:left">Group Tree</h5>
		<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		  <span aria-hidden="true">&times;</span>
		</button>
	  </div>
	  <div class="modal-body">
		<!--<h5 class="modal-title" id="exampleModalScrollableTitle">Q->Quantity, C->Cost, LC->Labour Cost, TC->Total Cost, TLC->Total Labour Cost</h5>-->
		<div id="group_tree" style="">
		</div>
	  </div>
	  <div class="modal-footer">
		<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
		
	  </div>
	</div>
  </div>
</div>
<div class="modal fade" id="ShowModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable" role="document" style="width:75%; max-width:80%">
	<div class="modal-content">
	  <div class="modal-header">
		<h5 class="modal-title" id="exampleModalScrollableTitle" style="float:left">Group Tree</h5>
		<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		  <span aria-hidden="true">&times;</span>
		</button>
	  </div>
	  <div class="modal-body">
		<!--<h5 class="modal-title" id="exampleModalScrollableTitle">Q->Quantity, C->Cost, LC->Labour Cost, TC->Total Cost, TLC->Total Labour Cost</h5>-->
		<div id="group_tree1" style="">
		</div>
	  </div>
	  <div class="modal-footer">
		<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
		
	  </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:150px;
		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 } ?>
});

</script>