

<!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">

</head>
  


<body class="hold-transition sidebar-mini">
  
<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>Add Design Code</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">






<div class="row">

<input type="hidden" id="Last_P_Code" name="Last_P_Code"/>

<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(),new_design_code()">
<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 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="metal_type" name="metal_type" onchange="remove_error(),new_design_code()">
<option value="">--- please select---</option>
<option value="GOLD">Gold</option>
<!--<option value="SILVER">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>
<input type="text" name="design_id" id="design_id" placeholder=" Enter Design Code" class="form-control err" onkeypress="remove_error()" oninput="this.value = this.value.replace(/[^0-9.]/g, ''); this.value = this.value.replace(/(\..*)\./g, '$1');" onblur="code_check()"  autocomplete="off" readonly>
</div>
</div>


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



<div class="col-3" id="form_select">
<div class="form-group">
<label>HSN Code <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="h_code" id="h_code" placeholder=" Enter HSN Code" 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');" value='7113'>
</div>
</div>





<div class="col-3">
<div class="form-group">
<label>Has Stone ?</label><span style="color:red;font-weight: bold;margin: 5px;">*</span><span id="stone_span" style="font-weight: bold;margin: 5px;cursor: pointer;display: none;" onclick="stone_modal()"><i class="fa-solid fa-fire-burner"></i> Details</span>
<select class="form-control err" id="stone_q" name="stone_q" onchange="stone_div(),stone_erase()">
<option value="No" selected>No</option>
<option value="Yes" >Yes</option>
</select>     
</div>
</div>



<div class="col-3">
<div class="form-group">
<label>Has Diamond ?</label><span style="color:red;font-weight: bold;margin: 5px;">*</span><span id="diamond_span" style="font-weight: bold;margin: 5px;cursor: pointer;display: none;" onclick="diamond_modal()"><i class="fa-solid fa-gem"></i> Details</span>
<select class="form-control err" id="diamont_q" name="diamont_q" onchange="diamon_div(),diamond_erase()">
<option value="No" selected>No</option>
<option value="Yes" >Yes</option>
</select>     
</div>
</div>



<div class="col-3">
<div class="form-group">
<label>Has Solitaire ?</label><span style="color:red;font-weight: bold;margin: 5px;">*</span><span id="solitaire_span" style="font-weight: bold;margin: 5px;cursor: pointer;display: none;" onclick="solitaire_modal()"><i class="fa-solid fa-gem"></i> Details</span>
<select class="form-control err" id="solitaire_q" name="solitaire_q" onchange="solitaire_div(),solitaire_erase()">
<option value="No" selected>No</option>
<option value="Yes" >Yes</option>
</select>     
</div>
</div>
	

<div class="col-3" id="form_select">
<div class="form-group">
<label>Has Size Variation? <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="size_variation" name="size_variation" onchange="remove_error()">
<option value="">--- please select---</option>
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</div>
</div>  


<div class="col-3" id="form_select">
<div class="form-group">
<label>Color <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="p_color" name="p_color" onchange="remove_error()">
<option value="">--- please select---</option>
<?php
$fetch_p_cate=$Mainclass->Fetch_multiple_data("gold_color_master","*","Active='Yes' order by Color");
foreach ($fetch_p_cate as $get_p_cate)
{
?>
<option value="<?php echo $get_p_cate['Color']?>"><?php echo $get_p_cate['Color']?></option>
<?php
}
?>
</select>
</div>
</div>
	
	
<div class="col-3" id="form_select">
<div class="form-group">
<label>Making Charges Type <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="mk_ch" name="mk_ch" onchange="remove_error()">
<option value="">--- please select---</option>
<option value="Flat">Flat</option>
<option value="Percentage">Percentage</option>
<option value="Rate per gram">Rate per gram</option>
</select>
</div>
</div>




<div class="col-3" id="form_select">
<div class="form-group">
<label>Making Charges Value <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="mk_ch_val" id="mk_ch_val" placeholder=" Enter Making Charges Value " 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>



