<!DOCTYPE html>
<html lang="en">
<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Chandrani Pearls Gold Billing</title>
  <link rel="icon" type="image/jpg" href="dist/img/favicon.png?v=2">
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">

    <!-- -=---- searchable dropdown link css ------ -->
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
   <!-- -=---- searchable dropdown link css ------ -->

  
  <!-- DataTables -->
  <link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
	<link rel="stylesheet" href="dist/css/custom.css?v=2">
	<style>
	
	.bg-light{
	   background-color:#f2f2f2 !important;
	   padding:10px;
	   margin-bottom:10px;
	}
	
	.bg1{
	    float:left;
	    height:50px;
	    width:100%;
	 background-color:#e6f2ff;
	 padding:5px 10px;
	}
	
	.bg2{
	    float:left;
	    width:100%;
	    height:50px;
	 background-color:#cce6ff; 
	  padding:5px 10px;
	}
	
	
	
	    label {
    display: inline-block;
    margin-bottom: 0rem;
}

.text-primary{
    color:#0a6abb !important;
}

button:focus{

outline: none;

}

	</style>

</head>
	


<body class="hold-transition sidebar-mini" onload="get_data(),get_color_select(),get_size_select(),get_sol_color_select(),get_sol_size_select(),stone_div(),diamon_div(),solitaire_div()">
	
<div class="wrapper">




  <!-- Navbar -->
    <?php include ("topheader.php"); ?>
  <!-- Main Sidebar Container -->
    <?php include ("sidemenu.php"); ?>








  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
 
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h3>Insert Product</h3>
                </div>
                <div class="col-sm-6">
                    
                </div>
            </div>
        </div>
    </section>
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            
            <!-- /.card -->
            <div class="card">
            
              
              <!-- /.card-header -->
			  
	
			  
              <div class="card-body">

<?php 

$i = base64_decode($_REQUEST['i']);
$serial_no = base64_decode($_REQUEST['j']);

$fetch_data = $Mainclass->Fetch_individual_data("gold_temp_product_master","*","Temp_Id='".$i."'");

if($i==""){

$a = "";

}

else{

$a = "disabled";

}


$fetch_data1 = $Mainclass->Fetch_individual_data("design_code_master","*","ParentId='".$fetch_data['ParentId']."'");

$product_count = $Mainclass->num_check("gold_temp_product_master","*","Temp_Id='".$i."'");

?>




<div class="row">
    
    
<input type="hidden" id="new_id" name="new_id" value="<?php echo $i?>">
<input type="hidden" id="SLN" name="SLN" value="<?php echo $fetch_data1['SLN']?>">    
<input type="hidden" id="has_d" name="new_id" value="<?php echo $fetch_data['has_diamond']?>">
<input type="hidden" id="has_s" name="SLN" value="<?php echo $fetch_data['has_solitaire']?>">  


              
<div class="col-3" id="form_select">
<div class="form-group">
<label>Product Category <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="p_cate" name="p_cate" onchange="remove_error(),get_design_code(),get_data(),val_val1()" <?php echo $a ; ?>>
<option value="">--- please select---</option>
<?php
$fetch_p_cate=$Mainclass->Fetch_multiple_data("gold_product_category_master","*","SLN!='' order by Category");
foreach ($fetch_p_cate as $get_p_cate)
{
?>
<option value="<?php echo $get_p_cate['SLN']?>" <?php if($fetch_data['ProductCategory']==$get_p_cate['SLN']) echo "selected"; ?>><?php echo strtoupper($get_p_cate['Category'])?></option>
<?php
}
?>
</select>
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Select Metal Type <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="m_type" name="m_type" onchange="remove_error(),get_design_code(),get_data(),val_val2()" <?php echo $a ; ?>>
<option value="">--- please select---</option>
<option value="GOLD"   <?php if($fetch_data['Metal_Type']=="GOLD") echo "selected"; ?>>Gold</option>
<option value="SILVER" <?php if($fetch_data['Metal_Type']=="SILVER") echo "selected"; ?>>Silver</option>
</select>
</div>
</div>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Design Code <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="design_id" name="design_id" onchange="get_data()" <?php echo $a ; ?>>
    
<?php 
if($i==""){

?>
<option value="">--- please select---</option>  

<?php }?>    
    
  

<?php 
if($i!=""){

?>

<option value="<?php echo $fetch_data['ParentId']?>" ><?php echo $fetch_data['ParentId']?></option>

<?php }?>

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


<div class="col-3" id="form_select">
<div class="form-group">
<label>Quantity  <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="design_qty" name="design_qty"  onchange="remove_error()" <?php echo $a ; ?>>
<option value="">--- please select---</option>
  <?php for ($qty = 1; $qty <= 20; $qty++): ?>
    <option value="<?= $qty ?>" <?php if($product_count==$qty) echo "selected"; ?>><?= $qty ?></option>
  <?php endfor; ?>
