| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app.ansachsongkhoe.net/public/js/ |
Upload File : |
$(document).ready(function() {
$(document).on('change', '.purchase_quantity', function() {
update_table_total($(this).closest('table'));
});
$(document).on('change', '.unit_price', function() {
update_table_total($(this).closest('table'));
});
$('.os_exp_date').datepicker({
autoclose: true,
format: datepicker_date_format,
});
$(document).on('click', '.add_stock_row', function() {
var tr = $(this).data('row-html');
var key = parseInt($(this).data('sub-key'));
tr = tr.replace(/\__subkey__/g, key);
$(this).data('sub-key', key + 1);
$(tr)
.insertAfter($(this).closest('tr'))
.find('.os_exp_date')
.datepicker({
autoclose: true,
format: datepicker_date_format,
});
});
$(document).on('click', '.add-opening-stock', function(e) {
e.preventDefault();
$.ajax({
url: $(this).data('href'),
dataType: 'html',
success: function(result) {
$('#opening_stock_modal')
.html(result)
.modal('show');
},
});
});
});
//Re-initialize data picker on modal opening
$('#opening_stock_modal')
.off()
.on('shown.bs.modal', function(e) {
$('.os_exp_date').datepicker({
autoclose: true,
format: datepicker_date_format,
});
});
$(document).on('click', 'button#add_opening_stock_btn', function(e) {
e.preventDefault();
var btn = $(this);
var data = $('form#add_opening_stock_form').serialize();
$.ajax({
method: 'POST',
url: $('form#add_opening_stock_form').attr('action'),
dataType: 'json',
data: data,
beforeSend: function(xhr) {
__disable_submit_button(btn);
},
success: function(result) {
if (result.success == true) {
$('#opening_stock_modal').modal('hide');
toastr.success(result.msg);
} else {
toastr.error(result.msg);
}
},
});
return false;
});
function update_table_total(table) {
var total_subtotal = 0;
table.find('tbody tr').each(function() {
var qty = __read_number($(this).find('.purchase_quantity'));
var unit_price = __read_number($(this).find('.unit_price'));
var row_subtotal = qty * unit_price;
$(this)
.find('.row_subtotal_before_tax')
.text(__number_f(row_subtotal));
total_subtotal += row_subtotal;
});
table.find('tfoot tr #total_subtotal').text(__currency_trans_from_en(total_subtotal, true));
table.find('tfoot tr #total_subtotal_hidden').val(total_subtotal);
}