<div class="col-3" id="gold_puriry_div" style="display: none">
<div class="form-group">
<label>Gold Purity <span style="color:crimson;font-weight:bold;">*</span></label>
<select class="form-control err" id="g_purity" name="g_purity" onchange="remove_error()">
<option value="">--- please select---</option>
<?php
$fetch_p_cate=$Mainclass->Fetch_multiple_data("gold_karat_master","*","Active='Yes'");
foreach ($fetch_p_cate as $get_p_cate)
{
?>
<option value="<?php echo $get_p_cate['Karat']?>"><?php echo $get_p_cate['Karat']?></option>
<?php
}
?>
</select>
</div>
</div>

<div class="col-3" id="mrp_div" style="display:none">
<div class="form-group">
<label>MRP <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="mrp" id="mrp" placeholder=" Enter MRP " 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>

<!-- <div class="col-3" id="form_select">
<div class="form-group">
<label>Wastage Cost </label>
<input type="text" name="wc" id="wc" placeholder=" Enter Wastage Cost " 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> -->

<div class="col-12" id="form_select">
<div class="form-group">
<label>Product Description </label>

<textarea type="text" name="remark" id="remark" placeholder=" Enter Description " class="form-control err" onkeypress="remove_error()" rows="5"></textarea>

</div>
</div>




</div>





<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="Submit"  style="width:100px;background-color:#0979d8;border: none;" onclick="Product_Val()">  
</div>
</div>


</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>

<!-- Diamond Details Modal -->
<div class="modal fade" id="StoneModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">



<div class="modal-dialog">
<div class="modal-content">

<div class="modal-header" style="background:#fff;border:none">
<h4 class="modal-title fs-5" id="exampleModalLabel">Stone Details</h4>
<i class="fa-solid fa-xmark" data-bs-dismiss="modal" style="cursor: pointer;"></i>
</div>


<div class="modal-body" style="background-color: #fff !important;">
<div class="row">


<div class="col-12" id="form_select">
<div class="form-group">
<label>Select Stone <span style="color:crimson;font-weight:bold;">*</span></label>
<select  onchange="remove_error()" class="label ui selection fluid dropdown err" multiple id="s_name" name="s_name[]"  placeholder="State">
<option value="">--- please select---</option>
<?php
$fetch_p_cate=$Mainclass->Fetch_multiple_data("stones_master","*","Active='Yes'");
foreach ($fetch_p_cate as $get_p_cate)
{
?>
<option value="<?php echo $get_p_cate['Stone']?>"><?php echo $get_p_cate['Stone']?></option>
<?php
}
?>
</select>
</div>
</div>


<div class="col-12" id="form_select">
<div class="form-group">
<label>No of Stones <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="no_stones" id="no_stones" placeholder=" Enter no of stones " 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>

<div class="col-12" id="form_select">
<div class="form-group">
<label>Stone Value <span style="color:crimson;font-weight:bold;">*</span></label>
<input type="text" name="stone_value" id="stone_value" placeholder=" Enter Stone Value" 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>



</div>
</div>


<div class="modal-footer">
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
<button type="button" id="add_rate_btn" class="btn btn-custom" data-bs-dismiss="modal" >Save</button>
</div>

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



<!-- Diamond Details Modal -->
<div class="modal fade" id="DiamondModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">



<div class="modal-dialog">
<div class="modal-content">

<div class="modal-header" style="background:#fff;border:none">
<h4 class="modal-title fs-5" id="exampleModalLabel">Diamond Details</h4>
<i class="fa-solid fa-xmark" data-bs-dismiss="modal" style="cursor: pointer;"></i>
</div>


<div class="modal-body" style="background-color: #fff !important;">
<div class="row">



<div class="col-12" id="form_select">
<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">Lab Grown</option>
              <option value="Natural">Natural</option>

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

<div class="col-12" id="form_select">
<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 echo $karat['Quality'];?></option>        
        <?php
        }
        ?>

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

<div class="col-12" id="form_select">
<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-12" 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>


<div class="col-12" 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">
</div>
</div>

<div class="col-12" 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>
</div>
</div>



</div>
</div>


<div class="modal-footer">
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
<button type="button" id="add_rate_btn" class="btn btn-custom" data-bs-dismiss="modal" >Save</button>
</div>

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





<!-- Diamond Details Modal -->
<div class="modal fade" id="SolitairesModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">



<div class="modal-dialog">
<div class="modal-content">