</select>
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Vendor Name  <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="vendor_name" name="vendor_name"  onchange="remove_error()" <?php echo $a ; ?>>
<option value="">--- please select---</option>
<?php
$fetch_p_cate=$Mainclass->Fetch_multiple_data("gold_vendor_master","*","SLN!=''");
foreach ($fetch_p_cate as $get_p_cate)
{
?>
<option value="<?php echo $get_p_cate['Vendor_Name']?>" <?php if($fetch_data['Vendor_Name']==$get_p_cate['Vendor_Name']) echo "selected"; ?>><?php echo $get_p_cate['Vendor_Name']?></option>
<?php
}
?>
</select>
</div>
</div>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Vendor Design Code <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="v_designcode" id="v_designcode" placeholder="Vendor Design Code" class="form-control err"  autocomplete="off"  onkeypress="remove_error()" value="<?php echo $fetch_data['VendorDesignCode'] ?>" <?php echo $a ; ?>>
</div>
</div>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Vendor Bill No <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="v_billno" id="v_billno" placeholder="Vendor Bill No" class="form-control err"  autocomplete="off"  onkeypress="remove_error()" value="<?php echo $fetch_data['VendorBillNo'] ?>" <?php echo $a ; ?> onblur="get_purchase_rate()">
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Purchase Gold Rate <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="purchase_gold_rate" id="purchase_gold_rate" placeholder="Purchase Gold Rate" class="form-control err"  autocomplete="off"  onkeypress="remove_error()" value="<?php echo $fetch_data['purchase_gold_rate'] ?>" <?php echo $a ; ?> oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');">
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Invoice Date <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="invoice_date" id="invoice_date" placeholder="Invoice Date" class="form-control err"  autocomplete="off"  onchange="remove_error()" value="<?php echo $fetch_data['invoice_date'] ?>" <?php echo $a ; ?> oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');">
</div>
</div>




<?php  

if($i==""){

?>

<div class="col-2 mt-lg-4" >
<input type="button" class="btn btn-primary" value="Next" style="width:100px;background-color:#0979d8;border: none;" onclick="form_valid()">
</div>


<?php } ?> 



</div>

<div class="row">

<div class="col-12">
<div class="form-group d-flex align-items-center justify-content-start" style="gap:30px;">
<div class="" role="alert" id="con-alrt" style="color: #e85c5c;text-align: center;font-size: 15px;display: none;">* Please provide information in all the required fields</div>
</div>
</div>


</div>

<!--###### Product Details  #########-->

<div class="row mt-4 mb-5" id="design_details_div">



</div>


<?php 

