var wizardData = {};
function wizardDelete(nr){
var path = '/manager/' + nr;
$.ajax({
url: path,
type: 'DELETE'
})
.done(function(){
viewChargenubersicht();
})
.fail(function(){
alert("Charge konnte nicht gelöscht werden");
});
};
function wizardSend(){
//wizardData -> ajax -> server -> fuckoff
var path = '/manager/' + JSON.stringify(wizardData);
$.ajax({
url: path,
type: 'RECEIVE'
})
.done(function(){
viewChargenubersicht();
})
.fail(function(){
alert("die Übertragung der Chargendaten zum Server ist fehlgeschlagen");
});
};
function wizardLosDataSave(los_nr, next_los_nr){
wizardData[los_nr]['beschreibung'] = document.getElementById('beschreibung').value;
wizardData[los_nr]['anzGebinde'] = parseInt(document.getElementById('anzGebinde').value);
wizardData[los_nr]['auktionDauer'] = parseInt(document.getElementById('auktionDauer').value);
wizardData[los_nr]['auktionLaufzeit'] = 0;
wizardData[los_nr]['startPreis'] = parseInt(document.getElementById('startPreis').value);
wizardData[los_nr]['minPreis'] = parseInt(document.getElementById('minPreis').value);
wizardData[los_nr]['auktionPreis'] = -1;
wizardData[los_nr]['vkPreis'] = -1;
if(next_los_nr == 0){
wizardSend();
}
else if(next_los_nr > wizardData['info']['anzAuk']){
wizardLosData(next_los_nr, 1);
}
else{
wizardLosData(next_los_nr, 0);
}
};
function wizardLosData(los_nr, neu){
$('#content').html('
Los ' + los_nr + '
');
if(neu){
wizardData['info']['anzAuk']++;
wizardData[los_nr] = {};
$.get('templates/html/losLeerForm.html', function(markup){
$('#content').append(markup);
if(los_nr > 9){
$('#content').append('');
}
else if(los_nr == 1){
$('#content').append('');
}
else{
$('#content').append('');
}
})
}
else{
markup = TPL.engine.execute_px('losFilledForm.tpl',wizardData[los_nr]);
$('#content').append(markup);
if(los_nr > 9){
$('#content').append('');
}
else if(los_nr == 1){
$('#content').append('');
}
else{
$('#content').append('');
}
}
};
function wizardChargennameSave(neu){
wizardData['info']['name'] = document.getElementById('chargenname').value;
if(neu){
wizardLosData(1, 1);
}
else{
wizardLosData(1, 0);
}
};
function wizardChargenname(neu){
if(neu){
$('#content').html('neue Charge
');
$('#content').append('');
$('#content').append('');
}
else{
$('#content').html('Charge bearbeiten
');
$('#content').append('');
$('#content').append('');
}
};
function wizardStart(chargenNr = 0){
if(chargenNr != 0){
var path = '/manager/' + chargenNr;
$.ajax({
dataType: "json",
url: path,
type: 'GET'
})
.done(function(data){
wizardData = eval("(" + data + ")");
wizardChargenname(0);
})
.fail(function(){
alert("Charge konnte nicht geladen werden");
});
}
else{
wizardData = {};
wizardData['info'] = {};
wizardData['info']['anzAuk'] = 0;
wizardData['info']['chargenNr'] = -1;
wizardChargenname(1);
}
}