body.on('change','#series',function(){requestSections(this);});
body.on('change','#sections',function(){requestSectionContent(this);});
body.on('change','#projecttypes',function(){showSeries(this);});
body.on('change','#letter_tasktype',function(){changeTaskTypeLetter(this);});
body.on('click','#delete_section',function(){requestDeleteSection();});
body.on('click','#add_new_section',function(){showAddSectionDialog();});
body.on('click','#write_section',function(){requestAddSection();});
body.on('click','#getsectionlist',function(){getSectionList();});
body.on('click','#addseriestopt',function(){addSeriesToProjecttype();});
body.on('click','#write_project_to_twx',function(){writeProjectTWX();});
body.on('click','#project_complete',function(){projectComplete();});
body.on('click','#project_limit',function(){projectLimit();});
body.on('click','#get_sections_from_twx',function(){getSectionsFromTWX(this);});
var activeproj = $("#activeproj").val();
// body.on('click','#add_new_series',function(){requestAddSeries();});
var chosen_section_id = 0;
var chosen_series = '';
var chosen_projecttype = -1;
$(function() {
if (page != 'projects')
GetSeries();
if (page == 'project_types')
showSeries(null);
});
function checkAnswerTWX()
{
var text = $("#result").html();
var yes = text.includes("error");
if (!yes)
Reload();
}
function getSectionsFromTWX(button) {
// alert("activeproj "+activeproj);
var dict = new Object(); //or Map()
dict['get_sections_from_twx'] = activeproj;
sendAjax('result', dict, checkAnswerTWX, 'loco_response.php');
}
function changeTaskTypeLetter(select) {
var letter = select.options[select.selectedIndex].value;
var dict = new Object(); //or Map()
var activett = $("#active_task_type").val();
dict['letter'] = letter;
dict['letter_tasktype'] = activett;
sendAjax('result', dict, Reload, 'loco_response.php');
}
function projectLimit()
{
var current = $("#project_limit").val();
var activeproj = $("#activeproj").val();
if (current == 'Все')
$("#project_limit").val('20');
else
$("#project_limit").val('Все');
SelectProject(activeproj);
// window.location.reload();
}
function projectComplete()
{
var dict = new Object(); //or Map()
var activeproj = $("#activeproj").val();
dict['project_complete'] = activeproj;
dict['userId'] = $("#userId").val();
sendAjax('result', dict, Reload, 'loco_response.php');
}
function writeProjectTWX()
{
var activeproj = $("#activeproj").val();
msgWindow=window.open("writeproject.php?id="+activeproj,"displayWindow",'width=750,height=600,screenX=100,resizable=yes,scrollbars=yes');
// var dict = new Object(); //or Map()
//
// dict['write_project_to_twx'] = activeproj;
// sendAjax('result', dict, null, 'loco_response.php');
}
function addSeriesToProjecttype()
{
var activept = $("#activeptid").val();
var select = $("#loco_type")[0];
series = select.options[select.selectedIndex].value;
var dict = new Object(); //or Map()
dict['pt_addseries'] = activept;
dict['series'] = series;
sendAjax('result', dict, Reload, 'loco_response.php');
}
function showSeries(select) {
var series = $("#activeptid").val();
if (select != null) {
series = select.options[select.selectedIndex].value;
}
chosen_projecttype = series;
var dict = new Object(); //or Map()
dict['showseries'] = series;
sendAjax('chooseseries', dict, null, 'loco_response.php');
GetSeries();
}
function getSectionList() {
var dict = new Object(); //or Map()
dict['getsectionlist'] = 1;
sendAjax('result', dict, null, 'loco_response.php');
}
function showAddSectionDialog() {
$("#section_content").html('');
$("#add_section_container").css("display", "inline-block");
}
function requestAddSection() {
var number = $("#number").val();
var subnumber = $("#subnumber").val();
var section_letter = $("#section_letter").val();
$("#section_content").html('');
var dict = new Object(); //or Map()
dict['addsections'] = chosen_series;
dict['number'] = number;
dict['subnumber'] = subnumber;
dict['section_letter'] = section_letter;
sendAjax('result', dict, null, 'loco_response.php');
GetSeries();
var seriesSelect = $("#series")[0];
requestSections(seriesSelect);
// alert("chosen_series "+chosen_series);
}
function requestDeleteSection() {
if (chosen_section_id > 0) {
var dict = new Object(); //or Map()
dict['delsection'] = chosen_section_id;
sendAjax('result', dict, DeleteSection, 'loco_response.php');
return true;
}
return false;
}
function DeleteSection() {
var seriesSelect = $("#series")[0];
requestSections(seriesSelect);
$("#section_content").html('');
GetSeries();
return true;
}
function GetSeries() {
var dict = new Object(); //or Map()
dict[ 'getseries' ] = -1;//chosen_projecttype;
sendAjax('', dict, ReceiveSeries, 'loco_response.php');
return true;
}
function ReceiveSeries(data) {
// $("#result").html(data);
// alert("page "+page);
data = JSON.parse(data);
var htm = "";
Object.keys(data).forEach(function(id, i, arr) {
var serie = data[id][0];
var uuids = data[id][1];
var all = data[id][2];
var numproj = data[id][3];
if (page == 'project_types' || page == 'projects')
htm += "";
else
htm += "";
});
$("#series").html(htm);
if (chosen_series != '')
$('#series option[value="'+chosen_series+'"]').prop('selected', true);
// $('#series option:contains("'+chosen_series+'")').prop('selected', true);
if (page == 'projects'){
$("#sections_load").css("display", "none");
$("#add_new_section").css("display", "none");
}
}
function requestSections(select) {
if (page == 'projects')
return;
var series = select.options[select.selectedIndex];
if (series.value == 0)
{
$("#sections_container").css("display", "none");
}
else {
$("#sections_container").css("display", "block");
}
chosen_series = series.value;
var dict = new Object(); //or Map()
$("#result").html('');
dict[ 'getsections' ] = series.value;
sendAjax('', dict, ReceiveSections, 'loco_response.php');
return true;
}
function ReceiveSections(data) {
var select = $("#series")[0];
var series = select.options[select.selectedIndex].value;
// if (page != 'projects')
$("#add_new_section").val('Добавить новую секцию серии: '+series);
// else {
//
// $("#sections_load").css("display", "none");
// $("#add_new_section").css("display", "none");
// }
$("#chosenserie").html('Список секций серии '+series);
data = JSON.parse(data);
if (data.length > 0) {
var htm = "";
data.forEach(function(section, i, arr) {
var uuid = "";
if (section.uuid != null)
{
uuid = ' [АСУ СГ]';
}
htm += "";
});
$("#sections").html(htm);
}
else
$("#sections").html("");
}
function requestSectionContent(select) {
if (page != 'projects') {
var section = select.options[select.selectedIndex];
$("#add_section_container").css("display", "none");
if (section.value == 0) {
$("#section_container").css("display", "none");
}
else
$("#section_container").css("display", "block");
var dict = new Object(); //or Map()
dict['getsectioncontent'] = section.value;
$("#result").html('');
sendAjax('', dict, ReceiveSectionContent, 'loco_response.php');
return true;
}
}
function ReceiveSectionContent(data) {
// $("#result").html(data);
data = JSON.parse(data);
var section = data[0];
if (section.id > 0) {
chosen_section_id = section.id;
var DKs = data[1];
var projects = data[2];
$("#section_content").html(
"["+section.id+"] "+section.section_number +" "+section.section_subnumber+"
UUID: "
+section.uuid
+"
Диагностическая карта: "+section.diagnostic_map
+"
Проекты: "+projects.length
+"
DKLen: "+DKs.length
);
for (var i=0; i < DKs.length; i++ ) {
$("#section_content").append("
Диагностическая карта "+(i+1)+": "+DKs[i].uuid);
}
}
else
$("#section_content").html("Нет данных");
}