if($i!=""){

?>

<div class="bg-light border">

<div id="product_div">
  
  

<h3 class="text-uppercase fw-bolder text-primary">Product <?php echo $serial_no?> Details  </h3>



<div class="row mt-4 ">

<?php 


if($fetch_data['Metal_Type']=="GOLD"){

?>
  
<div class="col-3" id="form_select">
<div class="form-group">
<label>Gold Weight <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="g_weight" id="g_weight" placeholder=" Enter Gold Weight " class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" autocomplete="off">
</div>
</div>

<?php } ?>

<?php  

if($fetch_data['has_diamond']=="Yes"){

?>

<div class="col-3">
<div class="form-group">
<label>Diamond Type <span style="color:crimson;font-weight:bold;">*</span></label>
            <select class="form-control" id="diamond_type" name="diamond_type" onchange="remove_error(),clearall()">
        <option value="">--- please select ---</option>
              <option value="Lab Grown"  <?php if($fetch_data['Diamond_Creation_Type']=='Lab Grown') echo "selected"; ?>>Lab Grown</option>
              <option value="Natural"    <?php if($fetch_data['Diamond_Creation_Type']=='Natural') echo "selected"; ?>>Natural</option>

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

<div class="col-3">
<div class="form-group">
<label>Diamond Quality <span style="color:crimson;font-weight:bold;">*</span></label>

<select class="form-control err" id="quality" name="quality" onchange="remove_error(),get_value(),get_color()">
<option value="">--- please select ---</option>
<?php
$Get_Karat=$Mainclass->Fetch_multiple_data('diamond_rate_master',"*","SLN!='' GROUP BY Quality");
foreach($Get_Karat as $karat)
{
?>
<option value="<?php echo $karat['Quality'];?>" <?php if($karat['Quality']==$fetch_data['DiamondQuality']) echo "selected"; ?> ><?php echo $karat['Quality'];?></option>        
<?php
}
?>
</select> 


</div>
</div>



<div class="col-3">
<div class="form-group">
<label>Diamond Color <span style="color:crimson;font-weight:bold;">*</span></label>

<select class="form-control err" id="color" name="color" onchange="remove_error(),get_value(),get_size()">
<option value="">--- please select ---</option>


</select>  


</div>
</div>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Diamond Size <span style="color:crimson;font-weight:bold;">*</span></label>
            <select class="form-control err" id="type" name="type" onchange="remove_error(),get_value()">
              <option value="">--- please select ---</option>

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


<?php

if($fetch_data['No_Diamond']==0){

$dqty =""; 
$dval =""; 

}

else{

$dqty =$fetch_data['No_Diamond']; 
$dval =$fetch_data['Diamond_Value']; 

}


?>


<input type="hidden" id="dia_quility" value="<?php echo $fetch_data['DiamondQuality'] ?>">
<input type="hidden" id="dia_color" value="<?php echo $fetch_data['DiamondColor'] ?>">
<input type="hidden" id="dia_type" value="<?php echo $fetch_data['DiamondType'] ?>">

<div class="col-3" id="form_select">
<div class="form-group">
<label>No of Diamond <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="no_diamonds" id="no_diamonds" placeholder=" Enter no of diamonds " class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');"  autocomplete="off" value="<?php echo $dqty ?>">
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Diamond Value (Per Carat)<span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="diamond_value" id="diamond_value" placeholder=" Enter Diamond Value (Per Carat)" class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');"   autocomplete="off" readonly value="<?php echo $dval ?>">
</div>
</div>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Diamond Carat <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="d_carat" id="d_carat" placeholder=" Diamond Carat " class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" autocomplete="off">
</div>
</div>


<?php 

}


?>

<?php

if($fetch_data['No_Solitaire']==0){

$sqty =""; 
$sval =""; 

}

else{

$sqty =$fetch_data['No_Solitaire']; 
$sval =$fetch_data['Solitaire_Value']; 

}


?>


<?php  

if($fetch_data['has_solitaire']=="Yes"){

?>


<div class="col-3">
<div class="form-group">
<label>Solitaire Type <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control" id="sol_diamond_type" name="sol_diamond_type" onchange="remove_error(),clearall_sol()">
        <option value="">--- please select---</option>
              <option value="Lab Grown"  <?php if($fetch_data['Solitaire_Creation_Type']=='Lab Grown') echo "selected"; ?>>Lab Grown</option>
              <option value="Natural"    <?php if($fetch_data['Solitaire_Creation_Type']=='Natural') echo "selected"; ?>>Natural</option>

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

<div class="col-3" id="form_select">
<div class="form-group">
<label>Solitaire Quality <span style="color:crimson;font-weight:bold;">*</span></label>
            <select class="form-control err" id="sol_quality" name="sol_quality" onchange="remove_error(),get_sol_value(),get_sol_color()">
        <option value="">--- please select---</option>
        <?php
        $Get_Karat=$Mainclass->Fetch_multiple_data('solitaire_rate_master',"*","SLN!='' GROUP BY Quality");
        foreach($Get_Karat as $karat)
        {
          ?>
        <option value="<?php echo $karat['Quality'];?>" <?php if($karat['Quality']==$fetch_data['SolitaireQuality']) echo "selected"; ?>><?php echo $karat['Quality'];?></option>        
        <?php
        }
        ?>

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

<div class="col-3" id="form_select">
<div class="form-group">
<label>Solitaire Color <span style="color:crimson;font-weight:bold;">*</span></label>
            <select class="form-control err" id="sol_color" name="sol_color" onchange="remove_error(),get_sol_value(),get_sol_size()">
              <option value="">--- please select---</option>


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


<div class="col-3" id="form_select">
<div class="form-group">
<label>Solitaire Size <span style="color:crimson;font-weight:bold;">*</span></label>
            <select class="form-control err" id="sol_type" name="sol_type" onchange="remove_error(),get_sol_value()">
              <option value="">--- please select---</option>

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


<div class="col-3" id="form_select">
<div class="form-group">
<label>No of Solitaires <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="sol_no_diamonds" id="sol_no_diamonds" placeholder=" Enter no of Solitaires " class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');"  autocomplete="off" value="<?php echo $sqty ?>">
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Solitaire Value (Per Carat) <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="sol_diamond_value" id="sol_diamond_value" placeholder=" Enter Solitaire Value (Per Carat)" class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');"   autocomplete="off" readonly value="<?php echo $sval ?>">
</div>
</div>

<div class="col-3" id="form_select">
<div class="form-group">
<label>Solitaire Carat <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="s_carat" id="s_carat" placeholder=" Solitaire Carat " class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" autocomplete="off">
</div>
</div>


<?php 

}


?>


<?php  

if($fetch_data['Has_Size_Variation']=="Yes"){

?>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Product Size <span style="color:crimson;font-weight:bold;">*</span></label>
<!-- <input type="text" name="product_size" id="product_size" placeholder=" Product Size " class="form-control err" onkeypress="remove_error()" autocomplete="off"> -->
            <select class="form-control err" id="product_size" name="product_size" onchange="remove_error">
        <option value="">--- please select---</option>
        <?php
        $Get_Karat=$Mainclass->Fetch_multiple_data('gold_product_size_master',"*","Category_Id='".$fetch_data['ProductCategory']."' and Active='Yes'");
        foreach($Get_Karat as $karat)
        {
          ?>
        <option value="<?php echo $karat['Size'];?>"><?php echo $karat['Size'];?></option>        
        <?php
        }
        ?>

        </select>   

</div>
</div>



<?php 

}


?>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Item No.<span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="item_no" id="item_no" placeholder=" Enter Item No." class="form-control err" onkeypress="remove_error()" autocomplete="off" >
</div>
</div>


<div class="col-3" id="form_select">
<div class="form-group">
<label>Total Price<span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="total_price" id="total_price" placeholder=" Enter Total Price." class="form-control err" onkeypress="remove_error()" autocomplete="off"   oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');">
</div>
</div>
 
</div>

</div>

<div class="row">

<div class="col-12">
<div class="form-group d-flex align-items-center justify-content-start" style="gap:30px;">
<div class="" role="alert" style="color: #000;text-align: center;font-size: 15px;font-weight: bold;">
Product <?php echo $serial_no?> Information – Product <?php echo $serial_no?> of <?php echo $product_count?></div>
</div>
</div>


</div>


<div class="row">

<div class="col-12">
<div class="form-group d-flex align-items-center justify-content-start" style="gap:30px;">
<div class="" role="alert" id="product-alrt" style="color: #e85c5c;text-align: center;font-size: 15px;display: none;font-weight: bold;">* Please provide information in all the required fields</div>
</div>
</div>


</div>


<?php 

if($product_count!=$serial_no){

?>

<div class="row">

<div class="col-12">
<div class="form-group d-flex align-items-center justify-content-end" style="gap:30px;">
<div class="" role="alert" id="con-alrt" style="color: #e85c5c;text-align: center;font-size: 15px;display: none;">* Please provide information in all the required fields</div>
<input type="button" class="btn btn-primary" value="Next"  style="width:100px;background-color:#0979d8;border: none;" onclick="product_form_valid('<?php echo $i?>','<?php echo $serial_no?>','<?php echo $fetch_data['has_diamond']?>','<?php echo $fetch_data['has_solitaire']?>','<?php echo $fetch_data['Has_Size_Variation']?>')">  
</div>
</div>


</div>

<?php } ?>



<?php 

if($product_count==$serial_no){

?>

<div class="row">

<div class="col-12">
<div class="form-group d-flex align-items-center justify-content-end" style="gap:30px;">
<div class="" role="alert" id="con-alrt" style="color: #e85c5c;text-align: center;font-size: 15px;display: none;">* Please provide information in all the required fields</div>
<input type="button" class="btn btn-primary" value="Confirm"  style="width:100px;background-color:#0979d8;border: none;" onclick="product_form_confirm('<?php echo $i?>','<?php echo $serial_no?>','<?php echo $fetch_data['has_diamond']?>','<?php echo $fetch_data['has_solitaire']?>','<?php echo $fetch_data['Has_Size_Variation']?>')">  
</div>
</div>


</div>

<?php } ?>

</div>



<?php } ?>


