JezK
Edit File: invoices.php
<?php include_once("../app/checkSession.php"); include("header.php"); $quote_list = $adminObj->db->get_results("SELECT quotation_id FROM uflexit_request_quote as urq where quotation_status =3 and closed_status != 4" ); // print_r($quote_list); ?> <div class="container pl-5 pr-5"> <a href="javascript:history.go(-1)"><img src="images/back_main.png" class="mb-3"></a> <p class="text-dark"><strong><?php echo $lang['INVOICE_GENERATION']; ?></strong></p> </div> <form method="post" action="app/add-invoices.php" class="px-5"> <div class="warehouse_boxshadow container pb-3"> <div class="containercontent"> <div class="card-body invoices_page_div"> <div class="row"> <div class="col-lg-2 col-md-4"> <label for="qutationid"><?php echo $lang['QUOTATION_ID'];?></label> </div> <div class="col-lg-3 col-md-8 "> <!-- <input type="text" class="" id="qutationid" required placeholder="014462" name="quotation_id"> --> <select class="form-control" name="quotation_id" id="qutationid" onchange="getqutationdata(this.value);" required=""> <option value=''><?php echo $lang['SELECT_QUOTATION']; ?></option> <?php foreach ($quote_list as $qlist) { ?> <option value='<?php echo $qlist['quotation_id'] ?>'><?php echo $qlist['quotation_id'] ?> </option> <?php } ?> </select> <div class="error qutationid_error"></div> </div> <div class="col-lg-2 col-md-4 mt-md-3 mt-lg-0" style="max-width: 215px;"> <label for="advshipmentid"><?php echo $lang['VALUE']; ?></label> </div> <div class="col-lg-3 col-md-8 mt-md-3 mt-lg-0"> <input type="text" class="form-control Value " id="val_id" placeholder="<?php echo $lang['VALUE']; ?>" name="val_id" readonly> <span id="currencyLabel" class=""></span> </div> </div> <div class="row mt-4"> <div class="col-lg-2 col-md-4 "> <label for="customername"><?php echo $lang['EMAIL'];?></label> </div> <div class="col-lg-3 col-md-8"> <input type="text" class="form-control " id="invoice_Email" placeholder="<?php echo $lang['EMAIL'];?>" name="invoice_Email" readonly> </div> <div class="col-lg-2 col-md-4 mt-md-3 mt-lg-0" style="max-width: 215px;"> <label for="email"><?php echo $lang['ADMIN']; ?> %</label> </div> <div class="col-lg-3 col-md-8 mt-md-3 mt-lg-0"> <input type="text" class="form-control" id="admin_Amount" placeholder="<?php echo $lang['ADMIN']; ?> %" name="admin_amount" autocomplete="off" > <div class="error admin_Amount_error"></div> <div class=" text-success admin_Amount_msg"></div> </div> </div> <div class="row mt-4 align-items-baseline"> <div class="col-lg-2 col-md-4"> <label for="city"><?php echo $lang['DESCRIPTION'];?></label> </div> <div class="col-lg-8 col-md-8"> <textarea type="text" class="form-control" id="invoice_description" placeholder="<?php echo $lang['DESCRIPTION'];?>" name="invoice_description" ></textarea> </div> </div> </div> </div> </div> <input type="hidden" name="adminper_amount" id="adminper_amount" > <input type="hidden" name="warehouse_id" id="warehouse_id" > <input type="hidden" name="admin_Ramount" id="admin_Ramount" > <input type="hidden" name="user_id" id="user_id" > <button id="addRowSave" type="submit" name="saveinvoice" class="float-right mr-1 mt-3" onclick="return receivedtransactionvalidations()"><?php echo $lang['SAVE']; ?></button> </form> </div> <?php include("footer.php"); ?> <style> .newRow_add tr td { padding: 0px !important; } .newRow_add tr td input { width: 100% !important; border: none; background: #eaeffa; padding: 10px; border-bottom: 1px solid #3663c88c; } button#addRow, button#addRowSave { background: #3663c8; border: none; padding: 5px 15px; color: #fff; font-weight: bold; } .invoices_page_div input { width: 100%; border: 1px solid #ced4da; border-radius: 5px; padding: 0px 5px; } .table-bordered td, .table-bordered th { border: 1px solid grey; } .btn-color { opacity: 0.5; } input.Value { width: 75% !important; } span.currencyType1 { position: absolute; right: 10px; bottom: 0px; padding: 6px; border: 1px solid #e9ecef; background-color: #e9ecef; color: #3663c8; border-radius: 4px; font-weight: bold; } </style> <script> function getqutationdata(qid) { var div_data = ""; $.ajax({ url: '../ajax.php', type: "POST", data: ({ action: 'get_invoiceData', qid: qid }), success: function(res) { console.log(res) result = JSON.parse(res); $('#val_id').val(result[0].admin_expected_rate); $('#invoice_Email').val(result[0].email); $("#warehouse_id").val(result[0].warehouse_id); $("#user_id").val(result[0].user_id) $('#currencyLabel').html(result[0].currency); } }) $('#currencyLabel').addClass('currencyType1') } function receivedtransactionvalidations() { let Quote_id = document.getElementById('qutationid').value; let admin_amount = document.getElementById('admin_Amount').value; console.log(admin_Amount); $('.error').html(''); if (Quote_id == '') { $('.qutationid_error').html('<?php echo $lang['SELECT_QUOTATION_ID']?>'); $('#Quote_id').focus(); return false; }else if (admin_amount == '') { $('.admin_Amount_error').html('<?php echo $lang['ADMIN_PERCENTAGE_SHOULD_NOT_BE_EMPTY']?>'); $('#admin_Amount').focus() return false; } } $("#admin_Amount").on('keyup',function(){ var totalAmount=this.value; if (totalAmount > 100){ $('.admin_Amount_error').html('<?php echo $lang['ADMIN_PERCENTAGE_SHOULD_NOT_BE_GREATER_THAN_100'] ?>'); $('#admin_Amount').val(""); $('#admin_Amount').focus(); $(".admin_Amount_msg").html(""); return false; } else{ var val_id = document.getElementById('val_id').value; if(val_id==""){ alert("<?php echo $lang['PLEASE_SELECT_THE_QUOTATION_FIRST'] ?>"); return false; } var adminPercent=(val_id/100)*totalAmount; var admin_Ramount=val_id-adminPercent; $('#adminper_amount').val(adminPercent); $('#admin_Ramount').val(admin_Ramount); $('.admin_Amount_error').html(''); $(".admin_Amount_msg").html("<?php echo $lang['YOU_WILL_RECIEVE_AN_AMOUNT_OF'] ?> "+adminPercent); } }) function checkLimit(value){ if ($(this).val() > 100){ alert("<?php echo $lang['NO_NUMBERS_ABOVE_100'] ?>"); $(this).val('100'); } } </script>