<div class="modal-header" style="background:#fff;border:none">
<h4 class="modal-title fs-5" id="exampleModalLabel">Solitaires Details</h4>
<i class="fa-solid fa-xmark" data-bs-dismiss="modal" style="cursor: pointer;"></i>
</div>


<div class="modal-body" style="background-color: #fff !important;">
<div class="row">


<div class="col-12" id="form_select">
<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">Lab Grown</option>
              <option value="Natural">Natural</option>

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


<div class="col-12" 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 echo $karat['Quality'];?></option>        
        <?php
        }
        ?>

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

<div class="col-12" 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-12" 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-12" 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">
</div>
</div>

<div class="col-12" 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>
</div>
</div>


</div>
</div>


<div class="modal-footer">
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
<button type="button" id="add_rate_btn" class="btn btn-custom" data-bs-dismiss="modal" >Save</button>
</div>

</div>
</div>
</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 Product_Val(){

var Last_P_Code = $('#Last_P_Code').val();
var p_cate = $('#p_cate').val();
var metal_type = $('#metal_type').val();
var design_id = $('#design_id').val();
var p_name = $('#p_name').val();
var h_code = $('#h_code').val();
var g_purity = $('#g_purity').val();
var g_weight = $('#g_weight').val();
var stone_q = $('#stone_q').val();
var s_name = $('#s_name').val();
var no_stones = $('#no_stones').val();
var stone_value = $('#stone_value').val();
var diamont_q=$('#diamont_q').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 solitaire_q=$('#solitaire_q').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 size_variation = $('#size_variation').val(); 	
var p_color = $('#p_color').val();  
var mk_ch = $('#mk_ch').val();
var mk_ch_val = $('#mk_ch_val').val();
//var wc = $('#wc').val();
var wc = "0.00";
var remark = $('#remark').val();
var MRP = $('#mrp').val();

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', '');

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

}


if(metal_type==""){

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

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

flag++;

}


else{

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

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

}


if(design_id==""){

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

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

flag++;

}
else{

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

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



if(p_name==""){

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

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

flag++;

}
else{

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

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


if(h_code==""){

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

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

flag++;

}
else{

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

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



if(stone_q=="Yes"){

if (s_name == "" || stone_value == "" || no_stones == "") {

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

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

flag++; 

} 

}

else{

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

}


if(diamont_q=="Yes"){

if (diamond_type == "" || quality == "" || color == "" || type == "" || diamond_value == "" || no_diamonds == "") {

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

flag++; 

} 

}

else{

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

}



if(solitaire_q=="Yes"){

if (sol_diamond_type == "" || sol_quality == "" || sol_color == "" || sol_type == "" || sol_diamond_value == "" || sol_no_diamonds == "") {

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

flag++; 

} 

}

else{

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

}

if(p_color==""){

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

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

flag++;

}
else{

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

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

}


if(size_variation==""){

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

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

flag++;

}
else{

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

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

}
	
if(mk_ch==""){

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

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

flag++;

}
else{

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

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

}

if(mk_ch_val==""){

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

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

flag++;

}
else{

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

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

}



if(metal_type=="GOLD"){

if(g_purity==""){

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

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

flag++;

}

else{

$('#g_purity').css('border-color', '');
$('#con-alrt').hide();
}

}

if(metal_type=="SILVER"){

if(MRP==""){

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

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

flag++;

}

else{

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

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

}


}


if(flag>0){

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

return false ;

}




else{

var data = {
    Last_P_Code: Last_P_Code,
    p_cate: p_cate,
    metal_type: metal_type,
    design_id: design_id,
    p_name: p_name,
    h_code: h_code,
    g_purity: g_purity,
    g_weight: g_weight,
    s_name: s_name,
    no_stones: no_stones,
    stone_value: stone_value,
    diamond_type: diamond_type,
    quality: quality,
    color: color,
    type: type,
    no_diamonds: no_diamonds,
    diamond_value: diamond_value,
    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,
    size_variation: size_variation,
    p_color: p_color,
    mk_ch: mk_ch,
    mk_ch_val: mk_ch_val,
    wc: wc,
    MRP: MRP,
    remark: remark
};

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


Swal.fire({
icon: 'success',
title: 'Success',
text: 'Design Code added successfully',
width: '450px',
showConfirmButton:false,
timer:2000,
}).then(function() {
window.location.href="add_design_code.php"
});


  }

  }); 

}

}

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', '');

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


}