</div>




              <!-- /.card-body -->

            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->


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

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->


  </aside>
  <!-- /.control-sidebar -->
</div>




<!-- ./wrapper -->
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="plugins/jszip/jszip.min.js"></script>
<script src="plugins/pdfmake/pdfmake.min.js"></script>
<script src="plugins/pdfmake/vfs_fonts.js"></script>
<script src="plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- Page specific script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
     // "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });
</script>





<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" ></script>

  
<script type="text/javascript">


function form_valid(){


var p_cate = $('#p_cate').val();
var m_type = $('#m_type').val();
var design_id = $('#design_id').val();
var design_qty = $('#design_qty').val();
var vendor_name = $('#vendor_name').val();
var v_designcode = $('#v_designcode').val();
var v_billno = $('#v_billno').val();
var purchase_gold_rate = $('#purchase_gold_rate').val();
var invoice_date = $('#invoice_date').val();
var serial_no = 1;

var flag = 0;


if(p_cate==""){

$('#p_cate').next('.select2').find('.select2-selection--single').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#p_cate').next('.select2').find('.select2-selection--single').css('border-color', '');
}


if(m_type==""){

$('#m_type').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#m_type').css('border-bottom-color', '');
}

if(design_id==""){

$('#design_id').next('.select2').find('.select2-selection--single').css('border-color', '#e85c5c');


$('#con-alrt').show();

flag++;

}
else{

$('#design_id').next('.select2').find('.select2-selection--single').css('border-color', '');
}



if(design_qty==""){

$('#design_qty').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#design_qty').css('border-bottom-color', '');
}




if(vendor_name==""){

$('#vendor_name').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#vendor_name').css('border-bottom-color', '');

$('#con-alrt').hide();
}

if(v_designcode==""){

$('#v_designcode').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#v_designcode').css('border-bottom-color', '');

$('#con-alrt').hide();
}


if(v_billno==""){

$('#v_billno').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#v_billno').css('border-bottom-color', '');

$('#con-alrt').hide();
}

if(purchase_gold_rate==""){

$('#purchase_gold_rate').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#purchase_gold_rate').css('border-bottom-color', '');

$('#con-alrt').hide();
}


if(invoice_date==""){

$('#invoice_date').css('border-color', '#e85c5c');

$('#con-alrt').show();

flag++;

}
else{

$('#invoice_date').css('border-bottom-color', '');

$('#con-alrt').hide();
}



if(flag>0){

return false ;

}



else{

var data = {
    p_cate: p_cate,
    design_id: design_id,
    m_type: m_type,
    design_qty: design_qty,
    vendor_name: vendor_name,
    v_designcode: v_designcode,
    v_billno: v_billno,
    purchase_gold_rate: purchase_gold_rate,
    invoice_date: invoice_date,
};


$.ajax({
url:'ajax-check-vendor-bill-no.php',
type:'POST',
data: data,
success:function(f){

if(f==0){

$.ajax({
url:'ajax-add-temp-pro.php',
type:'POST',
data: data,
success:function(f){


console.log(f);

window.location.href="add_product_new.php?i="+btoa(f)+"&j="+btoa(serial_no);

}

}); 


}


else{


            Swal.fire({
          title: 'Are you sure?',
          text: "This Bill No is already exits, Do you want to proceed?",
          icon: 'warning',
          showCancelButton: true,
          confirmButtonColor: '#3085d6',
          cancelButtonColor: '#d33',
          confirmButtonText: 'Yes'
            }).then((result) => {
  if (result.isConfirmed) {
$.ajax({
url:'ajax-add-temp-pro.php',
type:'POST',
data: data,
success:function(f){


console.log(f);

window.location.href="add_product_new.php?i="+btoa(f)+"&j="+btoa(serial_no);

}

});

  }
  
});


}

}

}); 

}

}

