2023-05-11 19:18:19 +08:00
|
|
|
/* global bwipjs PrintModalComponent RepositoryDatatable HelperModule MyModuleRepositories */
|
2021-07-22 03:32:42 +08:00
|
|
|
|
2018-02-27 23:21:46 +08:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
$(document).on('click', '.record-info-link', function(e) {
|
|
|
|
var that = $(this);
|
2023-04-25 20:30:14 +08:00
|
|
|
let params = {};
|
2023-05-24 16:35:58 +08:00
|
|
|
if ($('.my-modules-protocols-index, #results').length) {
|
|
|
|
params.my_module_id = $('.my-modules-protocols-index, #results').data('task-id');
|
2023-04-25 20:30:14 +08:00
|
|
|
}
|
2023-05-24 16:35:58 +08:00
|
|
|
|
2018-02-27 23:21:46 +08:00
|
|
|
$.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: that.attr('href'),
|
2023-04-25 20:30:14 +08:00
|
|
|
data: params,
|
2018-02-27 23:21:46 +08:00
|
|
|
dataType: 'json'
|
|
|
|
}).done(function(xhr, settings, data) {
|
2022-07-06 17:44:30 +08:00
|
|
|
if ($('#modal-info-repository-row').length) {
|
|
|
|
$('#modal-info-repository-row').find('.modal-body #repository_row-info-table').DataTable().destroy();
|
|
|
|
$('#modal-info-repository-row').remove();
|
|
|
|
$('.modal-backdrop').remove();
|
|
|
|
}
|
2018-02-27 23:21:46 +08:00
|
|
|
$('body').append($.parseHTML(data.responseJSON.html));
|
2023-04-25 20:30:14 +08:00
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
2018-02-27 23:21:46 +08:00
|
|
|
$('#modal-info-repository-row').modal('show', {
|
|
|
|
backdrop: true,
|
|
|
|
keyboard: false
|
|
|
|
}).on('hidden.bs.modal', function() {
|
2018-03-02 21:14:27 +08:00
|
|
|
$(this).find('.modal-body #repository_row-info-table').DataTable().destroy();
|
2018-02-27 23:21:46 +08:00
|
|
|
$(this).remove();
|
|
|
|
});
|
2021-07-22 03:32:42 +08:00
|
|
|
|
|
|
|
let barCodeCanvas = bwipjs.toCanvas('bar-code-canvas', {
|
|
|
|
bcid: 'qrcode',
|
|
|
|
text: $('#modal-info-repository-row #bar-code-canvas').data('id').toString(),
|
|
|
|
scale: 3
|
|
|
|
});
|
|
|
|
$('#modal-info-repository-row #bar-code-image').attr('src', barCodeCanvas.toDataURL('image/png'));
|
|
|
|
|
2018-03-02 21:14:27 +08:00
|
|
|
$('#repository_row-info-table').DataTable({
|
2018-02-27 23:21:46 +08:00
|
|
|
dom: 'RBltpi',
|
|
|
|
stateSave: false,
|
|
|
|
buttons: [],
|
|
|
|
processing: true,
|
|
|
|
colReorder: {
|
|
|
|
fixedColumnsLeft: 1000000 // Disable reordering
|
|
|
|
},
|
|
|
|
columnDefs: [{
|
|
|
|
targets: 0,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false
|
|
|
|
}],
|
|
|
|
fnDrawCallback: function(settings, json) {
|
|
|
|
animateSpinner(this, false);
|
|
|
|
},
|
|
|
|
preDrawCallback: function(settings) {
|
|
|
|
animateSpinner(this);
|
|
|
|
}
|
|
|
|
});
|
2023-09-07 19:12:27 +08:00
|
|
|
|
|
|
|
// Stock Consumption Export Action
|
|
|
|
$(document).on('click', '.export-consumption-button', function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
$('#modal-info-repository-row').modal('hide');
|
|
|
|
// set and unset data-rows value so export knows to ignore selected rows or not
|
|
|
|
$('#exportStockConsumptionModal')
|
|
|
|
.on('show.bs.modal', function() {
|
|
|
|
$('#exportStockConsumptionModal').attr(
|
|
|
|
'data-rows',
|
|
|
|
$('#modal-info-repository-row .print-label-button').attr('data-rows')
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.on('hide.bs.modal', function() {
|
|
|
|
$('#exportStockConsumptionModal').attr('data-rows', null);
|
|
|
|
})
|
|
|
|
.modal('show');
|
|
|
|
});
|
2018-02-27 23:21:46 +08:00
|
|
|
});
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
});
|
2021-07-22 03:32:42 +08:00
|
|
|
|
2023-05-17 17:27:55 +08:00
|
|
|
$(document).on('click', '.print-label-button', function(e) {
|
2022-09-29 20:43:06 +08:00
|
|
|
var selectedRows = $(this).data('rows');
|
2023-05-17 17:27:55 +08:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
2022-11-14 17:42:51 +08:00
|
|
|
if (typeof PrintModalComponent !== 'undefined') {
|
|
|
|
PrintModalComponent.showModal = true;
|
2023-05-17 17:27:55 +08:00
|
|
|
if (selectedRows && selectedRows.length) {
|
2022-11-14 17:42:51 +08:00
|
|
|
$('#modal-info-repository-row').modal('hide');
|
|
|
|
PrintModalComponent.row_ids = selectedRows;
|
|
|
|
} else {
|
2023-04-25 21:18:12 +08:00
|
|
|
PrintModalComponent.row_ids = [...RepositoryDatatable.selectedRows()];
|
2022-11-14 17:42:51 +08:00
|
|
|
}
|
2022-09-29 20:43:06 +08:00
|
|
|
}
|
2022-09-22 17:07:08 +08:00
|
|
|
});
|
2023-05-11 19:18:19 +08:00
|
|
|
|
|
|
|
$(document).on('click', '.assign-inventory-button', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
let assignUrl = $(this).data('assignUrl');
|
|
|
|
let repositoryRowId = $(this).data('repositoryRowId');
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: assignUrl,
|
|
|
|
type: 'POST',
|
|
|
|
data: { repository_row_id: repositoryRowId },
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
|
|
|
HelperModule.flashAlertMsg(data.flash, 'success');
|
|
|
|
$('#modal-info-repository-row').modal('hide');
|
|
|
|
if (typeof MyModuleRepositories !== 'undefined') {
|
|
|
|
MyModuleRepositories.reloadRepositoriesList(repositoryRowId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function(error) {
|
|
|
|
HelperModule.flashAlertMsg(error.responseJSON.flash, 'danger');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-07-06 17:44:30 +08:00
|
|
|
}());
|