commit milestone3 source
This commit is contained in:
@@ -23,6 +23,23 @@
|
||||
|
||||
<script src="../assets/js/jquery.min.js"></script>
|
||||
<style>
|
||||
.width-100 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.flex_center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mg_none {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.table-custom tr {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
@@ -73,6 +90,10 @@
|
||||
padding: 2px 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.padding_none {
|
||||
padding: 0 !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -232,9 +253,10 @@
|
||||
});
|
||||
|
||||
let tmp_id_template_importify = 0;
|
||||
|
||||
function onRunImport(id_template_importify) {
|
||||
tmp_id_template_importify = id_template_importify;
|
||||
$('#f_csv').trigger("click");
|
||||
$('#f_csv').trigger("click");
|
||||
}
|
||||
|
||||
$('#f_csv').change(function(){
|
||||
@@ -243,6 +265,262 @@
|
||||
formdata.append("f_csv", $(this).prop('files')[0]);
|
||||
formdata.append("template_id", tmp_id_template_importify);
|
||||
|
||||
$.ajax({
|
||||
url: 'check_vocabulary.php',
|
||||
type: 'POST',
|
||||
data: formdata,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
beforeSend: function() {
|
||||
$('#ajax_preloader').fadeIn();
|
||||
},
|
||||
error: function() {
|
||||
$('#f_csv').val("");
|
||||
$('#ajax_preloader').fadeOut();
|
||||
showWarningAlert("Server Error");
|
||||
},
|
||||
success: function(data) {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
if(data.indexOf("success") > -1) {
|
||||
let arr_data = JSON.parse(data);
|
||||
let arr_analysisvoc = arr_data['arr_analysis_data'];
|
||||
console.log(arr_analysisvoc);
|
||||
let arr_compundsvoc = arr_data['arr_compunds_data'];
|
||||
console.log(arr_compundsvoc);
|
||||
|
||||
tmp_analyvoc_idx = 0;
|
||||
tmp_compundsvoc_idx = 0;
|
||||
arr_total_analysisvoc = arr_analysisvoc;
|
||||
arr_total_compundsvoc = arr_compundsvoc;
|
||||
tmp_str_arr_compunds_kind_option = '';
|
||||
tmp_str_arr_kind_option = '';
|
||||
|
||||
show_analysis_add_pop();
|
||||
}else if(data.indexOf("none_define_column_error") > -1) {
|
||||
$('#f_csv').val("");
|
||||
showWarningPopup("The Associate Columns did not define yet!");
|
||||
} else if(data.indexOf("invalid_excel_data_format_error") > -1) {
|
||||
$('#f_csv').val("");
|
||||
showWarningPopup("Excel data format is not valid!")
|
||||
} else {
|
||||
$('#f_csv').val("");
|
||||
showWarningAlert("Server Error.")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
let arr_total_analysisvoc = Array();
|
||||
let tmp_analyvoc_idx = 0;
|
||||
let arr_total_compundsvoc = Array();
|
||||
let tmp_compundsvoc_idx = 0;
|
||||
function show_analysis_add_pop() {
|
||||
if(tmp_analyvoc_idx < arr_total_analysisvoc.length) {
|
||||
show_analysis_add_popup(arr_total_analysisvoc[tmp_analyvoc_idx], function() {
|
||||
tmp_analyvoc_idx++;
|
||||
show_analysis_add_pop();
|
||||
})
|
||||
} else {
|
||||
show_compunds_add_pop();
|
||||
}
|
||||
}
|
||||
|
||||
function show_compunds_add_pop() {
|
||||
if(tmp_compundsvoc_idx < arr_total_compundsvoc.length) {
|
||||
show_compunds_add_popup(arr_total_compundsvoc[tmp_compundsvoc_idx], function() {
|
||||
tmp_compundsvoc_idx++;
|
||||
show_compunds_add_pop();
|
||||
})
|
||||
} else {
|
||||
import_auto_script();
|
||||
}
|
||||
}
|
||||
|
||||
let tmp_str_arr_kind_option = '';
|
||||
function show_analysis_add_popup(voc_info, callback) {
|
||||
let str_word = voc_info['word'];
|
||||
let arr_similary = voc_info['arr_similary'];
|
||||
|
||||
let str_arr_option = '';
|
||||
for(let i=0; i<arr_similary.length; i++) {
|
||||
str_arr_option += '<option value="' + arr_similary[i]['refid'] + '">' + arr_similary[i]['nameanalysisvoc'] + '</option>';
|
||||
}
|
||||
str_arr_option += tmp_str_arr_kind_option;
|
||||
|
||||
let swal_html = `<div class="row">
|
||||
<div class="col-md-12">
|
||||
<select class="form-control ipt_type">`;
|
||||
swal_html += str_arr_option;
|
||||
|
||||
swal_html += `<option value="0">Add new</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Name</label>
|
||||
<input class="form-control ipt_name ipt_val" ` + (str_arr_option != "" ? "" : "readonly") + ` placeholder="Please input name." value="` + str_word + `">
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Kind</label>
|
||||
<input class="form-control ipt_kind ipt_val" placeholder="Please input kind.">
|
||||
</div>
|
||||
</div>`;
|
||||
Swal.fire({
|
||||
html: swal_html,
|
||||
title: 'Which analysis wants you to associate?<br><span>"' + str_word + '"</span>',
|
||||
showCancelButton: false,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Confirm',
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
$('.swal2-popup .ipt_type').bind("click", function() {
|
||||
if($(this).val() == 0) {
|
||||
$('.div_input').removeClass("hidden");
|
||||
$('.ipt_val').val("");
|
||||
$('.swal2-popup .ipt_name').val(str_word);
|
||||
$('.swal2-popup .ipt_name').attr("readonly", "readonly");
|
||||
} else {
|
||||
$('.div_input').addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
$('.swal2-popup .ipt_type').trigger("change");
|
||||
},
|
||||
}).then((result) => {
|
||||
let type = $('.swal2-popup .ipt_type').val();
|
||||
let str_name = $('.swal2-popup .ipt_name').val();
|
||||
let str_kind = $('.swal2-popup .ipt_kind').val();
|
||||
|
||||
$.ajax({
|
||||
url: 'add_analysis_voc.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
type: type,
|
||||
str_name: str_name,
|
||||
str_kind: str_kind,
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#ajax_preloader').fadeIn();
|
||||
},
|
||||
error: function() {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
showSuccessAlert("Successfully added!");
|
||||
},
|
||||
success: function(data) {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
if(data.indexOf("success") > -1) {
|
||||
if(type == 0) {
|
||||
let inserted_info = JSON.parse(data)['info'];
|
||||
tmp_str_arr_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||
}
|
||||
showSuccessAlert("Successfully added!");
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
let tmp_str_arr_compunds_kind_option = '';
|
||||
function show_compunds_add_popup(voc_info, callback) {
|
||||
let str_word = voc_info['word'];
|
||||
let str_analysis_word = voc_info['anaysis_word'];
|
||||
let arr_similary = voc_info['arr_similary'];
|
||||
|
||||
let str_arr_option = '';
|
||||
for(let i=0; i<arr_similary.length; i++) {
|
||||
str_arr_option += '<option value="' + arr_similary[i]['refid'] + '">' + arr_similary[i]['namecompoundsvocabulary'] + '</option>';
|
||||
}
|
||||
str_arr_option += tmp_str_arr_compunds_kind_option;
|
||||
|
||||
let swal_html = `<div class="row">
|
||||
<div class="col-md-12">
|
||||
<select class="form-control ipt_type">`;
|
||||
swal_html += str_arr_option;
|
||||
|
||||
swal_html += `<option value="0">Add new</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Name</label>
|
||||
<input class="form-control ipt_name ipt_val" ` + (str_arr_option != "" ? "" : "readonly") + ` placeholder="Please input component name." value="` + str_word + `">
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Cascompound</label>
|
||||
<input class="form-control ipt_kind ipt_val" placeholder="Please input cascompound.">
|
||||
</div>
|
||||
</div>`;
|
||||
Swal.fire({
|
||||
html: swal_html,
|
||||
title: 'Which component wants you to associate?<br><span>"' + str_word + '"</span>',
|
||||
showCancelButton: false,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Confirm',
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
$('.swal2-popup .ipt_type').bind("click", function() {
|
||||
if($(this).val() == 0) {
|
||||
$('.div_input').removeClass("hidden");
|
||||
$('.ipt_val').val("");
|
||||
$('.swal2-popup .ipt_name').val(str_word);
|
||||
$('.swal2-popup .ipt_name').attr("readonly", "readonly");
|
||||
} else {
|
||||
$('.div_input').addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
$('.swal2-popup .ipt_type').trigger("change");
|
||||
},
|
||||
}).then((result) => {
|
||||
let type = $('.swal2-popup .ipt_type').val();
|
||||
let str_name = $('.swal2-popup .ipt_name').val();
|
||||
let str_kind = $('.swal2-popup .ipt_kind').val();
|
||||
|
||||
$.ajax({
|
||||
url: 'add_compunds_voc.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
type: type,
|
||||
analysis_name: str_analysis_word,
|
||||
str_name: str_name,
|
||||
str_kind: str_kind,
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#ajax_preloader').fadeIn();
|
||||
},
|
||||
error: function() {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
showSuccessAlert("Successfully added!");
|
||||
},
|
||||
success: function(data) {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
if(data.indexOf("success") > -1) {
|
||||
if(type == 0) {
|
||||
let inserted_info = JSON.parse(data)['info'];
|
||||
tmp_str_arr_compunds_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||
}
|
||||
showSuccessAlert("Successfully added!");
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function import_auto_script() {
|
||||
let formdata = new FormData();
|
||||
if($('#f_csv').prop('files').length > 0) {
|
||||
formdata.append("f_csv", $('#f_csv').prop('files')[0]);
|
||||
formdata.append("template_id", tmp_id_template_importify);
|
||||
|
||||
$.ajax({
|
||||
url: 'import_auto_script.php',
|
||||
type: 'POST',
|
||||
@@ -272,7 +550,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user