function remove_error(){

$('.err').css('border-color', '');

$('.label.ui.selection.fluid.dropdown.multiple').css('border-bottom-color', '');

$('#p_cate').next('.select2').find('.select2-selection--single').css('border-color', '');

$('#design_id').next('.select2').find('.select2-selection--single').css('border-color', '');

$('#con-alrt').hide();

$('#product-alrt').hide();

}



</script>



<script type="text/javascript">
  

// $(document).ready(function(){

// $("input").on('input',function(){

// $('.err').css('border-bottom-color', '');

// });

// });


</script>


<!-- -=---- searchable dropdown link script ------ -->

<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet" />

<script src="https://code.jquery.com/jquery-3.1.1.min.js"integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
<script>
        $('.ui.dropdown').dropdown();
</script>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>

    <!-- -=---- searchable dropdown link script ------ -->
 
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
  function formatState (state) {
  if (!state.id) {
    return state.text;
  }

  var baseUrl = "/user/pages/images/flags";
  var $state = $(
    '<span><img class="img-flag" /> <span></span></span>'
  );

  // Use .text() instead of HTML string concatenation to avoid script injection issues
  $state.find("span").text(state.text);
  // $state.find("img").attr("src", baseUrl + "/" + state.element.value.toLowerCase() + ".png");

  return $state;
};


$("#p_cate").select2({
  templateSelection: formatState
});

$("#design_id").select2({
  templateSelection: formatState
});



</script>

<script>
  

function get_design_code(){

var p_cate = $('#p_cate').val();
var m_type = $('#m_type').val();



$.ajax({
url:'ajax-get-design-code.php',
type:'POST',
data:{p_cate:p_cate,m_type:m_type},
success:function(f){

$('#design_id').html(f);

}
});


}

function val_val1(){


$('#m_type').val('');

$('#design_id').val('');

$('#design_details_div').html('');

}

function val_val2(){


$('#design_id').val('');

$('#design_details_div').html('');

}



function get_data(){

var p_cate = $('#p_cate').val();
var m_type = $('#m_type').val();
var design_id = $('#design_id').val();


if(p_cate=="" || m_type=="" || design_id==""){

$('#design_details_div').html('');

return false;

}

if(p_cate!="" && m_type!="" && design_id!=""){

$.ajax({
url:'ajax-get-design-data.php',
type:'POST',
data:{design_id:design_id},
success:function(f){

$('#design_details_div').html(f);

}
});


}


}

