<!-- Button trigger modal 
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
  Launch static backdrop modal
</button>

<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Understood</button>
      </div>
    </div>
  </div>
</div>-->


<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog" role="document" style="width: 1000px;">
    <div class="modal-content">
        
        
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel"><b><i class="fa fa-inr"></i> Price Update</b></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-top: -22px; display: none;">
           Close <span aria-hidden="true">&times;</span> 
        </button>
      </div>
      
      
    <form id="price_update_form_details">
      <div class="modal-body">
                <?php foreach($price_results as $today){ ?>
                
                        <input type="hidden" name="ids[]" value="<?=$today['id']?>">
                        <div class="row" style="margin-top: 5px;">
                                        
                                        <div class="col-lg-4">
                                            <div class="form-group" style="">
                                                <label for="product_ids">Product Name</label> 
                                                <select name="product_ids[]" id="product_ids" class="form-control select2" style="width: 100%;">
                                                    <?php $statement = $pdo->prepare("SELECT * FROM `tbl_ids_products` WHERE status=1 and id=?");
                                                        $statement->execute(array($today['product_id']));
                                                        $resultss = $statement->fetchAll(PDO::FETCH_ASSOC); 
                                                        foreach ($resultss as $ress) { ?>
                                                            <option value="<?=$ress['id']?>"><?=$ress['name']?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        <div class="col-lg-4">
                                            <div class="form-group" style="">
                                                <label for="purity_ids">Karat</label> 
                                                <select name="purity_ids[]" id="purity_ids" class="form-control select2" style="width: 100%;">
                                                    <?php $statement = $pdo->prepare("SELECT * FROM `tbl_ids_purity` WHERE status=1 and id=?");
                                                        $statement->execute(array($today['purity_id']));
                                                        $resultss = $statement->fetchAll(PDO::FETCH_ASSOC); 
                                                        foreach ($resultss as $ress) { ?>
                                                            <option value="<?=$ress['id']?>"><?=$ress['name']?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        </div>
                                        
                                        
                                        <div class="col-lg-4">
                                            <div class="form-group">
                                                <label for="amount">Today Price <i class="fa fa-inr"></i></label> 
                                                <input type="text" name="amount[]" class="form-control" id="amount" value="<?=$today['amount']?>" placeholder="Today Price" required style="width: 100%;">
                                            </div>
                                        </div>
                                        
                                    </div>
                                    
                <?php } ?>
          
      </div>
      
      
      
      <div class="modal-footer">
        <button type="submit" class="btn btn-primary">Submit</button>
      </div>
    </form>
      
      
    </div>
  </div>
</div>
<!--<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"></script>-->

<script>
$(document).ready(function() {
   $('#price_update_form_details').on('submit', function(e){
                e.preventDefault();
                $('#loading-div').show();
                $('#content-div').hide();
                $("#submit").prop('disabled', true);
                var formData = new FormData(this);
                formData.append('type', 'update_price');
                            $.ajax({
                            url: 'apis/update_price.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                                console.log(response);
                                if(response['status']==200){
                                    //  alert(response['message']);
                                     toastr.success(response['message']);
                                     $("#submit").prop('disabled', false);
                                     $("#staticBackdrop .close").click();
                                     emp_datas();
                                     $('#success-div').show();
                                     $('#loading-div').hide();
                                }else{
                                    toastr.error(response['message']);
                                    $("#submit").prop('disabled', false);
                                    $('#loading-div').hide();
                                    $('#content-div').show();
                                }
                            }
                        });
   });
});
</script>