// inserat scripts
var t_inseratid; // holds the current edit inserat id. do not use "tempEditID", because this one will used in other chaning methods like rubric
var t_testauftrag; //holds the flag if its a test order
var t_isOnlineAuftrag; // if its a online auftrag
var t_isCopyFromOnline; // holds the flag, if its a copy from online inserat
var masterCopyTitleID = ""; // Holds the master copy titleid which is used for copy fields
// new inserat (from auftrag verwaltung and object verwaltung)
var t_woid;
function newInserat(resetWOID, isOnlineAuftrag) {
t_testauftrag = false;
t_isOnlineAuftrag = false;
if (resetWOID) {
t_woid = "";
}
if (isOnlineAuftrag) {
t_isOnlineAuftrag = true;
}
// create tempid and show sortiment selector dialog
t_inseratid = CreateNewTempID();
tempEditID = t_inseratid; // set temp edit id, beacuse tempid is used in a core.js method (showpage method)
if (ShowSortiment) {
$("#dialog_SortimentSelection").dialog("open");
}
else {
if (SortimentDefault == null) {
ShowMainAlert("Keine Sortiment verfübgar.");
}
else {
_newInserat(SortimentDefault.split("|")[0], SortimentDefault.split("|")[1]);
}
}
}
function _newInserat(sortiment, sortimentBez) {
$("#dialog_SortimentSelection").dialog("close");
ShowOverlay();
$.get("../ajax/rest.aspx?action=editInserat&isCopyFromOnline=" + t_isCopyFromOnline + "&inseratid=" + t_inseratid, { sortiment: sortiment, sortimentBez: sortimentBez, woid: t_woid, isOnlineAuftrag : t_isOnlineAuftrag }, function (restObj) {
// reset old hashtable and some flags
templateTable = new Hashtable();
ShowPage("inseratedit.aspx", false);
// if its a copy always show media selection, because vorlageid is already selected
if (t_isCopyFromOnline) {
setTimeout(function () {
ShowAllTitelSelection();
}, 1500);
t_isCopyFromOnline = false;
}
// overwrite t_woid
t_woid = restObj;
// set sortiment titel with timeout (page must loaded)
setTimeout(function () {
$('#SP_VorlagenMedienWahlSortimentTitle').html("(" + sortimentBez + ")");
}, 1500);
});
}
function newObjectInserat(woid) {
// set woid to temp var
t_woid = woid;
t_testauftrag = false;
// count drafts
$.get("../ajax/json.aspx?action=GetInseratEntwurfObject", function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
switch (jsonObj.aaData.length) {
case 0:
// no draft, create a new one
newInserat(false);
break;
case 1:
// only one, so get inserat id and jump
t_inseratid = jsonObj.aaData[0].fInseratID;
tempEditID = t_inseratid;
_newInserat(SortimentDefault.split("|")[0], SortimentDefault.split("|")[1]);
break;
default:
// more than once, so show draft dialog
draftHTML = "";
$(jsonObj.aaData).map(function () {
draftHTML += "" + this.fTitel + " (" + this.fSortimentBezeichnung + ")" + " ";
});
$("#dialog_InseratDraftSelectionContent").html(draftHTML + "
");
$("#dialog_InseratDraftSelection").dialog("open");
break;
}
});
}
function _newObjectInserat(inseratID) {
// draft is selected, so overwrite tempid with draft and go to inserat
t_inseratid = inseratID;
$("#dialog_InseratDraftSelection").dialog("close");
tempEditID = t_inseratid; // set temp edit id, beacuse tempid is used in a core.js method (showpage method)
_newInserat(SortimentDefault.split("|")[0], SortimentDefault.split("|")[1]);
}
// edit inserat from datatable
function EditInseratFromTable(auftragsnr, createNewOrderID) {
// get xml
ShowOverlay();
$.get("../ajax/rest.aspx?action=getAuftragXML&createNewOrderID=" + createNewOrderID + "&auftragsnr=" + auftragsnr, function (restObj) {
if (restObj.split('|')[0] != "false") {
EditInserat(restObj.split('|')[1]);
}
else {
HideOverlay();
ShowMainAlert(restObj.split('|')[1]);
}
});
}
// online2print
function OnlineToPrint(auftragsnr, vorlageID) {
t_vorlageid = vorlageID;
// get xml
ShowOverlay();
$.get("../ajax/rest.aspx?action=getAuftragXML&createNewOrderID=true&isFromOnline=true&auftragsnr=" + auftragsnr, function (restObj) {
HideOverlay();
t_isCopyFromOnline = true;
newInserat(true, false);
});
}
// test inserat
function newTestInserat() {
$("#dialog_testAuftrag").dialog("open");
}
function _newTestInserat() {
$("#dialog_testAuftrag").dialog("close");
// now save test values
$.get("../ajax/rest.aspx?action=saveEditorTestDatas", { testurl: $("#dialog_testAuftrag_url").val(), testfarbzahl: $("#dialog_testAuftrag_farbzahl").val(), testsprachcode: $("#dialog_testAuftrag_sprachcode").val(), testspalten: $("#dialog_testAuftrag_spaltzenzahl").val() }, function (restObj) {
__newTestInserat();
});
}
function __newTestInserat() {
t_testauftrag = true;
t_inseratid = CreateNewTempID();
tempEditID = t_inseratid;
ShowOverlay();
// cerate test auftrag, always use "TestSortiment" in bezeichnung for correct filtering and deleting these test orders!
$.get("../ajax/rest.aspx?action=editInserat&inseratid=" + t_inseratid, { sortiment: $("#dialog_testAuftrag_sortiment").val(), sortimentBez: 'TestSortiment', woid: t_woid }, function (restObj) {
// reset old hashtable
templateTable = new Hashtable();
ShowPage("inseratedit.aspx", false);
// show hidden datas
$("#hiddeneditordatas").css("display", "block");
});
}
// edit inserat normal
function EditInserat(inseratid) {
ShowOverlay();
tempEditID = inseratid; // set temp edit id, beacuse tempid is used in a core.js method (showpage method)
t_inseratid = inseratid;
$.get("../ajax/rest.aspx?action=editInserat&inseratid=" + t_inseratid, function (restObj) {
// reset old hashtable
templateTable = new Hashtable();
// and fill up hashtable
$.get("../ajax/json.aspx?action=GetEditorDatas&useFirtsTitle=true&id=" + t_inseratid, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
$(jsonObj.aaDataFields).map(function () {
// check if key exist
if (!templateTable.containsKey(this.fTextelement)) {
// insert with correct value
templateTable.put(this.fTextelement, this.fText);
}
else {
// replace with correct value
templateTable.remove(this.fTextelement);
templateTable.put(this.fTextelement, this.fText);
}
});
});
ShowPage("inseratedit.aspx", false);
});
}
// del inserat (only new)
function DelAuftrag(aufsujetnr) {
tempEditID = aufsujetnr;
$("#dialog_delAuftrag").dialog("open");
}
function _DelAuftrag() {
$("#dialog_delAuftrag").dialog("close");
ShowOverlay();
$.get("../ajax/rest.aspx?action=delAuftrag&sujetNr=" + tempEditID, function (restObj) {
ShowPage("auftraege_neu.aspx", false);
});
return false;
}
// cancel publication
var t_cancelauftragsnr;
var t_cancelobjekt;
function CancelPublication(auftragsnr, sujet, objekt) {
t_cancelauftragsnr = auftragsnr;
t_cancelobjekt = objekt;
$.get("../ajax/json.aspx?action=GetAuftragEinzel", { auftragsnr: auftragsnr, sujet: sujet, objekt: objekt }, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
var html = "Klicken Sie auf das zu löschende Publikationsdatum: ";
$(jsonObj.aaData).map(function () {
if (this.CancelPublication) {
html += "" + this.fErscheinung + " ";
}
});
$("#dialog_cancelPublicationContent").html(html + "
");
$("#dialog_cancelPublication").dialog("open");
});
}
function _CancelPublication(fAufdetnr, fErscheinung, fVerlagsmail) {
$("#dialog_cancelPublication").dialog("close");
$("#dialog_orderDetails").dialog("close"); // close both
$.get("../ajax/rest.aspx?action=delAuftragPublication", { fAufdetnr: fAufdetnr, fErscheinung: fErscheinung, auftragsnr: t_cancelauftragsnr, objekt: t_cancelobjekt, fVerlagsmail: fVerlagsmail }, function (restObj) {
refreshDatas('auftrag');
});
}
//and show details (use same temp values like in cancel publication function)
function ShowOrderDetails(auftragsnr, sujet, objekt) {
ShowOverlay(); // because, if files are must recreated, it takes more time
t_cancelauftragsnr = auftragsnr;
t_cancelobjekt = objekt;
$.get("../ajax/json.aspx?action=GetAuftragEinzel", { auftragsnr: auftragsnr, sujet: sujet, objekt: objekt }, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
var html = "Auftragsnummer: " + jsonObj.Aufnr + " ";
html += "Betreff: " + jsonObj.Betreff + " ";
html += "Objekt: " + jsonObj.Objekt + " ";
html += "Rubrik: " + jsonObj.Rubrik + " ";
html += "URubrik: " + jsonObj.URubrik + " ";
html += "Kundenkostenstelle: " + jsonObj.Kundenkostenstelle + " ";
html += "Referenz: " + jsonObj.Fremdauf + " ";
html += "Mitteilung an Verlag: " + jsonObj.manustext + " ";
html += "Bruttopreis: " + jsonObj.Brutto + " ";
html += "Nettopreis: " + jsonObj.Netto + " ";
html += "Farbzahl: " + jsonObj.Farbzahl + " ";
html += "Debitor: " + jsonObj.Debitor + " ";
html += "Versandadresse: " + jsonObj.Versandadresse + " ";
// cancel publications againg
html+="Erscheinungen Klicken Sie auf das zu löschende Publikationsdatum: ";
$(jsonObj.aaData).map(function () {
if (this.CancelPublication) {
html += "" + this.fErscheinung + " ";
}
else {
html += " " + this.fErscheinung + " (nicht mehr sistierbar)";
}
});
$("#dialog_orderDetailsContent").html(html + "
");
// image preview
if (jsonObj.Vorschaubild != "") {
var previewhtml = "";
$.each(jsonObj.Vorschaubild.split('|'), function (index, value) {
if (value != "") {
previewhtml+="
PDF laden ";
}
});
previewhtml+="
";
$("#dialog_orderDetailsContentPDFImage").html(previewhtml);
}
else {
$("#dialog_orderDetailsContentPDFImage").html("Kein Bild vorhanden.
");
}
HideOverlay();
$("#dialog_orderDetails").dialog("open");
});
}
// fill up inserat mask
var t_inseratmainid;
var t_vorlageid;
var t_UpdateErscheinungInseratID;
var t_sammelinseratSelected = false;
function FillUpEdiInseratForm(JSONData) {
// reset flag
t_sammelinseratSelected = false;
t_UpdateErscheinungInseratID = JSONData.fInseratID;
t_inseratmainid = JSONData.fInseratID;
// set anz erscheinungen
$("#anzErscheinungen").val(JSONData.fAnzahlErscheinungen);
// rechnungsadresse
$("#insadresse_anrede").val(JSONData.fAnredecode)
$("#insadresse_vorname").val(JSONData.fVorname);
$("#insadresse_namefirma").val(JSONData.fNameFirma);
$("#insadresse_strasse").val(JSONData.fStrasse);
$("#insadresse_strassenr").val(JSONData.fStrasseNr);
$("#insadresse_plz").val(JSONData.fPLZ);
$("#insadresse_ort").val(JSONData.fOrt);
$("#insadresse_land").val(JSONData.fLandcode)
$("#insadresse_telefon").val(JSONData.fTelefon);
$("#insadresse_email").val(JSONData.fEmail);
// create available objects
$('#inserat_objektselection').empty();
$('#inserat_objektselection').append($('', { value: "" }).text("Wählen Sie ein Objekt"));
$.get("../ajax/json.aspx?action=getInseratObjects&id=" + t_inseratid, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
if (jsonObj.aaDataInsObjects.length >= 1) {
$('#DV_ObjectSelectionBox').show();
$('#DV_Auftragsmappe').css("margin-top", "-128px");
}
else {
$('#DV_ObjectSelectionBox').hide();
$('#DV_Auftragsmappe').css("margin-top", "0px");
}
$(jsonObj.aaDataInsObjects).map(function () {
$('#inserat_objektselection').append($(' ', { value: this.Codewert }).text(this.Codetext));
if (this.Codewert == t_woid) {
$('#inserat_objektselection').val(t_woid);
// set sammelinserat flag for vorlagen selection
if ($("#inserat_objektselection").val().indexOf("sammelinserat") >= 0) {
t_sammelinseratSelected = true;
}
}
});
// append onchange event
$("#inserat_objektselection").change(function (e) { ReloadTitlesAndVorlagen(); });
// get gut zum druck text
$.get("../ajax/json.aspx?action=getGzDTextInfos", function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
$("#FM_GZD_mailText").val(jsonObj.GZDText);
$("#FM_GZD_mailAbsender").val(jsonObj.GZDMail);
$("#FM_GZD_mailEmpfaenger").val(jsonObj.GZDMail);
});
// get vorlagen and titles
$.get("../ajax/json.aspx?action=getVorlagen&sammelinserat=" + t_sammelinseratSelected + "&id=" + t_inseratid + "&onlyOnlineTitel=" + t_isOnlineAuftrag, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
// creat title selection buttons
titelhtml = "";
try {
if (jsonObj.aaDataTitelPersonal.length >= 1) {
// take personal liste
$(jsonObj.aaDataTitelPersonal).map(function () {
titelhtml += "" + this.fBezeichnung + " ";
});
if (!hideAllVorlagen) {
titelhtml += "Alle Medien anzeigen ";
}
}
else {
// take title liste
$(jsonObj.aaDataTitel).map(function () {
titelhtml += "" + this.fBezeichnung + " ";
});
}
// create template selection accordion
$("#DV_InseratEdit_VorlagenSelection").accordion('destroy');
$("#DV_InseratEdit_VorlagenSelection").html("");
$(jsonObj.aaDataVorlagen).map(function () {
$("#DV_InseratEdit_VorlagenSelection").append('');
$("#DV_InseratEdit_VorlagenSelection").append(' ID: ' + this.fVorlageNr + ' ' + titelhtml + '
');
});
$("#DV_InseratEdit_VorlagenSelection").accordion({
collapsible: true,
active: false,
autoHeight: false,
navigation: false
});
// tooltip the accordion again with titles
$(".tooltip").tipTip();
$('#DV_InseratEdit_VorlagenSelection').bind('accordionchangestart', function (event, ui) {
// set new vorlage id by change
t_vorlageid = $(ui.newContent).find('span').attr('vorlagenr');
});
// check test flag
if (t_testauftrag) {
// add default title
t_vorlageid = -1;
tt_title = $("#dialog_testAuftrag_objekt").val();
tt_titlebez = "TestAuftrag";
tt_KVariante = "";
__SetTitel2Inserat(tt_title, tt_titlebez, tt_KVariante, false, "", false, "", false);
}
else if (t_homegateFakeProgress) {
// check homegate fake progress
// add default title
t_vorlageid = 16;
tt_title = "homegate"
tt_titlebez = "homegate.ch - Online Objekt Auftrag";
tt_KVariante = "";
__SetTitel2Inserat(tt_title, tt_titlebez, tt_KVariante, false, "", false, "", false);
}
else {
// now reload auftragsmappe, but without creating pdf (nothing has changed)
ReloadAuftragsmappe(false, true);
}
}
catch(ex) {
//
}
});
// finally create form
CreateForm();
});
}
function ReloadTitlesAndVorlagen() {
// get vorlagen and titles
ShowOverlay();
// set flag
t_sammelinseratSelected = false;
if ($("#inserat_objektselection").val().indexOf("sammelinserat") >= 0) {
t_sammelinseratSelected = true;
}
$.get("../ajax/json.aspx?action=getVorlagen&sammelinserat=" + t_sammelinseratSelected + "&id=" + t_inseratid + "&onlyOnlineTitel=" + t_isOnlineAuftrag, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
// creat title selection buttons
titelhtml = "";
if (jsonObj.aaDataTitelPersonal.length >= 1) {
// take personal liste
$(jsonObj.aaDataTitelPersonal).map(function () {
titelhtml += "" + this.fBezeichnung + " ";
});
if (!hideAllVorlagen) {
titelhtml += "Alle Medien anzeigen ";
}
}
else {
// take title liste
$(jsonObj.aaDataTitel).map(function () {
titelhtml += "" + this.fBezeichnung + " ";
});
}
// create template selection accordion
$("#DV_InseratEdit_VorlagenSelection").accordion('destroy');
$("#DV_InseratEdit_VorlagenSelection").html("");
$(jsonObj.aaDataVorlagen).map(function () {
$("#DV_InseratEdit_VorlagenSelection").append('');
$("#DV_InseratEdit_VorlagenSelection").append('' + titelhtml + '
');
});
$("#DV_InseratEdit_VorlagenSelection").accordion({
collapsible: true,
active: false,
autoHeight: false,
navigation: false
});
// tooltip the accordion again with titles
$(".tooltip").tipTip();
$('#DV_InseratEdit_VorlagenSelection').bind('accordionchangestart', function (event, ui) {
// set new vorlage id by change
t_vorlageid = $(ui.newContent).find('span').attr('vorlagenr');
});
HideOverlay();
});
}
function ShowAllTitelSelection(onlyDivers) {
// first open dialog, for getting render datatable correct width
$("#dialog_titleSelection").dialog("option", "width", 1050);
$("#dialog_titleSelection").dialog("option", "height", 560);
$("#dialog_titleSelection").dialog("open");
// div title button control
if (onlyDivers) {
$("#dialog_titleSelectionShowDivTitles").fadeOut(0);
$("#dialog_titleSelectionShowNotDivTitles").fadeIn(0);
}
else {
$("#dialog_titleSelectionShowDivTitles").fadeIn(0);
$("#dialog_titleSelectionShowNotDivTitles").fadeOut(0);
}
// now always load media table as html in dialog
$("#dialog_titleSelectionContent").load("pages/allMedias.aspx", function () {
$('#TBL_AlleMedien .datatable').dataTable({
"bProcessing": true,
"sAjaxSource": '../ajax/json.aspx?action=GetAllTitles&id=' + t_inseratid + "&onlyDivers=" + onlyDivers + "&onlyOnlineTitel=" + t_isOnlineAuftrag + "&vorlagenr=" + t_vorlageid,
"bJQueryUI": true,
"sScrollX": "",
"bSortClasses": false,
"aaSorting": [[0, 'desc']],
"bDestroy": true, // let table destory for refreshing
"bAutoWidth": false,
"bInfo": true,
"sScrollX": "101%",
"bScrollCollapse": false,
"sPaginationType": "full_numbers",
"bRetrieve": true,
"sSearch": "Suchen",
"oLanguage": {
"sSearch": "Suchen",
"sProcessing": "Bitte warten...",
"sLengthMenu": "_MENU_ anzeigen",
"sZeroRecords": "Keine vorhanden.",
"sInfo": " _START_ bis _END_ von _TOTAL_",
"sInfoEmpty": "0 bis 0 von 0 Einträgen",
"sInfoFiltered": "(gefiltert von _MAX_ )",
"oPaginate": {
"sFirst": "Erster",
"sPrevious": "Zurück",
"sNext": "Nächster",
"sLast": "Letzter"
}
},
"fnInitComplete": function () {
$("#TBL_AlleMedien .dataTables_length > label > select").uniform();
$("#TBL_AlleMedien .dataTables_filter input[type=text]").addClass("text");
$("#TBL_AlleMedien .dataTables_filter input[type=text]").css("color", "black");
$("#TBL_AlleMedien .dataTables_filter input[type=text]").css("background-color", "white");
$("#TBL_AlleMedien .dataTables_filter input[type=text]").css("width", "400");
$(".datatable").css("visibility", "visible");
}
});
$('#TBL_AlleMedien').not('.initialized').addClass('initialized');
// create tooltips always
$(".tooltip").tipTip();
});
}
var tt_title;
var tt_titlebez;
var tt_KVariante;
function SetTitel2Inserat(title, titlebez, KVariante, istBijou, istDivers) {
$("#dialog_titleSelection").dialog("close");
// check, if it's a bijou title
if (istBijou.toLowerCase() == "true") {
// show bijou lang dialog and temp save values
tt_title = title;
tt_titlebez = titlebez;
tt_KVariante = KVariante;
$("#dialog_bijosprachwahl").dialog("open");
}
// now check for divers
else if (istDivers.toLowerCase() == "true") {
// show bijou window
tt_title = title;
tt_titlebez = titlebez;
tt_KVariante = KVariante;
// reset dialog title and open dialog
$("#dialog_diverstitleBezeichnung").val("");
$("#dialog_diverstitle").dialog("open");
// always create auto completer
$("#dialog_diverstitleBezeichnung").autocomplete(autocomp_opt);
}
else {
// just go and add title
__SetTitel2Inserat(title, titlebez, KVariante, false, "", false, "", istDivers);
}
}
function _SetTitel2Inserat(bijouSprachcode) {
$("#dialog_bijosprachwahl").dialog("close");
__SetTitel2Inserat(tt_title, tt_titlebez, tt_KVariante, true, bijouSprachcode, false, "", false);
}
function SetTitel2InseratFromDivers() {
$("#dialog_diverstitle").dialog("close");
// overwrite title bez and go
tt_titlebez = $("#dialog_diverstitleBezeichnung").val();
__SetTitel2Inserat(tt_title, tt_titlebez, tt_KVariante, false, "", false, "", true);
}
// some temp values only used for bijou process
var ttt_title;
var ttt_titlebez;
var ttt_KVariante;
var ttt_bijouSprachcode;
var ttt_fInseratTitelID;
function __SetTitel2Inserat(title, titlebez, KVariante, istBijou, bijouSprachcode, AddingBijouProcess, bijouMasterInseratTitelID, istDivers) {
// add title with vorlage to inserat
HideMainAlert();
ShowOverlay();
$.get("../ajax/json.aspx?action=addTitleVorlage2Inserat&id=" + t_inseratmainid, { title: title, vorlage: t_vorlageid, titlebez: titlebez, KVariante: KVariante, istBijou: istBijou, bijouSprachcode: bijouSprachcode, AddingBijouProcess: AddingBijouProcess, bijouMasterInseratTitelID: bijouMasterInseratTitelID, istDivers: istDivers, printDates: $("#anzErscheinungen").val(), objectid: $("#inserat_objektselection").val() }, function (jsonObj) {
// load template in hidden div
jsonObj = CreateJSONObject(jsonObj);
// check error
if (!jsonObj.Error) {
// set sortiment titel again
$('#SP_VorlagenMedienWahlSortimentTitle').html("(" + jsonObj.fSortiment + ")");
if (jsonObj.Upload) {
// the auftragsmappe can force reload now
ReloadAuftragsmappe(false, false);
}
else if (jsonObj.Sammelinserat) {
// 1. set repeater template to hidden tempalte, for replacing and handling html divs
$("#DV_HiddenTemplate").html(jsonObj.SammelinseratRepeaterTemplateHTML);
// 2. loop trough every sammel object for check vorschlagstexte and append to html sammel var
var sammelinseratHTML = "";
var tempBildHTMLPlaceHolder = "";
$(jsonObj.aaDataSammelObjects).map(function () {
var vorschlagstexte = this.aaDataTextvorschlag;
var bildUrlObj = this.BildUrl;
// loop trough container divs in hidden template
$('#DV_HiddenTemplate #container div').each(function (index) {
if ($(this).attr('id') != "" && $(this).attr('id') != "undefined" && $(this).attr('id') != null) {
if ($(this).attr('class') != null) {
var divObjID = $(this).attr('id');
var vorschlagstexhtml = "";
// loop trought vorschlagstexte
$(vorschlagstexte).map(function () {
// do not replace content of a div with id bild
if (vorschlagstexhtml == "" && this.DivID.toLowerCase() != "bild") {
if (this.DivID.toLowerCase() == divObjID.toLowerCase()) {
// take first vorschlagstext
vorschlagstexhtml = this.Textvorschlag;
}
}
});
if (vorschlagstexhtml != "") {
$(this).html(vorschlagstexhtml);
}
// check 4 bildupload
if ($(this).attr('class') == "bildupload") {
var bildHtml = $(this).html();
if (tempBildHTMLPlaceHolder == "") {
tempBildHTMLPlaceHolder = bildHtml;
}
// replace image
$(this).html(tempBildHTMLPlaceHolder.replace("#bild#", bildUrlObj));
}
}
}
});
sammelinseratHTML += $("#DV_HiddenTemplate").html();
});
// 3. now replace sammelinserat in container with repeater templates
var fullSammelInseratHTML = jsonObj.Template;
fullSammelInseratHTML = fullSammelInseratHTML.replace("#Sammelinserat#", sammelinseratHTML);
$('#DV_HiddenEditor_TempRender').html(fullSammelInseratHTML);
// 4. append full html to hidden editor and create correct vhtml and save back with timeout!
var vhtml = $('#DV_HiddenEditor_TempRender').html();
$('#HiddenEditor').val(vhtml);
setTimeout(function () {
vhtml = $('#HiddenEditor').val();
var data = {
fInseratTitelID: jsonObj.fInseratTitelID,
action: "createVorlagenHTML",
VorlagenBreite: 0,
vhtml: escape(vhtml)
};
$.post("../ajax/rest.aspx", data, function (jsonObj) {
// 4. finally just reload auftragsmappe
ShowOverlay();
ReloadAuftragsmappe(false, false);
});
}, 500);
}
else {
// set normal template
$("#DV_HiddenTemplate").val(jsonObj.Template);
$("#DV_HiddenTemplate").html(jsonObj.Template);
// check if master title is available
// das ganze zeugs unten kommt dann doppelt, weil sonst javascript nach dem get einfach code weiterausführt und nicht wartet.. danach katastrophe
if (masterCopyTitleID != "") {
// update templateTable with new values and keys
$.get("../ajax/json.aspx?action=GetTextelementsFromTitle&id=" + masterCopyTitleID, function (jsonObj2) {
jsonObj2 = CreateJSONObject(jsonObj2);
$(jsonObj2.aaDataFields).map(function () {
// check if key exist
if (!templateTable.containsKey(this.fTextelement)) {
// insert with correct value
templateTable.put(this.fTextelement, this.fText);
}
else {
// replace with correct value
templateTable.remove(this.fTextelement);
templateTable.put(this.fTextelement, this.fText);
}
});
// now get every id element for copy same elements
fieldString = "";
$('#DV_HiddenTemplate #container div').each(function (index) {
if ($(this).attr('id') != "" && $(this).attr('id') != "undefined" && $(this).attr('id') != null) {
if ($(this).attr('class') != null) {
// check template hashtable and put key
if (!templateTable.containsKey($(this).attr('id'))) {
//alert($(this).html());
//alert($(this).val());
// its a new field, put in templateTable
templateTable.put($(this).attr('id'), encodeURIComponent($(this).html().replace(/\+/g, 'THISISAPLUSSIGN')));
}
// create field string for creating fields
fieldString += $(this).attr('id') + "|" + templateTable.get($(this).attr('id')) + String.fromCharCode(7);
// set template text in hidden div
$(this).html(decodeURIComponent(templateTable.get($(this).attr('id'))).replace(/THISISAPLUSSIGN/g, '+'));
// check4sujet
if ($(this).attr('class').indexOf("sujet") >= 0) {
// update sujet
$.get("../ajax/rest.aspx?action=changeSujet&id=" + jsonObj.fInseratTitelID, { sujet: $(this).html() }, function (restObj) {
});
}
}
}
});
// calc template width
var realWidth = Number($(jsonObj.Template).filter('#container').width());
// create template fields and check for template textes
var fInseratTitelID = jsonObj.fInseratTitelID;
// setze hier der neue titel als master id. von jetzt wird bei einem neuen titel die texte von diesem übernommen. siehe code weiter oben. 28.10.15 / dk
masterCopyTitleID = jsonObj.fInseratTitelID;
var data = {
fInseratTitelID: fInseratTitelID,
action: "createTemplateFields",
vorlagenr: t_vorlageid,
woid: $("#inserat_objektselection").val(),
fields: escape(fieldString)
};
$.post("../ajax/rest.aspx", data, function (jsonObj) {
// now check, if its a bijou inserat, if true --> set the main bijou flag to true (in editor.js) and save temp values. and wait for call the action again, after html and vorlagenbreit is set from master obj
// do only create auto bijou inserat, if there is a woid selected.
// if no: let user self create bijou inserat
if (istBijou && !AddingBijouProcess && bijouSprachcode == "S" && $("#inserat_objektselection").val() != "") {
addingBjouAfterClosingEditor = false; // 4.7. always set to false. no auto translate from object selection. gregory
ttt_title = title;
ttt_titlebez = titlebez;
ttt_KVariante = KVariante;
ttt_bijouSprachcode = bijouSprachcode;
ttt_fInseratTitelID = fInseratTitelID;
}
else {
// ok, no bijou at this time
addingBjouAfterClosingEditor = false;
}
// ok, all things done, so now make a silent open for editor to calc prices and finally reload auftragsmappe
OpenEditor(fInseratTitelID, true);
});
});
}
else
{
// now get every id element for copy same elements
fieldString = "";
$('#DV_HiddenTemplate #container div').each(function (index) {
if ($(this).attr('id') != "" && $(this).attr('id') != "undefined" && $(this).attr('id') != null) {
if ($(this).attr('class') != null) {
// check template hashtable and put key
if (!templateTable.containsKey($(this).attr('id'))) {
//alert($(this).html());
//alert($(this).val());
// its a new field, put in templateTable
templateTable.put($(this).attr('id'), encodeURIComponent($(this).html().replace(/\+/g, 'THISISAPLUSSIGN')));
}
// create field string for creating fields
fieldString += $(this).attr('id') + "|" + templateTable.get($(this).attr('id')) + String.fromCharCode(7);
// set template text in hidden div
$(this).html(decodeURIComponent(templateTable.get($(this).attr('id'))).replace(/THISISAPLUSSIGN/g, '+'));
// check4sujet
if ($(this).attr('class').indexOf("sujet") >= 0) {
// update sujet
$.get("../ajax/rest.aspx?action=changeSujet&id=" + jsonObj.fInseratTitelID, { sujet: $(this).html() }, function (restObj) {
});
}
}
}
});
// calc template width
var realWidth = Number($(jsonObj.Template).filter('#container').width());
// create template fields and check for template textes
var fInseratTitelID = jsonObj.fInseratTitelID;
// setze hier der neue titel als master id. von jetzt wird bei einem neuen titel die texte von diesem übernommen. siehe code weiter oben. 28.10.15 / dk
masterCopyTitleID = jsonObj.fInseratTitelID;
var data = {
fInseratTitelID: fInseratTitelID,
action: "createTemplateFields",
vorlagenr: t_vorlageid,
woid: $("#inserat_objektselection").val(),
fields: escape(fieldString)
};
$.post("../ajax/rest.aspx", data, function (jsonObj) {
// now check, if its a bijou inserat, if true --> set the main bijou flag to true (in editor.js) and save temp values. and wait for call the action again, after html and vorlagenbreit is set from master obj
// do only create auto bijou inserat, if there is a woid selected.
// if no: let user self create bijou inserat
if (istBijou && !AddingBijouProcess && bijouSprachcode == "S" && $("#inserat_objektselection").val() != "") {
addingBjouAfterClosingEditor = false; // 4.7. always set to false. no auto translate from object selection. gregory
ttt_title = title;
ttt_titlebez = titlebez;
ttt_KVariante = KVariante;
ttt_bijouSprachcode = bijouSprachcode;
ttt_fInseratTitelID = fInseratTitelID;
}
else {
// ok, no bijou at this time
addingBjouAfterClosingEditor = false;
}
// ok, all things done, so now make a silent open for editor to calc prices and finally reload auftragsmappe
OpenEditor(fInseratTitelID, true);
});
}
}
}
else {
// show error
HideOverlay();
ShowMainAlert("Fehler beim Hinzfügen des Titels. " + jsonObj.ErrorDescription);
}
});
}
var t_bijouCheckerInsID;
function CreateBijouProcess(bijouCheckerInsID) {
t_bijouCheckerInsID = bijouCheckerInsID;
// show template selection
$.get("../ajax/json.aspx?action=getOnlyVorlagen&id=" + t_inseratid, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
var html = "Wählen Sie eine Vorlage aus, mit welcher das Inserat übersetzt werden soll: ";
$(jsonObj.aaDataVorlagen).map(function () {
html += "" + this.fBezeichnung + " - " + this.fSprache + " ";
});
$("#dialog_vorlageSelectionBijouContent").html(html + "
");
$("#dialog_vorlageSelectionBijou").dialog("open");
});
}
function _CreateBijouProcess(SelectedVorlageNr) {
$("#dialog_vorlageSelectionBijou").dialog("close");
ShowOverlay();
// get needed values for creating the bijou obi
$.get("../ajax/json.aspx?action=getBijouMasterTitleInfos", { bijouCheckerInsID: t_bijouCheckerInsID }, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
// set vorlage nr to main var again
t_vorlageid = SelectedVorlageNr;
__SetTitel2Inserat(jsonObj.title, jsonObj.titlebez, jsonObj.kavariante, true, jsonObj.bijousprachcode, true, t_bijouCheckerInsID, false);
});
}
function CreateBijouProcessUpload(bijouCheckerInsID, SelectedVorlageNr) {
t_bijouCheckerInsID = bijouCheckerInsID;
$("#dialog_vorlageSelectionBijou").dialog("close");
ShowOverlay();
// get needed values for creating the bijou obi
$.get("../ajax/json.aspx?action=getBijouMasterTitleInfos", { bijouCheckerInsID: t_bijouCheckerInsID }, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
// set vorlage nr to main var again
t_vorlageid = SelectedVorlageNr;
__SetTitel2Inserat(jsonObj.title, jsonObj.titlebez, jsonObj.kavariante, true, jsonObj.bijousprachcode, true, t_bijouCheckerInsID, false);
});
}
// reload complete auftragsmappe, default with pdf creation, start intervall param is not used at the time
function ReloadAuftragsmappe(startIntervall, onlyOffer) {
// always hide errors
HideOrderMainAlert();
createPDF = true;
if (onlyOffer) {
// light reload, only offer and title datas
createPDF = false;
}
$.get("../ajax/htmlgenerator.aspx?action=reloadAuftragsmappe&id=" + t_inseratid + "&createPDF=" + createPDF, function (htmlObj) {
var htmlstring = htmlObj;
if (htmlstring.indexOf("Error999") == 0) {
HideOverlay();
ShowMainAlert("Fehler in der Auftragsmappe. " + htmlObj.split("|")[1]);
}
else {
$("#DV_InseratEdit_Auftragsmappe").html(htmlObj);
HideOverlay();
// tooltip again
$(".tooltip").tipTip();
}
});
}
// word / pdf uploader
function ShowDocUploader(inserattitleid) {
tempEditID = inserattitleid;
$("#dialog_InseratDocUploader").dialog("open");
}
function _ShowDocUploader() {
$("#dialog_InseratDocUploaderAlert").delay(0).fadeOut(100);
ShowOverlay();
try {
var data = new FormData();
}
catch (ex) {
HideOverlay();
ShowMainAlert("Dieser Browser unterstützt leider keine Uploads. Verwenden Sie zurzeit Chrome oder Firefox als Option.");
}
jQuery.each($('#dialog_InseratDocUploaderDocUpload')[0].files, function (i, file) {
data.append('file-' + i, file);
});
$.ajax({
url: "../ajax/rest.aspx?action=uploadDocData&id=" + tempEditID,
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function (restObj) {
if (!isNaN(restObj)) {
tempEditID = restObj;
$("#dialog_InseratDocUploader").dialog("close");
ReloadAuftragsmappe(false, false);
}
else {
HideOverlay();
$("#dialog_InseratDocUploaderAlert").delay(0).fadeIn(100);
$("#dialog_InseratDocUploaderAlertContent").html(restObj);
}
}
});
}
// update erscheinungen
function UpdateErscheinungen() {
$.post("../ajax/rest.aspx?action=saveEditInseratDatas&id=" + t_UpdateErscheinungInseratID, $("#FM_InseratEdit").serialize(), function (restObj) {
$("#anzErscheinungen").val(restObj);
});
}
// change divers title
function ChangeTitelFromInserat(inserattitleid, title) {
tempEditID = inserattitleid;
$("#dialog_diverstitleChange_diverstitleBezeichnung").val(title);
$("#dialog_diverstitleChange").dialog("open");
}
function _ChangeTitelFromInserat() {
$("#dialog_diverstitleChange").dialog("close");
$.post("../ajax/rest.aspx?action=changeDiversTitle&id=" + tempEditID, { titlebez: $("#dialog_diverstitleChange_diverstitleBezeichnung").val() }, function (restObj) {
ReloadAuftragsmappe(false, true);
});
}
// change rubric from title
function ChangeRubric(inserattitleid, rubric) {
tempEditID = inserattitleid;
$.get("../ajax/json.aspx?action=getRubric&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
Html = "";
$(jsonObj.aaData).map(function () {
if (this.Codewert != rubric) {
Html += "" + this.Codetext + " ";
}
});
if (Html == "") {
Html = "Keine weiteren Rubriken verfügbar";
}
$("#dialog_InseratRubricChangerContent").html(Html + "
");
$("#dialog_InseratRubricChanger").dialog("open");
});
}
function _ChangeRubric(codewert, codetext) {
$.get("../ajax/rest.aspx?action=changeRubric&id=" + tempEditID, { codewert: codewert, codetext: codetext }, function (restObj) {
$("#dialog_InseratRubricChanger").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
// change urubric from title
function ChangeURubric(inserattitleid, urubric) {
tempEditID = inserattitleid;
$.get("../ajax/json.aspx?action=getURubric&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
Html = "";
$(jsonObj.aaData).map(function () {
if (this.Codewert != urubric) {
Html += "" + this.Codetext + " ";
}
});
if (Html == "") {
Html = "Keine weiteren Zeitungsrubriken verfügbar";
}
$("#dialog_InseratURubricChangerContent").html(Html + "
");
$("#dialog_InseratURubricChanger").dialog("open");
});
}
function _ChangeURubric(codewert, codetext) {
$.get("../ajax/rest.aspx?action=changeURubric&id=" + tempEditID, { codewert: codewert, codetext: codetext }, function (restObj) {
$("#dialog_InseratURubricChanger").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
// change print dates
function ChangePrintDate(inserattitleid) {
$.get("../ajax/json.aspx?action=getPrintDates&id=" + inserattitleid, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
// first check available print dates
if (jsonObj.AvailablePrintDates >= 1) {
// manuell remove old calendars and then append a new placeholder div (each title has his 'own' calendar div
$('#dialog_InseratPrintDateSelectionContentCalendar > div').each(function (index) {
$(this).remove();
});
$('#dialog_InseratPrintDateSelectionContentCalendar').append("
");
// now create mutli calendar
if (jsonObj.CheckedPrintDates.length >= 1) {
$('#dialog_InseratPrintDateSelectionContentCalendar_' + inserattitleid).multiDatesPicker({
dateFormat: "yy,mm,dd",
showWeek: true,
firstDay: 1,
minDate: 0,
maxDate: "+11M",
defaultDate: new Date(),
addDisabledDates: jsonObj.DisabledPrintDates, // alle anderen ausblenden
addDates: jsonObj.CheckedPrintDates, // aktivierten einblenden
onSelect: function (dateText, inst) {
$.get("../ajax/rest.aspx?action=ChangePrintDate&id=" + inserattitleid, { dateValue: dateText }, function (restObj) {
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
});
}
else {
// create multi calendar, without checked dates
$('#dialog_InseratPrintDateSelectionContentCalendar_' + inserattitleid).multiDatesPicker({
dateFormat: "yy,mm,dd",
showWeek: true,
firstDay: 1,
minDate: 0,
maxDate: "+11M",
defaultDate: new Date(),
addDisabledDates: jsonObj.DisabledPrintDates, // alle anderen ausblenden
onSelect: function (dateText, inst) {
$.get("../ajax/rest.aspx?action=ChangePrintDate&id=" + inserattitleid, { dateValue: dateText }, function (restObj) {
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
});
}
// append grossauflagen
if (jsonObj.GAPrintDates.length >= 1) {
var gaprintdate = "";
$(jsonObj.GAPrintDates).map(function () {
gaprintdate += "- " + this.Codewert + " ";
});
$('#dialog_InseratPrintDateSelectionContentCalendar').append("Grossauflagen: " + gaprintdate + "
");
}
$("#dialog_InseratPrintDateSelection").dialog("option", "width", 560);
$("#dialog_InseratPrintDateSelection").dialog("option", "height", 320);
$("#dialog_InseratPrintDateSelection").dialog("open");
}
else {
// no print dates available
ShowMainAlertPopUp("Zurzeit keine Erscheinungsdaten verfügbar. Wurde eine Zeitungsrubrik gewählt?");
}
});
}
function _ChangePrintDate(codewert, inserattitleid) {
if (removeDate) {
$.get("../ajax/rest.aspx?action=DeletePrintDate&id=" + inserattitleid, { printDate: codewert }, function (restObj) {
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
ChangePrintDate(inserattitleid);
});
}
else {
$.get("../ajax/rest.aspx?action=addPrintDate&id=" + inserattitleid, { codewert: codewert }, function (restObj) {
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
ChangePrintDate(inserattitleid);
});
}
}
// change print columns for title - make force auftragsmappe reload with pdf creation
function ChangeColumns(inserattitleid, spalten) {
tempEditID = inserattitleid;
$.get("../ajax/json.aspx?action=getPrintColumns&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
Html = "";
$(jsonObj.aaData).map(function () {
if (this.Codewert != spalten) {
Html += "" + this.Codetext + " ";
}
});
if (Html == "") {
Html = "Keine weiteren Spalten verfügbar";
}
$("#dialog_InseratPrintColumnChangerContent").html(Html + "
");
$("#dialog_InseratPrintColumnChanger").dialog("open");
});
}
function _ChangeColumns(codewert, codetext) {
$.get("../ajax/rest.aspx?action=changePrintColumn&id=" + tempEditID, { codewert: codewert, codetext: codetext }, function (restObj) {
$("#dialog_InseratPrintColumnChanger").dialog("close");
tempEditID = restObj;
ShowOverlay();
ReloadAuftragsmappe(false, false);
});
}
// change seitenteil
function ChangeSeitenteil(inserattitleid, seitenteilwahl) {
tempEditID = inserattitleid;
$.get("../ajax/json.aspx?action=getSeitenteile&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
Html = "";
$(jsonObj.aaData).map(function () {
Html += "" + this.Codetext + " ";
});
if (Html == "") {
Html = "Keine weiteren Seitenteile verfügbar";
}
$("#dialog_InseratPrintSeitenteilChangerContent").html(Html + "
");
$("#dialog_InseratPrintSeitenteilChanger").dialog("open");
});
}
function _ChangeSeitenteil(codewert, codetext) {
$.get("../ajax/rest.aspx?action=changeSeitenteil&id=" + tempEditID, { codewert: codewert, codetext: codetext }, function (restObj) {
$("#dialog_InseratPrintSeitenteilChanger").dialog("close");
tempEditID = restObj;
ShowOverlay();
ReloadAuftragsmappe(false, false);
});
}
// notizen
function ChangeNotes(inserattitleid) {
tempEditID = inserattitleid;
$.get("../ajax/json.aspx?action=getNotes&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
$("#dialog_InseratNotes").dialog("open");
$("#dialog_InseratNotesContent").val(jsonObj.Notes);
});
}
function _ChangeNotes() {
$.post("../ajax/json.aspx?action=saveNotes&id=" + tempEditID + "¬es=" + $("#dialog_InseratNotesContent").val(), function (jsonObj) {
$("#dialog_InseratNotes").dialog("close");
ReloadAuftragsmappe(false, true);
});
}
// change platzierung
function ChangePlatzierung(inserattitleid, platzierungsart, platzierungstext) {
tempEditID = inserattitleid;
var $radios = $('input:radio[name=platzierungsart]');
switch (platzierungsart) {
case "":
// select default first
$radios.filter('[value=]').attr('checked', true);
break;
case "01":
$radios.filter('[value=01]').attr('checked', true);
break;
case "03":
$radios.filter('[value=03]').attr('checked', true);
break;
}
$("#dialog_InseratPlatzierungsChangerPlatzierungswunsch").val(platzierungstext);
$("#dialog_InseratPlatzierungsChanger").dialog("open");
}
function _ChangePlatzierung() {
$.post("../ajax/rest.aspx?action=changePlatzierung&id=" + tempEditID, { platzierungsart: $('input[name=platzierungsart]:checked').val(), platztext: $("#dialog_InseratPlatzierungsChangerPlatzierungswunsch").val() }, function (restObj) {
$("#dialog_InseratPlatzierungsChanger").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
// change smartlink
function ChangeSmartlink(inserattitleid) {
tempEditID = inserattitleid;
$.get("../ajax/rest.aspx?action=getSmartlink&id=" + tempEditID, function (restObj) {
$("#dialog_InseratRechnungstextChangerSmartlink").val(restObj);
$("#dialog_InseratRechnungstextSmarlink").dialog("open");
});
}
function _ChangeSmartlink() {
$.post("../ajax/rest.aspx?action=changeSmartlink&id=" + tempEditID, { smartlink: $("#dialog_InseratRechnungstextChangerSmartlink").val() }, function (restObj) {
$("#dialog_InseratRechnungstextSmarlink").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
// change rechnungstext
function ChangeRechnungstext(inserattitleid, rechnungstext) {
tempEditID = inserattitleid;
$("#dialog_InseratRechnungstextChangerRechnungstext").val(rechnungstext);
$("#dialog_InseratRechnungstextChanger").dialog("open");
}
function _ChangeRechnungstext() {
$.post("../ajax/rest.aspx?action=changeRechnungstext&id=" + tempEditID, { rechnungstext: $("#dialog_InseratRechnungstextChangerRechnungstext").val() }, function (restObj) {
$("#dialog_InseratRechnungstextChanger").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
// change color - make force auftragsmappe reload with pdf creation
function ChangeColor(inserattitleid, farbzahl) {
tempEditID = inserattitleid;
Html = "Keine weiteren Farben verfügbar.";
// get template color
$.get("../ajax/json.aspx?action=getTemplateColor&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
// disable color selection. 23.01.13
/*
// manuell farbzahl 0-farbig (s/w)
if (farbzahl != 0) {
Html += "s/w ";
}
// manuell 4-farbig
if (farbzahl != 4) {
Html += "4-farbig ";
}
*/
$("#dialog_InseratColorChangerContent").html(Html + "
");
$("#dialog_InseratColorChanger").dialog("open");
});
}
function _ChangeColor(codewert) {
$.get("../ajax/rest.aspx?action=changeColor&id=" + tempEditID, { codewert: codewert }, function (restObj) {
$("#dialog_InseratColorChanger").dialog("close");
tempEditID = restObj;
ShowOverlay();
ReloadAuftragsmappe(false, false);
});
}
// change sujet betreff
function ChangeSujet(inserattitleid, sujet) {
tempEditID = inserattitleid;
$("#dialog_InseratSujetChangerSujet").val(sujet);
$("#dialog_InseratSujetChanger").dialog("open");
}
function _ChangeSujet(sujet) {
$.get("../ajax/rest.aspx?action=changeSujet&id=" + tempEditID, { sujet: sujet }, function (restObj) {
$("#dialog_InseratSujetChanger").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
function ChangeLongSujet(inserattitleid, sujet) {
alert("hier");
tempEditID = inserattitleid;
$("#dialog_InseratLongSujetChangerSujet").val(sujet);
$("#dialog_InseratLongSujetChanger").dialog("open");
}
function _ChangeLongSujet(sujet) {
$.get("../ajax/rest.aspx?action=changeSujet&id=" + tempEditID, { sujet: sujet }, function (restObj) {
$("#dialog_InseratLongSujetChanger").dialog("close");
tempEditID = restObj;
ReloadAuftragsmappe(false, true);
});
}
// dialog draft deleter
function DeleteInseratEdit(inseratid) {
tempEditID = inseratid;
$("#dialog_delInseratEntwurf").dialog("open");
}
function _DeleteInseratEdit() {
$("#dialog_delInseratEntwurf").dialog("close");
ShowOverlay();
// new: delete always all! 13.12.13 / dk
$.get("../ajax/rest.aspx?action=delAllInseratDrafts", function (restObj) {
ShowPage("inseratEntwurf.aspx", false);
});
/*
$.get("../ajax/rest.aspx?action=delEditInserat&id=" + tempEditID, function (restObj) {
ShowPage("inseratEntwurf.aspx", false);
});
*/
return false;
}
// rechnungadresse displayer
function ShowRechnungsadresse() {
if ($("#DV_dialog_saveInseratCreateRechnungadresse").is(":visible")) {
$("#DV_dialog_saveInseratCreateRechnungadresse").delay(0).fadeOut(500);
}
else {
$("#DV_dialog_saveInseratCreateRechnungadresse").delay(0).fadeIn(500);
}
}
function ChangeOnlineAuftragTyp(inserattitleid, vertragsid) {
$.get("../ajax/rest.aspx?action=changeOnlineAuftragTyp&id=" + inserattitleid + "&vertragsid=" + vertragsid, function (restObj) {
ReloadAuftragsmappe(false, true);
});
}
// create order
function CreateOrder(inseratid) {
ShowOverlay();
tempEditID = inseratid;
// get offer
HideMainAlert();
$.get("../ajax/json.aspx?action=getOffer&id=" + t_inseratid, function (jsonObj) {
//alert(jsonObj);
jsonObj = CreateJSONObject(jsonObj);
$('#DV_dialog_saveInserat_Offerte').delay(0).fadeIn();
$('#DV_dialog_saveInserat_OfferteDivers').delay(0).fadeOut();
if (!jsonObj.isDiversOffer) {
//fillup price
$("#sp_offerte_brutto").html(jsonObj.Bruttopreis);
$("#sp_offerte_mwst").html(jsonObj.MwSt);
$("#sp_offerte_total").html(jsonObj.Totalpreis);
$("#sp_offerte_zuschlag").html(jsonObj.OnlineZuschlag);
if (jsonObj.HasOnlineZuschlag) {
$('#DV_OfferteOnlineZuschlag').delay(0).fadeIn();
}
else {
$('#DV_OfferteOnlineZuschlag').delay(0).fadeOut();
}
}
else {
$('#DV_dialog_saveInserat_Offerte').delay(0).fadeOut();
$('#DV_dialog_saveInserat_OfferteDivers').delay(0).fadeIn();
}
if (jsonObj.OnlineVertrag) {
$('#DV_dialog_saveInserat_OfferteSlotKontingenBuchung').delay(0).fadeIn();
$('#DV_dialog_saveInserat_Offerte').delay(0).fadeOut();
}
else {
$('#DV_dialog_saveInserat_OfferteSlotKontingenBuchung').delay(0).fadeOut();
$('#DV_dialog_saveInserat_Offerte').delay(0).fadeIn();
}
// fill up kundenkostenstelle dropdownlist
$('#insOtherDatas_kundenkostenstelle').empty();
$('#insOtherDatas_kundenkostenstelle').append($(' ', { value: "" }).text("Wählen Sie optional eine Kundenkostenstelle"));
$(jsonObj.Kundenkostenstelle).map(function () {
$('#insOtherDatas_kundenkostenstelle').append($(' ', { value: this.Codetext }).text(this.Codetext));
});
if (jsonObj.Kundenkostenstelle.length == 0) {
// hide
$('#DV_Kundenkostenstelle').delay(0).fadeOut();
}
else {
$('#DV_Kundenkostenstelle').delay(0).fadeIn();
}
// fill up versandadresse dropdownlist
$('#insOtherDatas_versandadresse').empty();
$('#insOtherDatas_versandadresse').append($(' ', { value: "" }).text("Wählen Sie optional eine Versandadresse"));
$(jsonObj.Versandadresse).map(function () {
$('#insOtherDatas_versandadresse').append($(' ', { value: this.Codewert }).text(this.Codetext));
});
if (jsonObj.Versandadresse.length == 0) {
// hide
$('#DV_dialog_saveInserat_Versandadresse').delay(0).fadeOut();
}
else {
$('#DV_dialog_saveInserat_Versandadresse').delay(0).fadeIn();
}
// fill up debitoradresse dropdownlist
$('#insOtherDatas_debitoradresse').empty();
$('#insOtherDatas_debitoradresse').append($(' ', { value: "" }).text("Wählen Sie optional eine Debitoradresse"));
$(jsonObj.Debitoradresse).map(function () {
$('#insOtherDatas_debitoradresse').append($(' ', { value: this.Codewert }).text(this.Codetext));
});
if (jsonObj.Debitoradresse.length == 0) {
// hide
$('#DV_dialog_saveInserat_Debitoradresse').delay(0).fadeOut();
}
else {
$('#DV_dialog_saveInserat_Debitoradresse').delay(0).fadeIn();
}
// filll up add infos (=checkboxes)
$('#DV_Abschluss_Zusatzinfos').delay(0).fadeOut();
$('#DV_Abschluss_Zusatzinfos_Boxes').empty();
var idCounter = 0;
//alert(jsonObj.Zusatzinfos.length);
$(jsonObj.Zusatzinfos).map(function () {
$(' ', { type: 'checkbox', id: 'abschluss_chkbox_'+idCounter, name: 'abschluss_chkbox_'+idCounter, value: this.Codetext }).appendTo($('#DV_Abschluss_Zusatzinfos_Boxes'));
// $(' ', { 'for': 'abschluss_chkbox_'+idCounter, text: this.Codetext }).appendTo($('#DV_Abschluss_Zusatzinfos_Boxes'));
// neu ohne label, damit html formatierungen aus dem backend auch möglich sind
$('' + this.Codetext + ' ').appendTo($('#DV_Abschluss_Zusatzinfos_Boxes'));
$(' ').appendTo($('#DV_Abschluss_Zusatzinfos_Boxes'));
idCounter++;
//$('#DV_Abschluss_Zusatzinfos_Boxes').append($('', { value: this.Codewert }).text(this.Codetext));
});
//alert($('#DV_Abschluss_Zusatzinfos').html());
if (jsonObj.Zusatzinfos.length == 0) {
// hide
$('#DV_Abschluss_Zusatzinfos').delay(0).fadeOut();
}
else {
$('#DV_Abschluss_Zusatzinfos').delay(0).fadeIn();
}
// fill up email cutsomer
if (jsonObj.EMailCustomer != "false") {
$("#offerte_sendMailCustomerEmailAdress").val(jsonObj.EMailCustomer);
$("#chk_offerte_sendMailCustomer").attr('checked', true);
}
else {
$("#offerte_sendMailCustomerEmailAdress").val("");
$("#chk_offerte_sendMailCustomer").attr('checked', false);
}
// open end dialog with own widht / height
HideOverlay();
$("#dialog_saveInserat").dialog("option", "width", 500);
$("#dialog_saveInserat").dialog("option", "height", 700);
$("#dialog_saveInserat").dialog("open");
// reset fields. 13.8.2018 from corina somedia
$("#insOtherDatas_referenz").val("");
$("#insOtherDatas_manustext").val("");
// no, 6.11.2018 corina
//$( "#chk_offerte_sendMailCustomer" ).prop( "checked", false );
//$("#offerte_sendMailCustomerEmailAdress").val("");
});
}
function _CreateOrder() {
HideOrderMainAlert();
// first chck agbs
if ($('#CHK_AGB').is(':checked')) {
// create auftrag without rechnungsadresse
HideMainAlert();
$("#dialog_saveInserat").dialog("close");
ShowOverlay();
$.post("../ajax/json.aspx?action=createInseratOrder&id=" + t_inseratid, $("#FM_InseratComplete").serialize(), function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
if (jsonObj.Status == "true") {
// create email and pdfx. do not let user wait, so show auftraege page
$.get("../ajax/stateless.aspx?action=sendInseratMail&id=" + t_inseratid, { auftragsnr: jsonObj.fAuftragsnummer }, function (restObj) {
});
ClearIntervalls(true);
if (t_isOnlineAuftrag) {
ShowPage("auftraegeOnline.aspx", false);
}
else {
ShowPage("auftraege.aspx", false);
}
}
else {
HideOverlay();
ShowMainAlert(jsonObj.Status);
}
});
}
else {
// agb error
HideOverlay();
ShowOrderMainAlert("Bitte akzeptieren Sie die AGB's.");
}
return false;
}
function SaveOrder(inseratid) {
tempEditID = inseratid;
HideMainAlert();
ShowOverlay();
$.post("../ajax/json.aspx?action=createInseratOrder&id=" + t_inseratid + "&onlySave=true", function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
if (jsonObj.Status == "true") {
ClearIntervalls(true);
if (t_isOnlineAuftrag) {
ShowPage("auftraegeOnline_neu.aspx", false);
}
else {
ShowPage("auftraege_neu.aspx", false);
}
}
else {
HideOverlay();
ShowMainAlert(jsonObj.Status);
}
});
}
// gut zum druck sender
function SendPrintGZD(inseratid) {
tempEditID = inseratid;
// open gzd dialog
$("#dialog_sendGutZumDruck").dialog("option", "width", 580);
$("#dialog_sendGutZumDruck").dialog("option", "height", 550);
$("#dialog_sendGutZumDruck").dialog("open");
}
function _SendPrintGZD() {
// check email fields
if (IsEmail($("#FM_GZD_mailAbsender").val()) && IsEmail($("#FM_GZD_mailEmpfaenger").val())) {
$("#dialog_sendGutZumDruck").dialog("close");
$.post("../ajax/stateless.aspx?action=sendGutZumDruck&id=" + t_inseratid, $("#FM_GZD").serialize(), function (restObj) {
HideOverlay();
if (restObj == "true") {
HideMainAlert();
}
else {
// invalid adress
ShowMainAlert(restObj);
}
});
}
else {
if (!IsEmail($("#FM_GZD_mailAbsender").val())) {
ShowMainAlertPopUp("Bitte gültige E-Mail Absender Adresse eingeben. ");
}
else if (!IsEmail($("#FM_GZD_mailEmpfaenger").val())) {
ShowMainAlertPopUp("Bitte gültige E-Mail Empfänger Adresse eingeben. ");
}
}
return false;
}
// title remover
var t_institelid;
function DeleteTitelFromInserat(institelid) {
t_institelid = institelid;
$("#dialog_deletetitelins").dialog("open");
}
function _DeleteTitelFromInserat() {
$("#dialog_deletetitelins").dialog("close");
ShowOverlay();
$.get("../ajax/rest.aspx?action=delTitelfromInserat&id=" + t_institelid, function (restObj) {
tempEditID = t_UpdateErscheinungInseratID;
ReloadAuftragsmappe(false, true);
});
return false;
}
// auto completer options and events for divers titles
var autocomp_opt = {
source: function (request, response) {
$.ajax({
url: "../ajax/json.aspx?action=autocompletertitles&id=" + t_inseratid,
dataType: "json",
data: {
searchTerm: request.term,
autoField: 'dialog_diverstitleBezeichnung'
},
success: function (data) {
response($.map(data.SearchResults, function (item) {
return {
label: item.label,
value: item.id
}
}));
}
});
},
minLength: 2,
focus: function (event, ui) {
// focus
},
select: function (event, ui) {
// select and call settitle againg
$("#dialog_diverstitle").dialog("close");
SetTitel2Inserat(ui.item.value.split("|")[0], ui.item.value.split("|")[1], ui.item.value.split("|")[2], ui.item.value.split("|")[3], ui.item.value.split("|")[4]);
},
open: function () {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function () {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
}
};
// download pdf
function DownloadPDF(institelid, titelbez) {
rptDownloadFrame.document.location.href = "../getPDF.aspx?pdfx=false&id=" + institelid + "&titel=" + titelbez;
}
function DownloadPDFSingle(institelid, titelbez, aufnr) {
rptDownloadFrame.document.location.href = "../getPDF.aspx?single=true&pdfx=false&id=" + institelid + "&titel=" + titelbez + "&aufnr=" + aufnr;
}
// download pdfX
function DownloadPDFX(institelid, titelbez) {
$.get("../ajax/rest.aspx?action=createPDFX&id=" + institelid, function (restObj) {
rptDownloadFrame.document.location.href = "../getPDF.aspx?pdfx=true&id=" + institelid + "&titel=" + titelbez;
setTimeout(function () {
$('#SP_PDFX_DownloadInProgress' + institelid).fadeOut(500, function () {
$("#SP_PDFX_Download" + institelid).delay(0).fadeIn(500);
});
}, 1000);
});
$("#SP_PDFX_Download" + institelid).fadeOut(500, function () {
$("#SP_PDFX_DownloadInProgress" + institelid).delay(0).fadeIn(500);
});
}
// download html
function DownloadHTML(institelid, titelbez) {
$.get("../ajax/rest.aspx?action=getHTML&id=" + institelid, function (restObj) {
$('#SPHTMLDWNL').show();
$('#AHTMLDWNL').attr("href", "../temp/" + restObj);
});
}
function hidehtmldwnl() {
$('#SPHTMLDWNL').hide();
}
// online functions
var t_exportSlot; // temp obj slot
function ChangeXMLDatas(institelid, slotObjekt) {
console.log("ChangeXMLDatas start institelid:"+ institelid + " slotObjekt:" +slotObjekt);
ShowOverlay();
t_exportSlot = slotObjekt;
tempEditID = institelid;
switch(t_exportSlot) {
case "bt.ch":
case "jdj.ch":
$("#dialog_onlinexmlContent").load("../onlineExport/forms/bt.aspx", _ChangeXMLDatas);
break;
case "sojobs.ch":
$("#dialog_onlinexmlContent").load("../onlineExport/forms/sop.aspx", _ChangeXMLDatas);
break;
case "jobs.ch":
case "jobsEinzel":
$("#dialog_onlinexmlContent").load("../onlineExport/forms/jobs.aspx", _ChangeXMLDatas);
break;
case "eigenews":
$("#dialog_onlinexmlContent").load("../onlineExport/forms/eigenews.aspx", _ChangeXMLDatas);
break;
case "ostjob.ch":
$("#dialog_onlinexmlContent").load("../onlineExport/forms/ostjob.aspx", _ChangeXMLDatas);
break;
break;
}
}
function _ChangeXMLDatas() {
// load and get xml datas
$.get("../ajax/json.aspx?action=getExportXML&slot=" + t_exportSlot + "&id=" + tempEditID, function (jsonObj) {
jsonObj = CreateJSONObject(jsonObj);
switch(t_exportSlot) {
case "bt.ch":
case "jdj.ch":
FillExportMask_1(jsonObj);
break;
case "sojobs.ch":
FillExportMask_2(jsonObj);
break;
case "jobs.ch":
case "jobsEinzel":
FillExportMask_3(jsonObj);
break;
case "eigenews":
FillExportMask_4(jsonObj);
break;
case "ostjob.ch":
FillExportMask_5(jsonObj);
break;
}
// finally, open mask
$("#dialog_onlinexml").dialog("option", "width", 600);
$("#dialog_onlinexml").dialog("option", "height", 600);
$("#dialog_onlinexml").dialog("open");
HideOverlay();
});
}
function __ChangeXMLDatas() {
// save form
$("#DV_AlertOnlineExportForm").delay(0).fadeOut(100);
if (OnlineExportFormIsValid()) {
ShowOverlay();
$.post("../ajax/rest.aspx?action=saveExportForm&slot=" + t_exportSlot + "&id=" + tempEditID, $("#FM_OnlineExport").serialize(), function (restObj) {
$("#dialog_onlinexml").dialog("close");
ReloadAuftragsmappe(false, true);
});
}
else {
$("#DV_AlertOnlineExportForm").delay(0).fadeIn(100);
$("#DV_AlertOnlineExportFormMessage").html("Bitte alle Felder mit Stern erfassen.");
}
}
function CheckSmartlink(smartlink) {
if ($(smartlink).val() == "extern") {
$("#SP_export_smartlink_extern").show();
}
else {
$("#SP_export_smartlink_extern").hide();
}
}
function ChangeStartDate(institelid, startDatumValue) {
tempEditID = institelid;
$("#dialog_changeStartdate_value").val(startDatumValue);
// create datepicker
$("#dialog_changeStartdate_value").datepicker({ dateFormat: 'dd.mm.yy' });
// open dialog
$("#dialog_changeStartdate").dialog("open");
}
function _ChangeStartDate() {
$.get("../ajax/rest.aspx?action=changeOnlineStartdate&id=" + tempEditID + "&theStartDate=" + $("#dialog_changeStartdate_value").val(), function (restObj) {
$("#dialog_changeStartdate").dialog("close");
ShowOverlay();
ReloadAuftragsmappe(false, true);
});
}
function ChangeEndDate(institelid, endDatumValue) {
tempEditID = institelid;
$("#dialog_changeEnddate_value").val(endDatumValue);
// create datepicker
$("#dialog_changeEnddate_value").datepicker({ dateFormat: 'dd.mm.yy' });
// open dialog
$("#dialog_changeEnddate").dialog("open");
}
function _ChangeEndDate() {
$.get("../ajax/rest.aspx?action=changeOnlineEnddate&id=" + tempEditID + "&theEndDate=" + $("#dialog_changeEnddate_value").val(), function (restObj) {
$("#dialog_changeEnddate").dialog("close");
ShowOverlay();
ReloadAuftragsmappe(false, true);
});
}
var t_insxmlfile;
var t_slotObject;
function SwitchInseratToOffline(insxmlfile, slotObject) {
// show dialog
t_insxmlfile = insxmlfile;
t_slotObject = slotObject;
$("#dialog_switchInsOff").dialog("open");
}
function _SwitchInseratToOffline(insxmlfile) {
$("#dialog_switchInsOff").dialog("close");
ShowOverlay();
$.get("../ajax/rest.aspx?action=switchInseratOff&insxmlfile=" + t_insxmlfile + "&slot=" + t_slotObject, function (restObj) {
ShowPage("auftraegeOnline.aspx", false);
});
return false;
}
// delete functions
function delAllInseratDrafts() {
$("#dialog_delAllInsDrafts").dialog("open");
}
function _delAllInseratDrafts() {
$("#dialog_delAllInsDrafts").dialog("close");
ShowOverlay();
$.get("../ajax/rest.aspx?action=delAllInseratDrafts", function (restObj) {
ShowPage("inseratEntwurf.aspx", false);
});
return false;
}
// change master title id for get text templates
function ChangeMaster(_masterCopyTitleID) {
masterCopyTitleID = _masterCopyTitleID;
}
function ShowDebugHTML() {
alert($("#dvMainTemplate").html());
}
// alert
function ShowOrderMainAlert(msg) {
$("#DV_AlertOrder").delay(0).fadeIn(100);
$("#DV_AlertOrder_Message").html(msg);
}
function HideOrderMainAlert(msg) {
$("#DV_AlertOrder").delay(0).fadeOut(100);
}