Guest User

jq filter not working

a guest
Jul 4th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Some variables I removed
  2.  
  3. $(document).ready(function () {
  4.     writeAction();
  5.     writeTabs();
  6.     $("#DeltaPlaceHolderPageTitleInTitleArea").html("AKG Startseite");
  7.     $(".ms-breadcrumb-top").hide();
  8.     // $(".ms-core-listMenu-root").hide();
  9.  
  10.     //$("#zz17_RootAspMenu").hide();
  11.     $(".ms-mpSearchBox").hide();
  12.     $(".DeltaPlaceHolderSearchArea").hide();
  13.     //$("#titleAreaRow").hide();
  14.  
  15.     $("#Ribbon.ListForm.Display.Manage.EditItem-Large").hide();
  16.     $("#fullscreenmode").click();
  17.     window.setTimeout(showTabsBasedOnGroup, 3000);
  18.     checkAkgLink();
  19. });
  20.  
  21. function checkNull(chValue) {
  22.     if (chValue == null) {
  23.  
  24.         return "";
  25.     } else {
  26.         return chValue;
  27.     }
  28. }
  29.  
  30. function writeAction() {
  31.     var outHtml = "<a href=\"javascript:createNewAKG();\">" + imgAdd + "&nbsp;" + unescape("Neues AKG anlegen") + "</a>";
  32.     outHtml += "&nbsp;&nbsp;&nbsp;<a href=\"javascript:refresh();\">" + imgRefresh + "&nbsp;" + unescape("Aktualisieren") + "</a>";
  33.     outHtml += "&nbsp;&nbsp;&nbsp;<a href=\"https://thesite?objid=4515\" target=\"_blank\">" + "&nbsp;" + unescape("Führung von Auftragsklärungsgesprächen") + "</a>";
  34.     $("#startTableAction").html(outHtml);
  35. }
  36.  
  37. function getListItems(url) {
  38.  
  39.     return $.ajax({
  40.         url: _spPageContextInfo.webAbsoluteUrl + url,
  41.         type: 'GET',
  42.         headers: {
  43.             "Accept": "application/json; odata=verbose"
  44.         },
  45.         success: function (data) {
  46.         },
  47.         error: function (XMLHttpRequest, textStatus, errorThrown) {
  48.             console.log("Status: " + textStatus); alert("Error: " + errorThrown);
  49.         }
  50.     });
  51. }
  52.  
  53. function getCurrentUserProfileCity() {
  54.     return new Promise(function(resolve, reject) {
  55.         $.ajax({
  56.             url:_spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties",
  57.             type:"GET",
  58.             contentType : "application/json;odata=verbose",
  59.             headers: {
  60.                 "accept": "application/json;odata=verbose",
  61.                 "X-RequestDigest": $("#__REQUESTDIGEST").val()
  62.             },
  63.             success:function(data){
  64.                 var location = data.d.UserProfileProperties.results.filter(function(element) {
  65.                     return element.Key==="SPS-Location";
  66.                 })[0].Value;
  67.                 resolve(location);
  68.             },
  69.             error:function(jqxr){
  70.                 console.log(jqxr.responseText);
  71.                 reject();
  72.             }
  73.         });
  74.     });
  75. }
  76.  
  77. function CreateListItemWithDetails(listName, success, failure) {
  78.     currentUserProfileCity
  79.         .then(function(city){
  80.             var item = {
  81.                 "__metadata": { "type": "SP.Data.AKGListItem" },
  82.                 "ProjektleiterId": _spPageContextInfo.userId,
  83.                 "Standort": city,
  84.                 "ExcelExport": "<DIV class='opexcelexport'>ID</DIV>"
  85.             };
  86. //add set origID to ID
  87. //set Export to <DIV class='opexcelexport'>ID</DIV>
  88.             $.ajax({
  89.                 url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
  90.                 type: "POST",
  91.                 contentType: "application/json;odata=verbose",
  92.                 data: JSON.stringify(item),
  93.                 headers: {
  94.                     "accept": "application/json;odata=verbose",
  95.                     "X-RequestDigest": $("#__REQUESTDIGEST").val()
  96.                 },
  97.                 success: function (data)
  98.                 {
  99.                     refresh();
  100.                     success(data);
  101.                 },
  102.                 error: function (data)
  103.                 {
  104.                     failure(data);
  105.                 }
  106.             });
  107.         });
  108. }
  109.  
  110. function deleteListItemsBatch(listTitle, refId) {
  111.     var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/items?&$filter=refID eq " + refId;
  112.  
  113.     return $.ajax({
  114.         url: url,
  115.         type: "GET",
  116.         headers: { "Accept": "application/json;odata=verbose" }
  117.     })
  118.         .then(function(data) {
  119.             var items = data.d.results;
  120.  
  121.             var updateBatchValue = '<Batch OnError="Continue">';
  122.             for(var i = 0; i < items.length; i++){
  123.                 var currentItem = items[i];
  124.  
  125.                 updateBatchValue += '<Method ID="' + (currentItem.ID || currentItem.Id) + '" Cmd="Delete"><Field Name="ID">' + (currentItem.ID || currentItem.Id) + '</Field></Method>';
  126.             }
  127.             updateBatchValue += '</Batch>';
  128.  
  129.             var soapEnv =
  130.                 '<?xml version="1.0" encoding="utf-8"?>' +
  131.                 '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
  132.                 '<soap:Body>' +
  133.                 '<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">' +
  134.                 '<listName>' + listTitle + '</listName>' +
  135.                 '<updates>' + updateBatchValue + '</updates>' +
  136.                 '</UpdateListItems>' +
  137.                 '</soap:Body>' +
  138.                 '</soap:Envelope>';
  139.             return soapEnv;
  140.         })
  141.         .then(function(soapEnv) {
  142.             url = _spPageContextInfo.webAbsoluteUrl + '/_vti_bin/lists.asmx';
  143.             $.ajax({
  144.                 url: url,
  145.                 beforeSend: function(xhr) { xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");},
  146.                 type: "POST",
  147.                 dataType: "xml",
  148.                 data: soapEnv,
  149.                 contentType: "text/xml; charset=\"utf-8\"",
  150.                 success: function () {
  151.                 },
  152.                 error: function (XMLHttpRequest, textStatus, errorThrown) {
  153.                     console.log("Status: " + textStatus); alert("Error: " + errorThrown);
  154.                 }
  155.             });
  156.         });
  157. }
  158.  
  159. function createNewAKG() {
  160.  
  161.     var waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);
  162.  
  163.     var siteCollUrl = _spPageContextInfo.siteAbsoluteUrl;
  164.     var spHostUrl = encodeURI(siteCollUrl);
  165.     spHostUrl = escapeProperly(spHostUrl);
  166.     var listName = "AKG";
  167.  
  168.     CreateListItemWithDetails(listName, function (data)
  169.         {
  170.             var url = appSiteCollectionUrl + "/Lists/" + listName + "/EditForm.aspx?ID=" + data.d.ID;
  171.             waitDialog.close(SP.UI.DialogResult.OK);
  172.             openInDialog(1050, 1000, true, true, true, url);
  173.         },
  174.         function (data)
  175.         {
  176.             alert("Ooops, an error occured. Please try again." + data);
  177.         });
  178. }
  179.  
  180. function refresh() {
  181.     $.jgrid.gridUnload('gridmy');
  182.     $.jgrid.gridUnload('gridactive');
  183.     $.jgrid.gridUnload('gridall');
  184.     loadSubTables();
  185. }
  186.  
  187. function showTabsBasedOnGroup() {
  188.  
  189.     //Admins can see all tabs
  190.     IsCurrentUserMemberOfGroup(groupNameAdmin, function (isCurrentUserInGroup) {
  191.         if (isCurrentUserInGroup) {
  192.  
  193.             $("#gridadminli").show();
  194.             return;
  195.         } else {
  196.             //   $("span:contains('ADM-BM')").parent().hide();
  197.         }
  198.     });
  199. }
  200.  
  201. function printAKG(rowid, divname) {
  202.  
  203.     var rowData = $("#" + divname).getRowData(rowid);
  204.     var url = _spPageContextInfo.webAbsoluteUrl + "/SitePages/printAKG.html?ID=" + rowData.Id;
  205.     window.open(url, "tabnew" + rowData.Id, "toolbar=yes,titlebar=yes,scrollbars=yes,resizable=yes,width=800,height=600");
  206. }
  207.  
  208. function deleteAKGListItem(itemId) {
  209.  
  210.     return $.ajax({
  211.         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('AKG')/items(" + itemId + ")",
  212.         type: 'POST',
  213.         headers: {
  214.             "Accept": "application/json; odata=verbose",
  215.             "X-RequestDigest": $("#__REQUESTDIGEST").val(),
  216.             "IF-MATCH": "*",
  217.             "X-HTTP-Method": "DELETE"
  218.         },
  219.         success: function () {
  220.         },
  221.         error: function (XMLHttpRequest, textStatus, errorThrown) {
  222.             console.log("Status: " + textStatus); alert("Error: " + errorThrown);
  223.         }
  224.     });
  225. }
  226.  
  227. function getAKGListItem(itemId) {
  228.     return $.ajax({
  229.         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('AKG')/items(" + itemId + ")",
  230.         type: 'GET',
  231.         headers: {
  232.             "Accept": "application/json; odata=verbose",
  233.         },
  234.         success: function (data) {
  235.             return data.d;
  236.         },
  237.         error: function (XMLHttpRequest, textStatus, errorThrown) {
  238.             console.log("Status: " + textStatus); alert("Error: " + errorThrown);
  239.         }
  240.     });
  241. }
  242.  
  243. function deleteAKG(itemId) {
  244.     var waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);
  245.  
  246.     getAKGListItem(itemId).then(function(data) {
  247.         if(data.d.AKGStatus === "Entwurf") {
  248.             var actionItems = [];
  249.  
  250.             actionItems.push(deleteAKGListItem(itemId));
  251.             actionItems.push(deleteListItemsBatch('Aktionen', itemId));
  252.             actionItems.push(deleteListItemsBatch('Themen', itemId));
  253.  
  254.             Promise.all(actionItems)
  255.                 .then(function() {
  256.                     refresh();
  257.                     //$("#" + itemId).remove();
  258.                     waitDialog.close(SP.UI.DialogResult.OK);
  259.                 })
  260.                 .catch(function(error) {
  261.                     console.log("Error has occured while deleting! ", error);
  262.                     waitDialog.close(SP.UI.DialogResult.OK);
  263.                 });
  264.         }
  265.         else {
  266.             waitDialog.close(SP.UI.DialogResult.OK);
  267.             alert("Could not delete item: only items with status \"Entwurf\" can be deleted!");
  268.         }
  269.     });
  270. }
  271.  
  272. function writeTabs() {
  273.  
  274.     var htmlTags = '<div id="tabs">';
  275.     htmlTags += '<ul>';
  276.     htmlTags += '<li><a href="#tabs-1">Meine AKG<span id="gridmyno">[]</span></a></li>';
  277.     htmlTags += '<li><a href="#tabs-2">Aktive AKG<span id="gridactiveno">[]</span></a></li>';
  278.     htmlTags += '<li><a href="#tabs-3">Alle AKG<span id="gridallno">[]</span></a></li>';
  279.     htmlTags += '<li style="display:none;" id="gridadminli"><a title="Dieses Tab ist nur sichtbar fuer ' + groupNameAdmin + '" href="#tabs-4">ADMIN ' + imglock_open + '</a></li>';
  280.  
  281.     htmlTags += '</ul>';
  282.  
  283.     htmlTags += '<div id="tabs-1">';
  284.     htmlTags += '<table id="gridmy"></table><div id="pager">&#160;</div>';
  285.     htmlTags += '</div>';
  286.  
  287.     htmlTags += '<div id="tabs-2">';
  288.     htmlTags += '<table id="gridactive"></table>';
  289.     htmlTags += '</div>';
  290.  
  291.     htmlTags += '<div id="tabs-3">';
  292.     htmlTags += '<table id="gridall"></table>';
  293.     htmlTags += '</div>';
  294.  
  295.     htmlTags += '<div id="tabs-4">';
  296.     htmlTags += 'Admin';
  297.  
  298.     htmlTags += '<a href="/tools/AKG/Lists/Konfiguration/AllItems.aspx" target="_konfig">Konfiguration</a></br>';
  299.     htmlTags += '<a href="/tools/AKG/Lists/Themen/AllItems.aspx" target="_themen">Themen</a></br>';
  300.     htmlTags += '<a href="/tools/AKG/Lists/Aktionen/AllItems.aspx" target="_aktionen">Aktionen</a></br>';
  301.  
  302.     htmlTags += '</div>';
  303.  
  304.     htmlTags += '</div>';
  305.  
  306.     $("#startTabs").html(htmlTags);
  307.  
  308.     $("#tabs").tabs();
  309.  
  310.     loadSubTables();
  311.  
  312. }
  313.  
  314. function loadSubTables() {
  315.  
  316.     if (checkNull(curuserid) == "") {
  317.         curuserid = _spPageContextInfo.userId;
  318.     }
  319.     loadGrid("AKG", "&$select=Id,Title,Projektstichwort,SD_x002d_Nummer,AKGStatus,Created,Author/Title,Author/Department,Author/WorkPhone&$expand=Author&$filter=" +
  320.         "Author eq " + curuserid +
  321.         " or Projektleiter/Id eq " + curuserid +
  322.         " or Disponent/Id eq " + curuserid +
  323.         " or QM/Id eq " + curuserid +
  324.         " or Vertrieb/Id eq " + curuserid +
  325.         " or AV/Id eq " + curuserid +
  326.         " or Einkauf/Id eq " + curuserid +
  327.         " or Entwicklung/Id eq " + curuserid +
  328.         " or Service/Id eq " + curuserid +
  329.         " or ILS/Id eq " + curuserid +
  330.         " or Operations/Id eq " + curuserid +
  331.         " or PM/Id eq " + curuserid +
  332.         " or Controlling/Id eq " + curuserid +
  333.         " or OMWPQ/Id eq " + curuserid +
  334.         " or Preispr_x00fc_fung/Id eq " + curuserid +
  335.         " or Vertragsstrafe/Id eq " + curuserid +
  336.         " or KompensationOderOffset/Id eq " + curuserid +
  337.         " or Zusatz/Id eq " + curuserid +
  338.         "&$orderby=Id desc", "gridmy", cnMyEntries, cmMyEntries, true, false);
  339.     loadGrid("AKG", "&$select=Id,Title,Projektstichwort,SD_x002d_Nummer,AKGStatus,Created,Author/Title,Author/Department,Author/WorkPhone&$expand=Author&$filter=AKGStatus eq 'Aktiv'&$orderby=Id desc&$top=9999", "gridactive", cnMyEntries, cmMyEntries, true, false);
  340.     loadGrid("AKG", "&$select=Id,Title,archivFlag,Projektstichwort,SD_x002d_Nummer,AKGStatus,Created,Author/Title,Author/Department,Author/WorkPhone&$expand=Author&$orderby=Id desc&$top=9999", "gridall", cnAllEntries, cmAllEntries, true, false);
  341. }
  342.  
  343. function loadGridData(listname, query, divname) {
  344.  
  345.     $.ajax({
  346.         url: "/tools/AKG/_api/web/lists/getbytitle('" + listname + "')/Items?" + query,
  347.         type: "GET",
  348.         headers: { "Accept": "application/json;odata=verbose" },
  349.         success: function (data, textStatus, xhr) {
  350.             var thegrid = $("#" + divname)[0];
  351.             thegrid.addJSONData(data.d.results); //Binding data to the grid
  352.         },
  353.         error: function (xhr, textStatus, errorThrown) {
  354.             alert("error:" + JSON.stringify(xhr));
  355.             $('#' + divname + 'records').html(" [0]");
  356.         }
  357.     });
  358. }
  359.  
  360. function loadGrid(listname, query, divname, colnames, colmdodel, showFilter, showExcelExport) {
  361.  
  362.     $("#" + divname).jqGrid({
  363.         datatype: function () { loadGridData(listname, query, divname); },
  364.         colNames: colnames,
  365.         colModel: colmdodel,
  366.         height: "100%",
  367.         loadonce: true,
  368.         rowNum: 9999,
  369.         gridComplete: function () {
  370.             $("#" + divname + "no").html("&nbsp;[" + $("#" + divname).jqGrid('getGridParam', 'records') + "]");
  371.             $("#" + divname).jqGrid('setGridParam', { datatype: 'local' });
  372.         },
  373.         ondblClickRow: function (rowid, iRow, iCol, e) {
  374.             onDoubleClickGrid(rowid, iRow, iCol, e, divname, listname);
  375.         }
  376.     });
  377.  
  378.     if (showFilter) {
  379.         $("#" + divname).jqGrid('filterToolbar', {
  380.             autosearch: true,
  381.             stringResult: false,
  382.             searchOnEnter: true,
  383.             defaultSearch: "cn",
  384.         });
  385.     }
  386. }
  387.  
  388. function onDoubleClickGrid(rowid, iRow, iCol, e, divname, listname) {
  389.  
  390.     var rowData = $("#" + divname).getRowData(rowid);
  391.     var url = appSiteCollectionUrl + "/Lists/" + listname + "/EditForm.aspx?ID=" + rowData.Id;
  392.     openInDialog(1050, 1000, true, true, true, url);
  393. }
  394.  
  395. function onViewClick(rowid, iRow, iCol, e, divname, listname) {
  396.  
  397.     var rowData = $("#" + divname).getRowData(rowid);
  398.     var url = appSiteCollectionUrl + "/Lists/" + listname + "/DispForm.aspx?ID=" + rowData.Id;
  399.     openInDialog(1050, 1000, true, true, true, url);
  400. }
  401.  
  402. function archiveEntry(akgid, gridid) {
  403.     if (!confirm("Die Themen im ausgewaehlten AKG werden archiviert und sind danach nicht mehr bearbeitbar. Dieser Vorgang kann nicht rueckgaengig gemacht werden. Fortfahren?")) {
  404.         return;
  405.     }
  406.  
  407.     $("#" + gridid).jqGrid("setCell", akgid, "archivFlag", "startarchiving");
  408.  
  409.     var table = "<table><tr><td width='20px'>&nbsp;</td><td width='200px'>Thema?<div class='cssHelpTextHeader'>Aktion/Detaillierung/Kurzinformation</div></td><td width='100px'>Verbindl. Zust&#228;ndigkeit</td><td width='90px'>Termin</td><td width='90px'>Neuer Termin</td><td width='130px' >Status</td><td>Bemerkung</td></tr>";
  410.     var query = "&$filter=refID eq " + akgid + "&$orderby=Sort";
  411.     var tableEncoded = "";
  412.  
  413.     $.ajax({
  414.         url: "/tools/AKG/_api/web/lists/getbytitle('Themen')/Items?" + query,
  415.         type: "GET",
  416.         headers: { "Accept": "application/json;odata=verbose" },
  417.         success: function (data, textStatus, xhr) {
  418.             var camlQuery = "<Batch OnError='Continue'>"
  419.  
  420.             for (var i = 0; i < data.d.results.length; i++) {
  421.                 curId = data.d.results[i].Id;
  422.                 table += "<tr><td>" + data.d.results[i].Sort + "</td>";
  423.                 table += "<td>" + data.d.results[i].Title + "<div class='cssHelpText'>" + checkNull(data.d.results[i].Kurzinfo) + "</div></td>";
  424.                 table += "<td>" + checkNull(data.d.results[i].Zustandig) + "</td>";
  425.                 table += "<td>" + checkNull(data.d.results[i].Termin) + "</td>";
  426.                 table += "<td>" + checkNull(data.d.results[i].TerminNeu) + "</td>";
  427.                 table += "<td>" + checkNull(data.d.results[i].Status) + "</td>";
  428.                 table += "<td>" + checkNull(data.d.results[i].Bemerkung) + "</td>";
  429.  
  430.                 camlQuery += "<Method ID='" + (i + 1) + "' Cmd='Delete'>";
  431.                 camlQuery += "<Field Name='ID'>" + data.d.results[i].Id + "</Field>";
  432.                 camlQuery += "</Method>";
  433.                 table += "</tr>";
  434.             }
  435.  
  436.             table += "</table>";
  437.  
  438.             camlQuery += "</Batch>";
  439.  
  440.             tableEncoded = encodeURIComponent(table);
  441.  
  442.             // update the item
  443.             var MyvaluePairs = [];
  444.             MyvaluePairs.push(["archivThemen", tableEncoded]);
  445.             MyvaluePairs.push(["archivFlag", "1"]);
  446.  
  447.             //verschiebt die themen in ein feld innerhalb des akg
  448.             var resultArchiving = archiveAKGThemen(akgid, MyvaluePairs);
  449.  
  450.             //wenn erfolgreich dann werden die einzelnen themeneintr�ge gel�scht
  451.  
  452.             if (resultArchiving.status == 200) {
  453.  
  454.                 var resultDeleting = deleteArchivedEntries(camlQuery);
  455.                 if (resultDeleting.status == 200) {
  456.                     $("#" + gridid).jqGrid("setCell", akgid, "archivFlag", "archivingsuccessful");
  457.                 } else {
  458.                     //Fehler beim L�schen der Themen
  459.                     $("#" + gridid).jqGrid("setCell", akgid, "archivFlag", "archivingfailed");
  460.                     alert("Fehler: " + resultDeleting.status + " - " + resultDeleting.statusText + "\n\n" + resultDeleting.responseText);
  461.                 }
  462.             } else {
  463.                 //Fehler beim Archivieren der Themen
  464.                 $("#" + gridid).jqGrid("setCell", akgid, "archivFlag", "archivingfailed");
  465.                 alert("Fehler: " + resultArchiving.status + " - " + resultArchiving.statusText + "\n\n" + resultArchiving.responseText);
  466.             }
  467.         },
  468.         error: function (xhr, textStatus, errorThrown) {
  469.             alert("error:" + JSON.stringify(xhr));
  470.         }
  471.     });
  472. }
  473.  
  474. function deleteArchivedEntries(camlQuery) {
  475.  
  476.     var objPromise = $().SPServices({
  477.         operation: "UpdateListItems",
  478.         async: false,
  479.         listName: "Themen",
  480.         updates: camlQuery,
  481.     });
  482.     return objPromise;
  483. }
  484.  
  485. function archiveAKGThemen(akgid, valuepairs) {
  486.  
  487.     var result = $().SPServices({
  488.         operation: "UpdateListItems",
  489.         listName: "AKG",
  490.         async: false,
  491.         ID: akgid,
  492.         valuepairs: valuepairs
  493.     });
  494.     return result;
  495. }
  496.  
  497. function checkAkgLink() {
  498.     var akgId = GetUrlKeyValue("autolaunch");
  499.     if (!akgId) {
  500.         return;
  501.     }
  502.     var url = _spPageContextInfo.webAbsoluteUrl + "/Lists/AKG/DispForm.aspx?ID=" + akgId + "&IsDlg=1";
  503.     openInDialog(1050, 1000, true, true, true, url);
  504. }
  505.  
  506. var colIdTemplate = { key: true, index: 'Id', width: 50, sorttype: "int", align: 'center', jsonmap: "Id" }
  507. var colTitleTemplate = { width: 300 };
  508. var colTitleShortTemplate = { width: 100 };
  509.  
  510. var colActionTemplate = {
  511.     width: 60, align: 'center', sortable: false,
  512.     formatter: function (cellvalue, options, rowObject) {
  513.         var outHtml = "<a title='Eintrag oeffnen' href='javascript:onViewClick(" + options.rowId + ",\"\",\"\",\"\", \"" + options.gid + "\", \"AKG\");'>" + imgView + "</a>&nbsp;";
  514.         outHtml += "<a title='AKG Drucken' href='javascript:printAKG(" + options.rowId + ", \"" + options.gid + "\", \"AKG\");'>" + imgPrinter + "</a>";
  515.         if (rowObject.AKGStatus === "Entwurf") {
  516.             outHtml += "<a title='AKG Löschen' href='javascript:deleteAKG(" + options.rowId + ");'>" + imgDelete2 + "</a>";
  517.         }
  518.         return outHtml;
  519.     }
  520. };
  521.  
  522. var colArchivingTemplate = {
  523.     width: 50, align: 'center', sortable: false,
  524.     formatter: function (cellvalue, options, rowObject) {
  525.         var outHtml = "";
  526.  
  527.         switch (cellvalue) {
  528.             case "1":
  529.                 outHtml = "<span title='Vorgang bereits archiviert'>" + imgArchived + "</span>";
  530.                 break;
  531.  
  532.             case "startarchiving":
  533.                 outHtml = "<span title='Starte Archivierung der Themen'>" + imgLoading + "</span>";
  534.                 break;
  535.  
  536.             case "archivingsuccessful":
  537.                 outHtml = "<span title='Archivierung erfolgreich'>" + imgCheck2 + "</span>";
  538.                 break;
  539.  
  540.             case "archivingfailed":
  541.                 outHtml = "<span title='Bei der Archivierung trat ein Fehler auf. Bitte erneut versuchen.'>" + imgArchivingError + "</span>";
  542.                 break;
  543.  
  544.             default:
  545.                 if (rowObject.AKGStatus == "Archiv") {
  546.                     outHtml = "<a title='Themen im AKG archivieren' href='javascript:archiveEntry(" + options.rowId + ",\"" + options.gid + "\");'>" + imgToArchiv + "</a>&nbsp;";
  547.                 }
  548.         }
  549.         return outHtml;
  550.     }
  551. };
  552.  
  553. var colDateTemplate = {
  554.     width: 150, align: 'center', formatter: 'date',
  555.     formatoptions: { srcformat: "ISO8601Long", newformat: "d.m.Y H:i" }
  556. }
  557.  
  558. var colUserTemplate = {
  559.     width: 160, align: 'left',
  560.     formatter: function (cellvalue, options, rowObject) {
  561.         return "<span title='" + cellvalue.Title + "\n" + cellvalue.Department + "\n" + cellvalue.WorkPhone + "'>" + imgUser + " " + cellvalue.Title + "</span>";
  562.     }
  563. }
  564.  
  565. var cnMyEntries = ['ID', 'ProjektNr', '', 'Projektstichwort','AKGStatus','SD-Nummer','Erstellt von', 'Erstellt'];
  566. var cmMyEntries = [
  567.     { name: 'Id', template: colIdTemplate },
  568.     { name: 'Title', template: colTitleShortTemplate },
  569.     { name: 'actions', template: colActionTemplate },
  570.     { name: 'Projektstichwort', template: colTitleTemplate },
  571.     { name: 'AKGStatus', template: colTitleShortTemplate },
  572.     { name: 'SD_x002d_Nummer', template: colTitleShortTemplate },
  573.     { name: 'Author', template: colUserTemplate },
  574.     { name: 'Created', template: colDateTemplate }
  575. ];
  576.  
  577. var cnAllEntries = ['ID', 'ProjektNr', '', 'Projektstichwort', 'AKGStatus', 'SD-Nummer', 'Erstellt von', 'Erstellt','Archivieren'];
  578. var cmAllEntries = [
  579.     { name: 'Id', template: colIdTemplate },
  580.     { name: 'Title', template: colTitleShortTemplate },
  581.     { name: 'actions', template: colActionTemplate },
  582.     { name: 'Projektstichwort', template: colTitleTemplate },
  583.     { name: 'AKGStatus', template: colTitleShortTemplate },
  584.     { name: 'SD_x002d_Nummer', template: colTitleShortTemplate },
  585.     { name: 'Author', template: colUserTemplate },
  586.     { name: 'Created', template: colDateTemplate },
  587.     { name: 'archivFlag', template: colArchivingTemplate }
  588. ];
Add Comment
Please, Sign In to add comment