function val_cha(){

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

if(r_type=="Fixed"){

   $('#form_select1').show();
}

else{

   $('#form_select1').hide();

}



}


function code_check(){

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



$.ajax({
url:'ajax-code-check.php',
type:'POST',
data:{p_cate:p_cate,design_id:design_id,metal_type:metal_type},
success:function(f){

if(f==1){


Swal.fire({
icon: 'error',
title: 'Please Check',
text: 'The design code you mentioned is already present.',
showConfirmButton:false,
timer:2000,
}).then(function() {

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

}


}
});




}


  
function new_design_code(){
  
var p_cate = $('#p_cate').val();
var metal_type = $('#metal_type').val();  

if(metal_type=="SILVER"){

$('#mrp_div').show();
$('#gold_puriry_div').hide();

}

else if(metal_type=="GOLD"){
$('#mrp_div').hide();
$('#gold_puriry_div').show();
}


else{
$('#mrp_div').hide();
$('#gold_puriry_div').hide();
}




  
$.ajax({
url:'ajax-create-new-code.php',
type:'POST',
data:{p_cate:p_cate,metal_type:metal_type},
success:function(f){

var data  = f.split("*");
  
var Last_P_Code =   data[0];
var design_code =   data[1];  
var Product_Name =   data[2];

if(p_cate!=''  && metal_type!=""){

$('#Last_P_Code').val(Last_P_Code);
$('#design_id').val(design_code); 
$('#p_name').val(Product_Name);  

}

else{

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

}



}


});
  
  
} 
  

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 quality = $('#quality').val();	
var diamond_type = $('#diamond_type').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 quality = $('#quality').val();	
var color = $('#color').val();
var diamond_type = $('#diamond_type').val();		
$('#type').val('');	
$.ajax({
url:'ajax-get-diamond-size.php',
type:'POST',
data:{quality:quality,color:color,diamond_type:diamond_type},
success:function(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();

$.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_quality = $('#sol_quality').val();	
var sol_color = $('#sol_color').val();	
var sol_diamond_type = $('#sol_diamond_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('');
}

</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
});

</script>



<script type="text/javascript">
  

function stone_div(){

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

if(stone_q=='Yes'){

$('#stone_span').show();

}

else{
$('#stone_span').hide();

$('#making_charge').val('');
$('#final_price').val('');
$('#gross_price').val('');
$('#gst').val('');

}


}


function stone_modal(){

$('#StoneModal').modal('show');


}


function diamon_div(){

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

if(diamont_q=="Yes"){

$('#diamond_span').show();

}

if(diamont_q=="No"){

$('#diamond_span').hide();

$('#making_charge').val('');
$('#final_price').val('');
$('#gross_price').val('');
$('#gst').val('');


}

}



function diamond_modal(){

$('#DiamondModal').modal('show');


}





function stone_erase(){
    
var stone_q=$('#stone_q').val();   


if(stone_q=="No"){

    $('#stone').parent().find('.ui.label.transition.visible').remove();
    $('#stone').parent().find('.menu').html('');

$('#stone_price').val(''); 
$('#stone_w').val(''); 
$('#stone_g').val(''); 
$('#stone_mg').val(''); 
$('#total_stone_price').val(''); 

    
}    
    
}



function diamond_erase(){
    
var diamont_q=$('#diamont_q').val();   


if(diamont_q=="No"){
    
$('#dprice').val(''); 
$('#diamondw').val(''); 
$('#diamond_g').val(''); 
$('#diamond_mg').val(''); 
$('#total_diamond_price').val(''); 
$('#colour').val(''); 
$('#cut').val(''); 
$('#shape').val(''); 
$('#clarity').val('');
$('#size').val('');    
}    
    
}



function solitaire_div(){

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

if(solitaire_q=="Yes"){

$('#solitaire_span').show();

}

if(solitaire_q=="No"){

$('#solitaire_span').hide();

$('#making_charge').val('');
$('#final_price').val('');
$('#gross_price').val('');
$('#gst').val('');


}

}



function solitaire_modal(){

$('#SolitairesModal').modal('show');


}



</script>

</body>
</html>