// 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 += ""; }); $("#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 += ""; } }); $("#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 += "
"; } 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($('