function product_form_valid(design_id,serial_no,has_d,has_s,has_size) {

var g_weight = $('#g_weight').val();

var diamond_type = $('#diamond_type').val();
var quality = $('#quality').val();
var color = $('#color').val();
var type = $('#type').val();
var no_diamonds = $('#no_diamonds').val();
var diamond_value = $('#diamond_value').val();
var d_carat = $('#d_carat').val();

var sol_diamond_type = $('#sol_diamond_type').val();
var sol_quality = $('#sol_quality').val();
var sol_color = $('#sol_color').val();
var sol_type = $('#sol_type').val();
var sol_no_diamonds = $('#sol_no_diamonds').val();
var sol_diamond_value = $('#sol_diamond_value').val();
var s_carat = $('#s_carat').val();

var product_size = $('#product_size').val();

var item_no = $('#item_no').val();
var total_price = $('#total_price').val();

var flag = 0;



if (g_weight === "" || parseFloat(g_weight) <= 0) {

    $('#g_weight').css('border-color', '#e85c5c');

    $('#product-alrt').text("Please provide a valid gold weight greater than zero.").show();

    return false;

} else {

    $('#g_weight').css('border-color', '');

    $('#product-alrt').hide();

}

if(has_d=="Yes"){


if (diamond_type == "") {

$('#diamond_type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#diamond_type').css('border-color', '');

$('#product-alrt').hide();

}  

if (quality == "") {

$('#quality').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#quality').css('border-color', '');

$('#product-alrt').hide();

}

if (color == "") {

$('#color').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{


$('#color').css('border-color', '')

$('#product-alrt').hide();

}


if (type == "") {

$('#type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 


else{

$('#type').css('border-color', '');

$('#product-alrt').hide();

}

if (diamond_value == "") {

$('#diamond_value').css('border-color', '#e85c5c'); 

$('#product-alrt').show();

flag++; 

} 

else{

$('#diamond_value').css('border-color', ''); 

$('#product-alrt').hide();

}

if (no_diamonds == "") {

$('#no_diamonds').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#no_diamonds').css('border-color', '');

$('#product-alrt').hide();

}

if (d_carat === "" || parseFloat(d_carat) <= 0) {

    $('#d_carat').css('border-color', '#e85c5c');

    $('#product-alrt').text("Please provide a valid Diamond Carat greater than zero.").show();

   return false;

} else {

    $('#d_carat').css('border-color', '');

    $('#product-alrt').hide();

}

}


if(has_s=="Yes"){


if (sol_diamond_type == "") {

$('#sol_diamond_type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_diamond_type').css('border-color', '');

$('#product-alrt').hide();

}


if (sol_quality == "") {

$('#sol_quality').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_quality').css('border-color', '');

$('#product-alrt').hide();

}

if (sol_color == "") {

$('#sol_color').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{


$('#sol_color').css('border-color', '')

$('#product-alrt').hide();

}


if (sol_type == "") {

$('#sol_type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 


else{

$('#sol_type').css('border-color', '');

$('#product-alrt').hide();

}

if (sol_diamond_value == "") {

$('#sol_diamond_value').css('border-color', '#e85c5c'); 

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_diamond_value').css('border-color', ''); 

$('#product-alrt').hide();

}

if (sol_no_diamonds == "") {

$('#sol_no_diamonds').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_no_diamonds').css('border-color', '');

$('#product-alrt').hide();

}

if (s_carat === "" || parseFloat(s_carat) <= 0) {

    $('#s_carat').css('border-color', '#e85c5c');

    $('#product-alrt').text("Please provide a valid Solitaire Carat greater than zero.").show();

   return false;

} else {

    $('#s_carat').css('border-color', '');

    $('#product-alrt').hide();

}

}


if(has_size=="Yes"){

if(product_size==""){

$('#product_size').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++;

}

else{

$('#product_size').css('border-color', '');

$('#product-alrt').hide();

}

}


if(item_no==""){

$('#item_no').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++;

}

else{

$('#item_no').css('border-color', '');

$('#product-alrt').hide();

}

if(total_price==""){

$('#total_price').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++;

}

else{

$('#total_price').css('border-color', '');

$('#product-alrt').hide();

}

if(flag>0){

$('#product-alrt').show();

return false ;

}



var data = {
    g_weight: g_weight,
    diamond_type: diamond_type,
    quality: quality,
    color: color,
    type: type,
    no_diamonds: no_diamonds,
    diamond_value: diamond_value,
    d_carat: d_carat,
    sol_diamond_type: sol_diamond_type,
    sol_quality: sol_quality,
    sol_color: sol_color,
    sol_type: sol_type,
    sol_no_diamonds: sol_no_diamonds,
    sol_diamond_value: sol_diamond_value,
    s_carat: s_carat,
    product_size: product_size,
    design_id: design_id,
    serial_no: serial_no,
    has_d: has_d,
    has_s: has_s,
    has_size: has_size,
    item_no: item_no,
    total_price: total_price

};

$.ajax({
url:'ajax-update-temp-product.php',
type:'POST',
data: data,
success:function(f){


window.location.href="add_product_new.php?i="+btoa(design_id)+"&j="+btoa(f);

}
});



}


function product_form_confirm(design_id,serial_no,has_d,has_s,has_size) {

var g_weight = $('#g_weight').val();

var diamond_type = $('#diamond_type').val();
var quality = $('#quality').val();
var color = $('#color').val();
var type = $('#type').val();
var no_diamonds = $('#no_diamonds').val();
var diamond_value = $('#diamond_value').val();
var d_carat = $('#d_carat').val();

var sol_diamond_type = $('#sol_diamond_type').val();
var sol_quality = $('#sol_quality').val();
var sol_color = $('#sol_color').val();
var sol_type = $('#sol_type').val();
var sol_no_diamonds = $('#sol_no_diamonds').val();
var sol_diamond_value = $('#sol_diamond_value').val();
var s_carat = $('#s_carat').val();

var product_size = $('#product_size').val();

var item_no = $('#item_no').val();
var total_price = $('#total_price').val();

var flag = 0;

if (g_weight === "" || parseFloat(g_weight) <= 0) {

    $('#g_weight').css('border-color', '#e85c5c');

    $('#product-alrt').text("Please provide a valid gold weight greater than zero.").show();

   return false;

} else {

    $('#g_weight').css('border-color', '');

    $('#product-alrt').hide();

}

if(has_d=="Yes"){


if (diamond_type == "") {

$('#diamond_type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#diamond_type').css('border-color', '');

$('#product-alrt').hide();

}  

if (quality == "") {

$('#quality').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#quality').css('border-color', '');

$('#product-alrt').hide();

}

if (color == "") {

$('#color').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{


$('#color').css('border-color', '')

$('#product-alrt').hide();

}


if (type == "") {

$('#type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 


else{

$('#type').css('border-color', '');

$('#product-alrt').hide();

}

if (diamond_value == "") {

$('#diamond_value').css('border-color', '#e85c5c'); 

$('#product-alrt').show();

flag++; 

} 

else{

$('#diamond_value').css('border-color', ''); 

$('#product-alrt').hide();

}

if (no_diamonds == "") {

$('#no_diamonds').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#no_diamonds').css('border-color', '');

$('#product-alrt').hide();

}

// if (d_carat == "") {

// $('#d_carat').css('border-color', '#e85c5c'); 

// $('#product-alrt').show();

// flag++; 

// } 

// else{

// $('#d_carat').css('border-color', ''); 

// $('#product-alrt').hide();

// }



if (d_carat === "" || parseFloat(d_carat) <= 0) {

    $('#d_carat').css('border-color', '#e85c5c');

    $('#product-alrt').text("Please provide a valid Diamond Carat greater than zero.").show();

   return false;

} else {

    $('#d_carat').css('border-color', '');

    $('#product-alrt').hide();

}


}


if(has_s=="Yes"){


if (sol_diamond_type == "") {

$('#sol_diamond_type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_diamond_type').css('border-color', '');

$('#product-alrt').hide();

}


if (sol_quality == "") {

$('#sol_quality').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_quality').css('border-color', '');

$('#product-alrt').hide();

}

if (sol_color == "") {

$('#sol_color').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{


$('#sol_color').css('border-color', '')

$('#product-alrt').hide();

}


if (sol_type == "") {

$('#sol_type').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 


else{

$('#sol_type').css('border-color', '');

$('#product-alrt').hide();

}

if (sol_diamond_value == "") {

$('#sol_diamond_value').css('border-color', '#e85c5c'); 

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_diamond_value').css('border-color', ''); 

$('#product-alrt').hide();

}

if (sol_no_diamonds == "") {

$('#sol_no_diamonds').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++; 

} 

else{

$('#sol_no_diamonds').css('border-color', '');

$('#product-alrt').hide();

}

/*if (s_carat == "") {

$('#s_carat').css('border-color', '#e85c5c'); 

$('#product-alrt').show();

flag++; 

} 

else{

$('#s_carat').css('border-color', ''); 

$('#product-alrt').hide();

}*/



if (s_carat === "" || parseFloat(s_carat) <= 0) {

    $('#s_carat').css('border-color', '#e85c5c');

    $('#product-alrt').text("Please provide a valid Solitaire Carat greater than zero.").show();

    return false;

} else {

    $('#s_carat').css('border-color', '');

    $('#product-alrt').hide();

}

}


if(has_size=="Yes"){

if(product_size==""){

$('#product_size').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++;

}

else{

$('#product_size').css('border-color', '');

$('#product-alrt').hide();

}

}

if(item_no==""){

$('#item_no').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++;

}

else{

$('#item_no').css('border-color', '');

$('#product-alrt').hide();

}

if(total_price==""){

$('#total_price').css('border-color', '#e85c5c');

$('#product-alrt').show();

flag++;

}

else{

$('#total_price').css('border-color', '');

$('#product-alrt').hide();

}


if(flag>0){

$('#product-alrt').show();

return false ;

}


var data = {
    g_weight: g_weight,
    diamond_type: diamond_type,
    quality: quality,
    color: color,
    type: type,
    no_diamonds: no_diamonds,
    diamond_value: diamond_value,
    d_carat: d_carat,
    sol_diamond_type: sol_diamond_type,
    sol_quality: sol_quality,
    sol_color: sol_color,
    sol_type: sol_type,
    sol_no_diamonds: sol_no_diamonds,
    sol_diamond_value: sol_diamond_value,
    s_carat: s_carat,
    product_size: product_size,
    design_id: design_id,
    serial_no: serial_no,
    has_d: has_d,
    has_s: has_s,
    has_size: has_size,
    item_no: item_no,
    total_price: total_price

};

$.ajax({
url:'ajax-confirm-temp-product.php',
type:'POST',
data: data,
success:function(f){

 Swal.fire({
icon: 'success',
title: 'Success',
text: 'Product inserted successfully',
width: '450px',
showConfirmButton:false,
timer:3000,
}).then(function() {
window.location.href="add_product_new.php";
});

}
});



}

</script>



<script type="text/javascript">
  


function get_value(){

var quality = $('#quality').val();
var color = $('#color').val();
var type = $('#type').val();
var diamond_type = $('#diamond_type').val();


$.ajax({
url:'ajax-get-value.php',
type:'POST',
data:{quality:quality,color:color,type:type,diamond_type:diamond_type},
success:function(f){


$('#diamond_value').val(f);

}

});


}


function clearall() {

$('#quality').val('');
$('#color').val('');
$('#type').val('');
$('#no_diamonds').val('');
$('#diamond_value').val('');
}

function get_color(){
  var diamond_type = $('#diamond_type').val();
var quality = $('#quality').val();  
var SLN = $('#SLN').val();    
$('#color').val('');
$('#type').val('');
$.ajax({
url:'ajax-get-diamond-color.php',
type:'POST',
data:{quality:quality,diamond_type:diamond_type},
success:function(f){
  
$('#color').html(f);
  
}
}); 
  
} 
  
function get_size(){
  var diamond_type = $('#diamond_type').val();  
var quality = $('#quality').val();  
var color = $('#color').val();    

$('#type').val('');
$.ajax({
url:'ajax-get-diamond-size.php',
type:'POST',
data:{quality:quality,color:color,diamond_type:diamond_type},
success:function(f){
//alert(f);
  
$('#type').html(f);
  
}
}); 
  
    
}
  
  
function get_color_select(){
  
var SLN = $('#SLN').val();    
$.ajax({
url:'ajax-get-diamond-color-select.php',
type:'POST',
data:{SLN:SLN},
success:function(f){
  
$('#color').html(f);
  
}
}); 
  
} 
  
function get_size_select(){
  

var SLN = $('#SLN').val();  

$('#type').val('');
$.ajax({
url:'ajax-get-diamond-size-select.php',
type:'POST',
data:{SLN:SLN},
success:function(f){
//alert(f);
  
$('#type').html(f);
  
}
}); 
  
    
}

  

function get_sol_value(){

var quality = $('#sol_quality').val();
var color = $('#sol_color').val();
var type = $('#sol_type').val();
var sol_diamond_type = $('#sol_diamond_type').val();

$.ajax({
url:'ajax-get-sollitaire-value.php',
type:'POST',
data:{quality:quality,color:color,type:type,sol_diamond_type:sol_diamond_type},
success:function(f){

$('#sol_diamond_value').val(f);

}

});


} 
  
function get_sol_color(){
  
var sol_quality = $('#sol_quality').val();  
var sol_diamond_type = $('#sol_diamond_type').val();
$('#sol_color').val('');
$('#sol_type').val('');
$.ajax({
url:'ajax-get-solitaire-color.php',
type:'POST',
data:{sol_quality:sol_quality,sol_diamond_type:sol_diamond_type},
success:function(f){
  
$('#sol_color').html(f);
  
}
}); 
  
} 
  
function get_sol_size(){
var sol_diamond_type = $('#sol_diamond_type').val();  
var sol_quality = $('#sol_quality').val();  
var sol_color = $('#sol_color').val();    
$('#sol_type').val(''); 
$.ajax({
url:'ajax-get-solitaire-size.php',
type:'POST',
data:{sol_quality:sol_quality,sol_color:sol_color,sol_diamond_type:sol_diamond_type},
success:function(f){
  
$('#sol_type').html(f);
  
}
}); 
  
    
} 
  

function clearall_sol() {

$('#sol_quality').val('');
$('#sol_color').val('');
$('#sol_type').val('');
$('#sol_no_diamonds').val('');
$('#sol_diamond_value').val('');
}

  
function get_sol_color_select(){

  
var SLN = $('#SLN').val();  

$.ajax({
url:'ajax-get-solitaire-color-select.php',
type:'POST',
data:{SLN:SLN},
success:function(f){
  
$('#sol_color').html(f);
  
}
}); 
  
} 
  
function get_sol_size_select(){
  
var SLN = $('#SLN').val();    
  
$.ajax({
url:'ajax-get-solitaire-size-select.php',
type:'POST',
data:{SLN:SLN},
success:function(f){
  
$('#sol_type').html(f);
  
}
}); 
  
    
}    


function get_purchase_rate(){

var v_billno = $('#v_billno').val();

$.ajax({
url:'ajax-get-purchase-gold-rate.php ',
type:'POST',
data:{v_billno:v_billno},
success:function(f){

if(f!=''){

var data = f.split('*');

$('#purchase_gold_rate').val(data[0]);
$('#invoice_date').val(data[1]);

$('#purchase_gold_rate').prop('readonly', true);
$('#invoice_date').prop('readonly', true);

}

else {

$('#purchase_gold_rate').val('');
$('#invoice_date').val('');

$('#purchase_gold_rate').prop('readonly', false);
$('#invoice_date').prop('readonly', false);

}


}
});


}

</script>

        <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
 <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>


<script>
$(function() {
$( "#invoice_date" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy', 
maxDate: 0, 
});
});


</script>

</body>
</html>